akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct P
{
	int c, x, y, z;
	P(int c, int x, int y, int z) :c(c), x(x), y(y), z(z) {}
	P() :P(0, 0, 0, 0) {}
	bool operator<(const P& p)const
	{
		return c < p.c;
	}
	bool operator>(const P& p)const
	{
		return c > p.c;
	}
	bool operator>=(const P& p)const
	{
		return c >= p.c;
	}
	bool operator<=(const P& p)const
	{
		return c <= p.c;
	}
};

bool used[1010][1010][1010];

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

	priority_queue<P> pq;
	int X, Y, Z, K;
	int x[1010], y[1010], z[1010];
	cin >> X >> Y >> Z >> K;
	rep(i, 0, X)
	{
		cin >> x[i];
	}
	rep(i, 0, Y)
	{
		cin >> y[i];
	}
	rep(i, 0, Z)
	{
		cin >> z[i];
	}
	sort(x, x + X);
	sort(y, y + Y);
	sort(z, z + Z);
	pq.push(P(x[X - 1] + y[Y - 1] + z[Z - 1], X - 1, Y - 1, Z - 1));

	int k = 0;
	while (k < K)
	{
		const auto p = pq.top();
		pq.pop();
		if (used[p.x][p.y][p.z])continue;
		used[p.x][p.y][p.z] = true;
		cout << p.c << endl;
		if (0 < p.x)
		{
			pq.push(P(x[p.x - 1] + y[p.y] + z[p.z], p.x - 1, p.y, p.z));
		}
		if (0 < p.y)
		{
			pq.push(P(x[p.x] + y[p.y - 1] + z[p.z], p.x, p.y - 1, p.z));
		}
		if (0 < p.z)
		{
			pq.push(P(x[p.x] + y[p.y] + z[p.z - 1], p.x, p.y, p.z - 1));
		}
		k++;
	}

	return 0;
}



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

int main(void){
    int A,B,i,Sum=0;
    cin >> A >> B;

    for(i=0;i<2;i++){
        if(A>B){
            Sum += A;
            A--;
        }else{
            Sum += B;
            B--;
        }
    }

    cout << Sum;

    return 0;
}

Measured memory_bytes: 3592
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] ab = new int[m][2];
        for (int i = 0; i < m; i++) {
            ab[i][0] = sc.nextInt();
            ab[i][1] = sc.nextInt();
        }
        Arrays.sort(ab, Comparator.comparingInt(a -> a[0]));
        int min = Integer.MAX_VALUE;
        int cnt = 1;
        for (int i = 0; i < m; i++) {
            if (ab[i][0] >= min) {
                cnt++;
                min = ab[i][1];
                continue;
            }
            min = Math.min(min, ab[i][1]);
        }
        System.out.println(cnt);
    }

}


Measured memory_bytes: 94852
/*Lucky_Glass*/
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=1e5;

int n,q;
long long m;
bool B1;

struct MERGESET{
	int Mfa[N+3],Msiz[N+3];
	void Init(int Nn){
		for(int i=1;i<=Nn;i++)
			Mfa[i]=i,Msiz[i]=1;
	}
	int FindFa(int u){
		if(u==Mfa[u]) return u;
		return Mfa[u]=FindFa(Mfa[u]);
	}
	bool Merge(int u,int v){
		int Fu=FindFa(u),Fv=FindFa(v);
		if(Fu==Fv) return false;
		Mfa[Fu]=Fv;
		Msiz[Fv]+=Msiz[Fu];
		Msiz[Fu]=0;
		return true;
	}
}Mset;

vector< pair<int,int> > Opt1;

