akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<=n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 1000000007
#define mod 998244353
#define sec setprecision
#define Pair pair<ll,ll>
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using namespace std;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x)%mod , n / 2)%mod);
	else
		return (x * pow(x, n - 1))%mod;
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long com(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main() {
	int d; cin >> d;
	vector<int>c(26); rip(i, 26)cin >> c[i];
	vector<vector<int>>s(d, vector<int>(26));
	rip(i, d) {
		rip(j, 26)cin >> s[i][j];
	}
	vector<int>last(26,0);
	vector<int>ans(d);
	rip(i, d) {
		int maxx = 0;
		int k = 0;
		rip(j, 26) {
			maxx = max(maxx, s[i][j]);
			if (maxx == s[i][j])k = j;
		}
		ans[i] = k;
	}
	rip(i, d)cout << ans[i]+1 << endl;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define riterator reverse_iterator
#define pii pair<int,int>
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int INF = 1e7;

namespace NetFlow
{
	const int N = 2e5+2;
	const int M = 4e5;
	struct Edge
	{
		int v,w,nxt,rev;
	} e[(M<<1)+3];
	int fe[N+3];
	int te[N+3];
	int dep[N+3];
	int que[N+3];
	int n,en,s,t;
	void addedge(int u,int v,int w)
	{
		en++; e[en].v = v; e[en].w = w;
		e[en].nxt = fe[u]; fe[u] = en; e[en].rev = en+1;
		en++; e[en].v = u; e[en].w = 0;
		e[en].nxt = fe[v]; fe[v] = en; e[en].rev = en-1;
	}
	bool bfs()
	{
		for(int i=1; i<=n; i++) dep[i] = 0;
		int head = 1,tail = 1; que[1] = s; dep[s] = 1;
		while(head<=tail)
		{
			int u = que[head]; head++;
			for(int i=fe[u]; i; i=e[i].nxt)
			{
				int v = e[i].v;
				if(e[i].w>0 && dep[v]==0)
				{
					dep[v] = dep[u]+1;
					if(v==t) return true;
					tail++; que[tail] = v;
				}
			}
		}
		return false;
	}
	int dfs(int u,int cur)
	{
		if(u==t||cur==0) {return cur;}
		int rst = cur;
		for(int &i=te[u]; i; i=e[i].nxt)
		{
			int v = e[i].v;
			if(e[i].w>0 && rst>0 && dep[v]==dep[u]+1)
			{
				int flow = dfs(v,min(rst,e[i].w));
				if(flow>0)
				{
					e[i].w -= flow;	
					rst -= flow;
					e[e[i].rev].w += flow;
					if(rst==0) {return cur;}
				}
			}
		}
		if(rst==cur) {dep[u] = -2;}
		return cur-rst;
	}
	int dinic(int _n,int _s,int _t)
	{
		n = _n,s = _s,t = _t;
		int ret = 0;
		while(bfs())
		{
			for(int i=1; i<=n; i++) te[i] = fe[i];
			memcpy(te,fe,sizeof(int)*(n+1));
			ret += dfs(s,INF);
		}
		return ret;
	}
}
using NetFlow::addedge;
using NetFlow::dinic;

const int N = 1e5;
vector<int> adj[(N<<1)+3];
vector<pair<int,pii> > ans;
int mch[(N<<1)+3];
bool vis[(N<<1)+3];
int que[N+3];
int n;

bool bfs()
{
	int hd = 1,tl = 1; que[1] = 1; vis[1] = true;
	while(hd<=tl)
	{
		int u = que[hd]; hd++;
		for(int o=0; o<adj[u].size(); o++)
		{
			int v = adj[u][o]; if(vis[v]) continue;
			if(vis[mch[v]]) continue;
			que[++tl] = mch[v]; vis[v] = vis[mch[v]] = true;
			ans.push_back(mkpr(v,mkpr(u,mch[v])));
		}
	}
	if(tl<n) {return false;}
	return true;
}

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++) addedge(1,i+2,1);
	for(int i=n+1; i<n+n; i++) addedge(i+2,2,1);
	for(int i=1; i<n; i++)
	{
		int sz; scanf("%d",&sz);
		while(sz--)
		{
			int x; scanf("%d",&x); adj[i+n].push_back(x); adj[x].push_back(i+n);
			if(x!=1) {addedge(x+2,i+n+2,1);}
		}
	}
	if(dinic(n+n+1,1,2)<n-1) {puts("-1"); return 0;}
	for(int u=3; u<=n+2; u++)
	{
		for(int i=NetFlow::fe[u]; i; i=NetFlow::e[i].nxt)
		{
			int v = NetFlow::e[i].v; if(v<=n+2) continue;
			if(NetFlow::e[i].w==0)
			{
				mch[u-2] = v-2,mch[v-2] = u-2;
				break;
			}
		}
	}
//	printf("match: "); for(int i=1; i<=n+n-1; i++) printf("%d ",mch[i]); puts("");
	if(!bfs()) {puts("-1"); return 0;}
	sort(ans.begin(),ans.end());
	for(int i=0; i<ans.size(); i++) printf("%d %d\n",ans[i].second.first,ans[i].second.second);
	return 0;
}

