akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)

const int MOD = 998244353;

ll dp[3030][3030];

int main(){
    ll a,b,c,d; cin >> a >> b >> c >> d;
    ll x = c-a, y = d-b;

    rep(i,x+1){
        rep(j,y+1) dp[i][j] = 0;
    }
    dp[0][0] = 1;
    for(int i=0;i<=x;i++){
        for(int j=0;j<=y;j++){
            if(j){
                dp[i][j] += (dp[i][j-1] * (a+i) );
                dp[i][j] %= MOD;
            }
            if(i){
                dp[i][j] += (dp[i-1][j] * (b+j) );
                dp[i][j] %= MOD;
            }
            if(i && j){
                dp[i][j] -= (dp[i-1][j-1] * (a+i-1) * (b+j-1) );
                dp[i][j] %= MOD;
                if(dp[i][j] < 0) dp[i][j] += MOD;
            }
        }
    }
    cout << dp[x][y] << endl;
}


Measured memory_bytes: 74600
n = int(input())
l = list(map(int,input().split()))
l.sort()
k = 0
j = 1
cnt = 0
for i in range(n):
    if i == n-1:
        print(cnt)
        for _ in range(n - j):
            print(0)
    elif j == l[i]:
        cnt += 1
    elif l[i] - j >= 1:
        print(cnt)
        cnt = 1
        a = l[i] - j
        for _ in range(a-1):
            print(0)
        j += l[i] -j

        

Measured memory_bytes: 32304
import math
#最大公約数
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
#因数分解
def factorize(x):
    f=[]
    div=2
    while div**2<=x:
        while x%div==0:
            f.append(div)
            x=x//div
        div+=1
    if x>1:
        f.append(x)
    return f

"""def factorize(x):
    ans=1#約数１
    div=2
    while div**2<=x:
        while x%div==0:
            x=x//div
            flag=1
        if flag==1:
            ans+=1
        div+=1
        flag=0
    if x>1:
        ans+=1
    return ans"""

a,b=map(int,input().split())
g=gcd(a,b)
f=factorize(g)
print(len(set(f))+1)


Measured memory_bytes: 3064
#include <stdio.h>

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

    return gcd(b, a%b);
}

int main()
{
    unsigned long long sum = 0;
    int n, i, j, k;
    scanf("%d", &n);

    for(i=1; i<=n; i++)
    {
        for(j=1; j<=n; j++)
        {
            for(k=1; k<=n; k++)
            {
                sum += gcd(i, gcd(j, k));
            }
        }
    }
    printf("%llu\n", sum);

    return 0;
}


Measured memory_bytes: 1732
package main

import "fmt"