int main(){
	scanf("%d%lld%d",&n,&m,&q);
	Mset.Init(n);
	for(int i=1;i<=q;i++){
		int u,v,tmp;
		scanf("%d%d%d",&u,&v,&tmp);
		u++;v++;
		if(tmp)
			Opt1.emplace_back(u,v),
			B1=true;
		else
			Mset.Merge(u,v);
	}
	for(auto it : Opt1){
		int u=it.first,v=it.second;
		int Fu=Mset.FindFa(u),Fv=Mset.FindFa(v);
		if(Fu==Fv){
			printf("No\n");
			return 0;
		}
	}
	long long Etot=0,Etre=0;
	for(int i=1;i<=n;i++)
		if(Mset.Msiz[i])
			Etot+=Mset.Msiz[i]-1,
			Etre++;
	if(B1){
		if(Etot+Etre<=m && m<=Etot+Etre*(Etre-1)/2)
			printf("Yes\n");
		else
			printf("No\n");
	}
	else{
		if(Etot+Etre-1<=m && m<=Etot+Etre*(Etre-1)/2)
			printf("Yes\n");
		else
			printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 2168
#include <stdio.h>

int main(int argc, char const *argv[]) {
	char str[101];
	int x1, x2, y1, y2;
	int x3, x4, y3, y4;

	fgets(str, 100, stdin);
	sscanf(str, "%d %d %d %d\n", &x1, &y1, &x2, &y2);

	int vx, vy;

	vx = x2 - x1;
	vy = y2 - y1;

	x4 = x1 - vy;
	y4 = y1 + vx;
	x3 = x4 + vx;
	y3 = y4 + vy;

	printf("%d %d %d %d\n", x3, y3, x4, y4);

	return 0;
}


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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    
    printf("%d\n", n * (n - 1) / 2 + m * (m - 1) / 2);
    return 0;
}


Measured memory_bytes: 256
def solution(n, m, coins)
  dp = [0] + [Float::INFINITY] * n
  for coin in coins
    for amount in 0..n
      if amount >= coin
        dp[amount] = [dp[amount], dp[amount - coin] + 1].min
      else
        dp[amount] = dp[amount]
      end
    end
  end
  dp[n]
end


first_line = gets.split.map(&:to_i)
coins = gets.split.map(&:to_i)
p solution(first_line[0], first_line[1], coins)


Measured memory_bytes: 9260
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
using namespace std;
typedef long long ll;
ll mod = 1000000007;

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

	ll S[200001];
	for (int i = 0; i < N; i++)
	{
		cin >> S[i];
	}
	for (int i = 0; i < N; i++)
	{
		S[i + 1] = S[i + 1] + S[i];
	}

	ll minValue = 1000000000000;
	for (int i = 0; i < N - 1; i++) {
		ll x = S[i];
		ll y = S[N - 1] - S[i];

		minValue = min(minValue, abs(x - y));
	}

	cout << minValue << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

ll H, W;
char S[2002][2002];
ll num[2002][2002];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> H >> W;
    rep(i, H){
        string inp;
        cin >> inp;
        inp += "#";
        
        ll cnt = 0;
        vector<ll> space;
        rep(j, inp.size()){
            if(inp[j] == '.') cnt++;
            if(inp[j] == '#') {space.pb(cnt); cnt = 0;}
        }
        
        ll space_idx = 0;
        rep(j, W){
            S[i][j] = inp[j];
            if(inp[j] == '.') {
                num[i][j] = space[space_idx];
            }else{
                space_idx ++;
            }
        }
    }
    
    
    rep(i, W){
        
        ll cnt = 0;
        vector<ll> space;
        rep(j, H){
            if(S[j][i] == '.') cnt ++;
            if(S[j][i] == '#'){space.pb(cnt); cnt = 0;}
        }
        space.pb(cnt);
        
        ll space_idx = 0;
        rep(j, H){
            if(S[j][i] == '.'){
                num[j][i] += space[space_idx];
            }else{
                space_idx ++;
            }
        }
    }
    
    ll ans = 0;
    rep(i, H)rep(j, W){
        ans = max(ans, num[i][j]);
    }
    cout << ans -1 << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 35584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int h = sc1.nextInt();
		int w = sc1.nextInt();
		int count = 0;
		char[][] grid = new char[h][w];
		int[][] flag = new int[h][w];
		boolean ans = false;
		boolean flag1 = false;

		for (int i = 0; i < h ; i++) {
			String str = sc1.next();
			for (int j = 0; j < w ; j++) {
				grid[i][j] = str.charAt(j);
				flag[i][j] = 0;
			}
		}


		for (int i = 0; i < h ; i++) {
			if(flag1) {
				break;
			}
			for (int j = 0; j < w ; j++) {

				if(grid[i][j] == '#') {
					if(flag[i][j] == 0) {
						if(i < h-1 && grid[i+1][j] == '#') {
							flag[i+1][j] = 1;
							ans = true;
							continue;
						}
						else if (j < w-1 && grid[i][j+1] == '#') {
							flag[i][j+1] = 1;
							ans = true;
							continue;
						}
						else if (i > 0 && grid[i-1][j] == '#') {
							ans = true;
							continue;
						}
						else if(j > 0 && grid[i][j-1] == '#') {
							ans = true;
							continue;
						}
						else {
							ans = false;
							flag1 = true;
							break;
						}
					}
				}
				else {
					count++;
				}
			}
		}

		if(ans) {
			System.out.println("Yes");
		}
		else if(count == h * w) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		sc1.close();
	}

}

