akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

using ll = long long int;

ll arr[200010] = {};

ll k = 0, res = 0;

bool check() {
	for (int i = 0; i < k; i++) {
		if (arr[i] >= k) return true;
	}
	return false;
}

int main(void) {

	cin >> k;

	for (int i = 0; i < k; i++) {
		cin >> arr[i];
	}

	//k*k = 50*50 * 100000;
	for(ll l = 0; l <= k*k; l++)
	for (ll i = 0; i < k ; i++) {

		ll t = (arr[i]*k / (k+1))/k;
		res += t;
		arr[i] -= t*(k+1);

		if (t != 0) {

			for (ll j = 0; j < k; j++)
				arr[j] += (t);

			if (t > k) {
				res += (t - k)*k;

				for (ll j = 0; j < k; j++)
					arr[j] -= (t-k);
			}

		}

		/*
		for (int l = 0; l < k; l++) {
			cout << arr[l] << (l == k - 1 ? '\n' : ' ');
		}
		cout << res << endl;
		*/

	}

	while (check()) {
		res++;
		int tmp = 0;
		for (int i = 0; i < k; i++) {
			if (arr[tmp] < arr[i]) tmp = i;
		}
		for (int i = 0; i < k; i++) {
			arr[i]++;
		}
		arr[tmp] -= k+1;

	}
	/*
	for (int i = 0; i < k; i++) {
		cout << arr[i] << (i == k-1 ? '\n' : ' ');
	}*/
	
	cout << res << endl;


}


//
//int main(void) {
//
//	ll k = 0;
//
//	cin >> k;
//
//	for (int i = 0; i < 50; i++) {
//		arr[i] += 49;
//		arr[i] += k / 50;
//	}
//
//	for (ll i = 0; i < k%50; i++) {
//		arr[i%50] += 51;
//
//		for (ll j = 0; j < 50; j++) {
//			arr[j] -= 1;
//		}
//	}
//
//	cout << 50 << endl;
//
//	for (int i = 0; i < 50; i++) {
//		cout << arr[i] << (i == 49?'\n' : ' ');
//	}
//
//
//}


Measured memory_bytes: 256
#include<stdio.h>
#include<map>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<utility>
#include<string.h>
#include<string>
#define n 200000
#define loop(i, a, b) for(int i=a; i<=b; i++)
using namespace std;
typedef pair<int, int> P;
typedef long long lli;
typedef double llf;
bool visit[n + 50];
int arr[n + 50], arr2[n + 50], a, b, c, d, e, f;
string str1, str2;
struct edge{
	int from, to, weight;
	bool operator < (const edge& thing) const
	{
		return thing.weight < weight;
	}
};
vector<edge> V[n + 50];
void addedge(int a, int b, int c)
{
	edge temp;
	temp.from = a;
	temp.to = b;
	temp.weight = c;
}

////////////////////////////////////////

void solve()
{
	cin >> a;
	loop(i, 1, a - 1) cin >> arr[i];
	int sum = 0;
	loop(i, 0, a - 1)
	{
		if(i == a - 1) arr2[i] = arr[a - 1];
		else if(i == 0) arr2[i] = arr[1];
		else       arr2[i] = min(arr[i], arr[i + 1]);
		sum += arr2[i];
//		cout << sum << '\n';
	}
	cout << sum;
}
int main()
{
	int times = 1;
//	cin >> times;
	loop(i, 0, times - 1)
	{
		solve();
		printf("\n");
	}
	return 0;
}



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

const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void solve(long long N, vector<long long> d) {
  sort(d.begin(), d.end());
  int sum = 0;
  int prev = -1;
  for (auto x : d) {
    if (x != prev) sum += 1;
    prev = x;
  }
  cout << sum << '\n';
}

int main() {
  // cout << fixed << setprecision(5);

  long long N;
  scanf("%lld", &N);
  vector<long long> d(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &d[i]);
  }
  solve(N, move(d));
  return 0;
}


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

int main(){
  ll a, b;
  cin >> a >> b;
  ll ans = 0;
  ans = (a+b)/2;
  if((a+b)%2){
    puts("IMPOSSIBLE");
  }else
    cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#pragma GCC optimize ("O3")

inline static int gl(void){
    int x = 0;
    for(;;){
        unsigned int c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}

inline static void pl(unsigned int s){
    char str[9];
    int pos=9;
    if(s==0){
        putchar_unlocked('0');
        return;
    }
    do{
        pos--;
        str[pos]=s%10+48;
        s/=10;
    }while(s!=0);
    for(; pos<9; pos++){
        putchar_unlocked(str[pos]);
    }
}


int main(void){
    static unsigned short out[1000000];
    char a[501];
    const int h=gl(), w=gl();
    int pos=0;
    char haveCoin = 0;
    short old_y, old_x;
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            int t = getchar_unlocked() - 48;
            getchar_unlocked();
            a[j] = t;
        }
        if(i%2==1){
            for(int j=1; j<=w; j++){
                if(haveCoin){
                    out[4*pos+0]=old_y;
                    out[4*pos+1]=old_x;
                    out[4*pos+2]=i;
                    out[4*pos+3]=j;
                    pos++;
                }
                haveCoin ^= a[j]&1;
                old_y = i;
                old_x = j;
            }
        }else{
            for(int j=w; j>0; j--){
                if(haveCoin){
                    out[4*pos+0]=old_y;
                    out[4*pos+1]=old_x;
                    out[4*pos+2]=i;
                    out[4*pos+3]=j;
                    pos++;
                }
                haveCoin ^= a[j]&1;
                old_y = i;
                old_x = j;
            }
        }
    }
    pl(pos); putchar_unlocked('\n');
    for(int i=0; i<pos; i++){
        pl(out[4*i+0]); putchar_unlocked(' ');
        pl(out[4*i+1]); putchar_unlocked(' ');
        pl(out[4*i+2]); putchar_unlocked(' ');
        pl(out[4*i+3]); putchar_unlocked('\n');
    }
    return 0;
}