Measured memory_bytes: 33524
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;

#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

int main() {
    ll K, X;
    cin >> K >> X;
    cout << (X <= K * 500 ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
int mod = 1000000000 + 7;
int dp[101][4][4][4];
int main()
{
        //input->compute->output//

        int N;
        cin >> N;
        vector<int> val(N), cos(N);
        for (int i = 0; i < N; i++)
        {
                cin >> val[i];
        }
        for (int i = 0; i < N; i++)
        {
                cin >> cos[i];
        }

        int ans = 0;
        for (int i = 0; i < N; i++)
        {
                if (val[i] - cos[i] > 0)
                {
                        ans += val[i] - cos[i];
                }
        }

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long 
#define float long double 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
signed main(){
	IOS;
	set<int>st;
	int a; 
	for(int i=0;i<3;i++){
		cin >> a;
		st.insert(a);
	}
	cout << ( (int)st.size() == 2?"Yes":"No" ) << endl ;
	return 0;
}







Measured memory_bytes: 256
import sys
from itertools import product

input = sys.stdin.readline

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]

for i, j in product(range(H), range(W)):
    if S[i][j] == '#':
        continue
    if j == 0:
        L[i][j] = 1
    else:
        L[i][j] = L[i][j - 1] + 1
    if i == 0:
        U[i][j] = 1
    else:
        U[i][j] = U[i - 1][j] + 1

for i, j in product(range(H), range(W - 1, -1, -1)):
    if S[i][j] == '#':
        continue
    if j == W - 1:
        R[i][j] = 1
    else:
        R[i][j] = R[i][j + 1] + 1

for i, j in product(range(H - 1, -1, -1), range(W)):
    if S[i][j] == '#':
        continue
    if i == H - 1:
        D[i][j] = 1
    else:
        D[i][j] = D[i + 1][j] + 1

ans = 0
for i, j in product(range(H), range(W)):
    if S[i][j] == '#':
        continue
    x = L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3
    ans = max(ans, x)
print(ans)


Measured memory_bytes: 309896
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define log(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

// const int dx[4] = { 1, 0, -1, 0 };
// const int dy[4] = { 0, 1, 0, -1 };

const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}



// TODO: write
int main() {
  string s;cin>>s;
  rep(i,s.size())cout<<((s[i] == '?')?'D':s[i]);
  cout<<endl;
  return 0;
}


Measured memory_bytes: 3704
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	Scanner scan=new Scanner(System.in);
	int n=scan.nextInt();
	int a=scan.nextInt();
	if(n%500<=a) {
		System.out.println("Yes");
	}
	else {
		System.out.println("No");
	}

	}

}

Measured memory_bytes: 35644
def LI():
    return list(map(int, input().split()))


N = int(input())
mod = pow(10, 9)+7
if N == 1:
    ans = 0
else:
    total = pow(10, N, mod)
    a = 2*pow(9, N, mod)
    b = pow(8, N, mod)
    ans = (total-a+b) % mod

print(ans)


Measured memory_bytes: 9092
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

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

    int A[N];
    REP(0, i, N) {
        cin >> A[i];
    }

    sort(A, A + N);

    while (true) {
        bool done = true;

        REP(1, i, N) {
            if (A[i] % A[0] == 0) {
                A[i] = A[0];
            } else {
                A[i] %= A[0];
            }
        }

        REP(1, i, N) {
            if (A[i] != A[0]) {
                done = false;
                break;
            }
        }

        if (done) {
            break;
        }

        sort(A, A + N);
    }

    cout << A[0] << endl;

    return 0;
}


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