func main() {
  var s string
  fmt.Scan(&s)
  cups := map[rune]int{
    '0': 0,
    '1': 0,
  }
  for _, v := range s {
    cups[v]++
  }
  var ans int
  if cups['0'] < cups['1'] {
    ans = cups['0'] * 2
  } else {
    ans = cups['1'] * 2
  }
  fmt.Println(ans)
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define maxn 110
using namespace std;
typedef long long LL;
int a[maxn];
int main() {
    int n;
    scanf("%d", &n);
    int sum=0;
    for (int i = 0; i < n; ++i) scanf("%d", &a[i]), sum += a[i];
    sort(a,a+n);
    if (sum % 10) printf("%d\n", sum);
    else {
        int i=0;
        for (; i < n; ++i) if (a[i] % 10) break;
        if (i == n) puts("0");
        else printf("%d\n", sum-a[i]);
    }
    return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split(' '))
D=list(map(str,input().split(' ')))
ans=N
while True:
  judge=True
  m=len(str(ans))
  for i in range(m):
    if str(ans)[i] in D:
      judge=False
      break
    else:
      continue
  if judge==False:
    ans+=1
    continue
  else:
    break
print(ans)

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

int main() {

  int N, K;
  cin >> N >> K;

  int X[N];

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

  int t[100];
  int a = 0;

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

    t[i] = (min ( X[i]-0, K-X[i] ))*2;

    a += t[i];

   }
    cout << a << endl;

return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int cnt[] = { -1,0,1,0,2,0,2,0,0,2,0,2,0 };
int x, y;

int main() {
	cin >> x >> y;
	if (cnt[x] == cnt[y])cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
s = input()
n = len(s)
ans = "Yes"
half = int((n -1) / 2)
half2 = int((n+2)/2)
a = s[:half]
a_2 = s[half+1:n]
a_2 = a_2[::-1]
if a != a_2:
    ans = "No"
else:
    if (len(a)%2) == 0:
        a_half = int(len(a)/2)
        a_3 = a[0:a_half]
        a_4 = a[a_half:len(a)]
        a_4 = a_4[::-1]
    else:
        a_half = int((len(a)+1)/2)
        a_3 = a[0:a_half]
        a_4 = a[a_half-1:len(a)]
        a_4 = a_4[::-1]
    if a_3 != a_4:
        ans = "No"
    else:
        b = s[half2:n]
        if (len(b)%2) == 0:
            b_half = int(len(b)/2)
            b_2 = b[0:b_half]
            b_3 = b[b_half:len(b)]
            b_3 = b_3[::-1]
        else:
            b_half = int((len(b)+1)/2)
            b_2 = b[0:b_half]
            b_3 = b[b_half-1:len(b)]
            b_3 = b_3[::-1]            
        if b_2 != b_3:
            ans = "No"
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long a[300005],num[300005],m,n=1,sum[300005],ans[300005];
bool check(long long k,long long x){
    long long pos=upper_bound(a+1,a+n,x)-a-1;
    return sum[pos]+(n-pos-1)*x>=k*x;
}
int main(){
    cin>>m;
    for(long long i=1;i<=m;i++){
        long long x;
        cin>>x;
        num[x]++;
    }
    for(long long i=1;i<=300000;i++){
        if(num[i]) a[n++]=num[i];
    }
    sort(a+1,a+n);
    for(long long i=1;i<n;i++){
        sum[i]=sum[i-1]+a[i];
    }
    long long p=0;
    for(long long i=m;i>=1;i--){
        while(p<m&&check(i,p+1)) p++;
        ans[i]=p;
    }
    for(long long i=1;i<=m;i++){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 10112
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// make new Scanner.
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int t = Integer.parseInt(sc.next());
		
		if (n + t == 15 ) {
			System.out.println('+');
		} else if (n * t == 15) {
			System.out.println('*');
		} else {
			System.out.println('x');
		}
		
		// Listに格納.
//		List<Integer> list = inList(sc,n);
		

		// close Scanner
		sc.close();

	}

	
	/**
	 *  入力した数字を配列に格納するメソッド.
	 * @param sc
	 * @param n
	 * @return
	 */
	public static List<Integer> inList(Scanner sc, int n) {
		List<Integer> list = new ArrayList<Integer>();
		for (int a=0;a<n;a++) {
			list.add(sc.nextInt());
		}
		return list;
	}

}


Measured memory_bytes: 21844
import math
S = input()

def convert(arr):
    H = []
    for value in arr:
        H.append(int(value))
    return H

def fix0(arr):
    count = 0
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            arr[i] = math.fabs(arr[i-1] - 1)
            count = count + 1
    return count

def fix1(arr):
    count = 0
    if arr[0] == arr[1]:
        count = count + 1

    if len(arr) > 2:
        for i in range(2,len(arr)):
            if arr[i] == arr[i-1]:
                arr[i] = math.fabs(arr[i-1] - 1)
                count = count + 1
    return count

def compare(x,y):
    if x < y:
        return x
    else:
        return y

def main(arr):
    if len(arr) > 1:
        # 0 fixed
        # 1 fixed
        count1 = fix0(arr.copy())
        count2 = fix1(arr.copy())
        return compare(count1,count2)
    else:
        return 0


print(main(convert(S)))






Measured memory_bytes: 6012
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
const int Mod=1e9+7;
long long a[2000010],sum[2000010],n,i,ans;
int main () {
	scanf ("%lld",&n);
	for (i=1;i<=n;i++) 
		scanf ("%lld",&a[i]),sum[i]=sum[i-1]+a[i],sum[i]%=Mod;
	for (i=1;i<n;i++)
		ans=(ans+a[i]%Mod*(sum[n]-sum[i]+Mod)%Mod)%Mod;
	printf ("%lld\n",ans);
	return 0;
}

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

def fib(n):
    if n == 0:
        return 0
    one = 1
    two = 1
    for _ in range(n-2):
        two,one = one + two,two
    return two

ans,now = 1,0
for i in range(M):
    a = int(input())
    ans *= fib(a - now)
    now = a+1
    if ans > 10**9+7:
        ans %= 10**9 + 7
ans *= fib(N - now + 1)
ans %= 10**9 + 7

print(ans)

Measured memory_bytes: 9132
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int x;
  scanf("%lld",&x);
  long long i  =100,count = 0;
  while(i < x){
    i  += (i/100);
    count ++;
  }
  printf("%lld",count);
  return 0;
}

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

int main() {
  vector<int> a(3);
  for (int i = 0; i < 3; i ++) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = a[0] + a[1];
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	num, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return num
}

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

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	ans := func() string {
		if n%10 == 3 {
			return "bon"
		}
		if n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8 {
			return "pon"
		}
		return "hon"
	}()

	fmt.Println(ans)
}


Measured memory_bytes: 1756
n,m,x=map(int,input().split())
l=[]
for i in range(n):
    a=list(map(int,input().split()))
    l.append(a)
ans=99999999

for i in range(2 ** n):
    bag = []
    for j in range(n):
        if ((i >> j) & 1): 
            bag.append(l[j])  
    skill=[0]*m
    enough=[0]*m 
    money=0
    for sub in bag:
        money+=sub[0]
        for kk in range(1,m+1):
            skill[kk-1]+=sub[kk]
            if skill[kk-1]>=x:
                enough[kk-1]+=1
    if 0 not in enough: 
        if ans>money:
            ans=money
