akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void doIt() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int max = a + b;
		if(max < Math.max(a, b) * 2 - 1) {
			max = Math.max(a, b) * 2 - 1;
		}
		System.out.println(max);
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long t=1;
   while(t--){
        long long n;
        cin >> n;
        long long ans = 0;
        for(int i = 1; i <=n ; i ++)
        {
            long long x = n / i;
            ans += (i + i * x) * x / 2;
        }
        cout << ans << endl;   
   }
   return 0; 
} 

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define NMAX (int)(2e5+4)
#define all(x) x.begin(),x.end()
#define rep(i, l, r) for(int i = l; i < r; ++i)
#define rev(i, r, l) for(int i = r - 1; i >= l; --i)
#define ft first
#define sd second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;

int n,m,v[NMAX],sum,mn;

int main(){
    cin>>n>>m;
    rep(i, 0, n){
        cin>>v[i];
        sum+=v[i];
    }
    mn=ceil((sum*1.0)/(4.0*m));
    sort(v, v+n, greater <int>());
    --m;
    cout<<(v[m] >= mn ? "Yes":"No")<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

int main(){
    long N;
    cin >> N;
    vector<long> C(N), dp(N), before(200000, -1);
    for(auto& i : C){
        cin >> i;
        --i;
    }

    dp[0] = 1;
    before[C[0]] = 0;

    for(long i = 1; i < N; ++i){
        dp[i] = ((before[C[i]] >= 0 ? dp[before[C[i]]] : 0) + (before[C[i]] < i - 1 ? dp[i - 1] : 0)) % 1000000007;
        before[C[i]] = i;
    }

    for(const auto& i : dp)cerr << i << " ";
    cerr << endl;

    cout << dp[N - 1] % 1000000007 << endl;

    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;

int main(){
    string s; cin >> s;
    int n = s.size();
    bool flag1 = n % 2;
    bool flag2 = s[0] == s[n - 1];
    if(flag1 == flag2) cout << "Second" << endl;
    else cout << "First" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

int main() {
int n;
cin >> n;
vector<int> p(n);
rep(i, n) cin >> p[i];
int k = 0;
rep(i, n) if(p[i] != i + 1) k++;
if(k <= 2) cout << "YES" << endl;
else cout << "NO" << endl;
return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  map<int,int> mp;
  REP(i,N){
    int tmp;
    cin>>tmp;
    mp[tmp]++;
  }

  bool ans=false;

  if(N%3==0){
    if(mp.size()==2){
      if(mp[0]==N/3)ans=true;
    }
    if(mp.size()==3){
      if(
        (mp.begin()->first ^ (++mp.begin())->first ^ (++(++mp.begin()))->first) == 0 &&
        mp.begin()->second == N/3 && (++(mp.begin()))->second == N/3
      )ans=true;
    }
  }
  if(mp[0]==N)ans=true;
  if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
}


Measured memory_bytes: 3840
#include <stdio.h>
#include <math.h>

int MAX = 1000000;
int prime[1000000] = {0};

void make_prime(){
  int i, j;

  for (i = 2; i < MAX; i++) {
    prime[i] = 1;
  }

  for (i = 2; i * i < MAX; i++) {
    if (prime[i]){
      for (j = i * 2; j < MAX; j += i) {
        prime[j] = 0;
      }
    }
  }
}

int main() {
  int a, d, n;
  int i, count;

  make_prime();

  while (1) {
    scanf("%d %d %d", &a, &d, &n);
    if (a == 0 && d == 0 && n == 0) break;
    count = 0;

    for (i = 0; ; i++) {
      if (prime[a + i * d]) {
        if (++count == n) {
          printf("%d\n", a + i * d);
          break;
        }
      }
    }
  }

  return 0;
}

Measured memory_bytes: 4504
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string a;
  cin>>a;
  int i,j,k,l,flag=0,f=0;
  l=a.length();
  i=(l-1)/2;
  j=(l+3)/2;
  for(k=1;k<i;k++)
  {
    if(a[k]!=a[i-k-1])
       {
         flag=1;
         break;
       }
       }
 for(k=j;k<l;k++)
  {
    if(a[k]!=a[l-k-1])
       {
         f=1;
         break;
       }
       }
       if(f==0 && flag==0)
       cout<<"Yes";
       else
       cout<<"No";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>N;
    bool ans = false;
    rep(i,N){
        char c;
        cin>>c;
        ans |= c == 'Y';
    }
    cout<<(ans ? "Four" : "Three")<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
 

int main(){
    long long int h,w,sum;
    cin >> h >> w;
    if(h==1 || w==1){
        cout << "1" << endl;
        return 0;
    }
    sum = h*w/2;
    if((h%2 != 0)&&(w%2!=0)) sum+=1;
    cout << sum<< endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 2000000
 
int arr[MAX];
int n;
 
void count(int a[], int k)
{
  int ca[k],i,j;
  i = k;
  for(; i>=0 ; i--) ca[i] = 0;
  for(j=1; j<=n; j++) ca[a[j]]++;
  for(i=1; i<k; i++) ca[i] += ca[i-1];
  for(j=n; j>=1; j--){
    arr[ca[a[j]]] = a[j];
    ca[a[j]]--;
  }
}


int main(int argc,char *argv[])
{
  int k=0,i;
  int a[MAX];
  scanf("%d",&n);
  for(i=1; i<=n; i++)
    {
    scanf("%d",&a[i]);
  }
  k=a[1];
  for(i=2; i<=n; i++){
    if(k < a[i]) k = a[i];
  }
  
  count(a, k+1);
  for(i=1; i<n; i++) {
    printf("%d ",arr[i]);
  }

  
  printf("%d\n",arr[i]);
  return 0;
}


Measured memory_bytes: 17384
a,b,c,d = list(map(int, input().split()))
q1,r1 = divmod(c,b)
q2,r2 = divmod(a,d)
tak=q1+min(1,r1)
aoki=q2+min(1,r2)

if tak<=aoki:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9124
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int N, M; 
int par[100010] = {}; 
int depth[100010] = {}; 
int size[100010] = {}; 
int find(int x){
	if(par[x] == x){
		return x;
	}
	else{
		return par[x] = find(par[x]); 
	}
}
void unite(int x, int y){
	x = find(x); 
	y = find(y); 
	if(x == y) return;
	else if(depth[x] < depth[y]){
		par[x] = y; 
		int m = size[x] + size[y]; 
		size[x] = m; size[y] = m; 
	}else{
		par[y] = x; 
		int m = size[x] + size[y]; 
		size[x] = m; size[y] = m; 
		if(depth[x] == depth[y]) depth[x] ++; 
	}
}
bool same(int x, int y){
	return find(x) == find(y); 
}
int main(){
	cin >> N >> M; 
	for(int i = 1; i <= N; i++){
		par[i] = i, depth[i] = 0, size[i] = 1;  
	}
	int H[100010][2] = {}; 
	long long int ans[100010] = {}; 
	for(int i = 0; i < M; i++){
		cin >> H[i][0] >> H[i][1]; 
	}
	ans[M] = (long long) N * (N - 1) / 2; 
	for(int i = M - 1; i >= 1; i--){
		int c = H[i][0]; int d = H[i][1]; 
        int e = find(c); int f = find(d); 
      	if(e == f) ans[i] = ans[i+1]; 
		else{ans[i] = (long long) ans[i+1] - size[par[c]] * size[par[d]];}
      	unite(c, d); 
	}
	for(int i = 1; i <= M; i++){
		cout << ans[i] << endl; 
	}
}

Measured memory_bytes: 4096
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var N = sc.ReadInt();
        var A = sc.ReadLong();
        var B = sc.ReadLong();
        var X = sc.ReadLongArray(N);
        long ans = 0;
        for (int i = 1; i < N; i++)
        {
            var res = X[i] - X[i - 1] * A;
            ans += Math.Min(B, (X[i] - X[i - 1]) * A);
        }
        Console.WriteLine(ans);
    }

    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 22752
#include <iostream>
#include <utility>
#include <string>
#include <set>

using pii = std::pair<int, int>;
const int MAXN = (int)1e5 + 1;
const int INF = MAXN;

pii f[MAXN];  // dp.

void solve(int n, int m, const std::string &str) {
  f[n] = std::make_pair(0, n);
  std::set<pii> rem;
  rem.emplace(f[n]);
  for (int l = n - 1, r = l + m; l >= 0; --l, --r) {
    if (str[l] == '1') {
      f[l] = std::make_pair(INF, l);
    } else {
      f[l] = *rem.begin();
      ++f[l].first;
    }
    if (r <= n) {
      pii erase = std::make_pair(f[r].first, r);
      auto iter = rem.find(erase);
      if (iter != rem.end()) rem.erase(iter);
    }
    rem.emplace(f[l].first, l);
  }
}

int main() {
  int n, m;
  std::string str;
  std::cin >> n >> m >> str;
  
  solve(n, m, str);
  
  if (f[0].first >= INF) {
    std::cout << "-1" << std::endl;
  } else {
    int pos = 0;
    while (pos < n) {
      std::cout << f[pos].second - pos << " ";
      pos = f[pos].second;
    }
    std::cout << std::endl;
  }
  return 0;
}


Measured memory_bytes: 5632
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
int main(){
	string s;
	cin >> s;
	if (s[0] == '7' || s[1] == '7' || s[2] == '7'){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
}

Measured memory_bytes: 3528
MOD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)

def main():
    N = int(input())
    S = [input() for _ in range(N)]

    cnt = 0
    ba = 0
    a = 0
    b = 0
    for s in S:
        for i in range(len(s) - 1):
            if s[i] == 'A' and s[i + 1] == 'B':
                cnt += 1
        if s[0] == 'B' and s[-1] == 'A':
            ba += 1
        elif s[0] == 'B':
            b += 1
        elif s[-1] == 'A':
            a += 1
    
    if a > 0 and b > 0:
        cnt += ba + 1 + min(a - 1,b - 1)
    elif a > 0:
        cnt += ba
    elif b > 0:
        cnt += ba
    else:
        if ba > 0:
            cnt += ba - 1
    print(cnt)
if __name__ == '__main__':
    main() 

Measured memory_bytes: 3700
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

inline int f(int y, int x){
  return 2 * y + y * (y + 1) / 2 + x;
}
int table[18000000];

int main(){
  int N, M;
  while(cin >> N >> M && N){
    REP(i, M){
      int Y, X, L; 
      scanf("%d %d %d", &Y, &X, &L);
      Y--; X--;
      table[f(Y, X)]++;
      table[f(Y, X + 1)]--;
      table[f(Y + L + 1, X)]--;
      table[f(Y + L + 1, X + L + 2)]++;
      table[f(Y + L + 2, X + 1)]++;
      table[f(Y + L + 2, X + L + 2)]--;
    }
    for(int y = 0; y < N + 2; y++){
      for(int x = 1; x <= y + 2; x++){
        table[f(y, x)] += table[f(y, x - 1)];
      }
    }
    for(int y = 1; y < N + 2; y++){
      for(int x = 0; x <= y + 1; x++){
        table[f(y, x)] += table[f(y - 1, x)];
      }
    }
    for(int y = 1; y < N + 2; y++){
      for(int x = 1; x <= y + 2; x++){
        table[f(y, x)] += table[f(y - 1, x - 1)];
      }
    }
    int ans = 0;
    for(int y = 0; y < N; y++){
      for(int x = 0; x <= y; x++){
        if(table[f(y, x)] > 0) ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 50388
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define mod 1000000000+7
#define rep(i,n) for(int i=0;i<(int) (n);i++)
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
using namespace std;
int main(){
  int a,b;
  cin>>a;
  cin>>b;
  cout<<6-a-b;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n;
    cin >> n;
    cout << 180*(n-2) << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int x;
    cin >> x;
    if(x % 10 == 9)
    {
        cout << "Yes" << endl;
    }
    else if(89 < x)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
//yewala
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define unique(a)        (a).erase(unique((a).begin(), (a).end()),(a).end())
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define mod 1000000007 
typedef long long LL;
typedef long double LD;
typedef vector<int> VI;

inline LL moduloMultiplication(LL x, LL y) { return (x%mod * 1LL * y%mod) % mod; }
inline LL power(LL a, LL b) {
	LL x = 1 % mod;
	while (b) {
		if (b & 1) x = moduloMultiplication(x, a);
		a = moduloMultiplication(a, a);
		b >>= 1;
	}
	return x % mod;
}

inline LL add(LL x, LL y) { x += y; if (x >= mod) x -= mod; return x; }
inline LL inv(LL a) { return power(a, mod - 2) % mod; }

bool isPrime(int n)
{

	if (n <= 1)  return false;
	if (n <= 3)  return true;

	if (n % 2 == 0 || n % 3 == 0) return false;

	for (int i = 5; i*i <= n; i = i + 6)
		if (n%i == 0 || n % (i + 2) == 0)
			return false;

	return true;
}
//r 0 p 1 s 2
LL ans = 0;
map<char, int>m;
//int dp[100000][3];
//void recur(string s, int pos, string used,int k)
//{
//	if (pos >= s.length())return;
//	if (s[pos] == 'r')
//	{
//		if (pos < k)
//		{
//			used += 'p';
//			ans = m['p'];
//			recur(s, pos + 1, used,k);
//
//		}
//		else
//		{
//			if(m[s])
//		}
//	}
//	if (s[pos] == 'p')
//	{
//
//	}
//	if (s[pos] == 's')
//	{
//
//	}
//}

int main()
{

	int n,k;
	cin >> n>>k;

	cin >> m['r'];
	cin >> m['s'];
	cin >> m['p'];
	string output;
	string s;
	cin >> s;
	LL ans = 0;

	rep(i, n)
	{
		if (i < k)
		{
			if (s[i] == 'r')
			{
				output += 'p';
				ans += m['p'];
			}
			if (s[i] == 'p')
			{
				output += 's';
				ans += m['s'];
			}
			if (s[i] == 's')
			{
				output += 'r';
				ans += m['r'];
			}
			continue;
		}
		if (s[i] == 'r' && ( output[i - k] != 'p'))
		{
			output += 'p';
			ans += m['p'];
		}
		else if (s[i] == 'r' && ( output[i - k] == 'p'))
		{
			output += '?';

			//ans += m['r'];
		}
		else if (s[i] == 'p' && ( output[i - k] != 's'))
		{
			output += 's';
			ans += m['s'];

		}
		else if (s[i] == 'p' && ( output[i - k] == 's'))
		{
			output += '?';
		

		}
		else if (s[i] == 's' && ( output[i - k] != 'r'))
		{
			output += 'r';
			ans += m['r'];

		}
		else if (s[i] == 's' && ( output[i - k] == 'r'))
		{
			
			//ans += m['s'];
			output += '?';
		}
	}

	cout << ans << endl;



}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

int main() {
  int N;
  cin >> N;
  unordered_map<string, ll> m;
  string s;
  rep(i, 0, N) {
    cin >> s;
    sort(All(s));
    if (m.count(s) > 0) {
      m[s] += 1;
    } else {
      m[s] = 1;
    }
  }

  ll ans = 0;
  for (auto it = m.begin(); it != m.end(); it++) {
    if (it->second == 1) continue;
    ll tmp = it->second;
    ans += tmp * (tmp - 1) / ((ll) 2);
  }
  cout << ans << endl;
};


Measured memory_bytes: 10660
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

// int max: 2 x 10^9, long long max: 9 x 10^18

using namespace std;

int main()
{
  int m;
  long long k;
  cin >> m >> k;
  
  long long repeat = 1 << (m+1);
  
  if(k == 0){
    for(long long i=0; i< repeat; i++){
      cout << (long long)(i / 2) << " ";
    }
    cout << "\n";
  }else if(k > (1 << m)){
    cout << -1;
  }else{
    long long result = 0;
    repeat = 1 << m;
    for(long long i=0; i<repeat; i++){
      if(i != k){
        result = result ^ i;
      }
    }
    if(result == k){
      cout << k << " ";
      repeat = 1 << m;
      for(long long i=0; i<repeat; i++){
        if(i != k){
          cout << i << " ";
        }
      }
      cout << k;
      for(long long i=0; i<repeat; i++){
        if((repeat - i - 1) != k){
        	cout << " " << (repeat - i - 1);
        }
      }
    }else{
      cout << -1;
    }
  }

  return 0;
}

Measured memory_bytes: 3168
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    char c;
    cin >> c;
    
    if (c == 'a' ||c == 'i' ||c == 'u' ||c == 'e' || c == 'o'){
        cout << "vowel";
    }
    else {
        cout << "consonant";
    }
}


Measured memory_bytes: 256
n = int(input())
h_array = [int(x) for x in input().split()]

now = h_array[0]
for i in h_array[1:]:
    if now <= i or now <= i-1:
        now = max(i-1, now)
        pass
    else:
        print("No")
        exit()
else:
    print("Yes")


Measured memory_bytes: 14396
n=int(input())
a=list(map(int,input().split()))

import sys
import math
def setwise_coprime(a):
  ans=a[0]
  for i in range(1,n):
    ans=math.gcd(ans,a[i])
  return ans

#エラストテネスのふるい
def create_sieve(n):
  sieve=[0]*(n+1)
  for i in range(2,n+1):
    if sieve[i]==0:
      for j in range(i*i,n+1,i):
        sieve[j]=i
  return sieve

#高速素因数分解
def fast_factorization(n, sieve):
  prime={}
  while n>1:
    p=sieve[n]
    #nが素数の場合
    if p==0:
      prime[n]=prime.get(n,0)+1
      break
    #nが素数ではない場合
    else:
      prime[p]=prime.get(p,0)+1
      n=n//p
  return prime

check=set()
if setwise_coprime(a)==1:
  #素因数のダブリをcheck
  sieve=create_sieve(10**6)
  for i in range(n):
    if a[i]!=1:
      s=fast_factorization(a[i], sieve)
      for i in s:
        if i in check:
          print("setwise coprime")
          sys.exit()
        else:
          check.add(i)
  print("pairwise coprime")    
else:
  print("not coprime")
  
  



      
      
    


Measured memory_bytes: 189216
import java.util.*;

public class Main {

    static class Pair {
        int h, w;

        public Pair(int h, int w) {
            this.h = h;
            this.w = w;
        }
    }

    static void bfs() {
        visited = new boolean[H][W];
        visited[0][0] = true;
        dist = new int[H][W];
        dist[0][0] = 1;

        Deque<Pair> que = new ArrayDeque<>();
        que.offer(new Pair(0, 0));

        while (!que.isEmpty()) {
            Pair pair = que.poll();
            if (pair.h == H-1 && pair.w == W-1) break;

            for (int dir = 0; dir < 4; ++dir) {
                int nh = pair.h + dy[dir];
                int nw = pair.w + dx[dir];

                if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
                if (visited[nh][nw]) continue;
                if (grid[nh][nw] == '#') continue;

                dist[nh][nw] = dist[pair.h][pair.w] + 1;
                visited[nh][nw] = true;
                que.offer(new Pair(nh, nw));
            }
        }
    }

    static int H;
    static int W;
    static boolean[][] visited;
    static char[][] grid;
    static int[][] dist;
    static int[] dx = {-1, 1, 0, 0};
    static int[] dy = {0, 0, -1, 1};

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        H = Integer.parseInt(sc.next());
        W = Integer.parseInt(sc.next());
        int white = 0;
        grid = new char[H][W];
        for (int i = 0; i < H; ++i) {
            grid[i] = sc.next().toCharArray();
            for (int j = 0; j < W; ++j) {
                if (grid[i][j] == '.') ++white;
            }
        }

        bfs();

        if (visited[H-1][W-1])
            System.out.println(white - dist[H-1][W-1]);
        else
            System.out.println(-1);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;

using ll = unsigned long long;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

#define dump(x) cerr << #x << "=" << x << endl

void solve(ll N, std::vector<ll> A) {
  ll g = pow(10, 18);

  sort(all(A));

  ll m = 1;
  rep(i, N) {
    if (__builtin_mul_overflow(m, A.at(i), &m)) {
      cout << -1 << endl;
      return;
    } else {
      if (m == 0) {
        cout << 0 << endl;
        return;
      }
      if (m > g || m < 0) {
        cout << -1 << endl;
        return;
      }
    }
  }

  if (m > g) {
    cout << -1 << endl;
    return;
  }

  cout << m << endl;
  return;
}

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 4052
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;

using Weight = int;
using Capacity = int;
struct Edge {
    int src, dst; Weight weight;
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

vector<int> tsort(const Graph &g){
    int n = g.size();
    vector<int> res, vis(n);
    function<bool(int)> dfs = [&](int v){
        vis[v] = true;
        for(auto &e : g[v]) if(!vis[e.dst] && !dfs(e.dst)) return false;
        res.push_back(v);
        return true;
    };
    for(int i = 0; i < n; ++i) if(!vis[i]) if(!dfs(i)) return {};
    reverse(res.begin(), res.end());
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n,m;
    cin >> n >> m;
    Graph g(n);
    for(int i = 0; i < m; i++){
        int s,t;
        cin >> s >> t;
        g[s].emplace_back(s,t,0);
    }
    vector<int> ord = tsort(g);
    for(int i = 0; i < n; ++i){
        cout << ord[i] << '\n';
    }
}

Measured memory_bytes: 4188
/********************************************************************************
	
	Code by a weak man who named CYJian, and he hope the code can get more points.

	Algorithm: 

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T>
inline void chkmin(T&a, T b) { a = a < b ? a : b; }

int main() {
	ll n = rl, A = rl, B = rl;
	if((A ^ B) & 1) {
		if(A > B) swap(A, B);
		cout << min(A, n - B + 1) + (B - A) / 2 << endl;
	}
	else
		cout << abs(A - B) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) {

		Scanner sc  = new Scanner(System.in);
		int o= 1 ,p = 1,q = 0, y = 0;


        int s = Integer.parseInt(sc.next())+1;
        int[] test  = new int[100001];
        while(true){
            test[o] = Integer.parseInt(sc.next());
            o++;
            if(s==o)break;
        }
        
        while(true){
            
            y = test[p];
 //          System.out.print(p+"番目 "+test[y]+"==");
 //           System.out.print(test[p]-1);
 //           System.out.println(""+p);
            if( test[y] == p ) q++;
            p++;
            if(s==p)break;
        }
        


        System.out.print(q/2);
        System.out.println();
	}
}

Measured memory_bytes: 31560
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll ;

long long gcd(long long aaa,long long bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

int main (){

    int W,H,N,w1=0,w2=0,h3=0,h4=0;
    cin >> W >> H >> N;
    int x[N],y[N],a[N];
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i] >> a[i];
        if(a[i] == 1) {
            w1 = max(x[i],w1);
        }else if(a[i] == 2) {
            w2 = max(W-x[i],w2);
        }else if(a[i] == 3) {
            h3 = max(y[i],h3);
        }else if(a[i] == 4) {
            h4 = max(H-y[i],h4);
        }
    }

    if(w1+w2 >= W || h3+h4 >= H) {
        cout << 0 << endl;
    }else {
        cout << (W-w1-w2) * (H-h3-h4) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ll n;
vector <ll> v;
cin>>n;

for(int i=1;i<=(n);i++){
    if(i%3==0 && i%5==0){
        v.push_back(0);
    }
    else if(i%3==0){
       v.push_back(0);
    }
    else if(i%5==0){
        v.push_back(0);
    }
    else v.push_back(i);
}
ll sum =0;
vector<ll> :: iterator it;
for(it=v.begin();it<v.end();it++){

    sum = sum + *it;
}
cout<<sum;
}

Measured memory_bytes: 11656
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int a,b,mul,sub,add;
    cin>>a>>b;
    sub=a-b;
    mul=a*b;
    add=a+b;
    if((sub>mul)&&(sub>add))
        cout<<sub<<endl;
    else if(mul>add)
        cout<<mul<<endl;
    else
        cout<<add<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();
const int MOD = (1e9 + 7);


int main(){
  int N;
  cin >> N;
  ll A[N+1], B[N];
  rep(i, N+1){
    cin >> A[i];
  }
  rep(i, N){
    cin >> B[i];
  }
  ll cnt = 0;
  rep(i, N){
    cnt += min(A[i], B[i]);
    B[i] -= min(A[i], B[i]);
    if(B[i]>0){
      cnt += min(B[i], A[i+1]);
      A[i+1] -= min(B[i], A[i+1]); 
    }
  }
  cout << cnt << endl;
    
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define debug(x) cout<<#x<<": "<<(x)<<endl

typedef long long ll;

bool ques(ll n){
    cout<<"? "<<n<<endl<<flush;
    string ans;
    cin>>ans;
    return (ans=="Y");
}

bool pow10(ll n){
    ll d=1;
    rep(i,10){
        d*=10;
        if(n==d)return true;
    }
    return false;
}

void select(ll l,ll r){
    if(l==0)l=1;
    while(l<=r){
        if(ques(l*10)){
            cout<<"! "<<l<<endl;
            return;
        }
        l++;
    }
}

void bin(ll l,ll r){
    if(l>1e10){
        cout<<"! 1"<<endl;
        return;
    }
    ll m = (l+r)/2;
    bool yes = ques(m);
    if(m%10==9 && yes && (pow10(r)^ques(r))){
        select(m-9,m);
        return;
    }

    if(m+1==r && yes) bin(m*10,(m+1)*10); 
    else if(yes) bin(m,r);
    else bin(l,m);
}

int main(void){
    bin(0,10);
    return 0;
}


Measured memory_bytes: 656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);		

		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();

		String str = a < b && b < c ? "Yes" : "No";
		
		System.out.println(str);
		
		scan.close();

	}

}

Measured memory_bytes: 17156
#include<bits/stdc++.h>

using namespace std;

int main(){
   bool flag = false;
 int N,M,K; cin >> N >> M >> K;
  for(int i = 0; i <= M; i++){
    for(int j  = 0; j <= N; j++){
      if( i * N + j * M - 2 * i * j == K){ flag = true;}}}
  
  if( flag){ cout<< "Yes" << endl;}
  else{ cout << "No"<< endl; 
      }
  
  
  return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)((n) - 1); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define debug(x) cout << #x << ":" << x << endl
const intl INF = 1e9;
const intl MOD = 1e9+7;
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    string s;
    cin >> s;
    bool flag = true;
    if(!s.length()%2){
        flag = false;
        fp(flag);
        return 0;
    }
    for(intl i = 0; i < s.length(); i+= 2){
        if((s[i] != 'h')||(s[i + 1] != 'i'))flag = false;
    }
    fp(flag);
    return 0;
}

Measured memory_bytes: 256
////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 100;
int arr[N + 5];

void hora(int tc) {
	int n;
	cin>>n;
	for(int i = 0;i < n;i++) cin>>arr[i];
	int ct = 1e9;
	for(int i = 1;i <= 100;i++) {
		int tot = 0;
		for(int j = 0;j < n;j++) tot += (arr[j] - i) * (arr[j] - i);
		ct = min(ct, tot);
	}
	cout<<ct<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


Measured memory_bytes: 256
from itertools import combinations_with_replacement
def main():
    n, m, q = map(int, input().split())
    qlist = []
    for _ in range(q):
        qlist.append(tuple(map(int, input().split())))

    nums = [i for i in range(1, m + 1)]
    alist = tuple(combinations_with_replacement(nums, n))

    r = 0
    for al in alist:
        tr = 0
        for eq in qlist:
            eq0 = eq[0] - 1
            eq1 = eq[1] - 1
            eq2 = eq[2]
            eq3 = eq[3]
            if al[eq1] - al[eq0] == eq2:
                tr += eq3
        r = max(r, tr)

    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 21692
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000010;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n, m, q;
	cin >> n >> m >> q;
	vector<vector<int>> cnt(n + 1, vector<int>(n + 1));
	rep(i, m) {
		int l, r;
		cin >> l >> r;
		cnt[n + 1 - l][r]++;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cnt[i][j] += cnt[i - 1][j] + cnt[i][j - 1] - cnt[i - 1][j - 1];
		}
	}
	rep(_, q) {
		int l, r;
		cin >> l >> r;
		cout << cnt[n + 1 - l][r] << '\n';
	}
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s;
     cin>>s;

    int c=0;
      for(int i=0;i<s.length();i++)
      {
          if(i % 2 ==0)
          {
             if(s[i]!='R' && s[i]!='U' && s[i]!='D')
                 c++;
           }
           else
           {
                 if(s[i]!='L' && s[i]!='U' && s[i]!='D')
                  c++;
           }
      }
        if(c==0)
        cout<<"Yes";

        else
        cout<<"No";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;

int main()
{
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  vector<int> l(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  int ans = 10000;
  for (uint i = 0; i < 1U << (2 * n); i++) {
    int mp = 0;
    vector<uint> x(4);
    for (uint m = 0; m < n; m++) {
      uint ix = (i & (3U << (2 * m))) >> (2 * m);
      if (ix != 0) {
        x[ix] += l[m];
        mp += 10;
      }
    }
    if (x[1] == 0 || x[2] == 0 || x[3] == 0) continue;
    mp += x[1] > a ? x[1] - a : a - x[1];
    mp += x[2] > b ? x[2] - b : b - x[2];
    mp += x[3] > c ? x[3] - c : c - x[3];
    mp -= 30;
    ans = min(ans, mp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())
lst = [int(x) for x in input().split()]
counter = Counter(lst)

if N % 2 == 0:
    if len(counter) * 2 != N:
        print(0)
        exit()
    for x in range(1, N, 2):
        if counter[x] != 2:
            print(0)
            exit()

else:
    if len(counter) * 2 - 1 != N:
        print(0)
        exit()
    if counter[0] != 1:
        print(0)
        exit()
    for x in range(2, N + 1, 2):
        if counter[x] != 2:
            print(0)
            exit()

print(2 ** (N // 2) % (10 ** 9 + 7))

Measured memory_bytes: 14812
#include<iostream>
#include<algorithm>
 
using namespace std;
typedef long long ll;
 
int N, K;
const ll MOD = 998244353;
ll F[4002], F_inv[4002];
 
ll modpow(ll a, ll b) {
	ll rtn = 1, kakeru = a;
	while (b > 0) {
		if (b & 1)rtn *= kakeru;
		kakeru *= kakeru;
		kakeru %= MOD;
		rtn %= MOD;
		b >>= 1;
	}
	return rtn;
}
 
void calc_fac() {
	F[0] = 1, F[1] = 1;
	for (int i = 2; i <= 4001; i++) {
		F[i] = F[i - 1] * i;
		F[i] %= MOD;
	}
 
	F_inv[4001] = modpow(F[4001], MOD - 2);
	for (int j = 4000; j >= 0; j--) {
		F_inv[j] = F_inv[j + 1] * (j + 1);
		F_inv[j] %= MOD;
	}
 
}
 
ll comb(ll a, ll b) {
	if (a < 0)return 0;
	if (b < 0)return 0;
	if (b > a)return 0;
	ll ans = (F[a] * F_inv[b])%MOD * F_inv[a - b];
	return ans % MOD;
}
 
ll hcomb(ll a, ll b) {
	return comb(a + b - 1, b);
}
 
int main() {
 
	calc_fac();
 
	cin >> K >> N;
	
	for (int i = 2; i <= 2 * K; i++) {
		if (i % 2 == 1) {
			ll cnt = 0;
			int A = min((i - 1) / 2, (2 * (K + 1) - i) / 2);
			for (int j = 0; j <= A; j++) {
				ll tmp = 1;
				tmp *= (modpow(2, j) * comb(A, j)) % MOD;
				tmp *= hcomb(K - 2 * A + j, N - j);
				tmp %= MOD;
				cnt += tmp;
				cnt %= MOD;
			}
			cout << cnt << endl;
		}
		else {
			ll cnt = 0;
			int A = min((i) / 2, (2 * (K + 1) - i) / 2) - 1;
			for (int j = 0; j <= A; j++) {
				ll tmp = 1;
				tmp *= (modpow(2, j) * comb(A, j)) % MOD;
				ll a = hcomb(K - 2 * A + j - 1, N - j) + hcomb(K - 2 * A + j - 1, N - j - 1);
				a %= MOD;
				tmp *= a;
				tmp %= MOD;
				cnt += tmp;
				cnt %= MOD;
			}
			cout << cnt << endl;
		}
	}
 
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;


int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(b-a==c-b) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int c=0;
    char s;
    for(int i=0;i<4;i++)
    {
        cin>>s;
        if(s=='-') c--;
        else c++;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    char c;
    int ans = 0;
    rep(i, 4) {
        cin >> c;
        if (c == '+')
            ans++;
        else if (c == '-')
            ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3544
import java.util.*;

public class Main{
    public static void main(String[] args) {

      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();

      int[] foo;
      foo = new int[n];
      int T[] = new int[n];

      for(int i=0;i<n;i++){
      T[i] = sc.nextInt();
    }


        for(int i=T.length-1;i>=0;i--){
          if(i == 0){
          System.out.print(T[i]);
        }else{
            System.out.print(T[i]+" ");
          }
        }
        System.out.println("");
    }
}



Measured memory_bytes: 26296
N = int(input())
A = list(map(int, input().split()))

asum = 0
bsum = 0

for i in range(N) :
    ma = max(A)
    if i % 2 == 0:
        asum += ma
    else:
        bsum += ma
    A.remove(ma)

print(asum - bsum)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int a,b,c; cin >> a >> b >> c;

	swap(a, b);
	swap(a, c);
	cout << a << " " << b << " " << c << endl;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	string s;
	map<string,int>m;
	int out=0;
	while(cin>>s){
		m[s]++;
		int d=s.size();
		out=max(out,d);
	}
	int ma=0;
	string ans="";
	for(map<string,int>::iterator it=m.begin();it!=m.end();it++){
		ma=max(ma,it->second);
		if(out==it->first.size())ans=it->first;
	}
	for(map<string,int>::iterator it=m.begin();it!=m.end();it++){
		if(it->second==ma)cout<<(it->first)<<" ";
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1192
#include <iostream>
#include <cstdio>
#define N 105
using namespace std;

int n, m = 75, c, d[N]{0, 1};
bool v[N];
int main()
{
	int i, j, k;
	cin >> n;
	for (i = 2; i <= n; i++) {
		if (v[i]) continue;
		for (j = i * 2; j <= n; j += i) v[j] = 1;
		c = 0;
		for (j = i; j <= n; j *= i) c += n / j;
		for (j = m; j > 0; j--) {
			for (k = c; k > 0; k--) {
				if (j * (k + 1) <= m) d[j * (k + 1)] += d[j];
			}
		}
	}
    cout << d[m] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int main()
{
  int n, x;
  scanf("%d%d", &n, &x);
  int a[100];
  for (int i = 0; i < n; ++i)
  {
    scanf("%d", a + i);
  }
  std::sort(a, a + n);
  int ans = 0;
  for (int i = 0; i < n && x > 0; ++i)
  {
    x -= a[i];
    if (x >= 0) ++ans;
  }
  printf("%d\n", ans - (x > 0 ? 1 : 0));
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef int in;
typedef vector<in> VI;
typedef vector<VI> VVI;
struct unifnd{
  VI ht,pr;
  in fnd(in a){
    in ta=a;
    while(a!=pr[a])a=pr[a];
    in tt=ta;
    while(ta!=a){
      tt=pr[ta];
      pr[ta]=a;
      ta=tt;
    }
    return a;
  }
  void uni(in a, in b){
    a=fnd(a);
    b=fnd(b);
    if(a==b)return;
    if(ht[b]<ht[a])swap(a,b);
    pr[a]=b;
    ht[b]+=(ht[a]==ht[b]);
  }
  void ini(in n){
    ht.resize(n);
    pr.resize(n);
    forn(i,n){
      ht[i]=0;
      pr[i]=i;
    }
  }
};
unifnd tfd;
map<in,in> enc;
VI a,b;
VI dg;
VI pdg,ndg;
set<in> cmps;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  a.resize(n);
  b.resize(n);
  in x=0;
  forn(i,n){
    cin>>a[i];
    x^=a[i];
    enc[a[i]]=0;
  }
  forn(i,n){
    cin>>b[i];
    enc[b[i]]=0;
  }
  enc[x]=0;
  in nxt=0;
  fors(i,enc)
    i->second=nxt++;
  x=enc[x];
  dg.resize(nxt);
  in tcnt=0;
  tfd.ini(nxt);
  forn(i,n){
    a[i]=enc[a[i]];
    b[i]=enc[b[i]];
    if(a[i]==b[i])
      continue;
    tfd.uni(a[i],b[i]);
    ++tcnt;
    ++dg[b[i]];
    --dg[a[i]];
  }
  forv(i,dg){
    if(dg[i]>0)
      pdg.PB(i);
    if(dg[i]<0)
      ndg.PB(i);
  }
  if(!pdg.empty()){
    if(!(sz(pdg)==1 && pdg[0]==x && dg[x]==1)){
      cout<<-1<<endl;
      return 0;
    }
  }
  forn(i,n){
    if(a[i]!=b[i])
      cmps.insert(tfd.fnd(a[i]));
  }
  cmps.insert(tfd.fnd(x));
  tcnt+=sz(cmps)-1;
  cout<<tcnt<<endl;
  return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

typedef long long ll;
typedef pair<ll,ll> P;

vector<vector<int>> v(111111);

int dfs(int now, int pre, int s, int t){
	if(now == s)return 1;
	if(now == t)return 0;
	REP(i, v[now].size())if(v[now][i] != pre)return dfs(v[now][i], now, s, t);
	return 0;
}

int checkForm(int s, int t){
	int ret = 0;
	REP(i, 4)ret += dfs(v[s][i], s, s, t);
	return ret;
}

int main(){

	int n, m;cin >> n >> m;
	REP(i, m){
		int a, b;cin >> a >> b;
		a--;b--;
		v[a].EB(b);
		v[b].EB(a);
	}

	vector<int> four;
	int six = 0;

	REP(i, n){
		if(v[i].size() % 2){
			cout << "No" << endl;
			return 0;
		}

		if(v[i].size() == 4)four.PB(i);
		if(v[i].size() > 4)six++;
	}

	if(six > 0 || four.size() > 2){
		cout << "Yes" << endl;
		return 0;
	}

	if(four.size() < 2){
		cout << "No" << endl;
		return 0;
	}

	if(checkForm(four[0], four[1]) == 2)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string s,t;
  cin>>s>>t;
  t.pop_back();
  if(t==s)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3632