[ create a new paste ] login | about

Link: http://codepad.org/Il1yFXjg    [ raw code | output | fork ]

C++, pasted on Mar 9:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;

public class Palindrome {
	
	public static void main(String [] argv) throws IOException {
		
		System.setIn(new FileInputStream("C:\\Users\\sev_user\\eclipse-workspace\\Unknown\\src\\input.txt"));
		Scanner sc = new Scanner(System.in);
		
		for(int i=0;i<10;i++)
		{
			int a = Integer.parseInt(sc.nextLine());
			char [][] value = new char [8][8];
			
			for(int j=0;j<8;j++)
			{
				String line = sc.nextLine();
				char[]arr = line.toCharArray();
					for(int k=0;k<8;k++)
					{
						value[j][k] = arr[k];
					}
			}
			
			int count = 0;
			
	
			for (int j = 0; j < 8; j++){
				for (int k = 0; k <= 8 - a; k++){
					for (int l = k; l < a + k; l++){
						if (value[j][l] != value[j][k + a -(l-k) - 1]) break;
						if (l == a/2 + k - 1) {
							count++;
							break;
						}
					}
				}
			}
			
			for (int j = 0; j < 8; j++){
				for (int k = 0; k <= 8 - a; k++){
					for (int l = k; l < a + k; l++){
						if (value[l][j] != value[k + a -(l-k) - 1][j]) break;
						if (l == a/2 + k - 1) {
							count++;
							break;
						}
					}
				}
			}		
			System.out.println("# " + count);
			
		}
	
		
	}
	
}




import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;

public class Password {

	private int index=-1;
	private char[] stack;
	
	public Password(int n)
	{
		stack = new char [n];
		
	}
	public void push(char n)
	{
		stack[++index] = n;
	}
	
	public char pop()
	{
		return stack[index--];
	}
	
	public char getLast()
	{
		return stack[index];
	}
	
	public boolean isEmpty()
	{
		return index==-1;
	}
	
	public void retu()
	{
		for(int i=0;i<=index;i++)
			System.out.print(stack[i]);
	}
	
	public static void main(String []argv) throws IOException
	{
		System.setIn(new FileInputStream("C:\\Users\\sev_user\\eclipse-workspace\\Unknown\\src\\input.txt"));
		Scanner sc = new Scanner(System.in);
		
		
		for(int testcase=1;testcase<=10;testcase++)
		{
			String s = sc.nextLine();
		
			String arr[] = s.split(" ");
			
			char data[] = (arr[1].toCharArray());
			int len = Integer.parseInt(arr[0]);
			Password stack = new Password(len);
			
			for(int i=0;i<len;i++)
			{
				if(stack.isEmpty())
				{
					stack.push(data[i]);
				}
				else if(stack.getLast() == data[i])
				{
					stack.pop();
				}
				else
				{
					stack.push(data[i]);
				}
			}
			System.out.print("#" + testcase + " ");
			stack.retu();
			System.out.println();
			
		}
	}
	
	
}


import java.io.FileInputStream;
import java.io.IOException;
import java.util.Scanner;

public class Queue {

	private int l = -1;
	private int r = -1;
	private int[] queue;
	private int n;
	
	Queue(int n)
	{
		queue = new int [n];
		this.n = n;
	}
	
	public void push(int x)
	{
		queue[++r] = x;
	}
	
	public int pop()
	{
		return queue[r--];
	}
	
	public int pick()
	{
		return queue[++l];
	}
	
	public boolean isEmpty()
	{
		if(l == r)
			return true;
		else
			return false;
	}
	
	public int lastValue()
	{
		return queue[r];
	}
	
	public boolean isFull()
	{
		if(r == this.n - 1)
			return true;
		else
			return false;
	}
	
	public void in()
	{
		for(int i=0;i<n;i++)
			System.out.print(queue[i] + " ");
	}
	
	
	public static void main(String[] argv) throws IOException
	{
		System.setIn(new FileInputStream("input.txt"));
		Scanner sc = new Scanner(System.in);
		for(int testcase=1;testcase<=10;testcase++)
		{
			int n = sc.nextInt();
			
			int []a = new int [8];
			
			for(int i=0;i<8;i++)
			{
				a[i] = sc.nextInt();
			}
			
			int count=1;
			
			Queue Q = new Queue(1500);
			for(int i=0;i<8;i++)
			{
				Q.push(a[i]);
				
			}
			
			while(Q.lastValue() > 0)
			{
				int temp = Q.pop();
				Q.push(temp - count);
				count++;
			}
			
			Q.in();
			System.out.println();
		}
	}
}