Measured memory_bytes: 2944
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
         
        int n = sc.nextInt();
        int m = sc.nextInt();
         
        int[] a = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
         
        for(int k = 1; k <= m; k++) {
            for(int i = 0; i < n - 1; i++) {
                if(a[i] % k > a[i + 1] % k) {
                    int tmp = a[i];
                    a[i] = a[i + 1];
                    a[i + 1] = tmp;
                }
            }
        }
         
        for(int i = 0; i < n; i++) {
            System.out.println(a[i]);
        }
    }
}


Measured memory_bytes: 26452
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

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


# ===CODE===


def main():
    s = input()
    k = ni()

    substring = set()
    for i in range(97, 97 + 26):
        word = chr(i)

        for j in range(len(s)):
            if s[j] == word:
                tmp = s[j:j + k]

                while len(tmp) > 0:
                    substring.add(tmp)
                    tmp = tmp[:-1]

        if len(substring) >= k:
            break

    ans = list(substring)
    ans.sort()

    print(ans[k - 1])


if __name__ == '__main__':
    main()


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

using namespace std;

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


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

 int l=0;
 int r=s.size()-1;
  
  int res=0;
  while(l<r){
   if(s[l]==s[r]) {
     l++;
     r--;
   }
    else if(s[l]=='x'){
     l++;
     res++; 
    } 
    else if(s[r]=='x'){
     r--;
     res++;
    }
    else {
     res=-1;
      break;
    }
  
  }
  
   cout << res << endl;
}

Measured memory_bytes: 512
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

_, _, x, y = rl()
maxx = max(rm())
miny = min(rm())
if maxx < miny and x<miny and maxx<y:
  print('No War')
else:
  print('War')







Measured memory_bytes: 27108
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		long money[] = new long[4001];
		boolean flag[] = new boolean[4001];
		int order[] = new int[4001];
		
		final long threshold = 1000000;
		Scanner scanner = new Scanner(System.in);
		
		int n;
		
		n = scanner.nextInt();
		while (n != 0) {
			for(int i = 0; i < 4001; i++) {
				money[i] = 0;
				order[i] = 0;
				flag[i] = false;
			}
			int ord = 0;
			
			for(int i = 0; i < n; i++) {
				int id = scanner.nextInt();
				long cost = scanner.nextLong();
				long num = scanner.nextLong();
				
				money[id] += cost * num;
				
				if (flag[id] == false) {
					order[ord] = id;
					ord++;
					flag[id] = true;
				}
			} 
			
			boolean noOneFlag = true;
			
			for(int i = 0; i < 4001; i++) {
				if (money[order[i]] >= threshold) {
					System.out.println(order[i]);
					noOneFlag = false;
				}
			}
			
			if (noOneFlag == true) {
				System.out.println("NA");
			}
			n = scanner.nextInt();
		}
	}
}

Measured memory_bytes: 35272
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int N; cin >> N; 
	int B[2010], W[2010]; 
	for(int i = 1; i <= N*2; i++){
		char c; int a; 
		cin >> c >> a; 
		if(c == 'W') W[a] = i; 
		else B[a] = i; 
	}
	int BB[2010] = {}; // Biより前にあるB(i+1),...,B(N)の個数
	int WW[2010] = {}; // Wiより前にあるW(i+1),...,W(N)の個数
	int BW[2010][2010] = {}; // Biより前にあるW(j+1),...,W(N)の個数
	int WB[2010][2010] = {}; // Wiより前にあるB(j+1),...,B(N)の個数
	for(int i = 1; i <= N; i++){
		for(int j = i+1; j <= N; j++){
			if(B[i] > B[j]) BB[i] ++; 
			if(W[i] > W[j]) WW[i] ++; 
		}
	}
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= N; j++){
			if(B[i] > W[j]) BW[i][j-1] ++; 
			if(W[i] > B[j]) WB[i][j-1] ++; 
		}
	}
	for(int i = 1; i <= N; i++){
		for(int j = N-1; j >= 0; j--){
			BW[i][j] += BW[i][j+1]; 
			WB[i][j] += WB[i][j+1]; 
		}
	}
	int dp[2010][2010] = {}; 
	for(int i = 0; i <= N; i++){
		for(int j = 0; j <= N; j++){
			if(i + j == 0) continue; 
			int mn = 1145141919; 
			if(i){
				int tmp = dp[i-1][j];
				tmp += BB[i] + BW[i][j]; 
				mn = min(mn, tmp); 
			}
			if(j){
				int tmp = dp[i][j-1];
				tmp += WW[j] + WB[j][i]; 
				mn = min(mn, tmp); 
			}
			dp[i][j] = mn; 
		}
	}
	cout << dp[N][N] << "\n"; 
}

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