if ans==99999999:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 68620
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin>>n;
  long long k;
  cin>>k;
  bool ok[200001];
  int arr[200001];
  for(int i=0;i<200001;i++)ok[i]=true;
  for(int i=1;i<=n;i++)cin>>arr[i];
  long long ind=1;
  long long ind2;
  ok[1]=false;
  int arr2[200001];
  int arr3[200001];
  arr3[1]=0;
  for(int i=1;;){
  	i=arr[i];
  	arr2[ind]=i;
  	
  	if(!ok[i]){ind2=ind-arr3[i];break;}
  	if(ok[i])ok[i]=false;
  	arr3[i]=ind;
  	//cout<<i<<" "<<ind<<endl;
  	ind++;
  }
  if(k<=ind){
  	cout<<arr2[k]<<endl;
  	return 0;
  }
  k=k-ind;
 // cout<<k<<endl;
  k=k%ind2;
  if(!k)k=ind2;
 // cout<<k<<endl;
  k=ind-ind2+k;
 // cout<<k<<endl;
  cout<<arr2[k]<<endl;

  return 0;
}

Measured memory_bytes: 6100
#include <iostream>

using namespace std;

int main()
{
	string weather;
	cin >> weather;
	if (weather == "Sunny") cout << "Cloudy";
	else if (weather == "Cloudy") cout << "Rainy";
	else if (weather == "Rainy") cout << "Sunny";
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
int main(){
	
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	
	ll res = 0;
	ll d = 1;
	while(true){
		vector<ll> b(n);
		rep(i,n) b[i] = a[i]&1;
		
		ll n0=0,n1=0;
		rep(i,n){
			if(b[i]==0) n0++;
			else n1++;
		}
		
		res =  (res + (d * (n0 * n1 % MOD) % MOD)) % MOD;
      //cout << res << n0 << n1 << endl;
      bool notzero = false;
      rep(i,n){
        a[i] >>= 1;
        if(a[i]>0) notzero = true;
      }
      if(!notzero) break;
		d = 2 * d % MOD;
		
	}
	cout << res << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

int main(){
    ll x, n;
    cin >> x >> n;
    ll arr[101] = {0};
    for(ll i = 0; i < n; ++i){
        ll tmp; cin >> tmp;
        arr[tmp] = 1;
    }
    ll ans = 38259, kanta = 335893;
    for(ll i = -200; i < 120; ++i){
        if(i >= 0){
            if(arr[i] == 0 || i > 100){
                if(ans > abs(x - i)){
                    ans = min(ans, abs(x - i));
                    kanta = i;
                }
            }
        }
        else{
            if(ans > abs(x - i)){
                ans = min(ans, abs(x - i));
                kanta = i;
            }
        }
    }
    cout << kanta;
    return 0;

}


Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

// Dirichlet's Theorem on Arithmetic Progressions(1141)
int main()
{
	//freopen("1141.txt", "r", stdin);
	const int MAX = 1000000+1;
	static bool prime[MAX];
	for (int i = 0; i < MAX; ++i)
		prime[i] = true;
	prime[0] = prime[1] = false;

	for (int i = 0; i*i < MAX+1; ++i) {
		if (prime[i]) {
			for (int j = i+i; j < MAX; j += i)
				prime[j] = false;
		}
	}

	int a, d, n;
	while (cin >> a >> d >> n) {
		if (a == 0 && d == 0 && n == 0)
			break;

		int cnt = 0;
		for (int i = 0; ; ++i) {
			int seq = a + d*i;
			if (prime[seq])
				++cnt;
			if (cnt == n) {
				cout << seq << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    using namespace std;const int N=1e5+10;typedef long long ll;
    int n;long long a[200010];ll res=0;
    int main()
    {
    	scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%lld",&a[i]);ll x=0;ll s=0;
    	for(int i=1,j=1;i<=n;i++)
    		{x^=a[i];s+=a[i];while(x!=s){x^=a[j];s-=a[j];j++;}res+=i-j+1;}
    	printf("%lld",res);return 0;
    }

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

int K, N, p[200003];
double maxi, current;

int sum(int n) { return (n * n + n)/2; }

int main() {
    cin >> N >> K;
    for (int i = 1; i <= N; i++)
        cin >> p[i];

    current = 0;
    for (int i = 1; i <= K; i++) {
        current += (double) sum(p[i])/p[i];
    }

    maxi = current;

    int ptr = 1;
    for (int i = K + 1; i <= N; i++) {
        current += (double) sum(p[i])/p[i];
        current -= (double) sum(p[ptr])/p[ptr];

        ptr += 1;

        maxi = max(maxi, current);
    }

    printf("%.7f\n", maxi);
}


Measured memory_bytes: 1024
def main():
    n = int(input())
    indic = dict()
    ans = 0

    for _ in range(n):
        a = int(input())
        if a in indic:
            indic[a] += 1
        else:
            indic[a] = 1
    for k in indic:
        if indic[k] % 2 != 0:
            ans += 1
    
    print(ans)




if __name__ == "__main__":
    main()

Measured memory_bytes: 19280
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		while(true){
			var d = ria();
			N = d[0]; M = d[1];
			if(N == 0 && M == 0) return;
			C = new int[M];
			for(int i=0;i<M;i++) C[i] = ri();
			X = new int[N];
			for(int i=0;i<N;i++) X[i] = ri();
			
			long Inf = (long) 1e18;
			long[] dp = new long[256];
			for(int i=0;i<256;i++) dp[i] = Inf;
			dp[128] = 0;
			for(int i=0;i<N;i++){
				long[] nxt = new long[256];
				for(int j=0;j<256;j++) nxt[j] = Inf;
				for(int y=0;y<256;y++){
					if(dp[y] == Inf) continue;
					foreach(var c in C){
						int ny = y + c;
						if(ny < 0) ny = 0;
						if(ny > 255) ny = 255;
						nxt[ny] = Math.Min(nxt[ny], (X[i] - ny) * (X[i] - ny) + dp[y]);
					}
				}
				dp = nxt;
			}
			
			Console.WriteLine(dp.Min());
			
		}
	}
	
	int N,M;
	int[] C;
	int[] X;
	
	
	public Sol(){
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
    cin.sync_with_stdio(false);
    int n;
    while(cin >> n, n) {
        int l = 0, r = 0, cnt = 0;
        int flag = 0;
        rep(i, n) {
            string s;
            cin >> s;
            if (s[0] == 'l') {
                l = (l + 1) % 2;
            } else {
                r = (r + 1) % 2;
            }
            if (l == r && flag != l) {
                cnt++;
                flag = l;
            }
        }
        cout << cnt << endl;
    }

    return 0;
}

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

void solve(int N){
  vector<int> S(N);
  for(int i=0;i<N;i++) cin>>S[i];

  sort(S.begin(),S.end());

  int ans=0;
  for(int i=1;i<N-1;i++) ans+=S[i];
  cout<<ans/(N-2)<<endl;
}

int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0) break;
    solve(n);
  }

  return 0;
}



Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n,m; cin >> n >> m;
  vl wrong(n);
  vector<bool> acorwa(n,false);
  ll acsum = 0; ll wasum = 0;
  
  rep(i,m){
    ll p; string s; cin >> p >> s;
    if(s=="AC"&&acorwa.at(p-1)==false){
      acorwa.at(p-1) = true;
      acsum++;
      wasum += wrong.at(p-1);
    }
    else if(s=="WA"&&acorwa.at(p-1)==false) wrong.at(p-1)++;
  }
  
  cout << acsum << ' ' << wasum << endl;
}

Measured memory_bytes: 1024
//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define Ryuga ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back

using namespace std;

const ll sz=1e5+5;
const ll szz=1e6+6;
const ll mod=1e9+7;

int main()
{
	Ryuga;

	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("op.txt","w",stdout);
	#endif

	clock_t startTime=clock();

	ll n;
	cin>>n;
	ll ar[n];
	rep(i,0,n)
	{
		cin>>ar[i];
	}
	ll x=0;
	rep(i,0,n)
	{
		x^=ar[i];
	}
	rep(i,0,n)
	{
		cout<<(ar[i]^x)<<" ";
	}


	cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;

}//Goodbye...

Measured memory_bytes: 5344
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();
		int[] arr = new int[n];
		Arrays.fill(arr, k);
		if(k>q) {
			
			for(int i = 0;i<n;i++)System.out.println("Yes");
			return;
		}else {
			for(int i = 0;i<q;i++) {
				int temp = sc.nextInt();
				arr[temp-1]++;
			}
		}
		for(int i = 0;i<n;i++) {
			if(arr[i]>q)System.out.println("Yes");
			else System.out.println("No");
		}

	}

}


