akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> s(m);
    rep(i, 0, m) {
        int k;
        cin >> k;
        rep(j, 0, k) {
            int x;
            cin >> x;
            x--;
            s[i].push_back(x);
        }
    }
    int p[m];
    rep(i, 0, m) cin >> p[i];

    int ans = 0;
    rep(i, 0, (1 << n)) {
        int l_on = 0;
        rep(j, 0, m) {
            int s_on = 0;
            rep(k, 0, s[j].size()) {
                if (i & (1 << s[j][k])) s_on++;
            }
            if (s_on % 2 == p[j]) l_on++;
        }
        if (l_on == m) ans++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20191021
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            String[] s = Console.ReadLine().Split(' ');

            int[] p = new int[n];
            for (int i = 0; i < n; i++) 
            {
                p[i] = int.Parse(s[i]);
            }

            int[] q = new int[n];

            for (int i = 0; i < n; i++)
            {
                q[i] = i+1;
            }


            int count = 0;
            for(int i = 0;i+1 < n; i++)
            {
                if(p[i] != q[i])
                {
                    count++;
                }
            }

            if(count <= 2)
            {
                Console.WriteLine("YES");
            }

            else
            {
                Console.WriteLine("NO");
            }

        }
    }
}


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

}


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

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

    vector<int> H(N);
    for (int &h : H)
    {
        cin >> h;
    }

    bool ans = true;
    for (int i = N - 2; i >= 0; i--)
    {
        if (H[i] > H[i + 1])
        {
            H[i]--;
        }
        if (H[i] > H[i + 1])
        {
            ans = false;
        }
    }

    if (ans)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


signed main() {

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

    for(int i=1; i<=b; i++){
        if(i*a%b==c){YES;return 0;}
    }
    NO;
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
const int N = 200005, P = 1000000007;
int n;
std::vector<int> E[N];
int fac[N], inv[N];
int sz[N], f[N], g[N], ans[N];
int qpow(int a, int b = P - 2){
	int s = 1;
	for (; b; b >>= 1, a = 1ll * a * a % P) if (b & 1) s = 1ll * s * a % P;
	return s;
}
void init(int n){
	fac[0] = 1;
	for (register int i = 1; i <= n; ++i) fac[i] = 1ll * fac[i - 1] * i % P;
	inv[n] = qpow(fac[n], P - 2);
	for (register int i = n; i; --i) inv[i - 1] = 1ll * inv[i] * i % P;
}
int C(int n, int m){
	if (m < 0 || m > n) return 0;
	return 1ll * fac[n] * inv[m] % P * inv[n - m] % P; 
}
void dfs_f(int u, int fa = 0){
	f[u] = 1, sz[u] = 1;
	for (int v : E[u])
		if (v != fa){
			dfs_f(v, u), sz[u] += sz[v];
			f[u] = 1ll * f[u] * f[v] % P * C(sz[u] - 1, sz[v]) % P;
		}
}
void dfs_g(int u, int fa = 0){
	ans[u] = 1ll * f[u] * g[u] % P * C(n - 1, n - sz[u]) % P;
	for (int v : E[u])
		if (v != fa){
			g[v] = 1ll * ans[u] * qpow(1ll * f[v] * C(n - 1, sz[v]) % P, P - 2) % P;
			dfs_g(v, u);
		}
}
int main(){
	scanf("%d", &n);
	for (register int i = 1, u, v; i < n; ++i)
		scanf("%d%d", &u, &v), E[u].push_back(v), E[v].push_back(u);
	init(n);
	dfs_f(1), g[1] = 1, dfs_g(1);
	for (register int i = 1; i <= n; ++i) printf("%d\n", ans[i]);
}


Measured memory_bytes: 18548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }   

    int cnt = 1;
    int m = a[0];
    for (int i = 1; i < N; i++) {
        if(m <= a[i]){
            cnt++;
            m = a[i];
        }
    }
    printf("%d\n", cnt);

}

Measured memory_bytes: 3676
#include <cstdio>
#include <iostream>
using namespace std;
string str;
bool falg;

int main ()
{
	cin>>str;

	for (int i=0;i<str.size();i++)
	{
		if (!falg && str[i]=='C') falg=true;
		if (falg && str[i]=='F')
		{
			printf ("Yes\n");
			return 0;
		}
	}
	printf ("No\n");
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int w,a,b;
    cin>>w>>a>>b;
    
    if(a+w<b)cout<<b-(a+w)<<endl;
    else if(b+w<a)cout<<a-(b+w)<<endl;
    else cout<<0<<endl;
}


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