int main()
{
    int n;
    cin >> n;
    std::vector<int> a;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    
    std::vector<int>::iterator itr = a.begin();
    int cnt = 0;
    for(int i=1; i<=n; i++){
        itr = std::find(itr, a.end(), i);
        if(itr == a.end()){
            if(cnt == 0) cnt = -1;
            break;
        }
        size_t index = std::distance(a.begin(), itr);
        //cout << index << ",";

        cnt++;
    }
    //cout << endl;
    if(cnt == -1){
        cout << cnt << endl;
    }else{
        cout << n-cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 1400
import java.util.Scanner;

class Main {
    static final int INF = Integer.MAX_VALUE;

    static Scanner sc;
    static int[] input;
    static int n;
    static int count = 0;

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

        n = sc.nextInt();
        input = new int[n];
        for(int i = 0; i < n; i++) {
            input[i] = sc.nextInt();
        }
        MergeSort(0, n);

        for(int i = 0; i < n-1; i++)
            System.out.print(input[i] + (i == n-1 ? "\n" : " "));
        System.out.println(input[n-1]);
        System.out.println(count);
    }

    static void MergeSort(int left, int right) {
        if(left+1 < right) {
            int mid = (left + right) / 2;
            MergeSort(left, mid);
            MergeSort(mid, right);
            Merge(left, mid, right);
        }
    }

    static void Merge(int left, int mid, int right) {
        int n1 = mid - left;
        int n2 = right - mid;
        int[] L = new int[n1+1];
        int[] R = new int[n2+1];

        for(int i = 0; i < n1; i++)
            L[i] = input[left + i];
        for(int i = 0; i < n2; i++)
            R[i] = input[mid + i];

        L[n1] = R[n2] = INF;

        int i = 0; int j = 0;
        for (int k = left; k < right; k++) {
            count++;
            if(L[i] <= R[j]) {
                input[k] = L[i];
                i++;
            } else {
                input[k] = R[j];
                j++;
            }
        }
    }

    static void printArray() {
    }
}



Measured memory_bytes: 173916
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
 int n,x,y,z,w,i,a,c;
 while(cin >> n) {
	 if (n==0) break;
 c=0;
 for (;n>0;n--) {
 cin >> x >> y >> z >> w;
	 x=x+y+z;
	 for (i=0;i<6;i++) {
		 a=i==0 ? 2 : i*5;
		 if (w<=a && x<=60+i*20) { c+=600+i*200; break; }
	 }
 }
	 cout << c << endl;
 }
 return 0;
 }

Measured memory_bytes: 1160
/**
*    author:  souzai32
*    created: 02.08.2020 20:56:21
**/

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

int main() {

    int x;
    cin >> x;
    if(x>=30) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
using namespace std;
int main(){
  unsigned long long N,cur;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin >> A.at(i);
  cur=1000;
  for(int i=1;i<N;i++){
    if(A.at(i)>A.at(i-1)){
    	cur=cur+(cur/A.at(i-1))*(A.at(i)-A.at(i-1));
    }
  }
  cout << cur << endl;
}

Measured memory_bytes: 3616
/*There's a possibility*/
#define dbg(...) ; 
#define db(...) ; 
#include "bits/stdc++.h"
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(i=a;i<b;i++)
#define fr(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define tst cout<<'*';
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mod 1000000007
using namespace std;

ll n, ar[3005], dp[3005][3005];

ll fun(int l, int r)
{
    if(l==r)
        return ar[l];
    if(dp[l][r]!=-1)
        return dp[l][r];
    return dp[l][r]=max(ar[l]-fun(l+1,r),ar[r]-fun(l,r-1));
}

int main()
{
    fast;
    int i;
    cin>>n;
    f(i,0,n)
        cin>>ar[i];
    memset(dp,-1,sizeof(dp));
    cout<<fun(0,n-1);
}

Measured memory_bytes: 74408
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  st N;
  ci(N);
  if(N.at(0) == N.at(1) && N.at(1) == N.at(2)){
    co("Yes");
  }
  else if(N.at(1) == N.at(2) && N.at(2) == N.at(3)){
    co("Yes");
  }
  else{
    co("No");
  }
}


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

#define fo(i,n)   for(i=0;i<n;i++)
#define mod       1000000007
using namespace std;

int main()
{


	int n, m, c;
	cin >> n >> m >> c;

	int a[m];
	for (int i = 0; i < m; i++)
		cin >> a[i];
	int b[n][m];

	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> b[i][j];

	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		int sum = 0;
		for (int j = 0; j < m; j++)
		{
			sum += b[i][j] * a[j];
		}
		sum += c;
		if (sum > 0)
			cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int s=0;
		ArrayList<String> list=new ArrayList<String>();
		while(s!=-3) {
			//値の入力
			StringTokenizer st=new StringTokenizer(br.readLine());
			int m=Integer.parseInt(st.nextToken());
			int f=Integer.parseInt(st.nextToken());
			int r=Integer.parseInt(st.nextToken());
			s=m+f+r;
			int mf=m+f;

			if(s==-3) {
				break;
			}

			//式の評価
			String eva="";
			if(m==-1 || f==-1) {
				eva="F";
			}else if(mf>=80) {
				eva="A";
			}else if(65<=mf && mf<80) {
				eva="B";
			}else if(50<=mf && mf<65 || r>=50) {
				eva="C";
			}else if(30<=mf && mf<50) {
				eva="D";
			}else {
				eva="F";
			}

			//配列への追加
			list.add(eva);
		}
		//評価の出力
		for(String lists:list) {
			System.out.println(lists);
		}
	}

}



Measured memory_bytes: 24156
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0

A,B=[0],[0]
for i in range(n):
  A.append(a[i]+A[i])
for i in range(m):
  B.append(b[i]+B[i])