Measured memory_bytes: 60372
n = int(input())
a = list(map(int, input().split()))

c = [0] * n

for i in range(n):
    if (a[i] % 2 == 0):
        if (a[i] % 3 != 0) and (a[i] % 5 != 0):
            c[i] = 1
            
if (list(set(c)) == [0]):
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  int n;
  while(cin >>n){
    bool f = false;
    for(int i=1;i<=512;i*=2){
      if(n%2 == 1){
	if(f) cout <<" ";
	cout<<i;
	f = true;
      }
      n/=2;
    }
    cout <<endl;
  }
  return 0;
}

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

int main() {
        int a, b, i, j, count = 0;

        cin >> a >> b;

  		for (j = 1; j <= a; ++j) {
        for (i = 1; i <= b; ++i) {
                if (1 == (i / 10) || 1 == (i % 10)) {
                        continue;
                } 
                if (j == (i / 10) * (i % 10)) {
                        count++;
                }
        }
        }

        cout << count << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
L = [[0, 0, 0] for _ in range(n)]
for i in range(n):
    x, y, z = map(int, input().split())
    L[i][0], L[i][1], L[i][2] = x, y, z

ans = 0
for i in range(2**3):
    temp = [0]*n
    for k in range(n):
        for j in range(3):
            if (i >> j) & 1:
                temp[k] += L[k][j]
            else:
                temp[k] += L[k][j]*(-1)
    temp.sort(reverse=True)
    ans = max(ans, sum(temp[0:m]))
print(ans)    


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

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

    int count = 0;

    for(int i = 0; i < N.size(); ++i) {
        count += (int)(N.at(i) - '0');
    }

    if( (stoi(N) - 0) % count == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

int main() {
	int H, W;
	cin >> H >> W;
	int cnt = 0;
	for (int i = 0; i < H; i++) {
		for (int i = 0; i < W; i++) {
			char c;
			cin >> c;
			if (c == '#') cnt++;
		}
	}
	if (cnt == (H + W - 1)) {
		cout << "Possible" << endl;
	} else {
		cout << "Impossible" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    string S;
    cin >> S;
    cout << S.substr(0, S.size() - 8) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}



void solve() {
    int h, n;
    cin >> h >> n;
    
    vector<ll> dp(h + 1, inf);
    dp[h] = 0;
    
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        for (int j = h; j >= 0; --j) {
            chmin(dp[max(0, j - a)], dp[j] + b);
        }
    }
    cout << dp[0] << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(snip_i, h) cin >> s.at(snip_i);
  int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
  rep(i, h)rep(j, w){
    if(s.at(i).at(j) == '.') continue;
    bool e = true;
    rep(snip_i, 4){
      int nj = j + dx[snip_i], ni = i + dy[snip_i];
      if(nj < 0 || w <= nj || ni < 0 || h <= ni) continue;
      if(s.at(ni).at(nj) == '#') e = false;
    }
    if(e == true){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(N-1):
    if A[i] + 1 == A[i+1]:
        ans += C[A[i]-1]
print(ans + sum(B))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

// Description: Z[i]=sとs[i..]の最長共通部分列の長さ
// TimeComplexity: $\mathcal{O}(N)$
// Verifyed: ARC 060 D

auto z_algorithm(const vector<int> &s) {
	int n = s.size(), i = 1, j = 0, k;
	vector<int> z(n, n);
	while (i < n) {
		while (i + j < n && s[i + j] == s[j]) j++;
		z[i] = j, k = !!j;
		while (i + k < n && k + z[k] < j) z[i + k] = z[k], k++;
		i += k + !j, j -= k;
	}
	return z;
}

int main(void){
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);

	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];

	vector<int> da(n), db(n);
	rep(i, n) {
		da[i] = a[i] ^ a[(i + 1) % n];
		db[i] = b[i] ^ b[(i + 1) % n];
	}

	vector<int> s;
	rep(i, n) s.push_back(db[i]);
	s.push_back(-1);
	rep(i, n) s.push_back(da[i]);
	rep(i, n) s.push_back(da[i]);
	
	auto z = z_algorithm(s);
	const int offset = n + 1;

	vector<int> k, x;

	rep(i, n) {
		if(z[i + offset] != n) continue;
		k.push_back(i);
		x.push_back(b[0] ^ a[i]);
	}

	const int t = k.size();
	rep(i, t) cout << k[i] << " " << x[i] << endl;

	return 0;
}

Measured memory_bytes: 14572
N,K = map(int,input().split())
S = 0
w = 0
for k in range(K,N+2):
    s = 0
    if k-1 == 0:
        s = N+1
    else:
        w = int(k*(k-1)/2)
        s = k*N - 2*w +1
    S += s
print(S%(10**9+7))

Measured memory_bytes: 9136
#include<bits/stdc++.h>
#define ll long long
using namespace std;
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second&&a.first<b.first);
}

void solve(){
    int n,m,sum=0;
    cin>>n;
    vector<int>t(n);
    for(int i=0;i<n;i++){
        cin>>t[i];
        sum+=t[i];
    }
    cin>>m;
    vector<int>p(m),x(m);
    for(int i=0;i<m;i++){
        cin>>p[i]>>x[i];
        cout<<sum-t[p[i]-1]+x[i]<<endl;
    }


}


int main(){
    /*int t;
    cin>>t;
    while(t--)*/
        solve();


    return 0;
}
































































//1-(3+5-2+(3+19-(3-1-4+(9-4-(4-(1+(3)-2)-5)+8-(3-5)-1)-4)-5)-4+3-9)-4-(3+2-5)-10




















Measured memory_bytes: 3560
a = input()
b = input()
c = input()
sa = [i for i in a]
sb = [i for i in b]
sc = [i for i in c]
turn = sa[0]
while True:
    if turn == 'a':
        if len(sa) == 0:
            print('A')
            break
        turn = sa[0]
        sa.pop(0)
    if turn == 'b':
        if len(sb) == 0:
            print('B')
            break
        turn = sb[0]
        sb.pop(0)
    if turn == 'c':
        if len(sc) == 0:
            print('C')
            break
        turn = sc[0]
        sc.pop(0)

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

using namespace std;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
typedef long long ll;
typedef unsigned long long ull;
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)

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;}