Measured memory_bytes: 23124
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N;
    cin >> N;
    vector<ll> v(N + 1);
    rep(i, 0, N) {
        cin >> v[i + 1];
    }

    rep(i, 0, N) {
        v[i + 1] += v[i];
    }

    map<ll, ll> mp;
    rep(i, 0, N + 1) {
        mp[v[i]]++;
    }

    ll ans = 0ll;
    for (auto e: mp) {
        if (e.second >= 2) {
            ll tmp = e.second;
            ans += 1LL * tmp * (tmp - 1) / 2;
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 14336
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

x = int(input())
if x<1200:
    print("ABC")
else:
    print("ARC")

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll long long
#define ld double
using namespace std;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
int a[2000005],n;
ll s[2000005],ans=1e18;
int main(){
	n=read();
	for(int i=1;i<=n;++i)a[i]=read()-i;
	sort(a+1,a+n+1);
	for(int i=1;i<=n;++i)s[i]=s[i-1]+a[i];
	for(int i=1;i<=n;++i)ans=min(1ll*a[i]*i-s[i]+s[n]-s[i]-1ll*a[i]*(n-i),ans);
	printf("%lld",ans);
} 

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

using namespace std;
typedef long long ll;

const ll INF = 1e11;
ll memo[10][101][1001];

void init() {
    for (int i = 0; i < 10; i++)
        for (int j = 0; j < 101; j++)
            for (int k = 0; k < 1001; k++)
                memo[i][j][k] = INF;
    memo[1][100][100] = 1;
}

ll solve(int n, int i, int s) {
    if (i > 100) return 0;
    if (memo[n][i][s] != INF) return memo[n][i][s];

    if ((n == 0 && s > 0) || (n > 0 && i > s)) return memo[n][i][s] = 0;
    if (n == 0 && s == 0) return memo[n][i][s] = 1;
    return memo[n][i][s] = solve(n - 1, i + 1, s - i) + solve(n, i + 1, s);
}

int main() {
    init();

    int n, s;
    while (scanf("%d %d", &n, &s), n)
        cout << solve(n, 0, s) << endl;

    return 0;
}


Measured memory_bytes: 11092
x = int(input())

if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
else:
    print(1)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;
constexpr ll MOD = 1000000007;

// a^-1 mod p
ll inv(ll a,ll p){
  return ( a == 1 ? 1 : (1 - p*inv(p%a,a)) / a + p );
}

ll fact[200000];

int main()
{
  fact[0] = 1;
  for(auto&& i:irange(0,199999)) {
    fact[i+1] = fact[i] * (i+1) % MOD;
  }
  ll n;
  cin>>n;
  vecll a(n);
  for(auto&& e:a)cin>>e;
  for(auto&& i:irange(1l,n)) {
    a[i] -= a[0];
  }
  a[0] = 0;
  vecll ra(n);
  for(auto&& i:irange(0l,n)) {
    ra[i] = a[n-1] - a[n-1-i];
  }
  vecll psa(n), psra(n);
  boost::partial_sum(a, begin(psa));
  for(auto&& e:psa) e %= MOD;
  boost::partial_sum(ra, begin(psra));
  for(auto&& e:psra) e %= MOD;
  ll ans = 0;
  for (auto&& i:irange(1l,n-1)) {
    ll tmp = fact[n-1] * inv(i+1, MOD) % MOD * inv(i, MOD) % MOD;
    ll rsum = (n-1-i) * a[n-1] % MOD;
    //cerr<<a[n-1]<<' '<<rsum<<' ';
    rsum += (MOD - psa[n-i-2]);
    rsum %= MOD;
    rsum += (MOD - psra[n-i-1]);
    rsum %= MOD;
    //cerr<<rsum<<' '<<tmp<<endl;
    ans += tmp * rsum % MOD;
    ans %= MOD;
  }
  for (auto&& i:irange(1l,n)) {
    ll tmp = ra[i] * fact[n-1] % MOD * inv(i, MOD) % MOD;
    //cerr<<tmp<<endl;
    ans += tmp;
    ans %= MOD;
  }
  cout<<ans<<endl;
  return 0;
}


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

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

    vector<string> arr(n);

    char before;
    char beforeMix;
    int count = 1;

    for(int i = 0; i < n; i++) {
        if(i == 0) {
            before = s[i];
        }

        if(s[i] != before) {
            count++;
        }
        before = s[i];
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main()
{
  int N, A, B;
  cin >> N >> A >> B;
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    int keta_sum = 0;
    int x = i;
    while (x > 0) {
      keta_sum += x%10;
      x /= 10;
    }
    if (A <= keta_sum && keta_sum <= B) {
      ans += i;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 606000;
int n,a[N],b[N];
const int M = N*6, inf = 0x3f3f3f3f;
int S,T,head[N],cur[N],nxt[M],cap[M],to[M],edgenum=1; //1.WA£¨ÆäËüµØ·½Ó¦¸Ã¶¼²»ÈÝÒ×Ð´¹Ò£©--edgenum=1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
void addedge(int u, int v, int c){
	to[++edgenum]=v;cap[edgenum]=c;nxt[edgenum]=head[u];head[u]=edgenum;
}
void add(int u, int v, int c){
	addedge(u,v,c);addedge(v,u,0);
}
int dis[N],q[N];
inline bool bfs() {
	memset(dis,inf,4*(T+2));//2.memset²»ÓÃsizeof()
	int f=0,r=1; q[f]=T; dis[T]=0;
	while (f!=r) {
		int u=q[f++];
		L(i,u) if (cap[i^1]&&dis[to[i]]==inf){
			q[r++]=to[i];dis[to[i]]=dis[u]+1;if(to[i]==S)return 1;//3.¼ôÖ¦
		}
	}
	return dis[S]<inf;
}
inline int dfs(int u, int flow) {
	if (u==T||!flow)return flow;int res=0;
	for(register int &i=cur[u];i;i=nxt[i])if(cap[i]&&dis[u]==dis[to[i]]+1){//4.µ±Ç°»¡ 
		int tmp=dfs(to[i],min(flow,cap[i]));
		res+=tmp;flow-=tmp;cap[i]-=tmp;cap[i^1]+=tmp;if(!flow)break;
	}
	return res;
}
inline int dinic() {
	int res=0;
	while (bfs()) {
		memcpy(cur,head,4*(T+2)); res+=dfs(S,inf);
	}
	return res;
}
int bh1[N],bh2[N],tot,res;
int main() {
	read(n);rep(i,1,n)read(a[i]),a[i]++;rep(i,1,n)read(b[i]),b[i]++;
	S=2*n+1;T=S+1;
	rep(i,1,n)if(!bh1[i]){
		++tot;for(int j=i;!bh1[j];j=a[j])bh1[j]=tot;
	}
	rep(i,1,n)if(!bh2[i]){
		++tot;for(int j=i;!bh2[j];j=b[j])bh2[j]=tot;
	}
	rep(i,1,n)
		if(a[i]==b[i]){
			if(a[i]==i)res++;
			else add(bh1[i],bh2[i],1),add(bh2[i],bh1[i],1);
		}
		else if(a[i]==i)add(bh2[i],T,1);
		else if(b[i]==i)add(S,bh1[i],1);
		else add(bh2[i],bh1[i],1);
	cout<<n-(res+dinic());
	return 0;
}
/*
p[i]=q[i]=i:ans++
p[i]=q[i]!=i:00||11
p[i]=i:?0
q[i]=i:0?
:00
*/


Measured memory_bytes: 30592
#include<iostream>
#include<string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main() {
	long long N;
	cin >> N;
	long long i, j;
	vector<long long> A;
	vector<long long> gap;
	for (i = 0; i < N; i++) {
		long long a;
		cin >> a;
		A.push_back(a);
	}
	sort(A.begin(), A.end());
	for (i = 0; i < N - 1; i++) {
		gap.push_back(A.at(i + 1) - A.at(i));
	}
	sort(gap.begin(), gap.end());
	long long N2 = N;
	if (N >= 3) {
		for (i = 0; i < gap.size(); i++) {
			if (N == 2) {
				break;
			}
			if (gap.at(i) == 0) {
				N--;
			}
		}
	}
	long long ans = 1;
	long long M = min(A.at(N-1),1000000000/(N-1));

	for (i = M; i >= 2; i--) {
		long long flag = 0;
		for (j = 0; j < N2; j++) {
			if (A.at(j) % i != 0) {
				flag++;
				if (flag >= 2) {
					break;
				}
			}
		}
		if (flag <= 1) {
			ans = i;
			break;
		}
	}
	cout << ans;
}

Measured memory_bytes: 2548
//#include<bits/stdc++.h>	// 全てのヘッダーファイルをinclude
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#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 MOD 1e9+7			// int 1000000007
const int inf{int(1e9)};	// inf = 1000000000 // 1e9 はdouble型
using namespace std;
typedef long long ll;


int main(void) {
	int n, m, X, Y;
	int Z = inf, max_X = -inf;
	cin >> n >> m >> X >> Y;
	vector<int> x(n), y(m);

	REP(i, n) {
		cin >> x[i];
		max_X = max(max_X, x[i]);
	}
	REP(i, m) {
		cin >> y[i];
		Z = min(Z, y[i]);
	}

	if (X >= Z || Z > Y) cout << "War" << endl;
	else if (max_X >= Z) cout << "War" << endl;
	else cout << "No War" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1000000007;
const ll INF = 100000000000000007;

template <typename T>
struct Edge
{
    int to;
    T cost;
};

template <typename T>
struct WeightedGraph
{
    int n;
    vector<vector<Edge<T>>> g;
    
    WeightedGraph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to, T cost){
        g[from].push_back((Edge<T>){to, cost});
    }
};

struct Graph
{
    int n;
    vector<vector<int>> g;
    
    Graph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to){
        g[from].push_back(to);
    }
};

vector<P> Dijkstra(WeightedGraph<ll> &g, int s){
    int n = g.n;
    vector<P> d(n);
    fill(d.begin(), d.end(), P(INF, 0));
    priority_queue<P, vector<P>, greater<P>> que;
    d[s] = P(0, 1);
    que.push(P(0, s));
    while(que.size()){
        P nowp = que.top();
        que.pop();
        if(d[nowp.second].first < nowp.first) continue;
        for(Edge<ll> e : g.g[nowp.second]){
            if(d[e.to].first > d[nowp.second].first + e.cost){
                d[e.to].first = d[nowp.second].first + e.cost;
                d[e.to].second = d[nowp.second].second;
                que.push(P(d[e.to].first, e.to));
            }
            else if(d[e.to].first == d[nowp.second].first + e.cost){
                d[e.to].second = (d[e.to].second + d[nowp.second].second) % MOD;
            }
        }
    }
    return d;
}

int main()
{
    int n, m;
    cin >> n >> m;
    int s, t;
    cin >> s >> t;
    s--; t--;
    WeightedGraph<ll> g(n);
    int u[200002], v[200002];
    ll d[200002];
    for(int i = 0; i < m; i++){
        cin >> u[i] >> v[i] >> d[i];
        u[i]--; v[i]--;
        g.add_edge(u[i], v[i], d[i]);
        g.add_edge(v[i], u[i], d[i]);
    }
    vector<P> d1 = Dijkstra(g, s);
    vector<P> d2 = Dijkstra(g, t);
    ll dis = d1[t].first;
    ll ans = d1[t].second * d2[s].second % MOD;
    for(int i = 0; i < n; i++){
        if(d1[i].first == d2[i].first && d1[i].first + d2[i].first == dis)
            ans = (ans + MOD - d1[i].second * d2[i].second % MOD * d1[i].second % MOD * d2[i].second % MOD) % MOD;
    }
    for(int i = 0; i < m; i++){
        if(d1[u[i]].first * 2 < dis && d2[v[i]].first * 2 < dis && d1[u[i]].first + d2[v[i]].first + d[i] == dis)
            ans = (ans + MOD -
                   d1[u[i]].second * d2[v[i]].second % MOD * d1[u[i]].second % MOD * d2[v[i]].second % MOD) % MOD;
        if(d1[v[i]].first * 2 < dis && d2[u[i]].first * 2 < dis && d1[v[i]].first + d2[u[i]].first + d[i] == dis)
            ans = (ans + MOD -
                   d1[v[i]].second * d2[u[i]].second % MOD * d1[v[i]].second % MOD * d2[u[i]].second % MOD) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 21844
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    print(input()[:3])
    
main()

Measured memory_bytes: 65116
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_FLOWER_MAX	100000									// 最大花数

// 内部構造体 - 花情報
typedef struct Flower {
	long long mlStart;											// １本目
	long long mlSep;											// 間隔
} Flower;

// 内部変数
static FILE *szpFpI;											// 入力
static Flower sz1Flower[D_FLOWER_MAX];							// 花
static int siFCnt;												// 花数
static long long slNCnt;										// 必要花数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 花数 - 取得
long long
fGetFCnt(
	long long plPos				// <I> 位置
)
{
	int i;

	long long llSum = 0;
	for (i = 0; i < siFCnt; i++) {
		if (plPos >= sz1Flower[i].mlStart) {
			llSum += 1 + (plPos - sz1Flower[i].mlStart) / sz1Flower[i].mlSep;
		}
	}

	return llSum;
}

// 実行メイン
long long
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 花数・必要花数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%lld", &siFCnt, &slNCnt);

	// 花・最大位置 - 取得
	long long llMax = LLONG_MAX;
	for (i = 0; i < siFCnt; i++) {
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
		sscanf(lc1Buf, "%lld%lld", &sz1Flower[i].mlStart, &sz1Flower[i].mlSep);

		// 必要距離
		long long llLen = sz1Flower[i].mlStart + (slNCnt - 1) * sz1Flower[i].mlSep;
		if (llMax > llLen) {
			llMax = llLen;
		}
	}

	// 位置 - 取得
	long long llMin = 0;
	long long llPos = llMax;
	while (llMin <= llMax) {

		// 中間値
		long long llVal = (llMin + llMax) / 2;

		// 花数 - 取得
		long long llFCnt = fGetFCnt(llVal);

		// 範囲を絞る
		if (llFCnt >= slNCnt) {
			llPos = llVal;
			llMax = llVal - 1;
		}
		else {
			llMin = llVal + 1;
		}
	}

	return llPos;
}

// １回実行
int
fOne(
)
{
	long long llRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	llRet = fMain();

	// 出力
	sprintf(lc1Buf, "%lld\n", llRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 1664
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const int MOD = 1000000007;

int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

int lcm(int a, int b){
    return a*b/gcd(a, b);
}


int main(){
  int N;
  double v[50];
  cin >> N;
  for(int i=0;i<N;i++) cin >> v[i];
  sort(v,v+N);
  double value = (v[0]+v[1])/2;
  for(int i=2;i<N;i++) value = (value+v[i])/2;
  cout << value;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

int main() {
  ll n,t;
  cin >> n >> t;
  ll ans=1e18;
  for(ll i=0;i<n;i++) {
    ll tc,tt;
    cin >> tc >> tt;
    if(tt<=t&&tc<ans) {
      ans=tc;
    }
  }
  if(ans==1e18) {
    cout << "TLE" << endl;
  }
  else {
    cout << ans << endl;
  }
}

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

using namespace std;

int main() {
  int n, m, k; cin >> n >> m >> k; for (int a = 0; a <= n; a++) for (int b = 0; b <= m; b++) if (a * b + (n - a) * (m - b) == k) { cout << "Yes" << endl; return 0; } cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define int long long
int n, a[214514], ans = 0;
vector<int>v;
map<int, int>m;
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if(i)a[i] += a[i - 1];
		v.push_back(a[i]);
	}
	v.push_back(0);
	sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
	m[0] = 0;
	for (int i = 0; i < v.size(); i++) {
		m[v[i]] = 0;
	}
	m[0]++;
	for (int i = 0; i < n; i++) m[a[i]]++;
	for (int i = 0; i < v.size(); i++) ans += (m[v[i]] * (m[v[i]] - 1)) / 2;
	cout << ans << endl;
}

Measured memory_bytes: 15856
S=input()
N=len(S)
a=1
for i in range(N):
    if S[i]!=S[-1-i]:
        a=0
        break
for i in range((N-1)//2):
    if S[i]!=S[(N-3)//2-i]:
        a=0
        break
for i in range((N-1)//2):
    if S[i+(N+1)//2]!=S[-i-1]:
        a=0
        break
print("Yes" if a else "No")

Measured memory_bytes: 3064
// #include <iostream>
#include <bits/stdc++.h>
// https://beta.atcoder.jp/contests/arc098/submissions/2567080
// https://beta.atcoder.jp/contests/arc098/submissions/2563485

using namespace std;

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

    long n;
    cin >> n;
    char s[n];
    // string s;
    // scanf("%s", &s);
    cin >> s;
    long right_e = 0;
    // for (long i = 0; i < n; i++) if (s[i] == 'E') right_e++;
    for (long i = 1; i < n; i++) right_e += (s[i] == 'E');
    // for (long i = 1; i < n; i++) if (s[i] == 'E') right_e++;
    long min_count = right_e;
    long left_w = 0;
    for (long i = 1; i < n; i++) {
    // for (long i = 1; i < n; i++) {
        if (!min_count) break;
        right_e -= s[i] == 'E';
        left_w += s[i - 1] == 'W';
        min_count = min(min_count, right_e + left_w);
        //     if (s[i] == 'E') {
        //     right_e--;
        // } else {
        //     right_e++;
        // }
        // if (s[i ] == 'W') right_e++;
        // if (s[i -1] == 'W') left_w++;
        // min_count = min(min_count, right_e);
    }
    cout << min_count << '\n';
    
    return 0;
}

Measured memory_bytes: 512
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if a*500+b*100+c*50 == X:
                cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int maxN = 4005;

int pos[2][maxN], f[maxN][maxN], cost1[maxN][maxN], cost2[maxN][maxN];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(); cout.tie();
    int n;
    cin >> n;

    for(int i = 1; i <= n * 2; ++i){
        char c;
        int x;
        cin >> c >> x;

        if(c == 'B') pos[0][x] = i;
        else pos[1][x] = i;
    }

    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= n; ++j){
            cost1[i][j] = cost1[i][j-1];
            cost2[j][i] = cost2[j][i-1];
            if(pos[0][i] < pos[1][j])
                ++cost1[i][j];
            else
                ++cost2[j][i];
        }
    }

    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= n; ++j)
            f[i][j] = min(f[i-1][j] + cost1[i][j], f[i][j-1] + cost2[j][i]);

    int res = 0;
    for(int i = 1; i <= n; ++i)
        for(int j = i + 1; j <= n; ++j){
            if(pos[0][i] > pos[0][j]) ++res;
            if(pos[1][i] > pos[1][j]) ++res;
        }

    cout << res + f[n][n];
}


Measured memory_bytes: 74524
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;

ll choose(ll a) { //aC2
	return (a - 1) * a / 2;
}
int main()
{
	int n;
	cin >> n;
	vector<string> ss(n);
	rep(i, n) cin >> ss[i];
	rep(i, n) sort(ss[i].begin(), ss[i].end());
	sort(ss.begin(), ss.end());
	vector<ll> cnt(n,1);
	ll sum = 0;
	int j = 0;
	rep(i, n-1) {
		if (ss[i] == ss[i + 1])
			cnt[j]++;
		else
			j++;
	}
	j++;
	rep(i, j) sum += choose(cnt[i]);
	cout << sum;

}

Measured memory_bytes: 7124
#include <bits/stdc++.h>
using namespace std;
 
int mov[19][200000];
int even[200000];
int odd[200000];
 
int main() {
  int H, W, N;
  cin >> H >> W >> N;
  vector<pair<int, int>> del;
  for(int i = 0; i < N; ++i) {
    int a,b; cin >> a >> b;
    a--, b--;
    del.emplace_back(a,b);
  }
 
  for(int i = 0; i < W; ++i) {
    if(i == W - 1) {
      if(W % 2 == 0) {
        odd[i] = i - 1;
      }
      else {
        odd[i] = i;
      }
    }
    else {
      if(i % 2 == 0) {
        odd[i] = i + 1;
      }
      else {
        odd[i] = i - 1;
      }
    }
  }
 
  for(int i = 0; i < W; ++i) {
    if(i == W - 1) {
      if(W % 2 == 1) {
        even[i] = odd[i - 1];
      }
      else {
        even[i] = odd[i];
      }
    }
    else if(i > 0) {
      if(i % 2 == 0) {
        even[i] = odd[i - 1];
      }
      else {
        even[i] = odd[i + 1];
      }
    }
    else {
      even[i] = odd[i];
    }
  }
 
  for(int i = 0; i < W; ++i) {
    mov[0][i] = i;
    mov[1][i] = even[i];
  }
 
  for(int k = 2; k < 19; ++k) {
    for(int i = 0; i < W; ++i) {
      mov[k][i] = mov[k - 1][mov[k - 1][i]];
    }
  }
 
  sort(del.begin(), del.end());
  int start[W];
  for(int i = 0; i < W; ++i) {
    start[i] = i;
  }
 
  for(int d = 0; d < N; ++d) {
    const int y = del[d].first;
    const int x = del[d].second;
 
    int Y = y + 1;
    int left = x;
    int right = x + 1;
    if(Y % 2 == 1) {
      left = odd[left];
      right = odd[right];
    }
 
    for(int i = 1; i < 19; ++i) {
      if((Y >> i) & 1) {
        left = mov[i][left];
        right = mov[i][right];
      }
    }
 
    swap(start[left], start[right]);
  }
 
  int end[W];
  for(int i = 0; i < W; ++i) {
    int k = i;
    if(H % 2 == 1) k = odd[k];
    for(int j = 1; j < 19; ++j) {
      if((H >> j) & 1) k = mov[j][k];
    }
    end[i] = k;
  }
 
  int rstart[W];
  int rend[W];
  int arr[W];
  for(int i = 0; i < W; ++i) {
    rstart[start[i]] = i;
    rend[end[i]] = i;
  }
  for(int i = 0; i < W; ++i) {
    arr[rstart[rend[i]]] = i;
  }
 
  for(int i = 0; i < W; ++i) {
    cout << (rend[rstart[i]] + 1) << endl;
  }
 
  return 0;
}

Measured memory_bytes: 23188
import Data.List
--import Data.Array
import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.ST
--import Data.Vector as V
import Control.Monad
import Control.Monad.ST
import Debug.Trace

type Item  = (Int,Int)
type Items = [Item]
type DP s = STUArray s (Int,Int) Int

dp_i :: DP s -> Item -> Int -> Int -> ST s ()
dp_i dparr (w,v) maxw 1 = forM_ [w..maxw] $ \j -> writeArray dparr (1,j) v
dp_i dparr (w,v) maxw i = do
  forM_ [1..w] $ \j -> readArray dparr (i-1,j) >>= writeArray dparr (i,j)
  forM_ [w..maxw] $ \j -> do
    v0 <- readArray dparr (i-1,j)
    v1 <- readArray dparr (i-1,j-w)
    if v0 >= v1+v then writeArray dparr (i,j) v0
        else writeArray dparr (i,j) (v1+v)

solve :: [(Int,Item)] -> Int -> Int -> ST s Int
solve ls n maxw = do
  dparr <- newArray ((1,0),(n,maxw)) 0
  forM_ ls $ \(i,item) -> (dp_i dparr item maxw i) --dp
  ans <- readArray dparr (n,maxw)
  return ans

main :: IO ()
main = do
  [n,maxw] <- map read.words <$> getLine
  ls <- forM [1..n] $ \i -> do
      (w:v:emp) <- map read.words <$> getLine :: IO [Int]
      return (i,(w,v))
  putStrLn $ show $ runST $ solve ls n maxw


Measured memory_bytes: 79868
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

signed main(){
	int n,x,sum=0;
	cin>>n>>x;
	int a[n];
	r(i,n)cin>>a[i];

	int t=0;
	r(i,n){
		t+=a[i];
		if(t<=x)sum++;
	}
	cout<<sum+1<<endl;
}

Measured memory_bytes: 256
from collections import OrderedDict
n = int(input())
t = [input().split() for i in range(n)]
c =1
for i in range(n):
  t[i][1] = int(t[i][1])
  t[i].append(c)
  c = c+1
  
s = sorted(t,key=lambda x:x[1],reverse=True)
s = sorted(s,key = lambda x:x[0])

[print(str(s[i][2])) for i in range(n)]
  

Measured memory_bytes: 38384
from sys import stdin, setrecursionlimit
setrecursionlimit(10000000)

input = stdin.readline
lmi = lambda: list(map(int, input().split()))
mi = lambda: map(int, input().split())
si = lambda: input().strip('\n')
ssi = lambda: input().strip('\n').split()
ii = lambda: int(input())

x, a = mi()
if x<a:
    print("0")
else:
    print("10")


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
	int a[100]={0};
	int i,n;
	cin>>n;
	for(i=n-1;i>=0;i--){
		cin>>a[i];
	}
	for(i=0;i<n;i++){
		if(i!=0)cout<<" ";
		cout<<a[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 1000000009
using P = pair<int,int>;

ll max(ll a,ll b,ll c){
  if(a > b && a > c)
    return a;
  else if(b > a && b > c)
    return b;
  else
    return c;
}
int main(){
  #define int long long
  vint A(3);
  cin >> A[0] >> A[1] >> A[2];
  sort(A.begin(),A.end());
  //cout << A[0] << A[1] << A[2] << endl;
  if((A[2] - A[0]) % 2 == 0 && (A[2] - A[1]) % 2 == 0){
    cout << (A[2] - A[0]) / 2 +  (A[2] - A[1]) / 2 << endl;
  }
  else if((A[2] - A[0]) % 2 == 1 && (A[2] - A[1]) % 2 == 0){
    cout << (A[2]+1 - A[0]) / 2 +  (A[2] - A[1]) / 2 + 1 << endl;
  }
  else if((A[2] - A[0]) % 2 == 0 && (A[2] - A[1]) % 2 == 1){
    cout << (A[2] - A[0]) / 2 +  (A[2]+1 - A[1]) / 2 + 1 << endl;
  }
  else{
    cout << (A[2] - A[0]-1) / 2 +  (A[2] - A[1] - 1) / 2 + 1 << endl;
  }
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc121/tasks/abc121_c
#include <iostream>
#include <algorithm>
#include <string>
#include <utility>
// #include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  long long N,M;
  cin>>N>>M;
  pair<long long,long long> drink[100100];
  for (int i=0;i<N;i++){
    long long a,b;
    cin >> a >> b;
    drink[i].first = a;
    drink[i].second = b;
  }
  sort(drink,drink+N);

  long long cost = 0;
  int count = 0;

  // long long c = 0;
  // while(c+drink[count].second<M)
	// {
	// 	cost+=drink[count].first*drink[count].second;
	// 	c+=drink[count++].second;
	// }
	// cout<<cost+(M-c)*drink[count].first<<endl;

  while(1){
    if(drink[count].second<M){
      cost+= drink[count].first*drink[count].second;
      M -= drink[count].second;
    }
    else{
      cost+=drink[count].first*M;
      break;
    }
    count++;
  }
  cout << cost<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<iomanip>
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<string> vs;
Def inf = sizeof(Def) == sizeof(ll) ? 2e15:1e9+10;

#include<complex>
typedef complex<double> P;
typedef vector<P> G;
const double PI=acos(-1);
const double EPS=1e-7;

struct L: public vector<P> {
	L(const P &a,const P &b){
		push_back(a);push_back(b);
	}
};
struct C{
	P c;double r;
	C(const P &c,double r):c(c),r(r){}
};
namespace std{
	bool operator < (const P &a, const P &b){
		return real(a) != real(b) ? real(a)<real(b) :imag(a)<imag(b);
	}
	bool operator == (const P &a, const P &b){
		return a.real() == b.real() && a.imag() == b.imag();
	}
}


double dot(P a,P b){
	return real(conj(a)*b);
}

P projection(L a, P p){
	double t=dot(p-a[0],a[0]-a[1])/norm(a[0]-a[1]);
	return a[0]+t*(a[0]-a[1]);
}

double distanceLP(const L &l, const P &p){
	return abs(p-projection(l,p));
}


P turn(P p,double t){
	return p*exp(P(.0,t*PI/180.0));
}

vector<L> tangentCC(C a, C b){
	if(a.r<b.r)swap(a,b);
	double d=abs(a.c-b.c);
	vector<L> l;
	if(d<EPS)return l;
	if(a.r+b.r<d-EPS){
		double t=acos((a.r+b.r)/d);
		t=t*180/PI;
		l.pb(L(a.c+turn(a.r/d*(b.c-a.c),t),b.c+turn(b.r/d*(a.c-b.c),t)));
		l.pb(L(a.c+turn(a.r/d*(b.c-a.c),-t),b.c+turn(b.r/d*(a.c-b.c),-t)));
	}else if(a.r+b.r<d+EPS){
		P p=a.c+a.r/d*(b.c-a.c);
		l.pb(L(p,p+turn(b.c-a.c,90)));
	}
	
	if(abs(a.r-b.r)<d-EPS){
		double t1=acos((a.r-b.r)/d);
		t1=t1*180/PI;
		double t2=180-t1;
		l.pb(L(a.c+turn(a.r/d*(b.c-a.c),t1),b.c+turn(b.r/d*(a.c-b.c),-t2)));
		l.pb(L(a.c+turn(a.r/d*(b.c-a.c),-t1),b.c+turn(b.r/d*(a.c-b.c),t2)));	
	}else if(abs(a.r-b.r)<d+EPS){
		P p=a.c+a.r/d*(b.c-a.c);
		l.pb(L(p,p+turn(b.c-a.c,90)));
	}
	return l;
}

int main(){
	int n,m;
	while(cin>>n>>m,n){
		vvi L(n,vi(n,inf));
		vvi S(n,vi(n,inf));
		rep(i,n)L[i][i]=S[i][i]=0;
		rep(i,m){
			ll a,b,c;char d;
			cin>>a>>b>>c>>d;
			a--;b--;
			if(d=='L')L[a][b]=L[b][a]=min(L[a][b],c);
			if(d=='S')S[a][b]=S[b][a]=min(S[a][b],c);
		}
		rep(k,n)rep(i,n)rep(j,n){
			L[i][j]=min(L[i][j],L[i][k]+L[k][j]);
			S[i][j]=min(S[i][j],S[i][k]+S[k][j]);
		}
		int R;cin>>R;
		vi r(R);
		rep(i,R)cin>>r[i];
		rep(i,R)r[i]--;
		vvi dp(R,vi(n,inf));
		dp[0][r[0]]=0;
		rep(i,R-1)rep(j,n){
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]+L[r[i]][r[i+1]]);
			rep(k,n){
				dp[i+1][k]=min(dp[i+1][k],dp[i][j]+L[r[i]][j]+S[j][k]+L[k][r[i+1]]);
			}
		}
//		rep(i,R){rep(j,n)cout<<" "<<dp[i][j];cout<<endl;}
		ll out=inf;
		rep(i,n)out=min(out,dp[R-1][i]);
		cout<<out<<endl;
	}
}







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

using namespace std;

#define int long long

int a, b, c, d;

int f(int l, int d) {
    return l - (l / d);
}

int g(int num) {
    return f(b, num) - f(a - 1, num);
}

int ICM(int a, int b) {
    return a * b / __gcd(a, b);
}

int32_t main() {
    cin >> a >> b >> c >> d;
    return cout << g(c) + g(d) - g(ICM(c, d)), 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	int N, K, num = 1;
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++) {
		if (num + K <= num * 2) {
			num += K;
		}
		else {
			num *= 2;
		}
	}
	printf("%d", num);
	return 0;
}

Measured memory_bytes: 128
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val s = sc.next()

  if (s == "SSS") {
    println(0)
    return
  }
  if (s == "RRR") {
    println(3)
    return
  }
  if (s == "RRS" || s == "SRR") {
    println(2)
    return
  }
  println(1)


 
}


Measured memory_bytes: 36280
//
//  main.cpp
//  ABC167C

#include <iostream>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
const int INF=1001001001;
int main(int argc, const char * argv[]) {
    int a[12][12];
    int n,m,x;
    cin>>n>>m>>x;
    vector<int>cost(n); // 本の値段
    rep(i,n){
        cin>>cost.at(i);
        rep(j,m){
            cin>>a[i][j];
        }
    }
    int ans=INF;
    rep(s,1<<n){
        int all_cost=0;
        vector<int>d(m); // それぞれの理解度
        rep(i,n){
            if(s>>i&1){
                all_cost += cost.at(i);
                rep(j,m){
                    d.at(j) += a[i][j];
                }
            }
        }
        bool OK=true;
        rep(j,m){
            if(d.at(j)<x) OK=false;
        }
            if(OK) ans=min(ans,all_cost);
    }
    if (ans==INF) {
        cout<<-1<<endl;
    }else{
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3192
#include<stdio.h>
int main(void)
{
int a=0;
int b=0;
  
  scanf("%d",&a);
  while(a>=500)
    {
    b=b+1000;
    a=a-500;
    }
  while(a>=5)
    {
    b=b+5;
    a=a-5;
    }
  printf("%d",b);
  return 0;
}

Measured memory_bytes: 128
#include<ctype.h>
#include<stdio.h>
#include<iostream>
using namespace std;

main() {

  char ch, hen ;


  while(1){

    scanf("%c", &ch);
    
    if(ch == '\n'){
      break;
      
    } else if(islower(ch)) {
      hen = toupper(ch);
      cout << hen;
    }else{
      hen = tolower(ch);
      cout << hen;
    }

    
   

  }
  cout << "\n";

}

Measured memory_bytes: 1120
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int sa = b-a;
        int sum = 0;
        for(int i = 0; i < sa; i++) {
            sum += i;
        }
        System.out.println(sum - a);
    }
}


Measured memory_bytes: 21844
import itertools
N, M = map(int, input().split())
G = [[False]*10 for _ in range(10)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a][b] = G[b][a] = True

res = 0
L = list(itertools.permutations(range(N)))

for l in L:
    if l[0] != 0:
        break
    ok = True
    for i in range(N-1):
        from_ = l[i]
        to_ = l[i+1]
        if not G[from_][to_]:
            ok = False
    if ok:
        res += 1
print(res)


Measured memory_bytes: 8052
n = gets.to_i
srray = gets.split("").map(&:to_s)
k = gets.to_i
nn = ["\n"]
trray = srray - nn
i=0
while i<n
  if trray[i] != trray[k-1]
    trray[i] = "*"
  end
  i += 1
end
puts trray.join


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

int main() {
	// your code goes here
	int n,m;
	cin>>n>>m;
	if(n>1 && m>1)
	cout<<(n*(n-1)+m*(m-1))/2;
	else if(n>1)
	cout<<(n*(n-1))/2;
	else if(m>1)
	cout<<(m*(m-1))/2;
	else
	cout<<0;
	
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program {
    static void Main(string[] args){
      string[] s = Console.ReadLine().Split(' ');
      int a = int.Parse(s[0]);
      int b = int.Parse(s[1]);

      if(a*b%2==0){
        Console.Write("Even");
      } else {
        Console.Write("Odd");
      }
    }
  }


Measured memory_bytes: 11092
#include <iostream>

int main()
{
  int N;
  std::cin >> N;

  constexpr int CAKE = 4;
  constexpr int DONUTS = 7;

  int n_cake = (100 + CAKE - 1) / CAKE;

  bool can = false;
  for(int c=0; c<=n_cake; c++) {
    if(c * CAKE <= N && (N - c * CAKE) % DONUTS == 0) {
      // std::cout << "c = " << c << " d = " << (N - c * CAKE) / DONUTS << std::endl;
      can = true;
      goto END;
    }
  }

END:
  std::cout << (can ? "Yes" : "No") << std::endl;

  return 0;
}


Measured memory_bytes: 3632