for j in range(n+1):
  K=k-A[j]
  if K<0:
    break
  left=0
  right=m+1
  while left<right:
    mid=(left+right)//2
    if B[mid]>K:
      right=mid
    else:
      left=mid+1
  ans=max(ans,j+left-1)
print(ans)


Measured memory_bytes: 132092
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Int32.Parse(Console.ReadLine()); 
            string s = Console.ReadLine();
            int blue = s.Replace("R", "").Length;

            if(n - blue > blue)
            {
                Console.WriteLine("Yes");
                return;
            }
            Console.WriteLine("No");
        }      
    }
}


Measured memory_bytes: 13140
N, M = map(int, input().split())

num = {}
for i in range(M):
    P_i, Y_i = map(int, input().split())
    if P_i in num:
        num[P_i].append((Y_i, i))
    else:
        num[P_i] = [(Y_i, i)]

display = [0] * M
for i in num:
    k = str(0) * (6 - len(str(i))) + str(i)
    for index, j in enumerate(sorted(num[i], key=lambda x: x[0])):
        l = str(0) * (6 - len(str(index + 1))) + str(index + 1)
        display[j[1]] = k + l

for item in display:
    print(item)

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

int main() {
  int num;
  long long time;
  long long cnt = 0;
  long long lTime = 0;
  long long tmp;
  long long sTime = 0;
  bool chk = true;
  
  cin >> num >> time >> tmp;
  
  for(int i = 1; i < num; i++){
    cin >> tmp;
    if(tmp - lTime <= time){
      // 継続
      lTime = tmp;
      chk = true;
    }else{
      cnt += (lTime - sTime) + time;
      chk = false;

      sTime = tmp;
      lTime = tmp;
    }
  }
  
  // last
  if(chk == true){
    // 継続の状態で終了
    cnt += (lTime - sTime) + time;
  }else{
    // 新規
    cnt += time;
  }
  
  cout << cnt;
}


Measured memory_bytes: 256
#include <cstdio>

/*
g(L, R) := \prod_{i=L}^{R} (1 + q^{A_i})
f(L, R) = [q^S] g(L, R)
\sum_{1<=L<=R<=N} f(L, R)
p[i] := \sum_{1<=L<=i} g(L, i)
p[i] = (p[i-1] + 1) * (1 + q^{A_i})
*/

constexpr unsigned mod = 998244353;

int n, s;
unsigned long long dp[3001];

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

  int ans = 0;
  for(int i = 0; i < n; i++){
    int a;
    scanf("%d", &a);
    dp[s]++;
    for(int j = 0; j <= s-a; j++){
      dp[j] += dp[j + a];
    }
    if(i % 31 == 30){
      for(int j = 0; j <= s; j++)
        dp[j] %= mod;
    }
    ans = (ans + dp[0]) % mod;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	h, _ := strconv.Atoi(input())
	w, _ := strconv.Atoi(input())
	a, _ := strconv.Atoi(input())
	b, _ := strconv.Atoi(input())

	s1 := strings.Repeat("0", a) + strings.Repeat("1", w-a)
	s2 := strings.Repeat("1", a) + strings.Repeat("0", w-a)
	for i := 0; i < b; i++ {
		fmt.Println(s1)
	}
	for i := 0; i < h-b; i++ {
		fmt.Println(s2)
	}
}


Measured memory_bytes: 1664
# C - Train Ticket 桁ごとにリスト格納
A = str(input())
l = [int(x) for x in list(str(A))]
if l[0]+l[1]+l[2]+l[3] == 7 :
    print('{0}+{1}+{2}+{3}=7'.format(l[0],l[1],l[2],l[3]))
elif l[0]-l[1]+l[2]+l[3] == 7 :
    print('{0}-{1}+{2}+{3}=7'.format(l[0], l[1], l[2], l[3]))
elif l[0]+l[1]-l[2]+l[3] == 7 :
    print('{0}+{1}-{2}+{3}=7'.format(l[0], l[1], l[2], l[3]))
elif l[0]+l[1]+l[2]-l[3] == 7:
    print('{0}+{1}+{2}-{3}=7'.format(l[0], l[1], l[2], l[3]))
elif l[0]-l[1]-l[2]+l[3] == 7:
    print('{0}-{1}-{2}+{3}=7'.format(l[0], l[1], l[2], l[3]))
elif l[0]+l[1]-l[2]-l[3] == 7:
    print('{0}+{1}-{2}-{3}=7'.format(l[0], l[1], l[2], l[3]))
elif l[0]-l[1]+l[2]-l[3] == 7:
    print('{0}-{1}+{2}-{3}=7'.format(l[0], l[1], l[2], l[3]))
elif l[0]-l[1]-l[2]-l[3] == 7:
    print('{0}-{1}-{2}-{3}=7'.format(l[0], l[1], l[2], l[3]))
    

Measured memory_bytes: 3064
n = int(input())
A = input().split()

if n == 1:
    print(A[0])
    exit()