#define fil0(i,n) cout<<swet(n)<<setfill('0')<<i<<resetiosflags(ios_base::floatfield)
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define possible(n) cout<<((n)?"possible":"impossible")<<endl
#define Possible(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
    int k;
    string s;
    set<string> subs;
    cin>>s>>k;
    int n=sz(s);
    REP(i,n){
        REP(j,min(k,n-i)){
            subs.insert(s.substr(i,j+1));
        }
    }
    for(auto a:subs){
        if(!--k){
            cout<<a<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 1664
def main():
    a, b, c, d  = map(int, input().split())
    #A_list = list(map(int, input().split()))
    l = a * c
    m = a * d
    n = b * c
    o = b * d
    ans = max(l,m,n,o)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9164
fun main(args : Array<String>) {
    val s = readLine()!!
    val cc = IntArray(s.length){0}

    var rCnt = 1
    var lCnt = 0
    var wasR = true
    var lastRLIdx = 0

    for (i in 1 until s.length) {
        if (s[i] == 'R') {
            if (lCnt > 0) {
                cc[lastRLIdx] += ((lCnt+1)/2)
                cc[lastRLIdx+1] += (lCnt/2)
                lCnt = 0
            }
            wasR = true
            lastRLIdx = i
            rCnt++
        } else {
            if (wasR) { // RL
                cc[i-1] += ((rCnt-1)/2)+1
                cc[i] += (rCnt/2)+1
                rCnt = 0
            } else {
                lCnt++
            }
            wasR = false
        }
    }

    if (lCnt > 0) {
        cc[lastRLIdx] += ((lCnt+1)/2)
        cc[lastRLIdx+1] += (lCnt/2)
    }

    println(cc.joinToString(separator = " "))
}

Measured memory_bytes: 46016
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N ;
  int li;
  int ri;
  int result;
  result = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> li;
        cin >> ri;
        result = result + (ri-li) + 1;
    }
    cout << result << endl;
  
  // ここにプログラムを追記

}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  int ans = 111;
  while(ans<n) ans += 111;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <cstring>
