Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(raw_input()) if n <= 2: print -1 else: print '%s' % ' '.join(map(str, range(n,0,-1)))
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.Scanner; public class Practica_4 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); if (n == 1 || n==2) { System.out.println(-1); } else { String cdn = ""; for (int i = n; i >= ...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(input()) if n <= 2: print(-1) else: for i in range(n, 1, -1): print(i, end = ' ') print(1)
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.math.BigI...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.Scanner; import java.util.stream.IntStream; public class Codeforces{ public static void main( String[] args ){ Scanner scanner = new Scanner( System.in ); int n = scanner.nextInt( ); if( n > 2 ) IntStream.rangeClosed( 0, n - 1 ).map( i -> n - i ).forEach( i -> System.out.print( i + " " ) ); else S...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.*; public class Main { public static void main(String args[]) { Scanner in = new Scanner(System.in); int n = in.nextInt(); if(n<=2) System.out.println("-1"); else { for(int i=n ; i>0 ; i--) System.out.print(i+" "); } } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.Scanner; public class A { /** * @param args */ public static void main(String[] args) { NS ns = new NS(); if (ns.n < 3){ System.out.println("-1"); } else { ns.forma(); ns.print(); } /* ns.formda(); ns.nsort(); ns.print(); */ } } class NS { NS() { Scanner s...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(raw_input()) if n == 1 or n == 2: print -1 else: for i in range(n, 0, -1): print i,
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=input() if n<3: print -1 else: for x in range(1,n+1)[::-1]: print x,
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=int(raw_input()) if(n<3): print -1 elif n==3: print 3,2,1 else: print 3,2,1, for i in xrange(4,n): print i, print n
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int i, n, j, a[101]; int main() { cin >> n; if (n == 1 || n == 2) cout << -1; else for (i = n; i >= 1; i--) cout << i << ' '; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(input()) if n >= 3: print('3 2 1',end = ' ' ) for i in range (n - 3): print((i + 1), end = ' ') else: print('-1')
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Solution { public void solve() throws IOException { int n = in.nextInt(); if (n <= 2) { System.out.println(-1); } else { for (int i = ...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
a = raw_input() total = int(a) if total<3: print -1 else: print total-1, print total, for i in range(0,total-2): print 1,
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
# ~*~ coding:utf-8 ~*~ n = int(raw_input()) if n <= 2: print -1 else: print ' '.join(map(str, [2, 3] + [1] * (n - 2)))
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class A246 { public static void main(String args[]) throws IOException{ BufferedReader ip = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(ip.readLine()); Stri...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int arr[n]; if (n >= 3) { for (int i = 0; i < n; i++) { arr[i] = (n - i); } for (int i = 0; i < n; i++) { cout << arr[i]; if (i != n - 1) cout << " "; else cout << endl; } } else...
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.Scanner; public class Ishu { public static void main(String[] args) { Scanner scan=new Scanner(System.in); int n,i,j; boolean flag=true; int[] a=new int[50]; int[] b=new int[50]; n=scan.nextInt(); for(i=0;i<n;++i) { a[i]=n-i; b[i]=a[i]; } for(i=0;i<n-1;++i) for(j...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.Scanner; public class _246_A { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n=in.nextInt(); if(n<3) System.out.println(-1); else for (int i = 0; i < n; i++) { System.out.print(n-i+" "); } } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
//Date: Oct 4, 2013 //Time: 3:06:52 PM import java.util.*; import java.io.*; public class A246 implements Runnable { public void solve() throws IOException { int N = nextInt(); if(N <= 2) System.out.println(-1); else{ for(int i = N; i > 0; i--) System.out.print(i + " "); System.out.println(); } } ...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; const long long M = 1e9 + 7; bool isPrime(long long num) { bool flag = true; for (long long i = 2; i <= sqrt(num); i++) { if (num % i == 0) { flag = false; break; } } return flag; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0)...
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n < 3) cout << -1; else for (int i = n; i >= 1; i--) cout << i << " "; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 1 || n == 2) cout << -1; else while (n) { cout << n << " "; n--; } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n <= 2) { cout << -1 << endl; } else { cout << 4 << " " << 5 << " "; for (int i = 3; i <= n; i++) { cout << i << " "; } cout << "\n"; } }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#main n = int(input()) temp = [] if n<=2: print('-1') else: temp.append(n) temp.append(n) for i in range(n-2): temp.append(1) for k in temp: print(k,end=' ')
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); int n, m; int a[55]; int main() { cin >> n; if (n == 1) cout << -1 << endl; else if (n == 2) cout << -1 << endl; else { for (int i = n; i >= 1; i--) cout << i << " "; } }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.*; public class AUnsuccessfulSorting { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int inputByte=sc.nextInt(); if(inputByte<3) { System.out.print(-1); } else { for(int k=inputByte; k>0; k--)...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 5; long long arr[N]; long long ans[N]; long long dp[N]; set<long long> adj[N]; long long vis[N] = {0}; set<long long> temp; void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } void solve() { long long n; cin >...
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class A { static BufferedReader in; static StringTokenizer st; static PrintWriter out; static String next() throws I...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.*; import java.io.*; public class Main { public static void main(String[] arg) { new Main(); } public Main() { Scanner cin=new Scanner(new BufferedInputStream(System.in)); int n=cin.nextInt(); if (n<=2) System.out.println(-1); else { System.out.print(n+" "+(n-1)+" "); for (int i...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; void solve() { long long int n; cin >> n; if (n <= 2) { cout << "-1" << '\n'; return; } long long int i; for (i = n - 1; i >= 0; i--) cout << i + 1 << " "; cout << '\n'; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long ...
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.Arrays; import java.util.Locale; import java.util.Scanner; public class Codeforces2 { public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); if(n<3){ System.out.println(-1); }else{ int t=0; for(int i=n;i>=1;i--){ i...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(raw_input()) print -1 if n<3 else ' '.join(map(str, [3,2,1]+range(4,n+1)))
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=int(input()) if(n<=2): print('-1') else: ans=[ ] while(n>0): ans.append(n) n-=1 print(*ans)
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.io.IOException; import java.util.Arrays; import java.util.Collections; import java.util.Scanner; import java.applet.*; import java.awt.*; public class Cdfrc { public static void main(String[] args) throws NumberFormatException, IOException { Scanner sc = new Scanner(System.in); int n = sc.nextInt(...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(input()) if n <= 2: print("-1") else: for i in range(n, 0, -1): print(i, end=" ")
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
N = input() if (N <= 2): print -1 else: for a in range(N-1,-1,-1): print a+1, print
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(input()) if n > 2: print(' '.join(str(i) for i in range(n, 0, -1))) else: print(-1)
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.*; public class buggysorting { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = Integer.parseInt(in.nextLine()); if (n == 1 || n == 2) System.out.println(-1); else for (int i = 0; i < n; i++) System.out.print((((i+1)%n)+1) + " "); } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
X = int(input()) if X <= 2: print(-1) exit() print(*[i for i in range(X, 0, -1)])
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
# coding: utf-8 n = int(input()) if n<=2: print(-1) else: print(' '.join([str(i) for i in range(2,n+1)]+['1']))
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = input() if n <= 2: print -1 else: print ' '.join(["2"] * (n - 1) + ["1"])
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; long long n, e, o, res, S; int main() { cin >> n; if (n <= 2) cout << -1; else { for (long long i = n; i >= 1; --i) cout << i << " "; } }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int arr[1000000]; long long int i, j, k, n, q, jj, bb, m, a, z, x, y, xx1, yy1, xx2, yy2, t, ans; string s; int main() { cin >> n; if ((n == 1) || (n == 2)) cout << -1; else { cout << n << ' ' << n - 1 << ' '; for (i = 2; i < n; i++) cout << i - 1 << ' '; ...
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
def main(): i = input(); if i <= 2: print('-1') else: result = '7 8 5' for x in range (0, i-3): result = result + ' 10' print result main()
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.Scanner; public class A246 { public static void main(String[] args) { Scanner input = new Scanner(System.in); int N = input.nextInt(); if (N <= 2) { System.out.println("-1"); } else { for (int n=N; n>=1; n--) { System.out.pri...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
def main(): n = int(raw_input()) if n > 2: print(' '.join(map(str,[ i for i in range(n,0,-1)] ))) else: print(-1) main()
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { //IO public PrintWriter out; private StringTokenizer tokenizer; private...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n, i; cin >> n; if (n == 1 || n == 2) { cout << -1; return 0; } for (i = n; i >= 1; i--) cout << i << " "; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(input()) m = [] for i in range(1, n + 1): m.append(n + 1 - i) a = list(m) a.sort() for i in range(n - 1): for j in range(i, n - 1): if m[j] > m[j + 1]: m[j], m[j + 1] = m[j + 1], m[j] if m == a: print(-1) else: a.reverse() print(* a, sep = " ")
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=int(input()) k=[i for i in range(n,0,-1)] if n>2: print(*k) else: print("-1")
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(raw_input()) if n < 3:print -1 else:print " ".join(map(str,range(n,0,-1)))
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=input() if n>2: print ' '.join(map(str,[n-1]+range(1,n)[::-1])) else: print -1
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=int(input()) print(*[[2,2]+[1]*(n-2),[-1]][n<3])
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
//package Round_151; import java.util.*; import java.io.*; public class a { String input = ""; String output = ""; FastScanner in; PrintWriter out; void solve() throws Exception { int n = in.nextInt(); int a[] = new int[n+1]; if (n < 3){ out.println(-1); return; } for (int i = 2; i<=n; i++) ...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
# a=[5,4,3,2,1] # for i in range(3): # for j in range(3): # if a[i]>a[i+1]: # a[i],a[i+1]=a[i+1],a[i] # print(a) n=int(input()) if n==1 or n==2:print(-1) else:print(*[ x for x in range(n,0,-1)])
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int n; cin >> n; if (n == 0 || n == 1 || n == 2) cout << "-1" << "\n";...
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.io.BufferedReader; import java.io.InputStreamReader; public class BuggySorting { void run() throws Exception { BufferedReader bfd = new BufferedReader( new InputStreamReader(System.in)); int n = Integer.parseInt(bfd.readLine()); if(n <= 2) System.out.println(-1...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=int(input()) if n>2:print(*list(range(n,0,-1))) else:print(-1)
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n, i; scanf("%d", &n); if (n < 3) { printf("-1\n"); return 0; } printf("3 2 "); for (i = 3; i <= n; i++) { printf("1 "); } printf("\n"); return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.io.*; import java.util.*; public class Main { public static BufferedReader reader; public static StringTokenizer in; public static PrintWriter out; public static void main(String[] args) throws IOException { reader = new BufferedReader(new InputStreamReader(System.in)); in = new StringTokenize...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.io.*; import java.util.*; public class Main { public static void main(String[] args)throws IOException { new Main().start(); } public void start()throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; //int test=Integer.parseInt(br.readL...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int a, b, c, n, d, k, i; int main() { cin >> n; if (n <= 2) { cout << -1; } else { for (i = n; i >= 1; i--) { cout << i << " "; } } }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j; cin >> n; if (n == 1 || n == 2) cout << "-1"; else { for (i = n; i >= 1; i--) cout << i << ' '; } cout << endl; return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(raw_input()) if n <= 2: print -1 else: print ' '.join(map(str, range(n, 0, -1)))
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.Scanner; public class buddy { public static void main(String [] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); if(n <= 2 ) System.out.println("-1"); else { for(int i = n; i>=1; i--) System.out.print(i + " "); } } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
def main_function(): a = int(input()) if a > 2: return " ".join([str(a - i) for i in range(a)]) return -1 print(main_function())
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#from dust i have come dust i will be n=int(input()) if n<=2: print(-1) exit(0) print(2,n,end=' ') for i in range(1,n): if i!=2: print(i,end=' ')
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Random; import java.util.StringTokenizer; public class Main { static BufferedReader reader; static StringTokenizer tokenizer; static PrintWri...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileReader; import java.io.FileWriter; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class A { ...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(input()) if n <= 2: print(-1) else: x = '' for i in range(n,0,-1): x += str(i) + ' ' print(x[:-1])
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(input()) if n <= 2: print(-1) else: print(' '.join(map(str, list(range(2, n + 1)) + [1])))
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = input() if n <= 2: print -1 else: print n, n-1, for i in range(1, n-1): print i,
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.Scanner; import java.util.stream.IntStream; public class Solution { @SuppressWarnings("resource") public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); if (n < 3) System.out.println(-1); else IntStream.range(1, n + 1).map(i...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
t=int(input()) if t<3: print(-1) else: for i in range(t,1,-1): print(i,end=" ") print(1)
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int N; scanf("%d", &N); if (N <= 2) printf("%d", -1); else { for (int i = N; i >= 1; i--) { printf("%d", i); printf(" "); } } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.Scanner; public class A { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); if (n == 1 || n == 2) { System.out.println(-1); } else { for (int i = 0; i < n; i++) { System.out.print(n-i + " "); } } //System...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=int(input()) if(n==1 or n==2): print(-1) else: l=[i for i in range(1,n+1)] l.sort(reverse=True) print(*l)
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.*; import java.math.*; import java.io.*; public class problem2 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); if(n <=2)System.out.println(-1); else { for(i...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import sys def solve(lines, output): n = int(lines.readline()) if n < 3: output.write("-1\n") else: output.write(' '.join(str(x) for x in range(n, 0, -1)) + '\n') if __name__ == '__main__': solve(sys.stdin, sys.stdout)
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int i, n; while (scanf("%d", &n) != EOF) { if (n <= 2) printf("-1\n"); else { for (i = 2; i <= n; i++) printf("%d ", i); printf("1\n"); } } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n, i; cin >> n; if (n == 1 || n == 2) cout << -1 << endl; else { for (i = n; i >= 1; i--) { cout << i << " "; } } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(input()) if n == 1 or n == 2: print (-1) else: arr = [i for i in range(1,n+1)] arr.reverse() for i in arr: print(i,end=' ')
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Scanner; public class CodeForces { public static void main(String[] args) { Scanner input = new Scanner(new BufferedReader(new InputStreamReader(Syste...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n = 0; cin >> n; if (n == 1 || n == 2) { cout << -1 << endl; } else { for (int i = 2; i <= n; i++) { cout << i << " "; } cout << 1 << endl; } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n < 3) { cout << "-1"; return 0; } for (int i = n; i > 0; i--) { cout << i << " "; } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.io.*; import java.util.*; public class BuggySorting { public static void main(String[] args) throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(f.readLine()); if (n <= 2) { System.out.println...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int a[101], i, j, k, n, m; scanf("%d", &n); if (n > 2) { for (i = n; i > 0; i--) { printf("%d \n", i); } } else { printf("-1\n"); } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(input()) if n == 1 or n == 2: print(-1) else: lst = list(range(1,n+1)) a,b = lst.pop(),lst.pop() lst = [a,b] + lst print(*lst)
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
from sys import stdin,stdout,setrecursionlimit,maxint,exit #setrecursionlimit(2*10**5) from random import random def listInput(): return map(long,stdin.readline().split()) def printBS(li): for i in xrange(len(li)-1): stdout.write("%d "%li[i]) stdout.write("%d\n"%li[-1]) n=input() if n<=2: print -1 else: printBS([...
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int N, i; int main() { scanf("%d", &N); if (N <= 2) { printf("-1\n"); return 0; } for (i = N; i; i--) printf("%d%c", i, i == 1 ? '\n' : ' '); return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import sys def readints() : l = sys.stdin.readline() return map(int, l.split(' ')) def readstring() : l = sys.stdin.readline()[:-1] return l def readint() : l = sys.stdin.readline() return int(l) def clearchars(s, chars) : for c in chars : s = s.replace(c, '') return s def g...
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
//package sorting; import java.util.*; public class Valera { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); if (N <= 2) { System.out.print("-1"); } else for (int i = N; i > 0; i--) { System.ou...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(input()) print(*([-1],[3,2]+[1]*(n-2))[n>2])
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.io.*; import java.util.*; public class A { public static void main(String[] args) throws IOException { BufferedReader rd = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); StringTokenizer st; int N = Integer.parseInt(rd.readLine()); if(N<=2) pw....
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n <= 2) cout << -1; else { while (n != 0) cout << n-- << " "; } }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.Scanner; public class Day_10 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); if(n==1 || n==2) { System.out.println(-1); }else { System.out.print((n-1)+" "); for(int i = n; i>=1; i--) { if(i==n-1) { continue; } System.out.print(i+" "); } } } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> int fastread() { int input; char c = 0; while (c < 33) c = getchar(); input = 0; while (c > 33) { input = input * 10 + c - '0'; c = getchar(); } return input; } int main() { int n = fastread(); int i; if (n == 1 || n == 2) printf("-1\n"); else for (i = n; i...
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.*; import java.io.*; public class CF246A { public static void main(String[] args) throws IOException { in.init(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); if(n<=2) out.println(-1); else for(int i = n;i>0;i--) out.print(i + " "); out.close(); ...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n <= 2) cout << -1; else { for (int i = 0; i < n - 1; i++) cout << 2 << " "; cout << 1; } return 0; }
CPP