int main(void) {
	vector<bool> S;
	S.resize(101, false);
	for (int i = 1; i < 10; ++i) {
		for (int j = 1; j <= i; ++j)
			S[i * j] = true;
	}

	int N;
	cin >> N;
	if (S[N])
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

struct Info{
	Info(int arg_state,int arg_count){
		state = arg_state;
		count = arg_count;
	}
	int state,count;
};

int main(){

	int POW[17] = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536};
	int N,M,K,limit;

	scanf("%d %d %d",&N,&M,&K);

	limit = POW[M];

	int* min_Count = new int[limit];
	for(int i = 0; i < limit; i++){
		min_Count[i] = BIG_NUM;
	}

	bool isDark[N];
	int  dark_Index[M];

	for(int i = 0; i < N; i++)isDark[i] = false;

	vector<int> V[N];

	int tmp;

	for(int i = 0; i < M;i++){
		scanf("%d",&tmp);
		tmp--;
		isDark[tmp] = true;
		dark_Index[i] = tmp;
	}

	for(int i = 0; i < N; i++){
		for(int p = 0; p < K; p++){
			scanf("%d",&tmp);
			tmp--;
			V[i].push_back(tmp);
		}
	}

	queue<Info> Q;
	Q.push(Info(limit-1,0));
	min_Count[limit-1] = 0;

	int ans,state,next_state,room,next_room,next[M];

	while(!Q.empty()){

		if(Q.front().state == 0){
			ans = Q.front().count;
			break;
		}else if(Q.front().count > min_Count[Q.front().state]){
			Q.pop();
		}else{

			state = Q.front().state;

			for(int instruction = 0; instruction < K; instruction++){

				for(int a = 0; a < M; a++)next[a] = 0;

				for(int a = 0; a < M; a++){

					if(state & (1 << a)){
						room = dark_Index[a];
						next_room = V[room][instruction];
						if(isDark[next_room] == false){
							//Do nothing
						}else{
							for(int p = 0; p < M; p++){
								if(dark_Index[p] == next_room){
									next[p] = 1;
								}
							}
						}
					}
				}

				next_state = 0;
				for(int i = 0; i < M; i++)next_state += POW[i]*next[i];

				if(min_Count[next_state] > Q.front().count+1){
					min_Count[next_state] = Q.front().count+1;
					Q.push(Info(next_state,Q.front().count+1));
				}
			}

			Q.pop();
		}
	}

	printf("%d\n",ans);

	return 0;
}

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