#include <string>
#include <queue>
#include <cmath>
#include <map>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define rev(v) (v).rbegin(), (v).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> P;
typedef long long ll;

int dp[600000] = {};

int main(){
	int n;
	while(cin >> n, n){
		vector<vi> list(n);
		rep(i, n){
			int m;
			cin >> m;
			list[i].resize(m);
			rep(j, m) cin >> list[i][j];
		}

		vector<int> ok(n, 0);
		int k;
		cin >> k;
		rep(i, k){
			int l;
			cin >> l;
			rep(j, list.size()){
				if(ok[j]) continue;
				bool inc = false;
				rep(k, list[j].size()){
					if(list[j][k] == l){
						inc = true;
						break;
					}
				}
				ok[j] |= !inc;
			}
		}

		int cnt = 0;
		int ans;
		rep(i, n){
			if(!ok[i]){
				cnt++;
				ans = i+1;
			}
		}

		cout << (cnt==1?ans:-1) << endl;

	}


	return 0;
}

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

using namespace std;

#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define ok puts("ok");
#define whatis(x) cerr << #x << " = " << x << endl;

const int N = 223;
const int inf = (int)1e9 + 7;

pii ar[N];
vector < int > gr[N];
bool used[N];
int mt[N];

bool kuhn(int v) {
  if (used[v]) return false;
  used[v] = 1;
  for (int to : gr[v]) {
    if (mt[to] == -1 || kuhn(mt[to])) {
      mt[to] = v;
      return true;
    }
  }
  return false;
}