elif n % 2 == 0:
    l1 = [A[n - 2 * i - 1] for i in range(n//2)]
    l2 = [A[2 * j] for j in range(n//2)]

else:
    l1 = [A[n - 2 * i - 1] for i in range(n//2 + 1)]
    l2 = [A[2 * j + 1] for j in range(n//2)]

print(" ".join(l1), " ".join(l2))


Measured memory_bytes: 25232
import java.util.*

fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val row = readLine()!!.split(" ").map { it.toInt() }.toList()
  
  var num = 0
  val list = mutableListOf<Int>()

  row.reduce {a,b ->
    if(a >= b) {
      num++
    } else {
      list.add(num)
      num = 0
    }
    b
  }
  list.add(num)
  println(list.max())   
}


Measured memory_bytes: 59520
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define SIZE 100
#define INF  1e9

typedef struct tQueue_
{
    int queue[SIZE];
    int head;
    int tail;
}tQueue;

typedef struct tNode_
{
    int u;
    int k;
    int v[SIZE];
}tNode;

bool IsFull(tQueue *q){
    return (q->head == (q->tail + 1) % SIZE);
}

bool IsEmpty(tQueue *q){
    return (q->head == q->tail);
}

void Enqueue(tQueue *q, int value){
    if(IsFull(q)){
        return;
    }
    else{
        q->queue[q->tail] = value;
        q->tail = (q->tail + 1) % SIZE;
    }
}

int Dequeue(tQueue *q){
    if(IsEmpty(q)){
        return 0;
    }
    else{
        short data = q->queue[q->head];
        q->head = (q->head + 1) % SIZE;
        return data;
    }
}

void BFS(tQueue *q, tNode data[], int path[]){
    int node = Dequeue(q) - 1;

    for(int i = 0; i < data[node].k; i++){
        int nextNode = data[node].v[i] - 1;
        if(path[nextNode] < path[node] + 1){ continue; }
        path[nextNode] = path[node] + 1;
        Enqueue(q, nextNode + 1);
        BFS(q, data, path);
    }
}

int main(){
    tQueue q = {{0}, 0, 0};
    tNode data[SIZE];
    int n, path[SIZE];

    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d %d", &data[i].u, &data[i].k);
        for(int j = 0; j < data[i].k; j++){
            scanf("%d", &data[i].v[j]);
        }
        path[i] = INF;
    }

    path[0] = 0;
    Enqueue(&q, 1);
    BFS(&q, data, path);

    for(int i = 0; i < n; i++){
        if(path[i] == INF){ path[i] = -1; }
        printf("%d %d\n", i + 1, path[i]);
    }

    return 0;
}


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

int main() {
    int n, x, ans[2000100] = {-1}, a = 2000000, b = 2000001;
    string command;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> command;
        if (command == "insert") {
            cin >> x;
            ans[a] = x;
            --a;
        }
        else if (command == "delete") {
            cin >> x;
            int pnt = -1;
            for (int j = 0; j < b; ++j) {
                if (ans[j] == x) {
                    pnt = j;
                    break;
                }
            }
            if (pnt >= 0) {
                ans[pnt] = -1;
                if (pnt == b - 1) --b;
                if (pnt == a + 1) ++a;
            }
        }
        else if (command == "deleteFirst") {
            ans[a + 1] = -1;
            ++a;
        }
        else if (command == "deleteLast") {
            ans[b - 1] = -1;
            --b;
        }
    }
    for (int i = a + 1; i < b; ++i) {
        if (ans[i] != -1) {
            if (i > a + 1) cout << ' ';
            cout << ans[i];
        }
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 11012
import java.awt.TexturePaint;
import java.awt.event.ComponentAdapter;
import java.io.BufferedReader;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double first = Double.parseDouble(sc.next()); 
		double second = Double.parseDouble(sc.next());
		double third = Double.parseDouble(sc.next()); 
		double force = Double.parseDouble(sc.next());
		System.out.print(String.format("%.6f", (first*second/2)));
		System.out.print(" ");
		int flg = 0;
		if(third==(first/2) && force==(second/2)) {
			flg = 1;
		}
		System.out.println(flg);
	}
}

Measured memory_bytes: 21716
from collections import deque

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

p_table = {"r": P, "s": R, "p": S}
h_table = {"r": "p", "s": "r", "p": "s"}
hist = deque(maxlen=K)
point = 0
for i, t in enumerate(T, 1):
    if i <= K or h_table[t] != hist[0]:
        point += p_table[t]
        hist.append(h_table[t])
    else:
        hist.append("_")
    #print(hist, t, h_table[t], point, i)

print(point)


Measured memory_bytes: 4084
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL
int main() {
	ll		h,i,j,k,l,m,n,x,y,z;
	ll		ans = 0;
	string	s;
	cin >> x >> y >> z >> k;
	vector<ll>	a(x), b(y), c(z), ab(x*y), abc(k*z);

	for(i=0;i<x;i++) cin >> a[i];
	for(i=0;i<y;i++) cin >> b[i];
	for(i=0;i<z;i++) cin >> c[i];

	m = 0;
	for(i=0;i<x;i++) {
		for(j=0;j<y;j++) {
			ab[m++] = a[i]+b[j];
		}
	}
	sort(ab.begin(),ab.end());
	reverse(ab.begin(),ab.end());
	m = 0;
	for(i=0;i<min(k,x*y);i++) {
		for(j=0;j<z;j++) {
			abc[m++] = ab[i]+c[j];
		}
	}
	sort(abc.begin(),abc.end());
	reverse(abc.begin(),abc.end());
	for(i=0;i<k;i++) cout << abc[i] << endl;

}


Measured memory_bytes: 34648
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;
const ll mod=1e9+7;

int main(){
    ll k;
    cin >> k;
    if(k%2==0 || k%5==0){
        cout << -1 << endl;
        return 0;
    }
    ll v=0;
    ll cnt=0;
    while(true){
        cnt++;
        v=v*10+7;
        v%=k;
        if(v==0) break;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <math.h>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <utility> //pair
#include <algorithm> //sort
using namespace std;


int main(){
    int n, p[30], cnt = 0;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> p[i];
    for (int i = 0; i < n-2; i++)
    {
        if ((p[i] < p[i+1] and p[i+1] < p[i+2]) or (p[i] > p[i+1] and p[i+1] > p[i+2]))
        {
            cnt ++;
        }
        
    }
    cout << cnt << endl;
    
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？


n,m=mii()
arr=limii()

sumvote=sum(arr)
cnt=0
for i in range(n):
    if arr[i] >= sumvote/(4*m):
        cnt+=1
if cnt>=m:
    print("Yes")
else:
    print("No")





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

int main(){

  long long A, B; cin >> A >> B;
  int K; cin >> K;

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

    if(A % 2 == 1) --A;
    A /= 2;
    B += A;
    ++i; if(i >= K) break;

    if(B % 2 == 1) --B;
    B /= 2;
    A += B;

  }

  cout << A << "\t" << B << endl;
    

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    rep(i, n) {
        if (s[i] == ',') s[i] = ' ';
    }
    cout << s << endl;
    return 0;
}

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

int main()
{
	int n,m;
	cin>>n>>m;
	int a = 0;
	for(size_t i = 0; i<m; i++)
	{
		int aa;
		cin>>aa;
		a += aa;
	}
	if(n<a)
	{
		cout<<"-1"<<endl;
	}
	else
	{
		cout<<n-a<<endl;
	}

	return 0;
}

Measured memory_bytes: 3644
/*
    हॉंजी । की हाल चाल?
    बड़ीया सब?
*/

#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             unordered_map<int,int>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define MOD             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define EPS             1e-9

void gogeta()
{
    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
}

int MAXN = 1000001;

vector<int> spf(MAXN);

void sieve()
{
    spf[1] = 1;
    for (int i = 2; i < MAXN; i++)

        // marking smallest prime factor for every
        // number to be itself.
        spf[i] = i;

    // separately marking spf for every even
    // number as 2
    for (int i = 4; i < MAXN; i += 2)
        spf[i] = 2;

    for (int i = 3; i * i < MAXN; i++)
    {
        // checking if i is prime
        if (spf[i] == i)
        {
            // marking SPF for all numbers divisible by i
            for (int j = i * i; j < MAXN; j += i)

                // marking spf[j] if it is not
                // previously marked
                if (spf[j] == j)
                    spf[j] = i;
        }
    }
}

int getFactorization(int x)
{
    mii ret;
    while (x != 1)
    {
        ret[(spf[x])]++;
        x = x / spf[x];
    }
    int ans = 1;
    for (auto x : ret) {
        ans *= (x.ss + 1);
    }
    return ans;
}

int32_t main()
{
    gogeta();
    int n; cin >> n;
    sieve();
    int ans = 0;
    for (int i = 1; i < n; i++) {
        ans += getFactorization(i);
        // cout << fac[i] << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 10984
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    string s;
    ll k;
    cin >> s >> k;
    for(int i = 0; i < s.size(); i++){
        if (i == k-1){
            cout << s[i] << endl;
            return 0;
        }
        if (s[i] != '1'){
            cout << s[i] << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3600
S = input()
if S[2:-1].count('C') == 1 and S[0] == 'A':
    idx = S.index('C')
    s = S[1:idx] + S[idx+1:]
    if s.lower() == s:
        print('AC')
    else:
        print('WA')
else:
    print('WA')

Measured memory_bytes: 3060
function main(input){
  input = input.split('\n');
  const [N, K] = input[0].split(' ').map(Number);
  const A = [];
  for(let i=0; i<K; i++){
    const a = input[i*2+2].split(' ').map(Number);
    A.push(...a);
  }
  const set = new Set(A);
  console.log(N - set.size);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim());


Measured memory_bytes: 30448
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a,b) printf(a,b);
#define c(s) cout<< (s) << endl;
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define cyn(c) cout<<(c?"Yes":"No")<<endl;
#define cYN(c) cout<<(c?"YES":"NO")<<endl;
#define pyn(c) printf("%s\n",c?"Yes":"No");
#define pYN(c) printf("%s\n",c?"YES":"NO");
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    string s1,s2,s3; cin>>s1>>s2>>s3;
    s1.push_back('0');
    s2.push_back('0');
    s3.push_back('0');
    reverse(s1.begin(),s1.end());
    reverse(s2.begin(),s2.end());
    reverse(s3.begin(),s3.end());
    char c=s1.back();
    s1.pop_back();
    while(!s1.empty()&&!s2.empty()&&!s3.empty()){
        if(c=='a'){
            c=s1.back();
            s1.pop_back();
        }else if(c=='b'){
            c=s2.back();
            s2.pop_back();
        }else{
            c=s3.back();
            s3.pop_back();
        }
    }
    if(s1.empty()){
        c("A");
    }else if(s2.empty()){
        c("B");
    }else{
        c("C")
    }
}


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

int main() {
  string s;
  cin >> s;
  
  if(s.size()==2){
    cout << s << endl;
  }
  
  else{
    cout << s.at(2) << s.at(1) << s.at(0) << endl;
  }
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')
import math


def main():
	
	k=II()
	
	ans=0
	
	li=[[0]*(k+1) for i in range(k+1)]
	
	for a in range(1,k+1):
		for b in range(1,k+1):
			for c in range(1,k+1):
				d=math.gcd(a,b)
				ans+=math.gcd(d,c)
				
	
	print(ans)





	
if __name__ == "__main__":
	main()


Measured memory_bytes: 70596
#include<iostream>
using namespace std;
int main()
{
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int temp=i,sum=0;
		while(temp>0)
		{
			sum++;
			temp/=10;
		}
		if(sum%2==1)
		{
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
N,M,K=list(map(int,input().split()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
AA=[0]*(N+1)
BB=[0]*(M+1)
A3=0
B3=0
high=0
for i in range(0,N):
    A3+=A[i]
    AA[i+1]=A3
for j in range(0,M):
    B3+=B[j]
    BB[j+1]=B3
for i in range(0,N+1):
    if AA[i]>K:
        break
    while True:
        if BB==[]:
            break
        elif BB==[0]:
            BB=[]
            break
        elif AA[i]+BB[-1]>K:
            BB.pop(-1)
        else:
            break
    if BB!=[]:
        time=AA[i]+BB[-1]
        judge=1
    else:
        time=AA[i]
        judge=0
    if time<=K:
        if judge==0:
            if high<i:
                high=i
        else:
            if high<i+len(BB)-1:
                high=i+len(BB)-1
print(high)

Measured memory_bytes: 46900
use proconio::input;

fn main() {
    input! {
        n: f64,
        m: f64,
        d: f64,
    }

    let ans = if d == 0.0 {
        (m - 1.0) / n
    } else {
        (m - 1.0) * 2.0 * (n - d) / n / n
    };

    println!("{}", ans);
}


Measured memory_bytes: 2204
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<int> length(n);
    for(int i=0; i<n; i++){
        cin >>length.at(i);
    }
    sort(length.begin(),length.end());
    int c=0;
    for(int i=0;i<n-1;i++){
        c+=length.at(i);
    }
    if(c>length.at(n-1)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

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

bool isPrime(int x)
{
  for (int i = 2; i*i <= x; ++i) if (x % i == 0) return false;
  return true;
}

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

  int x;
  cin >> x;

  while (!isPrime(x)) ++x;

  cout << x << '\n';

  return (0);
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,n)  for(ll i=0;i<n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef pair<int,int> pii;
int main()
{
	IOS;
	//int t; cin>>t;
	int t=1;
	while(t)
	{
		int n; cin>>n;
		ll a[n]; f(i,n) cin>>a[i];
		ll ans=0;
		f(i,n)
		{
			ans=(ans^a[i]);
		}
		f(i,n)
		{
			ans=(ans^a[i]);
			cout<<ans<<" ";
			ans=(ans^a[i]);
		}
		t--;
	}
	return 0;
}

Measured memory_bytes: 5228
#include <cstdio>
#include <climits>
#include <cstring>

using namespace std;

int m[11][11];
int n;
int dist[11][11];


void flood()
{
	int i, j, k;
	
	memcpy(dist, m, sizeof(m));
	for (k=0; k<n; k++) {
		for (i=0; i<n; i++) {
			if (i==k || dist[i][k]==INT_MAX) continue;
			for (j=i+1; j<n; j++) {
				if (j==k || dist[k][j]==INT_MAX) continue;
				if (dist[i][j] > dist[i][k]+dist[k][j]) {
					dist[i][j] = dist[j][i] = dist[i][k]+dist[k][j];
				}
			}
		}
	}

}

int main()
{
	//freopen("in.txt", "r", stdin);

	int road;
	while (scanf("%d", &road)==1) {
		if (road==0) break;
		int i, j;
		n = 0;
		for (i=0; i<=10; i++) {
			m[i][i] = 0;
			for (j=i+1; j<=10; j++) {
				m[i][j] = m[j][i] = INT_MAX;
			}
		}

		for (i=0; i<road; i++) {
			int a, b, c;
			scanf("%d%d%d", &a, &b, &c);
			if (m[a][b] > c)
				m[a][b] = m[b][a] = c;
			if (n<a+1) n=a+1;
			if (n<b+1) n=b+1;
		}

		flood();

		int min, min_k;
		min = INT_MAX;
		for (i=0; i<n; i++) {
			int sum = 0;
			for (j=0; j<n; j++) {
				sum += dist[i][j];
			}
			if (sum<min) {
				min = sum;
				min_k = i;
			}
		}

		printf("%d %d\n", min_k, min);

	}

	return 0;
}

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

using namespace std;

int main(){
        int a, b;
        cin>>a>>b;
        if(a==b){
                cout<<"Draw"<<endl;
        }
        else if(a>b){
                if(b==1)
                        cout<<"Bob"<<endl;
                else
                        cout<<"Alice"<<endl;
        }
        else{
                if(a==1)
                        cout<<"Alice"<<endl;
                else
                        cout<<"Bob"<<endl;
        }
        return 0;
}


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

int main(){
    string S;
    cin>>S;
    int cnt=1;

    if(S[0]=='A'){
        for(int i=2;i<=S.size()-2;i++){
            if(S[i]=='C'){
                cnt--;
            }
        }
    }
    int cnt2=0;
    for(int i=0;i<S.size();i++){
        if(S[i]>='A'&&S[i]<='Z'){
            cnt2++;
        }
    }
    if(cnt||!(cnt2==2)){
        cout<<"WA"<<endl;
    }else cout<<"AC"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定
#include <list> //前後に数値を入れれる配列



#define REP(i,m,n) for(int i = (int) (m);i < (int) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = 3.141592653589793; //円周率

//常設関数↓

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//degree → radian
ll chg_DegRad(int deg) {
	return deg * PI / 180.0;
}

//radian → degree
ll chg_RadDeg(int rad) {
	return rad * 180.0 / PI;
}

//提出コード↓

string s;
list<char> S;
ll Q, T, F;
char c;
bool J = true;




int main() {
	cin >> s;
	cin >> Q;
	rep(i, s.size()) {
		S.push_back(s[i]);
	}
	rep(i, Q) {
		cin >> T;
		if (T == 1) {
			if (J) J = false;
			else J = true;
		}
		else {
			cin >> F;
			cin >> c;
			if (J) {
				if (F == 1) {
					S.push_front(c);
				}
				else {
					S.push_back(c);
				}
			}
			else {
				if (F == 2) {
					S.push_front(c);
				}
				else {
					S.push_back(c);
				}
			}
		}
	}
	if (!J) reverse(S.begin(), S.end());
	for (auto itr = S.begin(); itr != S.end();itr++){
		cout << *itr;
		}
	cout << endl;

	return 0;
}



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

using namespace std;

const int maxn = 100 + 6;

int a[maxn];

int main() {

	int n;
	cin >> n;
	bool flag = 1;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		if (!(a[i] % 2)) {
			if (a[i] % 3 != 0 and a[i] % 5 != 0) {
				flag = 0;
				break;
			}
		}
	}

	if (!flag) {
		cout << "DENIED\n";
	} else {
		cout << "APPROVED\n";
	}

	return 0;
}

Measured memory_bytes: 256
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0008
  */
object Main {
  def main(args: Array[String]): Unit = {
    Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).map(_.toInt)
      .map {
        case n if n > 9 * 4 => 0
        case n => {
          val ub = math.min(9, n)
          (for (a <- 0 to ub; b <- 0 to ub; c <- 0 to ub; d <- 0 to ub if a + b + c + d == n) yield 0)
            .length
        }
      }
      .foreach(println)
  }
}

Measured memory_bytes: 61480
#include <stdio.h>
int mx(int a, int b) {return (a<b)?b:a;}
int bin_search_modified(int val, int right) {int ans=1,left=1;while (left<=right) {int center=(left+right)>>1,fuego=center*center*center;if (fuego<=val) ans=mx(ans,center),left=center+1; else right=center-1;} return ans;}
int main() {int X,Y,Z,z,max;while (1) {scanf("%d",&Z);if (!Z) return 0;z=Z*Z*Z;max=0;X=bin_search_modified(z/2,Z-1);for (;X>0;X--) {Y=z-X*X*X;Y=bin_search_modified(Y,Z-1);max=mx(max,Y*Y*Y+X*X*X);} printf("%d\n",z-max);}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int sume[300010]={0},sumw[300010]={0};
int n;
int main(){
	string s;
	cin>>n>>s;
	int i,k=s.length(),ans=3000010;
	for(i=0;i<k;i++){
		sumw[i+1]=sumw[i];
		sume[i+1]=sume[i];
		if(s[i]=='W')sumw[i+1]++;
		else sume[i+1]++;
	}
	for(i=1;i<=k;i++){
		ans=min(ans,sumw[i-1]+sume[k]-sume[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3076
N, K = map(int, input().split())
K = min(N-1, K)
fact = [1 for _ in range(200001)]
inv = [1 for _ in range(200001)]
fact_inv = [1 for _ in range(200001)]
mod = 10**9+7
for i in range(2, 200001):
    fact[i] = (fact[i-1]*i) % mod
    inv[i] = mod - (inv[mod % i] * (mod // i)) % mod
    fact_inv[i] = (fact_inv[i-1] * inv[i]) % mod

dp = [0] * N
for i in range(N):
    f1 = (fact[N] * fact_inv[N-i] * fact_inv[i]) % mod  
    f2 = (fact[N-1] * fact_inv[N-i-1] * fact_inv[i]) % mod 
    f = (f1*f2)%mod
    if i == 0:
        dp[i] = f
    else:
        dp[i] = (dp[i-1] + f) % mod
print(dp[K])

Measured memory_bytes: 40656
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  int n, m, s[5], c[5], ans[3];

  cin >> n >> m;

  for (int i = 0; i < n; i++) ans[i] = -1;

  for (int i = 0; i < m; i++)
  {
    cin >> s[i] >> c[i];
  }

  for (int i = 0; i < m; i++)
  {
    if (ans[s[i] - 1] != -1 && ans[s[i] - 1] != c[i])
    {
      cout << -1 << endl;
      return 0;
    }
    ans[s[i] - 1] = c[i];
  }

  if (ans[0] == 0 && n != 1)
  {
      cout << -1 << endl;
  }
  else
  {
    for (int i = 0; i < n; i++)
    {
      if (ans[i] == -1)
      {
        if (i == 0 && n != 1)
        {
          cout << 1;
        }
        else
        {
          cout << 0;
        }
      }
      else
      {
        cout << ans[i];
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
N, M = gets.chomp.split(" ").map(&:to_i)

ab = []
N.times do
  ab << gets.chomp.split(" ").map(&:to_i)
end

ab.sort_by!{|x| x[0]}


mrem = M
ans = 0

N.times do |i|
  a, b = ab[i]
  buy = [mrem, b].min
  ans += a * buy
  mrem -= buy
  if mrem == 0
    puts ans
    exit
  end
end

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

int main() {
    int N;  cin >> N;
    map<string, int> mp;
    for (int i = 0; i < N; ++i) {
        string s;  cin >> s;
        ++mp[s];
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}


Measured memory_bytes: 3628