int main(){
	int N, K;
	cin >> N >> K;
	int ans = 0;
	rep(i, N) {
		int h;
		cin >> h;
		if (h >= K) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const int INF = 1<<30;
static const int SIZE = 110000;

int dp[SIZE];

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

    fill(dp,dp+SIZE,INF);
    dp[0] = 0;

    for(int i=1; i<=n; i++){
        
        for(int six=1; six<=i; six *= 6){
            if(i-six < 0) continue;
            dp[i] = min(dp[i],dp[i-six]+1);
        }

        for(int nine=1; nine<=i; nine *= 9){
            if(i-nine < 0) continue;
            dp[i] = min(dp[i],dp[i-nine]+1);
        }
    }

    cout<<dp[n]<<endl;

    return 0;
}



Measured memory_bytes: 640
n = input()
x = len(n)

if n == n[::-1]:
    if n[:((x-1)//2)] == n[:((x-1)//2)][::-1]:
        if n[((x+3)//2)-1:] == n[((x+3)//2)-1:][::-1]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
bool f(int N, int dist, int C, int D)
{
    for (long long i = 0; i <= N-1; i++) {
        long long j = N - 1 - i;
        if (i * C - j * D <= dist && dist <= i * D - j * C) {
            return true;
        }
    }
    return false;
}

int main()
{
    int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
    cout << (f(N, abs(B - A), C, D) ? "YES" : "NO") << endl;
    return 0;
}


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

using namespace std;

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main() {

    string S;
    cin >> S;

    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i)
        reverse(divide[i].begin(), divide[i].end());

    bool can = true;
    for (int i = 0; i < S.size();) {
        bool can2 = false;

        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) {
                can2 = true;
                i += d.size();
            }
        }
        if (!can2) {
            can = false;
            break;
        }
    }

    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;
const ll MINF = LLONG_MIN;
const int INT_INF = INT_MAX;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n - 1; i++)
    {
        cin >> b[i];
    }
    a[0] = b[0];
    for (int i = 1; i < n - 1; i++)
    {
        a[i] = min(b[i], b[i - 1]);
    }
    a[n - 1] = b[n - 2];
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

string s;
int l;

long long calc(int bit){
    long long temp=0;
    long long sum=0;
    temp=s[0]-'0';
    for(int i=1;i<l;i++){
        if((bit>>(i-1))&1){
            sum+=temp;
            temp=s[i]-'0';
        }else{
            temp=temp*10+(s[i]-'0');
        }
    }
    sum+=temp;
    return sum;
}

int main(){
    
    cin>>s;
    l=s.length();
    
    int pat=1<<(l-1);
    long long res=0;
    while(pat--){
        res+=calc(pat);
    }
    
    cout<<res;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

struct data{
  int h,p,q;
}b[1000];

int cmp(const void *a,const void *b){
  return ((struct data *)b)->h-((struct data *)a)->h;
}

int main(void) {
  int i=0,tmp,d[101];
  int n,m,a;
  
  while(scanf("%d%d%d",&n,&m,&a),n){
    for(i=0;i<m;i++){
     scanf("%d%d%d",&b[i].h,&b[i].p,&b[i].q);
    }
    qsort(b,m,sizeof(struct data),cmp);
    for(i=0;i<101;i++)d[i]=i;
    for(i=0;i<m;i++){
      tmp=d[b[i].p];
      d[b[i].p]=d[b[i].q];
      d[b[i].q]=tmp;
    }
    for(i=0;i<=n;i++){
      if(d[i]==a){
        printf("%d\n",i);
        break;
      }
    }
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int> > vp;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define For(i, a, n) for(int i = a; i < (n); i++)
#define out(n) cout << (n) << endl;
#define vut(v) rep(i, v.size()) out(v[i]);

int main() {
  int n, m, d[100001] = {0};
  cin >> n >> m;

  int a, b;
  rep(i, m) {
    cin >> a >> b;
    d[a]++, d[b]++;
  }

  rep(i, n + 1) {
    if(d[i] & 1) {
      out("NO")
      return 0;
    }
  }

  out("YES")
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,Ma,Mb;
  cin >> N >> Ma >> Mb;
  vector<pair<P,int>> abc(N);
  rep(i,N) {
    int a,b,c;
    cin >> a >> b >> c;
    abc[i] = make_pair(P(a,b),c);
  }
  vvi dp(410,vi(410,INF));
  dp[0][0] = 0;
  rep(i,N) {
    int a = abc[i].first.first;
    int b = abc[i].first.second;
    int c = abc[i].second;
    vvi dp2(410,vi(410,INF));
    dp2[0][0] = 0;
    rep(j,410) {
      rep(k,410) {
        if(j-a>=0&&k-b>=0) {
          dp2[j][k] = min(dp[j][k],dp[j-a][k-b]+c);
        } else {
          dp2[j][k] = dp[j][k];
        }
      }
    }
    dp = dp2;
  }
  int ans = INF;
  for(int i=1;i * Ma < 410 && i * Mb < 410;i++) {
    int ma = i * Ma;
    int mb = i * Mb;
    if(dp[ma][mb] < 4100) {
      ans = min(ans,dp[ma][mb]);
    }
  }
  if(ans == INF) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1640
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int n, a[100009];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	vector<int> z;
	int p = 0;
	for (int i = 1; i <= n; i++) {
		if (i == n || a[i - 1] == a[i]) {
			z.push_back(i - p);
			p = i;
		}
	}
	int ret = (z.size() <= 3 ? n : 0);
	for (int i = 3; i <= z.size(); i++) {
		ret = max(ret, z[i - 3] + z[i - 2] + z[i - 1]);
	}
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 3288
#!/usr/bin/env pypy
from __future__ import division, print_function
from collections import defaultdict, Counter, deque
from future_builtins import ascii, filter, hex, map, oct, zip
from random import randint
from itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement
from __builtin__ import xrange as range
from math import ceil
from _continuation import continulet
from cStringIO import StringIO
from io import IOBase
import __pypy__
from bisect import bisect, insort, bisect_left, bisect_right
import sys
import os
import re
sys.setrecursionlimit(9999)
inf = float('inf')
mod = int(1e9) + 7
mod_ = 998244353
N = 5001
 
'''
Check for special cases (n=1)
One wrong submission = 10 mins penalty!
do smth instead of nothing and stay organized
'''


def main():
	n = int(input())
	arr = list(map(int, input().split()))
	total = 0
	for i in range(n):
		for j in range(i+1, n):
			total += arr[i]*arr[j]
	print(total)


BUFSIZE = 8192
class FastI(IOBase):
	def __init__(self, file):
		self._fd = file.fileno()
		self._buffer = StringIO()
		self.newlines = 0
 
	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines = 0
		return self.buffer.read()
 
	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count("\n") + (not b)
			ptr = self._buffer.tell()
			self._buffer.seek(0, 2), self._buffer.write(
				b), self._buffer.seek(ptr)
		self.newlines -= 1
		return self._buffer.readline()
class FastO(IOBase):
	def __init__(self, file):
		self._fd = file.fileno()
		self._buffer = __pypy__.builders.StringBuilder()
		self.write = lambda s: self._buffer.append(s)
 
	def flush(self):
		os.write(self._fd, self._buffer.build())
		self._buffer = __pypy__.builders.StringBuilder()
def print(*args, **kwargs):
	sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop("end", "\n"))
	if kwargs.pop("flush", False):
		file.flush()
def gcd(x, y):
	while y:
		x, y = y, x % y
	return x
sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
def input(): return sys.stdin.readline().rstrip("\r\n")
if __name__ == "__main__":
	def bootstrap(cont):
		call, arg = cont.switch()
		while True:
			call, arg = cont.switch(to=continulet(
				lambda _, f, args: f(*args), call, arg))
	cont = continulet(bootstrap)
	cont.switch()
	main()

Measured memory_bytes: 31340
#include<iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;

ll max(ll a, ll b, ll c = 0, ll d = 0)
{
  if (c == 0 && d == 0)
    return a > b ? a : b;
  return max(a, max(b, max(c, d)));
}

int main()
{
  int n;
  cin >> n;
  vector<vector<ll>> board(n + 1, vector<ll>(3, 0)),
      dp(n + 1, vector<ll>(3, 0));
  for (int i = 1; i<=n; i++)
  {
    cin >> board[i][0] >> board[i][1] >> board[i][2];
  }

  // Intial Condition.
  dp[1] = board[1];
  // This code is for same activity for at max 2 days. 
  // Read the Question wrong.
  // Commenting this because this is a better question.
  // Same activity for atmax k days =>
  // dp[i][j] = max(dp[i][j - k] + sum(board(i , i, j -k, j)), dp[i][j-1]....)
  /*
  for (int i = 2; i <= n; i++)
  {
    dp[i][0] = board[i][0] + max(dp[i - 1][1], dp[i - 1][2],
        board[i - 1][0] + dp[i - 2][1], board[i - 1][0] + dp[i - 2][2]);
    dp[i][1] = board[i][1] + max(dp[i - 1][0], dp[i - 1][2],
        board[i - 1][1] + dp[i - 2][2], board[i - 1][1] + dp[i - 2][0]);
    dp[i][2] = board[i][2] + max(dp[i - 1][0], dp[i - 1][1],
        board[i - 1][2] + dp[i - 2][0], board[i - 1][2] + dp[i - 2][1]);
  }
  */
 for (int i = 2; i <= n; i++)
  {
    dp[i][0] = board[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
    dp[i][1] = board[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
    dp[i][2] = board[i][2] + max(dp[i - 1][0], dp[i - 1][1]);
  }
  cout << max(dp[n][0], dp[n][1], dp[n][2]) << endl;
  return 0;
}

Measured memory_bytes: 11136
n = int(input())
a = sorted([(v, i) for i, v in enumerate(list(map(int, input().split())))])[::-1]

dp = [[0 for _ in range(n + 1)] for _ in range(n + 1)]

ans = 0
for i in range(n):
    for j in range(n - i):
        v, p = a[i + j]
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + v * abs(n - 1 - i - p))
        dp[i][j + 1] = max(dp[i][j + 1], dp[i][j] + v * abs(j - p))
        ans = max(ans, dp[i + 1][j], dp[i][j + 1])
print(ans)


Measured memory_bytes: 102020
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

#define out(t) cout << (t) << "\n"

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int uint;

int popcount(uint x) {
    x -= x >> 1 & 0x55555555;
    x = (x & 0x33333333) + (x >> 2 & 0x33333333);
    x = x + (x >> 4) & 0x0F0F0F0F;
    return x * 0x01010101 >> 24;
}

int tzcnt(uint x) {
    return popcount(~x & x - 1);
}

struct Point {
    int x, y;

    Point(int p, int q) : x(p), y(q) {}
};

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

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

    out((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d ? "Yes" : "No");
    
    int aaa;
    cin >> aaa;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>

int main() {

    char s[4];
    scanf("%s", s);

    if ((s[0] == s[1]) && (s[0] == s[2]) && (s[0] == s[3])) {
        puts("No");
    } else if ((s[0] == s[1]) && (s[2] == s[3])) {
        puts("Yes");
    } else if ((s[0] == s[2]) && (s[1] == s[3])) {
        puts("Yes");
    } else if ((s[0] == s[3]) && (s[1] == s[2])) {
        puts("Yes");
    } else {
        puts("No");
    }


    return 0;

}


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

string rotate(string s){
    return s.substr(1) + s[0];
}

string S,T;
int main (){
    cin >> S >> T;
    if( S.length() != T.length()) { cout << "No" << endl; return 0;
    }
    for(int i=0; i<S.length(); i++){
        if( S == T ) {
            cout << "Yes" << endl;
            return 0;
        }
        S = rotate(S);
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second

const int mxn = 1000000;
int n;
string s;
int a[mxn], b[mxn];

int sol(int x){
	int r1 = 0, r2 = 0;
	for(int i = 0; i < n; i++){
		r2 += 2 * (s[i] == '?' && b[i] + r2 < x - 1);
		r1 = min(r1, a[i] + r2);
	}
	return x - r1;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s;
	n = s.size();
	
	for(int i = 0; i < n; i++){
		a[i] = 2 * (s[i] == '1') - 1 + (i ? a[i - 1] : 0);
	}
	for(int i = n - 1; ~i; i--){
		b[i] = max(a[i], (i < n - 1 ? b[i + 1] : a[i]));
	} 
	int v = max(b[0], 0);
	
	cout << min(sol(v), sol(v + 1)) << endl;

	return 0;
}

Measured memory_bytes: 12148
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
int w[131072],sum[131072],n,k,l,r,mid;
char c;
bool is_digit(){
    return c<='9'&&c>='0';
}
void read(int &a){
    a=0;
    while((c=getchar())&&(is_digit())) a=a*10+c-'0';
}
bool pc(int a){
    memset(sum,0,sizeof(sum));
    int j=0;
    for(int i=0,t=0;i<n;i++){
        if(t+w[i]>a) j++,t=w[i];
        else t+=w[i];
    }
    return j<k;
}
int main(){
    read(n);
    read(k);
    for(int i=0;i<n;i++){
        read(w[i]);
        l=max(w[i],l);
        r+=w[i];
    }
    while(l!=r){
        mid=(l+r)/2;
        if(pc(mid)) r=mid;
        else l=mid+1;
    }
    cout<<l<<"\n";
    return 0;
}

Measured memory_bytes: 4008
#include <iostream>
#include <set>

int main() {
  int n;
  std::cin >> n;
  std::set<int> st;
  for (int i = 0; i != n; i += 1) {
    int a;
    std::cin >> a;
    st.insert(a);
  }
  std::cout << (st.size() == n ? "YES" : "NO") << std::endl;
}

Measured memory_bytes: 9600
#include <iostream>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int D,N;
    cin >> D >> N;
    if(D == 0){
        if(N != 100)cout << N << endl;
        else cout << 101 << endl;
        return 0;
    }
    int x = 1; for(int i = 0; i < D; ++i) x *= 100;
    if(N != 100)cout << x*N << endl;
    else cout << x*101 << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define REP(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL
const ll MOD=1000000007;

int main(){
  ll n; cin>>n;
  ll ans = LLINF;
  for (ll i=1; i*i<=n; i++){
    if (n%i==0){
      ll a = i;
      ll b = n/i;
      ans = min(a+b, ans);
    }
  }
  cout << ans - 2 << endl;
}

Measured memory_bytes: 3640
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define x first
#define y second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

int main()
{

	int n,m,k;scanf("%d%d%d",&n,&m,&k);
	for (int i=0;i<=n;i++)
		for (int j=0;j<=m;j++)
			if (n*m-i*j-(n-i)*(m-j)==k) {puts("Yes");return 0;}
	puts("No");
	return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
B - Buffet
https://atcoder.jp/contests/abc140/tasks/abc140_b

"""
import sys


def solve(N, A, B, C):
    ans = 0
    prev = -100
    for a in A[1:]:
        ans += B[a]
        if a == prev + 1:
            ans += C[a-1]
        prev = a
    return ans


def main(args):
    N = int(input())
    A = [-1] + [int(a) for a in input().split()]
    B = [-1] + [int(b) for b in input().split()]
    C = [-1] + [int(c) for c in input().split()]
    ans = solve(N, A, B, C)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
import sys

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

s = input()
ans = ""
for i in range(len(s)):
    if s[i] == '0' or s[i] == '1':
        ans += s[i]
    else:
        if len(ans) > 0:
            ans = ans[:-1]
print(ans)

Measured memory_bytes: 3064
a,b,c = map(int,input().split())

if (a%2!=0) or (b%2!=0) or (c%2!=0):
  print(0)
elif (a == b ) and (b == c):
  print(-1)
else:
  def exchange(a,b,c):
    return (b+c)/2,(c+a)/2,(a+b)/2
  num = 0
  ans = 0
  while num  == 0:
    a,b,c = exchange(a,b,c)
    ans += 1
    for j in range(3):
      if [a,b,c][j] % 2 ==1:
        num = 1
  print(ans)

Measured memory_bytes: 3192
# 約数の列挙
#############################################################


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
#############################################################


N, K = map(int, input().split())
A = list(map(int, input().split()))

sum_A = sum(A)
div_list = make_divisors(sum_A)
ans = 1
# print(div_list)

for div in div_list:
    tmp = []
    for a in A:
        tmp.append(a % div)
    tmp.sort()
    cumsum1 = [0]
    cumsum2 = [0]
    for i in tmp:
        cumsum1.append(cumsum1[-1] + i)
        if i != 0:
            cumsum2.append(cumsum2[-1] + (div - i))
        else:
            cumsum2.append(cumsum2[-1])
    for i in range(1, N):
        if cumsum1[i] <= K and cumsum2[N] - cumsum2[i] <= K:
            ans = div

print(ans)


Measured memory_bytes: 9376
/* author   : mpily :-()
title : Competing.cpp
time :Sun Jun 14 13:11:23 2020

*/
#include<random>
#include<cassert>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<utility>
#include<cstdint>
#include<queue>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdio>
using namespace std;

void solve(int cnum){
	int64_t n;
	cin >> n;
	vector<int64_t>arr(n);
	vector<int64_t>freq(100005);
	int64_t sum = 0;
	for(int i = 0; i < n; ++i){
		cin >> arr[i];
		sum+=arr[i];
		freq[arr[i]]++;
	}
	int  q;
	cin>> q;
	for(int i = 0; i < q; ++i){
		int64_t a,b;
		cin >> a >> b;
		int64_t num = freq[a];
		int64_t torem = a * num;
		freq[a] = 0;
		sum-=torem;
		torem = b * num;
		sum +=torem;
		freq[b]+=num;
		cout << sum <<"\n";
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	//cout.tie(nullptr);
	int t;
	int count = 1;
	for(t = 1;t--; solve(count));
	return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}

int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    rep(i,n) {
        cin >> A[i];
    }
    int cnt = 0;
    bool pika = false;
    int i=1;
    int next =0;
    int now = 1;
    while(i<=n) {
        now = A[now-1];
        if (now==2) {
            cout << i << "\n";
            return 0;
        }
        i++;
    }
    cout << -1 << "\n";
}

Measured memory_bytes: 768
#include <cstdio>
#include <cstring>
#define min(a,b) ((a)<(b)?(a):(b))
char s[1003],t[1003];
int lens,lent,ans=1<<30,sum;
int main(){
    scanf("%s%s",s,t);
    lens=strlen(s),lent=strlen(t);
    for(int i=0;i<lens-lent+1;i++){
        sum=0;
        for(int j=0;j<lent;j++) if(s[i+j]!=t[j]) ++sum;
        ans=min(ans,sum);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1720
import java.io.*;
import java.util.*;

class Main{
    public static void main(String args[]){
        
            BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
            String s;
        
            int[] x=new int[10000];
            
            for(int i=0;i<10000;i++){
                try{
                    s=reader.readLine();
                    x[i]=Integer.parseInt(s);
                    
                    if(x[i]==0){
                        break;
                    }else{
                        System.out.println("Case "+(i+1)+": "+x[i]);
                    }
                }catch(IOException e){
                    System.out.println(e);
                }
            }
            
            
    }
}

Measured memory_bytes: 31944
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    ll n, m;
    cin >> n >> m;
    if (2*n >= m) cout << m / 2 << endl;
    else cout << n + (m-2*n)/4 << endl;
    return 0;
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int N; cin >> N;
    map<int, int> freq;
    rep(i, N) {
        int A; cin >> A;
        freq[A]++;
    }
    int ans = 0;
    for (auto p : freq) ans += (p.second&1);
    cout << ans << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;


int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    if(s.back() == 's'){
        cout << s + "es" << endl;
    }else cout << s + "s" << endl;
    return 0;
    
}

Measured memory_bytes: 3664
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	var s string
	fmt.Scan(&n)
	fmt.Scan(&s)

	const az = "ABCDEFGHIJKLMNOPQRSTUVWXYZA"

	ss := strings.Split(s, "")

	for i, c := range ss {
		idx := (strings.Index(az, c) + n)%26
		ss[i] = az[idx:idx+1]
	}
	fmt.Println(strings.Join(ss, ""))
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  vector<int>a(n+1,0);
  int size=min(n+1,k);
  for(int i=1;i<size;i++){
    a.at(i)=1;
  }
  int kk=0;
  int tmpkk=1;
  while(tmpkk<k){
    tmpkk*=2;
    kk++;
  }
  for(int ii=1;ii<=kk;ii++){
    int i=1;
    while(i*pow(2,(ii))<k){
      a.at(i)++;
      i++;
      if(i==n+1)break;
    }
  }
  double ans=0;
  for(int i=1;i<=n;i++){
    double anstmp=1.0/n;
    for(int j=0;j<a.at(i);j++){
      anstmp/=2.0;
    }
    ans+=anstmp;
  }
  cout<< fixed << setprecision(15) <<ans<<endl;
}

Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;


void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
//#define P pair<ll, ll>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}
ll INF = 1e+18;
int iINF = 1e9;


int main() {
  string S, T; cin >> S >> T;
  int N = S.size(), M = T.size();
  vector<vector<int>> dp(N + 1, vector<int>(M + 1, 0));

  rep(i, 0, N){
    rep(k, 0, M){
      if(S[i] == T[k]) dp[i + 1][k + 1] = max(dp[i + 1][k + 1], dp[i][k] + 1);
      dp[i + 1][k + 1] = max(dp[i + 1][k + 1], dp[i + 1][k]);
      dp[i + 1][k + 1] = max(dp[i + 1][k + 1], dp[i][k + 1]);
    }
  }

  vector<char> ans;
  int i = N, k = M;
  while(i > 0 && k > 0){
    if(dp[i - 1][k] == dp[i][k]){
      --i;
    }
    else if(dp[i][k - 1] == dp[i][k]){
      --k;
    } else {
      ans.insert(ans.begin(), S[i - 1]);
      --i, --k;
    }
  }
  
  for(auto x: ans) cout << x;
  cout << endl;

}

Measured memory_bytes: 38612
#include<bits/stdc++.h>
#define LIM 1+2+4+8+16+32+64+128
using namespace std;
typedef long long int ll;
int main(){
  int n,a,b;
  cin>>n>>a>>b;
  if(n*a>b){
    cout<<b<<endl;
  }else{
    cout<<n*a<<endl;
  }
  return(0);
}


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

using namespace std;

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;
    int ans[2] = {0,0};
    for(int i=0;i<=30;i++){
        for(int j=0;j<=30;j++){
            int water = (A*i + B*j)*100;
            int sugar = 0;
            for(int c=0;c<=100;c++){
                for(int d=0;d<=100;d++){
                    sugar = c*C + d*D;
                    if(water+sugar <= F && water*E/100 >= sugar){
                        if(ans[1]*(water+sugar)>sugar*(ans[0]+ans[1])){
                        }else{
                            ans[0] = water;
                            ans[1] = sugar;
                        }
                    }
                }
            }
        }
    }
    cout << ans[0]+ans[1] << " " << ans[1] << endl;
}

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

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> x >> y >> z;
	if(x%(y+z) < z) cout << x/(y+z) - 1 << endl;
	else cout << x/(y+z) << endl;
}	

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a,b;

		while(true){
			a = sc.nextInt();
			b = sc.nextInt();

			if(a == 0 && b == 0)break;

			System.out.printf("%d %d\n", Math.min(a, b),Math.max(a, b));
		}

	}
}




Measured memory_bytes: 41296
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

using ll = long long int;
using namespace std;

ll MOD = 2019;

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

  ll N = S.length();

  vector<ll> rem(N+1);
  ll tmp = 1;
  rem[N] = 0;
  for(ll i = N-1; i >= 0; i--){
    rem[i] = (rem[i+1] + tmp*((int)S[i]-'0') + MOD)%MOD;
    tmp = (tmp*10+MOD)%MOD;
  }

  vector<ll> count(2019);
  for(ll i = 0; i <= N; i++){
    count[rem[i]]++;
  }

  ll ans = 0;
  for(ll i = 0; i < 2019; i++){
    ans += (count[i]*(count[i]-1))/2;
  }

  cout << ans << endl;

  return 0;


}


Measured memory_bytes: 5176
#----------------------------------------------------------
P = 10**9 + 7
N = 500000 #使える最大値、値に注意
inv = [0] + [1] # 1/x
finv = [1] + [1] # 1/x!
fac = [1] + [1] # x!
for i in range(2,N):
  inv += [inv[P % i] * (P - int(P / i)) % P]
  fac += [(fac[i-1] * i) % P]
  finv += [(finv[i-1] * inv[i]) % P]

def comb(a, b):
    if a<b:
        return -1 # error
    return (fac[a] * ((finv[b] * finv[a-b]) % P)) %P
#----------------------------------------------------------

n, k = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a, key=lambda x: x, reverse=False)
ans = 0
# a[i]が最小値になる場合の数
for i in range(len(a)):
    tmp = comb(n-1-i, k-1)
    if tmp<0:
        continue
    if a[i] < 0:
        ans = (ans + (abs(a[i])*tmp)%P)%P
    else:
        ans = (ans - (abs(a[i])*tmp)%P + P)%P

# a[i]が最大値になる場合の数
for i in range(len(a)):
    tmp = comb(n-1-i, k-1)
    if tmp<0:
        continue
    if a[n-1-i] < 0:
        ans = (ans - (abs(a[n-1-i])*tmp)%P + P)%P
    else:
        ans = (ans + (abs(a[n-1-i])*tmp)%P)%P
print(ans)


Measured memory_bytes: 73488
n, d = map(int, input().split(" "))
xs = set(tuple(map(int, input().split(" "))) for i in range(n))
ys = set(xs)
ans = 0
for x in xs:
    ys.remove(x)
    for y in ys:
        d2 = sum(abs(xx - yy) ** 2 for xx,yy in zip(x, y))
        j = 1
        while j ** 2 < d2:
            j += 1
        if j ** 2 == d2:
            ans += 1
print(ans)


Measured memory_bytes: 3060
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val rawsec = sc.nextInt

    val hour = rawsec / 3600
    val min = (rawsec - hour*3600) / 60 
    val sec = rawsec - hour*3600 - min*60
    println(hour+":"+min+":"+sec)
  }
}

Measured memory_bytes: 45040
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    const char C = 'C';
    string s; cin >> s;
    string s1(s), s2(s), s3(s),s4(s);
    int l = s.size();
    int k; cin >> k;
    ll ans = 0;
    if (l == 1) {
        ans = k / 2;
    } else {
        // c1:1文字目を変えない c2:1文字目を変える c3:末尾を変える c4:両端変更
        ll c1 = 0, c2 = 1, c3 = 1, c4 = 2;
        s2[0] = C; s3[l-1] = C;
        s4[0] = C; s4[l-1] = C;
        FOR(i,1,l) {
            if (s1[i-1] == s1[i]) {
                c1++; s1[i] = C;
            }
            if (s2[i-1] == s2[i]) {
                c2++; s2[i] = C;
            }
            if (s3[l-i] == s3[l-i-1]) {
                c3++; s3[l-i-1] = C;
            }
            if (s4[i-1] != C  && s4[i-1] == s4[i]) {
                c4++; s4[i] = C;
            }
        }
        cerr << c1 << " " << c2 << " " << c3 << " " << c4 << endl;
        if (k == 1) ans = c1;
        else if  (s1[0] != s1[l-1]) ans = c1 * k;
        else {
            // 1. 14141..
            ans = c1 * ((k+1) / 2) + c4 * (k / 2);
            // 2. 22222...
            //ans = min(ans,c2 * k);
            // 3. 33333...
            //ans = min(ans,c3 * k);
            // 4. 12222...
            ans = min(ans,c2 * (k-1) + c1);
            // 5. 33...331
            ans = min(ans,c3 * (k-1) + c1);
        }
    }

    cout << ans << endl;

    return 0;
}

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

int strcnp(const void* l, const void* r) {
    return strcmp((char*)l, (char*)r);
}

int main() {
    int n, l;
    scanf("%d %d", &n, &l);

    char s[n][l+1];
    for (int i = 0; i < n; i++) {
        scanf("%s", s[i]);
    }

    qsort(s, n, sizeof(s[0]), strcnp);

    for (int i = 0; i < n; i++) {
        printf("%s", s[i]);
    }
    puts("");

    return 0;
}

Measured memory_bytes: 252
def gcd(x, y):
    if x < y:
        x, y = y, x
    if y == 0:
        return x
    return gcd(x % y, y)


def lcm(x, y):
    return x // gcd(x, y) * y


n = int(input())
ans = 1
for i in range(n):
    t = int(input())
    ans = lcm(ans, t)
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

int main(){
    int N;
    cin >> N;
    for(int i=0;i<N;i++){
        char c;
        cin >> c;
        if(c=='Y'){
            puts("Four");
            return 0;
        }
    }
    puts("Three");
    return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    h, w, d = map(int, input().split())
    f = [list(map(int, input().split())) for _ in range(h)]

    # f => (y, x) mapping
    c_map = [0] * (h * w)
    for y in range(h):
        for x in range(w):
            c_map[f[y][x] - 1] = (y, x)

    # cost accumulation
    d_map = [0] * (h * w)
    for i in range(d, h * w):
        y, x = c_map[i]
        y2, x2 = c_map[i - d]
        d_map[i] = d_map[i - d] + abs(y2 - y) + abs(x2 - x)

    results = []
    q = int(input())
    for _ in range(q):
        l, r = map(int, input().split())
        results.append(d_map[r - 1] - d_map[l - 1])

    print("\n".join(map(str, results)))


Measured memory_bytes: 29092
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <algorithm>
#include <complex>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace  std;

using ll = long long;
const ll mod = 1e9 + 7;
typedef pair<ll, ll> pairs;
typedef complex<ll> G;
const int N=1e5+5;

const int INF = 1e9+5;


void done() {



int n;
    cin >> n;
    int a[n];
    int bad = false;
    bool vis[2*n+1] = {false};
    for(int i=0;i < n;i++) {
        cin >> a[i];
        vis[a[i]] = true;


    }

    vector<int>ans(2*n);
    for(int i=0; i< n;i++) {
        ans[i*2] = a[i];
    }
    for(int i=1;i < 2*n;i+=2) {
        int p = ans[i-1];
        while(p <=2*n) {
            if(!vis[p]) {
                ans[i] = p;
                vis[p] = true;
                break;
            }
            p++;
        }
    }
    for(auto x : ans) {
        if(x==0) {
            cout << -1 << '\n';
            return;
        }
    }
    for(auto x : ans) {
        cout << x << " ";
    }
    cout << '\n';


}
void solve() {
    int n;
    cin >> n;
    int a[n];
    int tot = 0;
    for(int i=0;i < n;i++) {
        cin >> a[i];
        tot ^= a[i];

    }
    for(int i=0;i < n;i++) {
        cout << (tot ^ a[i]) << " ";
    }




}
void another() {
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll p = (ll)s.size();






}
int main() {

    fast;
    solve();

}


Measured memory_bytes: 4388