int main(){
	char wo[1000][32], fa[32], len[32];
	int cnt = 0, maxlen = -1, nfwo = -1;
	while(cin >>wo[cnt]){
		cnt++;
	}
	for(int i = 0; i < cnt; i++){
		int cntwo = 0;
		for(int j = 0; wo[i][j] != '\0'; j++){
			cntwo++;
		}
		if(cntwo > maxlen){
			maxlen = cntwo;
			int k = 0;
			for(k = 0; wo[i][k] != '\0'; k++){
				len[k] = wo[i][k];
			}
			len[k] = '\0';
		}
		int cntnfwo = 0;
		for(int j = 0; j < cnt; j++){
			if(strcmp(wo[i], wo[j]) == 0){
				cntnfwo++;
			}
		}
		if(cntnfwo > nfwo){
			nfwo = cntnfwo;
			int k = 0;
			for(k = 0; wo[i][k] != '\0'; k++){
				fa[k] = wo[i][k];
			}
			fa[k] = '\0';
		}
	}
	cout <<fa <<" " <<len <<endl;
	return 0;
}

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

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

  bool sunuke[N];
  for (int i = 0; i < N; i++) {
    sunuke[i] = true;
  }

  int d;
  for (int i = 0; i < K; i++) {
    cin >> d;
    for (int j = 0; j < d; j++) {
      int t;
      cin >> t;
      sunuke[t - 1] = false;
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (sunuke[i] == true) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = 0;
        if (a < b) {
            if (a + w >= b) {
                ans = 0;
            } else {
                ans = b - (a + w);
            }
        } else {
            if (b + w >= a) {
                ans = 0;
            } else {
                ans = a - (b + w);
            }
        }
        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 21204
n, k = map(int,input().split())
s = list(map(int,list((input()))))

l = [0]

for i in range(0,n-1):
    if s[i] != s[i+1]:
        l.append(i+1)

t = len(l)

for x in range(0,2*k+1):
    l.append(n)

#print(l)

can = []

for j in range(0,t):
    if s[l[j]] == 0:
        can.append(l[j+2*k]-l[j])
    elif s[l[j]] == 1:
        can.append(l[j+2*k+1]-l[j])
    else:
        break

#print(can)
print(max(can))

Measured memory_bytes: 12644
def main():
    x, y = map(int, input().split())
    a = [1, 3, 5, 7, 8, 10, 12]
    b = [4, 6, 9, 11]
    if x == 2 or y == 2:
        print('No')
    elif (x in a and y in a) or (x in b and y in b):
        print('Yes')
    else:
        print('No')
main()

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
int main()
  {
int a,b,c,cn=0;
cin>>a>>b>>c;
for(int i=a;i<=b;i++)
  {
  if(i%c==0)cn++;
  }
cout<<cn<<endl;
  return 0;
  }


Measured memory_bytes: 3620
#include<stdio.h>
int main(void)
{
    int h,w,i,j;
    while(1){
        scanf("%d%d",&h,&w);
        if(h==0&&w==0) break;
        for(i=0; i<h; i++){
            for(j=0; j<w; j++){
                if((i+j)%2) putchar('.');
                else putchar('#');
            }
            putchar('\n');
        }
        putchar('\n');
    }
}


Measured memory_bytes: 2044
#include <iostream>
#include <string>
#include <map>

int main()
{
  std::map<std::string, int> mp;
  mp["SUN"] = 7;
  mp["MON"] = 6;
  mp["TUE"] = 5;
  mp["WED"] = 4;
  mp["THU"] = 3;
  mp["FRI"] = 2;
  mp["SAT"] = 1;
  std::string s;
  std::cin >> s;
  std::cout << mp[s] << std::endl;
  return 0;
}

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

int main() {
  int n;
  cin>>n;
  int64_t luca[n+1];
  for(int i = 0;i<n+1;i++){
    if(!i){
      luca[i]=2;
      continue;
    }else if(i==1){
      luca[i]=1;
    }else{
    luca[i]=luca[i-1]+luca[i-2];
  	}
  }
  cout<<luca[n]<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i,j=0,n;
  char s[100],t[100],u[200];
  
  scanf("%d",&n);
  scanf("%*c%s %s",s,t);
  
  for(i=0;i<n;i++){
    u[j]=s[i];
    j++;
    u[j]=t[i];
    j++;
  }
  
  for(j=0;j<2*n;j++){
 	printf("%c",u[j]); 
  }
 
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n;
    cin >> n;
    vector<ll> z(n);
    vector<ll> ans(n);
    for (int i = 0; i < n; i++) {
        cin >> z[i];
    }
    for (int i = 0; i < 32; i++) {
        ll t = 0;
        for (int j = 0; j < n; j++) {
            if (z[j]&(1 << i))t++;
        }
        t %= 2;
        if (t == 0) {
            for (int j = 0; j < n; j++) {
                if (z[j] & (1 << i))ans[j] |= (1 << i);
            }
        }
        else {
            for (int j = 0; j < n; j++) {
                if (!(z[j] & (1 << i)))ans[j] |= (1 << i);
            }
        }
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i];
        if (i != n - 1)cout << " ";
    }
    cout << endl;
}

Measured memory_bytes: 6368
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

A, V = mi()
B, W = mi()
t = ii()

if B >= A:
    if B + t * W <= A + V * t:
        print('YES')
        exit()
    print('NO')
else:
    if B - t*W >= A - V * t:
        print('YES')
        exit()
    print('NO')

Measured memory_bytes: 9236
#include <iostream>
#include <cmath>
#include <cctype>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <unordered_set>
#include <sstream>
#include <cstring>
#include <iomanip>
#include <queue>
#include <unordered_map>

int main() {
	int32_t n;
	std::cin >> n;

	bool ok = true;
	for(int32_t i = 0; i < n; i++) {
		int32_t cur;
		std::cin >> cur;

		if(cur % 2 == 0 && cur % 3 != 0 && cur % 5 != 0)
			ok = false;
	}
	std::cout << (ok ? "APPROVED" : "DENIED");
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

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

  int ans = 0;
  rep(i, 10) {
    rep(j, 10) {
      rep(k, 10) {
        vector<int> num = {i, j, k, -1};
        int ind = 0;

        rep(n, N) {
          int temp = S[n] - '0';
          if (temp == num[ind])
            ind++;
        }
        if (ind == 3)
          ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
long long L, n, ans, now;
long long a[maxn], sum[maxn];

int main() {
	scanf("%lld%lld", &L, &n);
	for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
	for (int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + a[i];
	long long p, d;
	ans = max(a[n], L - a[1]);
	for (long long i = 1; i < n; ++i) {
		p = min(i, n - i);
		if(i) {
			d = min(p + 1, i);
			now = 0;
			now += (sum[i] - sum[i - d]) * 2;
			now -= a[i];
			now += (p * L - (sum[i + p] - sum[i])) * 2;
			ans = max(ans, now);
		//printf("%lld\n", now);
		}
		if(n - i > 0) {
			d = min(p + 1, n - i);
			now = 0;
			now += (d * L - (sum[i + d] - sum[i])) * 2;
			now -= L - a[i + 1];
			now += (sum[i] - sum[i - p]) * 2;
			ans = max(ans, now);
		//printf("%lld\n", now);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
	int n,i,j,k,ans = 0;
	cin >> n;
	int l[n];
	for(i = 0; i < n; i++){
		cin >> l[i];
	}
	sort(l, l + n);
	for(i = n - 1; i >= 2; i--){
		for(j = i - 1; j >= 1; j--){
			for(k = j - 1; k >= 0; k--){
				if(l[i] < l[j] + l[k]){
					ans++;
				}
				else{
					break;
				}
			}
		}
	}

	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int gcd(int a, int b){
    int r,temp;
    if (a < b){
        temp = a;
        a = b;
        b = temp;
    }
    while ( (r = a % b) != 0){
        a = b;
        b = r;
    }
    return b;
}

int main(){
    int K;
    cin >> K;
    int ans = 0;
    for(int i = 1; i <= K; i++){
        for (int j = 1; j <= K; j++){
            for (int l = 1; l <= K; l++){
                ans += gcd(gcd(i,j),l);
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3672
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct Node
{
  int key;
  struct Node *prev,*next;
}Node;

Node *nill;

void init()
{
  nill = (Node *)malloc(sizeof(Node));
  nill->next = nill;
  nill->prev = nill;
}

void insert(int key)
{
  Node *p = (Node *)malloc(sizeof(Node));

  p->key = key;

  p->next = nill->next;
  nill->next->prev = p;
  nill->next = p;
  p->prev = nill;
}

Node* listserch(int key)
{
  Node *cur = nill->next;

  while(cur != nill && cur->key != key)
  {
    cur = cur->next;
  }

  return cur;
}

void printList()
{
  Node *cur = nill->next;
  int isf = 0;

  while(1)
  {
    if(cur == nill) break;
    if(isf++ > 0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t)
{
  if(t == nill) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst()
{
  deleteNode(nill->next);
}

void deleteLast()
{
  deleteNode(nill->prev);
}

void deleteKey(int key)
{
  deleteNode(listserch(key));
}

int main()
{
  int key,n,i,nd = 0;
  char com[20];

  scanf("%d",&n);
  init();
  for(i = 0;i < n;i++)
  {
    scanf("%s%d",com,&key);
    if(com[0] == 'i') insert(key);
    else if(com[0] == 'd')
    {
      if(strlen(com) > 6)
      {
        if(com[6] == 'F') deleteFirst();
        else if(com[6] == 'L') deleteLast();
      }
      else deleteKey(key);nd++;
    }
  }
  printList();

  return 0;
}



Measured memory_bytes: 32948
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * https://qiita.com/drken/items/fd4e5e3630d0f5859067
 *
 * @author YukihiroLocal
 *
 */
public class Main {
  public static void main(String[] args) {


    Scanner sc = new Scanner(System.in);
    // get a integer

    int N = sc.nextInt();
    // System.out.println(" integer is " + N);

    List<Coordinate> coordinateList = new ArrayList<>();
    coordinateList.add(new Coordinate(0, 0, 0));
    for (int i = 0; i < N; i++) {
      int t = sc.nextInt();
      int x = sc.nextInt();
      int y = sc.nextInt();

      coordinateList.add(new Coordinate(t, x, y));
    } ;
    boolean continueFlag = true;
//    //N=1
//    int diffT =Math.abs( coordinateList.get(0).getT());
//    int diffX =Math.abs( coordinateList.get(0).getX());
//    int diffY =Math.abs( coordinateList.get(0).getY());
//    if(diffT >= diffX + diffY && (diffT - diffX - diffY ) % 2 == 0){
//      continueFlag = true;
//    }else {
//      continueFlag = false;
//    }

    //N>1
    for(int i = 0 ; i < N ; i++){
      int diffT =Math.abs( coordinateList.get(i).getT() - coordinateList.get(i+1).getT());
      int diffX =Math.abs( coordinateList.get(i).getX() - coordinateList.get(i+1).getX());
      int diffY =Math.abs( coordinateList.get(i).getY() - coordinateList.get(i+1).getY());
      if(diffT >= diffX + diffY && (diffT - diffX - diffY ) % 2 == 0){
        continueFlag = true;
      }else {
        continueFlag = false;
        break;
      }
    }
    if(continueFlag){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }

  };
}


class Coordinate {
  int t, x, y;

  Coordinate(int t, int x, int y) {
    this.t = t;
    this.x = x;
    this.y = y;
  }

  int getX() {
    return this.x;
  };

  int getT() {
    return this.t;
  };

  int getY() {
    return this.y;
  };
}


Measured memory_bytes: 90360
n,q=map(int,input().split())
nt=[]
for i in range(n):
    nt.append(input().split())
Queue=[]
time=0
def Enqueue(x):
    return Queue.append(x)

def Dequeue():
    temp=Queue[0]
    del Queue[0]
    return temp
    
for j in range(n):
    Enqueue(nt[j])

while len(Queue)!=0:
    if int(Queue[0][1])<=q:
        time+=int(Queue[0][1])
        print(Queue[0][0],time)
        Dequeue()
    else:
        time+=q
        Temp=Dequeue()
        Temp[1]=int(Temp[1])-int(q)
        Enqueue(Temp)


Measured memory_bytes: 17388
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long x;
	cin>>x;
	if(x==5)
	  cout<<1;
	else if(x==6)
	  cout<<1;
	else
	  {
	  	 long long y = x/11;
	  	 long long r = x%11;
	  	 if(r!=0){
	  	 	 if(r<=6)
	  	 	   r = 1;
	  	 	 else
	  	 	   r = 2; 
		   }
		   cout<<y*2  + r;
	  }
	return 0;
}

Measured memory_bytes: 256
#![allow(dead_code)]
use std::io;

fn main() {
    //solve_b();
    solve_c();
}

fn solve_c() {
    let mut x = String::new();

    io::stdin().read_line(&mut x).unwrap();

    let v: Vec<u32> = x.trim()
        .split(' ')
        .map(|s| s.parse::<u32>().unwrap())
        .collect();

    let a = v[0];
    let b = v[1];
    println!("{} {}", a * b, 2 * (a + b));
}



Measured memory_bytes: 5028
#include<bits/stdc++.h>
using namespace std;
const int N=1e6;
int k,n;
int main()
{
    cin>>k>>n;
    for(int i=max(-N,n-k+1);i<=min(N,n+k-1);i++){
        cout<<i<<endl;
    }
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  string alphabet = "abcdefghijklmnopqrstuvwxyz";
  map<char, int> tonum;
  rep(i,26) tonum[alphabet[i]] = i;
  vector<bool> exist(26, false);
  
  rep(i,s.size()) exist[tonum[s[i]]] = true;
  
  rep(i,26) {
    if (!exist[i]) {
      cout << alphabet[i] << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
#define MAX_N 100
#define INF 10000000
int M,N;
int X1[MAX_N],Y1[MAX_N],X2[MAX_N],Z2[MAX_N];

double width(int *X,int *Y,int n,double x)
{
	double lb=INF,ub=-INF;
	for(int i=0;i<n;i++)
	{
		double x1=X[i],y1=Y[i],x2=X[(i+1)%n],y2=Y[(i+1)%n];
		if((x1-x)*(x2-x)<=0&&x1!=x2)
		{
			double y=y1+(y2-y1)*(x-x1)/(x2-x1);
			lb=min(lb,y);
			ub=max(ub,y);
		}
	}
	return max(0.0,ub-lb);
}

void solve()
{
	int min1=*min_element(X1,X1+M),max1=*max_element(X1,X1+M);
	int min2=*min_element(X2,X2+N),max2=*max_element(X2,X2+N);
	vector<int>xs;
	for(int i=0;i<M;i++)xs.push_back(X1[i]);
	for(int i=0;i<N;i++)xs.push_back(X2[i]);
	sort(xs.begin(),xs.end());

	double res=0;
	for(int i=0;i+1<xs.size();i++)
	{
		double a=xs[i],b=xs[i+1],c=(a+b)/2;
		if(min1<=c&&c<=max1&&min2<=c&&c<=max2)
		{
			double fa=width(X1,Y1,M,a)*width(X2,Z2,N,a);
			double fb=width(X1,Y1,M,b)*width(X2,Z2,N,b);
			double fc=width(X1,Y1,M,c)*width(X2,Z2,N,c);
			res+=(b-a)/6*(fa+4*fc+fb);
		}
	}
	printf("%.10f\n",res);
}

int main()
{
	for(;scanf("%d%d",&M,&N),N+M;)
	{
		for(int i=0;i<M;i++)
			scanf("%d%d",&X1[i],&Y1[i]);
		for(int i=0;i<N;i++)
			scanf("%d%d",&X2[i],&Z2[i]);
		solve();
	}
	return 0;
}

Measured memory_bytes: 1244
n = int(input())
x_arr = [[] for i in range(n)]
y_arr = [[] for i in range(n)]
for i in range(n):
  a = int(input())
  for j in range(a):
    x,y = map(int,input().split())
    x_arr[i].append(x-1)
    y_arr[i].append(y)

ans = 0

for i in range(2**n):
  ok = 1
  count = 0
  for j in range(n):
    if not ((i >> j) & 1):
      continue
    else:
      count += 1
      for k in range(len(x_arr[j])):
        if y_arr[j][k] == 0 and ((i >> x_arr[j][k]) & 1):
          ok = 0
        if y_arr[j][k] == 1 and (not ((i >> x_arr[j][k]) & 1)):
          ok = 0
  if ok:
    ans = max(ans,count)
    
print(ans)

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)


int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

void aryan_p() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return;
}



int32_t main() {


	string s, t;
	cin >> s >> t;
	int count = 0; 
	for (int i = 0; i < s.length(); i++){
		if(s[i]!=t[i]){
			count++;
		}
	}
	cout << count;

	return 0;
}

Measured memory_bytes: 3916
#include <stdio.h>
int main()
{
    int a,b,c,sum1,sum2,sum3;
    scanf("%d %d %d",&a,&b,&c);
    sum1 = a+b;
    sum2 = a+c;
    sum3 = b+c;
    if (sum1==sum2&&sum2==sum3)
    {
        printf("%d\n",sum1);
        goto end;
    }
    if (sum1<sum2&&sum1<sum3)
        printf("%d",sum1);
    else
    {
        if (sum2<sum3)
            printf("%d\n",sum2);
        else
            printf("%d\n",sum3);
    }
    end:return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

using Edge = pair<int, int>;
using Graph = vector< vector<Edge> >;

int N;
Graph G;
vector<int> res;


void dfs(int v, int p, int c){
    res[v] = c;
    for(auto e : G[v]){
        if(e.first == p){
            continue;
        }
        if(e.second % 2 == 1){
            dfs(e.first, v, 1-c);
        }else{
            dfs(e.first, v, c);
        }
    }
}


int main() {
    cin >> N;
    G.assign(N, vector<Edge>());
    for(int i = 0; i < N-1; i++){
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }

    res.assign(N, 0);

    dfs(0, -1, 1);

    for(auto v : res){
        cout << v << endl;
    }


    return 0;
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
const Int INF = 1e15;

int main(){
    Int N, W; cin >> N >> W;
    vector<Int> v(110), w(110);
    rep1(i, N) cin >> w[i] >> v[i];

    // dp[i][j]: 品物iまで，価値j以上での最小重量
    vector<vector<Int>> dp(110, vector<Int>(100010, INF));
    dp[0][0] = 0;

    rep1(i, N){
        rep(j, 100010){
            if(j >= v[i]){
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + w[i]);
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    Int ans = 0;
    rep(i,100010) {
        if(dp[N][i] <= W) ans = i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 87296
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
using namespace std;

int main() {
    string A;
    cin >> A;
    int N = A.size();

    int ans = 0,cnt = 0;
    for (int i = 2; i < N - 1; i++) {
        if (A[0] == 'A' && A[i] == 'C') {
            ans++;
        }
    }
    for (int j = 0; j < N; j++) {
        if (isupper(A[j])){
            cnt++;
        }
    }
    
    if (ans != 1 || cnt != 2) {
        cout << "WA" << endl;
    }
    else {
        cout << "AC" << endl;
    }
}

Measured memory_bytes: 256
//contest abc161_A swap
//get box A,B,and,C
//change A to B,than change A to C;
#include <iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	cout << c << " " << a <<  " " << b;
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <string>
#include <math.h>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repp(i, m, n) for(int i = m; i < (int)n; i++)
#define reps(i, n) for(int i = 1; i <= (int)n; i++)
#define pb push_back
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;

int main()
{
	ll x, y;
	cin >> x >> y;
	int ans=1;
	while(y/2>=x)
	{
		ans++;
		x*=2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl
int n,a[100000],b[100000],c[100000];

ll lower_index(ll b){
  return lower_bound(a,a+n,b)-a;
}

ll upper_index(ll b){
  return upper_bound(c,c+n,b)-c;
}
int main(){
  cin>>n;
  rep(i,n){
    cin>>a[i];
  }
  rep(i,n){
    cin>>b[i];
  }
  rep(i,n){
    cin>>c[i];
  }
  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);
  ll ans=0;
  rep(i,n){
    ll x=n-upper_index(b[i]);
    ll y=lower_index(b[i]);
    ans+=x*y;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;
char s[60][60];
int main() {
 int H,W;
 cin>>H>>W;
 for(int i=0;i<W;i++){
     for(int j=0;j<H;j++){
         cin>>s[i][j];
     }
 }

 for(int i=0;i<W;i++){
     for(int j=0;j<H;j++){
         if(s[i][j]=='#'&&s[i-1][j]!='#'&&s[i+1][j]!='#'&&s[i][j-1]!='#'&&s[i][j+1]!='#'){
             cout<<"No"<<endl;return 0;
         }
 }}
 cout<<"Yes"<<endl;
 return 0;}

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

int main() {

	int n;
	cin >> n;
	vector<ll> vec(n*2);

	vec[0] = 2;
	vec[1] = 1;

	for (int i = 2; i <= n; i++) {
		vec[i] = vec[i-2]+vec[i-1];
	}

	cout << vec[n] << endl;
	
}


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


void insertionSort(vector<int> A, int N){
  for (int i=1; i<N; i++){
    int v = A.at(i);
    for (int j = i-1; j >=0; j--){
      if(v < A.at(j)){
        A.at(j +1) = A.at(j);
        A.at(j) = v;
      }
      else
        break;
    }

    for(int i =0; i<N;i++){
      if(i>0)
        cout <<' ';
      cout << A.at(i);
    }

    cout << endl;
  }
}



int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N;i++)
    cin >> A.at(i);
  for (int i=0; i<N;i++){
    if(i>0)
      cout << ' ';
    cout <<  A.at(i);
  
  }
  cout << endl;


  insertionSort(A, N);
}


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

int main() {
  int x,y;
  cin >> x >>y;
  
  vector<bool> x1(x,false);
  vector<bool> y1(y,false);
  
  vector<vector<char>> v(x,vector<char>(y));
  
  for(int i=0; i<x; i++){
    for(int j=0; j<y; j++){
      cin >> v.at(i).at(j);
    }
  }
  
  for(int i=0; i<x;i++){
    for(int j=0; j<y;j++){
      if(!(v.at(i).at(j)=='.'))
        break;
      if(j==y-1)
        x1.at(i)=true;
    }
  }
  
  for(int i=0; i<y;i++){
    for(int j=0;j<x; j++){
      if(!(v.at(j).at(i)=='.'))
        break;
      if(j==x-1)
        y1.at(i)=true;
    }
  }
  
  for(int i=0;i<x;i++){
    for(int j=0;j<y;j++){
      if( !( x1.at(i) || y1.at(j) ) )
        cout <<v.at(i).at(j);
    }
    cout << endl;
  }

  // ここにプログラムを追記
  // (ここで"試合結果の表"の2次元配列を宣言)
}


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


int main(){
  int n,m,i,j;
  cin >> n >> m;
  int ans=0;
  j=m/n;
  vector<int> ret;
  for(i=1;i*i<=m;++i){
    if(m%i==0){
      ret.push_back(i);
      if(i*i!=m) ret.push_back(m/i);
    }
  }
  sort(ret.begin(),ret.end(),greater<int>());
  i=0;
  while(ans==0){
    if(ret[i]<=j){
      ans=ret[i];
    }
    i++;
  }
  cout << ans << endl;
  return 0;

}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

const int MAX = 10010;

int N, P;
string S;

ll sub() {
    ll ans = 0;
    REP (i, N) {
        if ((S[i] - '0') % P == 0) ans += i+1;
    }
    return ans;
}

ll solve() {
    if (P == 2 || P == 5) return sub();

    vi count(MAX);
    ll x = 0, k = 1;
    REPR (i, N) {
        x += k * (S[i] - '0');
        k = k * 10 % P;
        x %= P;
        count[x]++;
    }
    ll ans = count[0];
    REP (i, MAX) {
        ans += count[i] * (count[i] - 1) / 2;
    }
    return ans;
}

int main() {
    cin >> N >> P >> S;
    cout << solve() << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

struct A { int a, b, c; };
struct A T[10000];
int n;

void preParse(int u)
{

if ( u == -1 ) {
return;
}

printf(" %d", u);
preParse( T[ u ].b );
preParse( T[ u ].c );

}

void inParse(int u)
{

if ( u == -1 ) {
return;
}

inParse( T[ u ].b );
printf(" %d", u);
inParse( T[ u ].c );

}

void postParse(int u)
{

if ( u == -1 ) {
return;
}

postParse( T[ u ].b );
postParse( T[ u ].c );
printf(" %d", u);

}

int main(void)
{

int i, k, b, c, root;

scanf("%d", &n);
for ( i = 0; i < n; i++ ) {
T[ i ].a = -1;
}

for ( i = 0; i < n; i++ ) {

scanf("%d %d %d", &k, &b, &c);

T[ k ].b = b;
T[ k ].c = c;

if ( b != -1 ) {
T[ b ].a = k;
}

if ( c != -1 ) {
T[ c ].a = k;
}

}

for ( i = 0; i < n; i++ ) {

if ( T[ i ].a == -1 ) {
root =i;
}

}

printf("Preorder\n");
preParse(root);
printf("\n");
printf("Inorder\n");
inParse(root);
printf("\n");
printf("Postorder\n");
postParse(root);
printf("\n");

return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(),l.end());
  ll ans = 0;
  rep(b,n){
    rep(a,b){
      int ab = l[a] + l[b];
      int c = lower_bound(l.begin(),l.end(),ab) - l.begin();
      int L = b + 1;
      ans += c - L;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<ll> v;
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
  }

  ll X = 0;
  REP(i,2,N) X ^= v[i];

  ll S = v[0] + v[1];

  if((S-X)&1){
    cout << -1 << endl;
    return 0;
  }

  ll D = (S-X)/2;

  ll ret = 0;
  for(ll i=62; i>=0; i--){
    ll x = (D>>i)&1;
    ll y = (X>>i)&1;
    if(x == 0 && y == 0){
      ;
    }
    else if(x == 0 && y == 1){
      ;
    }
    else if(x == 1 && y == 0){
      ret += (1LL<<i);
    }
    else{
      cout << -1 << endl;
      return 0;
    }
  }

  if(ret > v[0]){
    cout << -1 << endl;
    return 0;
  }
  
  for(ll i=62; i>=0; i--){
    ll x = (D>>i)&1;
    ll y = (X>>i)&1;
    if(x == 0 && y == 1){
      if((ret + (1LL<<i)) <= v[0]){
        ret += (1LL<<i);
      }
    }
  }

  if(ret == 0) cout << -1 << endl;
  else cout << v[0] - ret << endl;
  
  return 0;
}


Measured memory_bytes: 3608
/**
 * @brief  剰余演算(modular arthmetic)に関するアルゴリズムを扱います
 *
 * @note   剰余演算とは、形式ばらずにいうと、モジュロnについて考えているとき、すべての結果xはnを法として
 *         xに等しい{0,1,...,n-1}の要素で置き換えられる(すなわち、xはx mod nで置き換えられる)ことを除いて、
 *         整数に関する普通通りの算術と考えることができる. 加算、減算、および乗算の演算に固執するならば、
 *         この略式モデルでも十分である. これから与える剰余演算に対する形式的なモデルは、群論の枠内で記述するのが最善である
 *
 * @date   2016/03/30
 */



//****************************************
// 必要なヘッダファイルのインクルード
//****************************************

#include <tuple>
#include <iostream>
#include <cstdint> 
#include <set>



//****************************************
// 型シノニム
//****************************************

using int_t    = std::int64_t;
using uint_t   = std::uint64_t;
using bit_t    = uint_t;
using intset_t = std::set<int_t>;


//****************************************
// 関数の定義
//****************************************

/**
 * @brief 反復2乗法(repeated squaring)はbの2進表現を用いてベキ乗剰余(modular exponentiation)を解く
 *
 * @note  aとbを非負整数, nを正整数とするとき、a^b mod nを効率良く計算する
 *
 * @note  次の手続きでは、2倍にする操作と1を加える操作を繰り返してcを1からbまで増加させるのにしたがって、
 *        対応するa^c mod nを計算する
 *
 * @note  入力a, b, nがβビットの数ならば、必要な算術演算の総数はΟ(β)であり、したがって、必要なビット演算の総数はΟ(β^3)である
 */
uint_t modular_exponentiation(uint_t a, uint_t b, uint_t n)
{
    uint_t d = 1;
    while (b > 0) {
        if (b & 0x01) {
            d = (d * a) % n;
        }
        a = (a * a) % n; 
        b >>= 1;
    }
    
    return d;
}



//****************************************
// エントリポイント
//****************************************

int main()
{
    using namespace std;

    const int_t n = 1000000007;
    int_t a, b;

    cin >> a >> b;
    cout << modular_exponentiation(a, b, n) << endl;
    
    return 0;
}

Measured memory_bytes: 3100
#include <cstdio>

int N, M, a, b;

int main() {
	scanf("%d%d%d%d", &N, &M, &a, &b);
	if (N % a == 0 && M % b == 0) return puts("No"), 0;
	puts("Yes");
	int v = 999999999 / (a * b - 1);
	for (int i = 1; i <= N; ++i)
		for (int j = 1; j <= M; ++j)
			printf("%d%c", i % a == 0 && j % b == 0 ? -(a * b - 1) * v - 1 : v, " \n"[j == M]);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> mountains(N);
  for (int i = 0; i < N; i++) {
    cin >> mountains[i];
  }
  int count = 1;
  for (int i = 1; i < N; i++) {
    int flag = 0;
    for (int j = 0; j < i; j++) {
      if (mountains[j] > mountains[i]) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      count++;
    }
  }
  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 256
n,k = list(map(int, input().split()))
lst = list(map(int, input().split()))

checker = [None for i in range(n)]
checker[0] = 0
num = 0
count = 0

flag = 0
while flag==0 and count!=k:
    if checker[lst[num]-1]==None:
        checker[lst[num]-1]=count+1
        count+=1
        num = lst[num]-1
    else:
        flag = 1
        count+=1

if flag==1:
    remaining = (k-checker[lst[num]-1])%(count-checker[lst[num]-1])
    num = lst[num]-1
    # print("~~~")
    # print("rem",remaining)
    # print("checker",checker)
    # print("num",num)
    # print("count",count)
    for i in range(remaining):
        num = lst[num]-1

print(num+1)


Measured memory_bytes: 32372