import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;

public class StockExchange {
	
	public static void main(String []argv) throws IOException
	{
		System.setIn(new FileInputStream("C:\\Users\\sev_user\\Desktop\\input.txt"));
		Scanner sc = new Scanner(System.in);
		
		int testcase = sc.nextInt();
		for(int i=0;i<testcase;i++)
		{
			int n = sc.nextInt();
			int []data = new int [n];
			for(int j=0;j<n;j++)
			{
				data[j] = sc.nextInt();
			}
			
			
			int index = 0;
			int total=0;
			
			while(index!=n) {
				int sum=0;
				int max = data[index];
				int count=0;
				
				for(int j=1+index;j<n;j++)
				{
					if(data[j] > max)
					{
						max = data[j];
						index = j;
					}
				}
				
				for(int j=0;j<=index;j++)
				{
					if(data[j] != 0) {
						sum += data[j];
						count++;
					}
				}
				
				int val = data[index]*count - sum;
				
				total+=val;
				
				for(int j=0;j<=index;j++)
				{
					data[j] = 0;
				}
				
				
				index = index+1;
			}
			
			System.out.println("#" + (i+1) + " " + total);
		}
	}

}

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;

public class Sum {
	public static void main(String [] argv) throws IOException
	{
		System.setIn(new FileInputStream("C:\\Users\\sev_user\\eclipse-workspace\\Unknown\\src\\input.txt"));
		Scanner sc = new Scanner(System.in);
		

		for(int i=0;i<10;i++)
		{
			int a = 0;
			int [] save_data = new int [10000];
			int [] sum = new int [202];
			a = sc.nextInt();
			for(int j=0;j<10000;j++)
			{
				save_data[j] = sc.nextInt();
			}
			
			int k=0;
			
			for(int j=0;j<10000;j=j+100)
			{
				sum[k] = 0;
				for(int x=j;x<100+j;x++)
				{
					sum[k] += save_data[x];
				}
				
				k++;
				
			}
			
			for(int j=0;j<100;j++)
			{
				sum[k] = 0;
				for(int x=j;x<10000;x=x+100)
				{
					sum[k] += save_data[x];
				}
				
				k++;
			}
			
			
			sum[100] = 0;
			sum[101] = 0;
			
			for(int j=0;j<10000;j=j+101)
			{
				sum[200] += save_data[j];
			}
			
			for(int j=99;j<10000;j=j+99)
			{
				sum[201] += save_data[j];
			}
			
			int max = sum[0];
			for(int j=1;j<202;j++)
			{
				if(sum[j] > max)
					max = sum[j];
			}
			System.out.println("#" + a + " " + max);
			
		}
	}
}


import java.io.FileInputStream;
import java.io.IOException;
import java.util.Scanner;

public class View {

	 int compare2(int a, int b)
		{
			if(a>b)
				return a;
			else
				return b;
		}
		
	int compare4(int a, int b, int c, int d)
		{
			int max1 = compare2(a, b);
			int max2 = compare2(c, d);
			return compare2(max1, max2);
		}
	
	public static void main(String[] argv) throws IOException
	{
		
		System.setIn(new FileInputStream("C:\\Users\\sev_user\\eclipse-workspace\\Unknown\\src\\input.txt"));
		Scanner sc = new Scanner(System.in);
		
		int a=0;
		for(int i=0;i<10;i++) {
			View t = new View();
			a = sc.nextInt();
			int [] value = new int [a];
			int [] data = new int[a];
			for(int j=0;j<a;j++)
			{
				value[j] = sc.nextInt();
				data[j] = 0;
				
			}
		
			for(int j=2;j<a-2;j++)
			{
					if((value[j] - t.compare4(value[j-1], value[j-2], value[j+1], value[j+2])) > 0)
					{
						data[j] = value[j] - t.compare4(value[j-1], value[j-2], value[j+1], value[j+2]);
					}
					else
					{
						data[j] = 0;
					}
				
			}
			int sum=0;
			for(int j=2;j<a-2;j++)
			{
				sum+=data[j];
			}
			
			System.out.println("#" + (i+1) + " " + sum);
		
		}
		
	}
}


Output:
1
2
Line 1: error: 'import' does not name a type
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: