akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")


int cost[100][100];
int main()
{
	int H, W;
		cin >> H >> W;
		char field[100][100];
		fx(H) {
			string s;
			cin >> s;
			fy(W) {
				field[x][y] = s[y];
				cost[x][y] = INT_MAX/2;
			}
		}
		cost[0][0] = 0;
		fx(H) {
			fy(W) {
				if (x+1<H) {
					if (field[x][y]=='.'&&field[x+1][y]=='#') {
						cost[x + 1][y] = min(cost[x+1][y],cost[x][y]+1);
					}
					else {
						cost[x + 1][y] = min(cost[x + 1][y], cost[x][y]);
					}
				}
				if (y+1<W) {
					if (field[x][y] == '.' && field[x][y + 1] == '#') {
						cost[x][y + 1] = min(cost[x][y + 1], cost[x][y] + 1);
					}
					else {
						cost[x][y + 1] = min(cost[x][y + 1], cost[x][y]);
					}
				}
			}
		}

		if (field[0][0] == '#') {
			ce(cost[H - 1][W - 1]+1)
		}
		else {
			ce(cost[H - 1][W - 1])
		}

    return 0;
}



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

int main()
{
  int a, b;

  for (int i = 0; i < 10000; i++) {
    cin >> a >> b;
    if (a == 0 && b == 0) break;
    for (int j = 0; j < a; j++) {
      for (int k = 0; k < b; k++) cout << "#";
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3076
#include                        <bits/stdc++.h>
#include                        <ext/pb_ds/assoc_container.hpp>
#define lb                      lower_bound
#define ub                      upper_bound
#define pb(x)                   push_back(x)
#define ook(x)                  order_of_key(x)
#define fbo(x)                  find_by_order(x)
#define all(x)                  (x).begin(),(x).end()
#define FOR(i,a,b)              for(int i = a; i<=b; i++)
#define REP(i,a,b)              for(int i = a; i<b;  i++)
#define dbg(a)                  cout<<#a <<" --> "<<(a)<<endl;
#define TT                      int TC;  cin>>TC;  while(TC--)
#define read                    freopen("input.txt","r",stdin)
#define write                   freopen("output.txt","w",stdout)
#define set(x)                  tree<x,null_type,less<x>,rb_tree_tag,tree_order_statistics_node_update>
using                           namespace std;
using                           namespace __gnu_pbds;
typedef                         long long ll;
typedef                         pair<ll,ll> pll;
typedef                         pair<int,int> pii;

#define mx 200002
ll ar[27][mx];


main(){
//read;

string s;
cin>>s;
s = " " + s;
int n = s.size();
for(int i = 1; i<n; i++){
    int x = s[i] - 'a';
    ar[x][i]++;
    for(int j = 0; j<26; j++)
        ar[j][i]+=ar[j][i-1];
}

ll ans = 1;
for(ll i = 1; i<n; i++){
    int x = s[i] - 'a',b = 0;
    for(int j = 0; j<26; j++){
        if(j==x)    continue;
        b+=ar[j][n-1] - ar[j][i-1];
    }
    ans+=b;
}
cout<<ans;
return 0;
}


Measured memory_bytes: 41536
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

const int Mod = 1e9 + 7;
int dp[52][2505][52];

int Add(int &a, const int &b)
{
    a += b;
    if (a >= Mod) a -= Mod;
    return 1;
}

int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        int n, k;
        cin >> n >> k;
        dp[0][0][0] = 1;
        for (int i = 0; i <= n; i++) {
            for (int s = 0; s <= k; s++) {
                for (int j = 0; j <= n; j++) {
                    if (s + 2 * j <= k) {
                        //dp[i + 1][s + 2 * j][j] += dp[i][s][j] % Mod;
                        //dp[i + 1][s + 2 * j][j + 1] += dp[i][s][j] % Mod;
                        (dp[i + 1][s + 2 * j][j] += dp[i][s][j]) %= Mod;
                        (dp[i + 1][s + 2 * j][j + 1] += dp[i][s][j]) %= Mod;
                        if (j > 0) {
                            (dp[i + 1][s + 2 * j][j - 1] += 1ll * j * j * dp[i][s][j] % Mod) %= Mod;
                            (dp[i + 1][s + 2 * j][j] += 2ll * j * dp[i][s][j] % Mod) %= Mod;
                            // dp[i + 1][s + 2 * j][j - 1] += j * j * dp[i][s][j] % Mod;
                            // dp[i + 1][s + 2 * j][j - 1] %= Mod;
                            //dp[i + 1][s + 2 * j][j] += 2 * j * dp[i][s][j] % Mod;
                            //dp[i + 1][s + 2 * j][j] %= Mod;
                        }
                    }
                }
            }
        }
        cout << dp[n][k][0] << endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

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

#define MAXN (2010)

int n, a[MAXN];
bool vis[MAXN];
std::vector<int> vec[MAXN];
std::vector<int> seq[MAXN];

void merge(std::vector<int> &u, std::vector<int> &v){
	std::vector<int> tmp;
	int i = 0, j = 0, nu = u.size(), nv = v.size();
	for( ; i < nu && j < nv; ){
		if(u[i] > v[j]){
			tmp.push_back(u[i ++]);
		}
		else{
			tmp.push_back(v[j ++]);
		}
	}
	while(i < nu) tmp.push_back(u[i ++]);
	while(j < nv) tmp.push_back(v[j ++]);
	u = tmp;
}

bool cmp(const int &u, const int &v){
	return a[u] < a[v];
}

void dfs(int u){
	vis[u] = true;
	std::sort(vec[u].begin(), vec[u].end(), cmp);
	for(auto v : vec[u]){
		if(vis[v]) continue;
		dfs(v);
		merge(seq[u], seq[v]);
	}
	seq[u].insert(seq[u].begin(), a[u]);
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++ i){
		scanf("%d", a + i);
	}
	std::sort(a + 1, n + a + 1);
	for(int i = 1; i <= n; ++ i){
		for(int j = 1; j < i; ++ j){
			if(std::__gcd(a[i], a[j]) != 1){
				vec[i].push_back(j);
				vec[j].push_back(i);
			}
		}
	}
	std::vector<int> ans;
	for(int i = 1; i <= n; ++ i){
		if(!vis[i]){
			dfs(i);
			merge(ans, seq[i]);
		}
	}
	for(auto p : ans){
		printf("%d ", p);
	}
	printf("\n");
	return 0;
}

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

long long ans = 0;

long long merge(vector<int> &A, int left, int mid, int right)
{
    int n1 = mid + 1 - left;
    int n2 = right - mid;
    vector<int> L(n1 + 1);
    vector<int> R(n2 + 1);

    for (int i = 0; i < n1; i++)
    {
        L[i] = A[left + i];
    }
    for (int i = 0; i < n2; i++)
    {
        R[i] = A[mid + 1 + i];
    }
    L[n1] = R[n2] = 1e9 + 7;

    long long cnt = 0;
    int i = 0, j = 0;
    for (int k = left; k <= right; k++)
    {
        if (R[j] < L[i])
        {
            A[k] = R[j];
            j++;
            cnt += n1 - i;
        }
        else
        {
            A[k] = L[i];
            i++;
        }
    }

    return cnt;
}

void mergeSort(vector<int> &A, int left, int right)
{
    if (left < right)
    {
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid + 1, right);
        long long x = merge(A, left, mid, right);

        // cout << x << endl;
        // for (auto a : A)
        // {
        //     cout << a << " ";
        // }
        // cout << endl;

        ans += x;
    }

    return;
}

int main()
{
    int n;
    cin >> n;

    vector<int> A(n);
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
    }

    mergeSort(A, 0, n - 1);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4316
from collections import deque
n = int(input())
u = []
k = []
v = []

for i in range(n):
    tmp = list(map(int, input().split()))
    u.append(tmp[0])
    k.append(tmp[1])
    if tmp[1] != 0:
        v.append(tmp[2:])
    else:
        v.append([])
        
d = deque([1])
dis = [-1]*n
dis[0] = 0
visit = [False]*n
visit[0] = True
while len(d) > 0:
    go = d[0]
    flag = False
    for i in v[go-1]:
        if not visit[i-1]:
            d.append(i)
            dis[i-1] = dis[go-1] + 1
            visit[i-1] = True
            flag = True
    d.popleft()
    
for i in range(n):
    print(i+1, dis[i])


Measured memory_bytes: 6040
/*
ID: wangjun30
TASK:
LANG: C++
*/
#include<iostream>
using namespace std;
int main(){
	char a1,a2,a3,b1,b2,b3;
	cin>>a1>>a2>>a3>>b1>>b2>>b3;
	int x=0;
	if(a1==b1)
		x++;
	if(a2==b2)
		x++;
	if(a3==b3)
		x++;
	cout<<x;
	return 0;
}


Measured memory_bytes: 768
S, T = [input() for _ in range(2)]
smemo, tmemo = {}, {}
for si, ti in zip(S, T):
    if si in smemo and smemo[si] != ti or ti in tmemo and tmemo[ti] != si:
        print("No")
        quit()
    smemo[si], tmemo[ti] = ti, si
print("Yes")


Measured memory_bytes: 3632
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

#define all(A) A.begin(), A.end()

const ll mod = 1e9 + 7;
// const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

template<class t, class u>
ostream& operator<<(ostream& os, const pair<t, u>& p) {
	return os << "{" << p.first << "," << p.second << "}";
}

template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
	os << "{";
	for (auto e : v)os << e << ",";
	return os << "}";
}

// 約数列挙
vector< ll > divisor(ll n) {
	vector< ll > ret;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(all(ret));
	return (ret);
}

int main() {
	string S;
	ll K;
	cin >> S >> K;
	ll N = S.size();

	ll count = 0;
	if (S[0] != S[N - 1]) {

		repa(i, 1, N) {
			if (S[i - 1] == S[i]) {
				S[i] = '#';
				count++;
			}
		}

		cout << count * K << endl;

	}
	else {
		string S2 = S + S + S;

		ll count0 = 0;
		ll count1 = 0;
		ll count2 = 0;
		repa(i, 1, 3 * N) {
			if (S2[i - 1] == S2[i]) {
				S2[i] = '#';
				if (i < N) {
					count0++;
				}
				else if (i < 2*N) {
					count1++;
				}
				else {
					count2++;
				}
			}
		}

		ll ans;
		if (S2[0] == S2[N]) {
			ans = count0 * K;
		}
		else if(S2[N] == S2[2*N]) {
			ans = count0 + count1 * (K - 1);
		}
		else if (S2[0] == S2[2 * N]) {
			ans = (count0 + count1) * (K / 2);
			if (K % 2 == 1) {
				ans += count0;
			}
		}

		cout << ans << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DEBUG
  #include "debug.hpp"
#else
  #define DUMP(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
using value_type = typename iterator_traits<FwdIter>::value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */


int main(const int /*argc*/, char ** /*argv*/) {
  ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

  uint64_t k;
  cin >> k;
  cout << k * (k - 1) / 2ULL;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
a, v, = map(int, input().split())
b, w, = map(int, input().split())
t = (int)(input())

# 方向
dir = 1
if b < a:
    dir = -1

# 移動先
pos_a = a + v * dir * t
pos_b = b + w * dir * t

ret = "NO"
if dir == 1 and pos_a >= pos_b:
    ret = "YES"
elif dir == -1 and pos_b >= pos_a:
    ret = "YES"

print("{}".format(ret))

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

using namespace std;

inline void Boost() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}
typedef long long int ll;
typedef long double ld;

int main() {
	Boost();

	int n; cin >> n;
	vector < int > v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];

	vector < int > DP(n);
	DP[0] = 0; DP[1] = abs(v[1] - v[0]);

	for (int i = 2; i < n; ++i) {
		DP[i] = min(DP[i - 1] + abs(v[i - 1] - v[i]), DP[i - 2] + abs(v[i - 2] - v[i]));
	}

	cout << DP[n - 1];
	return 0;
}

Measured memory_bytes: 1024
h, w, k = map(int, input().split())
c = [list(map(int, list(input().replace('.', '0').replace('#', '1')))) for _ in range(h)]
cs = [[0] for _ in range(h)]
y = 0
for i, ci in enumerate(c):
    for j, cij in enumerate(ci):
        cs[i].append(cs[i][-1])
        cs[i][-1] += c[i][j]
    y += cs[i][-1]
ans = 0
for i in range(2 ** h):
    for j in range(2 ** w):
        x = 0
        for ii in range(h):
            if (i >> ii) & 1:
                x += cs[ii][-1]
            else:
                for jj in range(j):
                    if (j >> jj) & 1:
                        x += c[ii][jj]
        ans += (y - x == k)
print(ans)


Measured memory_bytes: 9240
import fractions
a, b = map(int, input().split())
g = fractions.gcd(a, b)
res = 1
x = 2
while x * x <= g:
  if g % x == 0:
    res += 1
    while g % x == 0:
      g //= x
  x += 1
print(res + int(g != 1))

Measured memory_bytes: 5176
#include<bits/stdc++.h>
using namespace std;
map<int,int> m;
int main(){
	int n,difer=0,ji=0;
	int a[100001];
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(m[a[i]]==0){
			m[a[i]]=1;
			difer++;
		}
		else{
			ji++;
		}
	}
	if(ji%2){
		printf("%d\n",difer-1);
	}
	else{
		printf("%d\n",difer);
	}
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, m; scanf("%d%d", &n, &m); std::vector<int> h(n, 0);
	for(int i = 0; i < m; i++) {
		int a, b; scanf("%d%d", &a, &b); a--; b--;

		h[a]++; h[b]++;
	}
	
	for(auto v: h) {
		if(v & 1) {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}


Measured memory_bytes: 640
import math
N,D = [int(x) for x in input().split()]
X = [list(map(int,input().split())) for i in range(N)]
count = 0
for j in range(N):
    for k in range(j+1,N):
        tmp = 0
        for l in range(D):
            tmp += pow(X[j][l] - X[k][l],2)
        if math.sqrt(tmp) % 1 == 0:
            count += 1
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cmath>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int n, cnt = 0, ans = 0;
	cin >> n;
	for (int i = 1; i < n + 1; i++) {
		if (i % 2 != 0) {

			for (int j = 1; j < 10000; j++) {
				if (i % j == 0) {
					cnt++;
				}
			}
		}
		if (cnt == 8) {
			ans++;
		}
		cnt = 0;
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long     ll;
#define fast          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fr            first
#define sc            second
#define com(i,n)      for(int i=0;i<n;i++)
#define dom(i,n)      for(int i=1;i<=n;i++)
#define mom(i,n)      for(int i=n;i>=0;i--)
#define sortI(a,n)    sort(a,a+n)
#define sortD(a,n)    sort(a,a+n,greater<int>())
#define sortvi(a)     sort(a.begin(),a.end())
#define sortvd(a)     sort(a.begin(),a.end(),greater<int>())
#define sumall(a,x)   accumulate(a.begin(),a.end(),x)
#define pi            3.14159265358979323846264338327950
using namespace std;
map<ll,ll>mp,xp;

int func(ll x)
{
    return x*x*x*x*x;
}

int main()
{
    ll n;
    cin>>n;
    if(n==1)
        cout << 0 << " " << -1 << endl;
    else
    {
        for(ll i=-200; i<=200; i++)
        {
            for(ll j=-200; j<=200; j++)
            {
                if(func(i)-func(j)==n)
                {
                    cout << i << " " << j << endl;
                    return 0;
                }
            }
        }
    }
}


Measured memory_bytes: 3620
import sys
input = sys.stdin.readline

maxLR = 10**9

N = int(input())
LRs = []
for _ in range(N):
    L, R = map(int, input().split())
    LRs.append((L, R))

LRs.sort()

accMinRs = [LRs[0][1]]
for L, R in LRs[1:]:
    accMinRs.append(min(accMinRs[-1], R))

accMinRRevs = [LRs[-1][1]]
for L, R in reversed(LRs[:-1]):
    accMinRRevs.append(min(accMinRRevs[-1], R))
accMinRRevs.reverse()

L2 = LRs[-1][0]
ans = 0
for x in range(N-1):
    L1, R1 = LRs[x]
    L0 = LRs[x-1][0] if x > 0 else 0
    R0 = accMinRs[x] if x > 0 else maxLR
    R2 = accMinRRevs[x+1]
    score1 = max(0, min(R0, R1)-max(L0, L1)+1) + max(0, R2-L2+1)
    score2 = max(0, R1-L1+1) + max(0, min(R0, R2)-max(L0, L2)+1)
    ans = max(ans, score1, score2)

print(ans)


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int A, B;
  cin >> A >> B;

  cout << A * B - A - B + 1 << endl;

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
//#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    int res = 1;

    x = x;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);

        y = y>>1;
        x = (x*x);
    }
    return res;
}
bool isprime(int x)
{
      if(x<2)
        return false;
    for(int i=2;i*i<=x;i++)
     {
        if (x%i==0)
            return false;
    }
    return true;
}
vector<int>primeFactors(int n)
{
    vector<int>v;
    int x=0;
    while (n % 2 == 0)
    {
        x++;
        n = n/2;
        v.pb(2);
    }
    //if(x>0)
    //v.pb({2,x});
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        int y=0;
        while (n % i == 0)
        {
            y++;
            n = n/i;
            v.pb(i);
        }
        //if(y>0)
        //v.pb({i,y});
    }
    if (n > 2)
        v.pb(n);
    return v;
}

vector<int>leastPrimeFactor(int n)
{
    vector<int>least_prime(n);
    // Create a vector to store least primes.
    // Initialize all entries as 0.
    // We need to print 1 for 1.
    least_prime[1] = 1;

    for (int i = 2; i <= n; i++)
    {
        // least_prime[i] == 0
        // means it i is prime
        if (least_prime[i] == 0)
        {
            // marking the prime number
            // as its own lpf
            least_prime[i] = i;

            // mark it as a divisor for all its
            // multiples if not already marked
            for (int j = 2*i; j <= n; j += i)
                if (least_prime[j] == 0)
                   least_prime[j] = i;
        }
    }
    return least_prime;
}
void constructXOR(int A[], int n)
{
    // calculate xor of array
    int XOR = 0;
    for (int i = 0; i < n; i++)
        XOR ^= A[i];

    // update array
    for (int i = 0; i < n; i++)
        A[i] = XOR ^ A[i];
}
void solve()
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
    cin>>a[i];
constructXOR(a,n);
for(int i=0;i<n;i++)
    cout<<a[i]<<" ";
}
signed main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
//cin>>t;
t=1;
while(t--)
{
solve();
}
}



Measured memory_bytes: 5240
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin >> a;
  int b = a/100000000 + a%100000000/10000000 + a%10000000/1000000
            +a%1000000/100000 + a%100000/10000 + a%10000/1000
               +a%1000/100 + a%100/10 + a%10;
  if(a%b == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
def main():
    s=input()
    l=len(s)
    i,j=0,l-1
    ans,cnti,cntj=0,0,0
    while i+1<j:
        if s[i]=='x':
            i+=1
            cnti+=1
        elif s[j]=='x':
            j-=1
            cntj+=1
        else:
            if s[i]==s[j]:
                ans+=abs(cnti-cntj)
                cnti,cntj=0,0
                i+=1
                j-=1
            else:
                print(-1)
                exit()
    if i==j:
        print(ans)
    else:
        if s[i]==s[j]:
            print(ans)
        else:
            if s[i]=='x':
                print(ans+abs(cnti+1-cntj))  
            elif s[j]=='x':
                print(ans+abs(cnti-cntj-1))
            else:
                print(-1)          
    
if __name__=='__main__':
    main()

Measured memory_bytes: 3316
using System;

namespace ConsoleApplication1{
    class Program{
        static void Main(string[] args){
            while (true) {
                String str=Console.ReadLine();
                if(str==null){
                    break;
                }
                String[] a = str.Split();
                Console.WriteLine((int.Parse(a[0]) + int.Parse(a[1])).ToString().Length);
            }
        }
    }
}

Measured memory_bytes: 5624
#include <iostream>

using namespace std;

int main(){
	long n, a, d = -1e9, m = 1e9;
	cin >> n;
	for(int i = 0;i < n;++i){
		cin >> a;
		if(i != 0 && (a - m) > d) d = a - m;
		if(a < m) m = a;
	}
	cout << d << endl;
}

Measured memory_bytes: 3076
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }

int main() {
    int N;
    cin >> N;
    vector<ll> T(N);
    rep(i, N) cin >> T[i];
    ll lcm = T[0];
    rep(i, N) { lcm = lcm * (T[i] / gcd(lcm, T[i])); }
    cout << lcm << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);


int solve(int a) {
	if (a <= 9)return a;
	return solve(a / 10) + (a % 10);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	int ans = intmax;
	for (int i = 1; i < N; ++i) {
		ans = min(ans, solve(i) + solve(N - i));
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	var N int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)

	for i := 0; i < N; i++ {
		var str string
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%s", &str)
		if str == "Y" {
			fmt.Println("Four")
			return
		}
	}
	fmt.Println("Three")
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define PLL pair<ll,ll>
#define F first
#define S second
#define MP make_pair
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define N 100001

int main()
{
    fastio;
   
    ll r,i,n;
    cin >> n>>r;
    ll h[n+1];
    for(i=1;i<=n;i++)
    cin >> h[i];
    ll ng[n+1]={0};
    
    while(r--)
    {
        ll u,v;
        cin >> u >> v;
        
        if(h[u]>h[v])
        ng[v]=1;
        
        if(h[v] > h[u])
        ng[u]=1;
        
        if(h[v]==h[u])
        {
            ng[u]=1;
            ng[v]=1;
        }
    }
    ll count=0;
    for(i=1;i<=n;i++)
    {
        if(!ng[i])
        count++;
    }
    
    cout << count <<'\n';
}

Measured memory_bytes: 5200
#include <iostream>
#include <vector>
#include <set>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
int n, m, q;
int a[51], b[51], c[51], d[51];
int v[11];
int ans = 0;
 
void dfs(int cid) {
    if (cid <= n) {
        rep(i, v[cid - 1], m + 1) {
            v[cid] = i;
            dfs(cid + 1);
        }
    } else {
        int sc = 0;
        rep(i, 0, q) {
            if (v[b[i]] - v[a[i]] == c[i]) sc += d[i];
        }
        ans = max(ans, sc);
    }
}
 
int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit);
 
    cin >> n >> m >> q;
    
    rep(i, 0, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
 
    v[0] = 1;
    dfs(1);
 
    cout << ans << endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define show(x) cout << #x << " : " << x << endl
int n, i, j, k, h[100001], dp[100001];
int main ()
{
    cin >> n >> k;
    for(i = 1; i <= n; i++) cin >> h[i];
    for(i = 2; i <= n; i++) dp[i] = INT_MAX;
    for(i = 2; i <= n; i++)
    {
        for(j = 1; j <= k and i-j > 0; j++)
        {
            dp[i] = min(abs(h[i-j]-h[i])+dp[i-j], dp[i]);
        }
    }
    cout << dp[n] << endl;
}



Measured memory_bytes: 1024
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    s = str(input().rstrip('\n'))
    c = 0
    cl = 0
    mcl = 0
    cr = 0
    mcr = 0
    for i in range(n):
        if i != 0:
            if s[i] != s[i-1]:
                c += 1
                
        if s[i] == "R":
            cr += 1
            mcl += max((cl - 1), 0)
            cl = 0
        else:
            cl += 1
            mcr += max((cr - 1), 0)
            cr = 0

        if i == n - 1:
            mcl += max((cl - 1), 0)
            mcr += max((cr - 1), 0)

    print(min(mcl + mcr + k * 2, n - 1))


if __name__ == '__main__':
    slove()


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

template<class E>
using nega_queue=priority_queue<E,vector<E>,greater<E>>;

UL N;
ULL D[100000];
vector<pair<UL,ULL>> E[100000];

int main() {
 scanf("%u",&N);
 rep(i,N){
  UL u,k; scanf("%u%u",&u,&k);
  rep(j,k){
   UL v,c; scanf("%u%u",&v,&c);
   E[u].push_back({v,c});
  }
 }
 rep(i,N) D[i]=~0u;
 nega_queue<pair<ULL,UL>> G;
 G.push({0,0});
 int ans=0;
 while(G.size()){
  ULL d=G.top().first;
  UL p=G.top().second;
  G.pop();
  if(D[p]!=~0u) continue;
  D[p]=d;
  for(auto e:E[p]) G.push({d+e.second,e.first});
 }
 rep(i,N) printf("%u %llu\n",i,D[i]);
 return 0;
}



Measured memory_bytes: 22304
#!/usr/bin/env python3
from collections import Counter
n = int(input())
s = [0]*n
a = [[0 for l in range(26)] for m in range(n)]
for i in range(n):
    s[i] = input()
for j in range(n):
    a[j][0] = s[j].count('a')
    a[j][1] = s[j].count('b')
    a[j][2] = s[j].count('c')
    a[j][3] = s[j].count('d')
    a[j][4] = s[j].count('e')
    a[j][5] = s[j].count('f')
    a[j][6] = s[j].count('g')
    a[j][7] = s[j].count('h')
    a[j][8] = s[j].count('i')
    a[j][9] = s[j].count('j')
    a[j][10] = s[j].count('k')
    a[j][11] = s[j].count('l')
    a[j][12] = s[j].count('m')
    a[j][13] = s[j].count('n')
    a[j][14] = s[j].count('o')
    a[j][15] = s[j].count('p')
    a[j][16] = s[j].count('q')
    a[j][17] = s[j].count('r')
    a[j][18] = s[j].count('s')
    a[j][19] = s[j].count('t')
    a[j][20] = s[j].count('u')
    a[j][21] = s[j].count('v')
    a[j][22] = s[j].count('w')
    a[j][23] = s[j].count('x')
    a[j][24] = s[j].count('y')
    a[j][25] = s[j].count('z')
counter = Counter(tuple(x) for x in a)
k = list(counter.values())
ans = 0
for y in k:
    ans += (y*(y-1))//2
print(ans)

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

const int MAXN = 205;

int H, W;
char A[MAXN][MAXN];

int x[MAXN][MAXN][MAXN], y[MAXN][MAXN][MAXN], z[MAXN];
int nx[MAXN][MAXN][MAXN], ny[MAXN][MAXN][MAXN];

int main(){
	scanf("%d %d", &H, &W);
	for(int i = 0; i < H; i++)
		scanf("%s", A[i]);
		
	for(int c = 0; ; c++){
		if(c == 0){
			for(int i = 0; i < H; i++){
				for(int j = i; j < H; j++){
					for(int k = 0; k < W; k++){
						if(j == i){
							if(A[j][k] == '#')z[k] = 1;
							else z[k] = 0;
						}else{
							if(A[j][k] == '#' && z[k] == 0)z[k] = 2;
							else if(A[j][k] == '.' && z[k] == 1)z[k] = 2;
						}
					}
					
					int R = -1, c = -1;
					for(int k = 0; k < W; k++){
						if(R < k){
							R = k - 1;
							c = -1;
						}
						
						while(R + 1 < W && z[R + 1] != 2 && (c == -1 || c == z[R + 1])){
							R++;
							c = z[R];
						}
						
						x[i][j][k] = R;
					}
				}
			}
			
			for(int i = 0; i < W; i++){
				for(int j = i; j < W; j++){
					for(int k = 0; k < H; k++){
						if(j == i){
							if(A[k][j] == '#')z[k] = 1;
							else z[k] = 0;
						}else{
							if(A[k][j] == '#' && z[k] == 0)z[k] = 2;
							else if(A[k][j] == '.' && z[k] == 1)z[k] = 2;
						}
					}
					
					int R = -1, c = -1;
					for(int k = 0; k < H; k++){
						if(R < k){
							R = k - 1;
							c = -1;
						}
						
						while(R + 1 < H && z[R + 1] != 2 && (c == -1 || c == z[R + 1])){
							R++;
							c = z[R];
						}
						
						y[i][j][k] = R;
					}
				}
			}
		}else{
			for(int i = 0; i < H; i++)
			for(int j = i; j < H; j++){
				int R = -1;
				for(int k = 0; k < W; k++){
					if(R < k)R = k - 1;
					
					if(x[i][j][k] >= k){
						if(x[i][j][k] < W - 1 && x[i][j][x[i][j][k] + 1] > x[i][j][k]){
							R = max(R, x[i][j][x[i][j][k] + 1]);
						}else{
							R = max(R, x[i][j][k]);
						}
					}
					
					while(R + 1 < W){
						if(y[k][R + 1][i] >= i){
							if(y[k][R + 1][i] >= j)R++;
							else if(y[k][R + 1][y[k][R + 1][i] + 1] >= j)R++;
							else break;
						}else break;
					}
					
					nx[i][j][k] = R;
				}
			}
			
			for(int i = 0; i < W; i++)
			for(int j = i; j < W; j++){
				int R = -1;
				for(int k = 0; k < H; k++){
					if(R < k)R = k - 1;
					
					if(y[i][j][k] >= k){
						if(y[i][j][k] < H - 1 && y[i][j][y[i][j][k] + 1] > y[i][j][k]){
							R = max(R, y[i][j][y[i][j][k] + 1]);
						}else{
							R = max(R, y[i][j][k]);
						}
					}
					
					while(R + 1 < H){
						if(x[k][R + 1][i] >= i){
							if(x[k][R + 1][i] >= j)R++;
							else if(x[k][R + 1][x[k][R + 1][i] + 1] >= j)R++;
							else break;
						}else break;
					}
					
					ny[i][j][k] = R;
				}
			}
			
			for(int i = 0; i < H; i++)
			for(int j = i; j < H; j++)
			for(int k = 0; k < W; k++)
				x[i][j][k] = nx[i][j][k];
				
			for(int i = 0; i < W; i++)
			for(int j = i; j < W; j++)
			for(int k = 0; k < H; k++)
				y[i][j][k] = ny[i][j][k];
		}
		
		if(x[0][H - 1][0] == W - 1){
			printf("%d\n", c);
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 129152
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long i,j,n,m,s=0;
    cin>>n>>m;
    int a[m];
    for(i=0;i<m;i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    if(s>n)cout<<-1;
    else cout<<n-s;
}


Measured memory_bytes: 3636
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int N = Integer.parseInt(sc.next());
		int Y = Integer.parseInt(sc.next());

		out.println(otoshidama(N, Y));
		out.flush();
	}
	
	public static String otoshidama(int N, int Y) {
		int a = N;
		for (int b = 0; b <= N; b++) {
			for (int c = 0; c <= N-b; c++) {
				int total = 10000*(a-b-c)+5000*b+1000*c;
				if (total == Y) {
					return String.format("%d %d %d", (a-b-c), b, c);
				}
			}
		}
		return "-1 -1 -1";
	}
}

Measured memory_bytes: 35932
n = int(input())
def f(a, b):
  return max(map(len, map(str, (a, b))))

a, b = 1, n
for i in range(2, int(n**0.5) + 1):
  q, r = divmod(n, i)
  if r == 0:
    a, b = i, q
print(f(a, b))

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<String> l = Arrays.asList(sc.nextLine().split(" "));
		int a = Integer.parseInt(l.get(0));
		int b = Integer.parseInt(l.get(1));
		int ans = a * b;
		System.out.print(ans);
	}
}

Measured memory_bytes: 35752
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s, t; cin >> s >> t;
    int n_s = s.size();
    int n_t = t.size();
    queue<char> q;
    rep(i,n_t) q.push(t[i]);
    vvint data(26);
    rep(i,2*n_s) {
        data[s[i%n_s]-'a'].push_back(i);
    }
    rep(i,n_t) {
        if (data[t[i]-'a'].size() == 0) {cout << -1 << endl; return 0;}
    }
    ll ans = 0;
    int now = 0;
    while (!q.empty()) {
        now = *lower_bound(all(data[q.front()-'a']),now)+1;
        if (now >= n_s) {
            ans += n_s; 
            now %= n_s;
        }
        q.pop();
    }
    cout << ans + now << endl;
}

Measured memory_bytes: 1792
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

h, w = na()
a, b = na()
c, d = a * w, b * (h - a)
print((h * w) - (c + d))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() 
{
  int N;
  cin >>N;
  int ans=0;
  vector<int> p(N);
  rep(i,N)
    cin >>p[i];
  rep(i, N-2){
  if(p[i]<p[i+1]&&p[i+1]<p[i+2])
    ans++;
  if(p[i]>p[i+1]&&p[i+1]>p[i+2])
    ans++;
  }
cout << ans << endl;
}


Measured memory_bytes: 256
PROGRAM piyo
      IMPLICIT NONE
      integer(16) :: n
      character(:),allocatable :: s
      integer(16) :: l,c,r,ans,pos1,pos2,pos3
      character(1) :: ch(0:9)
      
      ch(:) = ['0','1','2','3','4','5','6','7','8','9']
      
      read*,n
      allocate( character(n) :: s )
      read*,s
      
      ans = 0
      do l = 0,9
        pos1 = index(s(1:n),ch(l))
        if(pos1==0.or.pos1==n) cycle
        do c = 0,9
          pos2 = index(s(pos1+1:n),ch(c) )
          if(pos2==0) cycle
          pos2 = pos2 + pos1
          if(pos2==n) cycle
          do r = 0,9
            pos3 = index(s(pos2+1:n),ch(r) )
            if(pos3==0)then
              cycle
            else
              ans = ans + 1
            end if
          end do
        end do
      end do
      
      print*,ans
      
      
      END PROGRAM

Measured memory_bytes: 384
import itertools
D, G = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(D)]
bit = itertools.product([0, 1], repeat=D)
ans = 1000
for bi in bit:
    cnt = 0
    score = 0
    nokori = []
    for i in range(D):
        if bi[i] == 0:
            nokori.append([pc[i][0], (i+1)*100])
            continue
        score += pc[i][1] + 100*(i+1)*(pc[i][0])
        cnt += pc[i][0]
    if score >= G:
        ans = min(ans, cnt)
    else:
        for num, point in reversed(nokori):
            for j in range(1, num):
                cnt += 1
                score += point
                if score >= G:
                    ans = min(ans, cnt)
                    break
            else:
                continue
            break
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>         //可以处理负权边
using namespace std;
const int INF =  0x3f3f3f;
#define rep(i,n) for( i = 0; i < n; i++)
#define rep2(i,n) for(i = n-1; i >= 0; i--)
#define rep3(i,n,m) for(i = m; i < n; i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
typedef long long ll;
const int N = 10000+50;
typedef pair<int, int> P;
typedef vector<P> vctp;
int a[N] = {0};
int main(){
    CloseIo;
    int a,b,c;
    cin>>a>>b>>c;
    int mx = b/a;
    if(mx > c) mx = c;
    cout<<mx<<endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	Scanner scan = new Scanner(System.in);
	int n;
	int i;
	int j;
	public Main(){
		n = scan.nextInt();
		int[] a=new int[n];
		for(i=0; i<n; i++){
			a[i]=scan.nextInt();
		}
		int[] b=new int[n];
		i = 0;
		for(j=n-1;j>=0;j--){
			b[i]=a[j];
			i++;
		}
		for(i=0;i<n;i++){
			System.out.print(b[i]);
                        if(i==n-1){
                            System.out.println("");
                            break;
                        }else{
			    System.out.print(" ");
		        }
	        }
        }
	public static void main(String[] args){
		new Main();
	}
}

Measured memory_bytes: 26256
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;
class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        char[][] map = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().ToArray()).ToArray();
        //[x][y][深さ]
        bool[][][] isSame = Enumerable.Repeat(0, n).Select(_ => Enumerable.Repeat(0, n).Select(__ => new bool[n]).ToArray()).ToArray();
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                for (int k = 0; k < n; k++)
                {
                    isSame[i][j][k] = map[i][j] == map[(i + k) % n][(n + j - k) % n];
                }
            }
        }
        bool[][] isAllSame = Enumerable.Repeat(0, n).Select(_ => Enumerable.Repeat(true, n).ToArray()).ToArray();
        //スタート
        for (int i = 0; i < n; i++)
        {
            //串のインデックス
            for (int j = 0; j < n; j++)
            {
                //ズラす
                for (int k = 0; k < n; k++)
                {
                    if (!isSame[(i + k) % n][k][j])
                    {
                        isAllSame[i][j] = false;
                        break;
                    }
                }
            }
        }
        int count = 0;
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                if (!isAllSame[(i + j) % n][n - (j + 1)]) goto end;
            }
            count++;
            end:;
        }
        Console.WriteLine(count * n);
    }
}


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

using namespace std;

#define inf 1<<30
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;


int main(){
	int N, W, w[100];
	llong v[100];
	vector<llong> dp(100001, 0);

	cin >> N >> W;
	for(int i = 0; i < N; i++)
		cin >> w[i] >> v[i];
	for(int i = 0; i < N; i++)
		for(int j = W; j >= w[i]; j--)
			dp[j] = max(dp[j], dp[j-w[i]] + v[i]);

	for(int i = 1; i <= W; i++)
		dp[i] = max(dp[i], dp[i-1]);
	cout << dp[W] << endl;

	return 0;
}