main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &ar[i].fr, &ar[i].sc);
  }
  for (int i = n + 1; i <= n + n; i++) {
    scanf("%d %d", &ar[i].fr, &ar[i].sc);
    mt[i] = -1;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = n + 1; j <= n + n; j++) {
      if (ar[i].fr < ar[j].fr && ar[i].sc < ar[j].sc) {
        gr[i].pb(j);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    memset(used, 0, sizeof(used));
    kuhn(i);
  }

  for (int i = n + 1; i <= n + n; i++) {
    if (mt[i] != -1) {
      ans++;
//      cout << i << ' ' << mt[i] << endl;
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
import java.util.*;
public class Main { 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int o=0;
        int x=sc.nextInt();
        int y=sc.nextInt();
        PriorityQueue<Integer> q=new PriorityQueue<>();
		for(int i=0;i<y;i++){
        		int p=sc.nextInt();
        		q.add(p);
		}
      	for(int i=0;i<=100;i++){         
          if(!q.contains(x-i)){
          	o=x-i;
            break;
          }else if(!q.contains(x+i)){
          	o=x+i;
            break;
          }
        }  
      System.out.println(o);
    }
    
}

Measured memory_bytes: 35956
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};



int main(){
  int a,b,c; cin>>a>>b>>c;
  if(b-a==c-b)
  puts("YES");
  else
  puts("NO");

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
const int maxn=10000+10;
int V,E;
vector<int> g[maxn];
vector<int> rg[maxn];
vector<int> rs;
int vis[maxn];
int check[maxn];


void dfs(int u)
{
    vis[u]=1;
    for(int i=0;i<g[u].size();i++)
    {
        int v=g[u][i];
        if(!vis[v]) dfs(v);
    }
    rs.push_back(u);

}
void rdfs(int u,int k)
{
    vis[u]=1;
    check[u]=k;
    for(int i=0;i<rg[u].size();i++)
    {
        int v=rg[u][i];
        if(!vis[v]) rdfs(v,k);
    }
}
void scc()
{
    memset(vis,0,sizeof(vis));
    int k=0;
    for(int i=0;i<V;i++)
    {
        if(!vis[i]) dfs(i);
    }
    memset(vis,0,sizeof(vis));
    for(int i=rs.size()-1;i>=0;i--)
    {
        if(!vis[rs[i]]) rdfs(rs[i],k++);
    }

}
int main(void){
//   freopen("in.txt","r",stdin);
   scanf("%d%d",&V,&E);
   int u,v;
   for(int i=0;i<E;i++)
   {
       scanf("%d%d",&u,&v);
       //vector ???????????\?????????
       g[u].push_back(v);
       rg[v].push_back(u);
   }
   //?????¢????????§??????
   scc();
   int q;
   //???????????§??????
   scanf("%d",&q);
   while(q--)
   {
       scanf("%d%d",&u,&v);
       printf("%d\n",check[u]==check[v]?1:0);
   }

  return 0;
}

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

int main() {
	int N;
	cin >> N;
	unsigned int P[N];
	unsigned int max = 0;
	unsigned int sum = 0;
	
	for (int i = 0;i < N;i++) {
		cin >> P[i];
		if (max <= P[i])
			max = P[i];
		sum += P[i];
	}
	cout << sum - (max/2) << endl;


}


Measured memory_bytes: 256
#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(s) cout << s << endl;
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()
{
   int a,b,c,d; cin>>a>>b>>c>>d;
   cout << (abs(a-c)<=d?"Yes":((abs(a-b)<=d&&abs(b-c)<=d)?"Yes":"No")) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
string s;
int k;
int main()
{
	cin>>s;
	cin>>k;
	for(int i=0;i<k;++i)
	if(s[i]!='1')
	{
		printf("%c",s[i]);
		return 0;
	}
	printf("1");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define DEBUG2(x, y) cerr << #x << ": " << x << " " << #y << ": " << y << "\n"
#define DEBUG3(x, y, z)                                                        \
  cerr << #x << ": " << x << " " << #y << ": " << y << " " << #z << ": " << z  \
       << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair< int, int >
#define ld long double
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N, C, K;
  cin >> N >> C >> K;
  vec< int > t(N);
  REP(i, N) cin >> t[i];
  sort(ALL(t));
  int ans = 1;
  int time = t[0] + K;
  int cnt = 0;
  REP(i, N) {
    int val = t[i];
    if (cnt == C) {
      ans++;
      cnt = 0;
      time = t[i] + K;
    }
    if (val <= time) {
      cnt++;
    } else {
      cnt = 1;
      ans++;
      time = t[i] + K;
    }
  }
  print(cnt ? ans : ans - 1);
}

Measured memory_bytes: 1024
fun main(args :Array<String>) {
    val a = readInteger()
    val b = readInteger()
    if (a == 1) {
        when (b) {
            2 -> 3
            3 -> 2
            else -> 0
        }.let { println(it) }
    } else if (a == 2) {
        when (b) {
            1 -> 3
            3 -> 1
            else -> 0
        }.let { println(it) }
    } else {
        when (b) {
            1 -> 2
            2 -> 1
            else -> 0
        }.let { println(it) }
    }
}

fun readInteger() = readLine()!!.toInt()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


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


int main() {
    int s,w;
    cin >> s>>w;
    if(w>=s) {
        cout<<"unsafe"<<endl;
    }else{
        cout<<"safe"<<endl;
    }
    return 0;

}



Measured memory_bytes: 3632
use std::io;

// Avoids to use unstable feature iter_unfold
fn unfold<In, Out, F>(seed: &In, f: F) -> Vec<Out>
where F: FnMut(&In) -> Option<(Out, In)> {
    fn go<In, Out, F>(seed: &In, mut f: F, acc: &mut Vec<Out>)
    where F: FnMut(&In) -> Option<(Out, In)> {
        match f(seed) {
            Some((out, next)) => {
                acc.push(out);
                go(&next, f, acc);
            }
            None => ()
        }
    }

    let mut result = Vec::new();
    go(seed, f, &mut result);
    result
}

// Avoids to use experimental trait std::slice::SliceConcatExt
// A more general signature of this function seems to be:
//   fn concat<'a, Seq>(ss: Seq) -> String where Seq: Iterator<Item = &'a str>
// but I don't know how to pass the compilation.
fn concat<Seq>(ss: Seq) -> String where Seq: Iterator<Item = String> {
    let mut result = String::new();
    for s in ss {
        result = result + &s;
    }
    result
}

fn split_at_safe(s: &str, at: usize) -> (&str, &str) {
    if s.len() <= at { (s, "") } else { s.split_at(at) }
}

fn main() {
    let mut line1 = String::new();
    io::stdin()
        .read_line(&mut line1)
        .unwrap();
    let s = line1.trim();

    let mut line2 = String::new();
    io::stdin()
        .read_line(&mut line2)
        .unwrap();
    let w = line2.trim().parse::<usize>().unwrap();

    let fragments = unfold(&s, |s| {
        if s.is_empty() { None } else { Some(split_at_safe(s, w)) }
    });
    println!("{}", concat(
        fragments.iter()
            .map(|&s| { s.chars().nth(0).unwrap().to_string() })
    ));
}


Measured memory_bytes: 4352
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 3e3 + 6, M = 998244353;
ll p(ll a, ll b = M - 2, ll m = M)
{
    ll r = 1;
    while (b)
    {
        if (b % 2)
            r = (r * a) % m;
        a = (a * a) % m;
        b /= 2;
    }
    return r;
}
ll a, b, c, d, dp[N][N];
ll f(ll x, ll y)
{
    if (x == a)
        return p(a, y - b);
    if (y == b)
        return p(b, x - a);
    if (dp[x][y])
        return dp[x][y];
    dp[x][y] += f(x, y - 1) * x % M;
    dp[x][y] += f(x - 1, y) * y % M;
    dp[x][y] -= f(x - 1, y - 1) * (x - 1) % M * (y - 1) % M;
    dp[x][y] += M;
    dp[x][y] %= M;
    return dp[x][y];
}
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    cin >> a >> b >> c >> d;
    cout << f(c, d);
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define sp cout << " ";
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';				

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;


clock_t time_p = clock();

void ktj(){
    time_p = clock() - time_p;
	cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

int main(){
	IOS

	ll w,h,x,y;
	cin >> w >> h >> x >> y;

	decimal_digits

	if(2*x == w and 2*y == h){
		cout << (1.0*w*h)/2 << " 1\n";
	}else{
		cout << (1.0*w*h)/2 << " 0\n";
	}

	ktj();
}


Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<cstdio>
using namespace std;
#define N 100005
#define LL long long
#define max(a,b) (a>b?a:b)
#define rep(i,j,k) for(i=j;i<=k;++i)
int n,i,j,ans,tot,k,m;
int prime[330],vis[2160];
LL s,bs[N],ms[N];
map<LL,int> mp;
void read(int &p){
	p=0; char x=getchar();
	while(x<'0' || x>'9') x=getchar();
	while(x>='0'&&x<='9'){p=p*10+x-'0'; x=getchar();}
}
void read(LL &p){
	p=0; char x=getchar();
	while(x<'0' || x>'9') x=getchar();
	while(x>='0'&&x<='9'){p=p*10+x-'0'; x=getchar();}
}
void init(){
	rep(i,2,2155){
		if(!vis[i]) tot++,prime[tot]=i;
		rep(j,1,tot){
			if(i*prime[j]>2155) break;
			vis[i*prime[j]]=1;
			if(!(i%prime[j])) break;
		}
	}
}
void work(LL s){
	LL bu=1,self=1;
	rep(j,1,tot){
		k=0; 
		while(!(s%prime[j])) s/=prime[j],k++;
		k%=3;
		if(k==1) self=self*1LL*prime[j],bu=bu*prime[j]*1LL*prime[j];
		if(k==2) bu=bu*1LL*prime[j],self=self*prime[j]*1LL*prime[j];
	}
	LL gh=sqrt(s)+0.5;
	if(gh*gh==s) bu=bu*1LL*gh;
	else bu=bu*1LL*s*1LL*s;
	bs[i]=bu; ms[i]=self*1LL*s; mp[ms[i]]++;
}
int main(){
//	freopen("in.txt","r",stdin);
	init();
	read(n);
	rep(i,1,n){
		read(s);
		work(s);
	}
	ans=min(mp[1],1); mp[1]=0;
	rep(i,1,n){
		ans+=max(mp[ms[i]],mp[bs[i]]);
		mp[ms[i]]=mp[bs[i]]=0;
	}
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 14336