Measured memory_bytes: 1024
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


int main()
{
    
    string S;
    cin >> S;
    vector<string> wds = {"dream" , "dreamer" , "erase" , "eraser" };
    reverse(S.begin(), S.end());
    for(int i=0;i<4;i++){
        reverse(wds[i].begin(), wds[i].end());
    }
    int flag = 1;
    string head;
    while(!S.empty() && flag){
        flag = 0;
        for(auto wd:wds){
            head = S.substr(0,wd.length());
            if(head == wd){
                flag = 1;
                S.erase(S.begin(), S.begin() + wd.length());
            }
        }
    }
    if(S.empty()) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}


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

int main()
{
	int n;
	cin>>n;
	vector<double> p;
	p.resize(n+1);
	int i,j,k;
	for(i=1;i<=n;i++)
		cin>>p[i];
	vector<vector<double> > prob;
	prob.resize(n+1);
	for(i=0;i<=n;i++)
		prob[i].resize(n+1);
	prob[1][1] = p[1];
	prob[1][0] = 1.0 - p[1];

	for(i=2;i<=n;i++)
	{
		prob[i][0] = (1.0 - p[i])*prob[i-1][0];
		for(j=1;j<=i;j++)
		{
			prob[i][j] = prob[i-1][j]*(1.0 - p[i]) + prob[i-1][j-1]*p[i];
		}
	}
	double ans = 0.0;
	int lim = (n+1)/2;
	for(i=lim;i<=n;i++)
		ans = ans + prob[n][i];
	cout<<setprecision(12)<<ans<<endl;
	return 0;
}

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

using namespace std;

int K, L;
char s[1000000];

// 'a' <- 97
// 'z' <- 122

int main() {
    scanf("%s", s);
    scanf("%d", &K);
    L = strlen(s);
    
    // Greedy algorithm, always try to flip from first character
    // Keep rotating till 'a' if possible, if not, move to next index
    int i = 0;
    
    while (i < L && K > 0) {
        // Compute how much needed to hit 'a'
        int current = (int) s[i];
        int need = (123 - current) % 26;
        if (need <= K) {
            s[i] = 'a';
            K -= need;
        }
        i++;
    }
    
    // Rotate all on last index
    i = L-1;
    if (K > 0) {
        int current = (int) s[i];
        int result = 97 + ((current - 97 + K) % 26);
        s[i] = result;
        K = 0;
    }
    
    printf("%s\n", s);

    return 0;
}

Measured memory_bytes: 512
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
/*
template <typename T>  using ordered_set =
    tree<T, null_type, less<T>,   /// greater<T> for sorting decreasingly
    rb_tree_tag, tree_order_statistics_node_update>;
*/

#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         mod                         1000000007
#define         INF                         2e18
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;

ll a[55];
int main(){
    ll n;
    sfl(n);
    for(ll i=1;i<=n;i++) sfl(a[i]);
    bool ans=1;
    for(ll i=1;i<=n;i++){
        if(a[i]<a[i-1]){
            ans = 0;
        }
    }
    if(ans){
        printf("YES\n");
        return 0;
    }
    ans = 0;
    for(ll i=1;i<=n;i++){
        for(ll j=i+1;j<=n;j++){
            swap(a[i],a[j]);
            ans  = 1;
            for(ll k=1;k<=n;k++){
                if(a[k]<a[k-1]){
                    ans = 0;
                }
            }
            if(ans){
                printf("YES\n");
                return 0;
            }
            swap(a[i],a[j]);
        }
    }
    printf("NO\n");
    return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> l(m);
    vector<int> r(m);
    int i;
    for(i = 0; i < m; i++){
        cin >> l.at(i) >> r.at(i);
    }
    int ans = 0;
    int max = 0, min = 100001;
    for(i = 0; i < m; i++){
        if(l.at(i) > max){
            max = l.at(i);
        }
        if(r.at(i) < min){
            min = r.at(i);
        }
    }
    if(min - max < -1){
        cout << 0 << endl;
    }
    else{
        cout << min - max + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 1024