akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <vector>
#include <valarray>
#include <queue>
#include <iostream>
#include <numeric>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(int i = (a); i >= (b); --i)
#define rREP(i, n) rFOR(i, n-1, 0)
#define AND &&
#define OR ||
#define IN(x, min, max) (min <= x AND x < max)
#define VEC(type) vector<type>
#define DVEC(type) vector<vector<type>>
#define VAL(type) valarray<type>
#define ARRAY_SIZE(array) (sizeof(array)/sizeof(array[0]))
#define HOGE printf("%s\n", "hoge");
#define DUMP(p) cout << p << endl;
const int INF = 2323232323;
using namespace std;
typedef pair<int, int> P;

#define MAX 10*10*10*10*10+1
char s[MAX];
int K;
int main(){
    scanf("%s", s);
    scanf(" %d", &K);
    int N = 0;
    while (s[N] != '\0') {
        N++;
    }
    int i = 0;
    while (K) {
        if (i != N-1) {
            if ((s[i]+K > 122 OR K >= 26) AND s[i] != 'a') {
                K = K-(123-s[i]);
                s[i] = 'a';
                i++;
            } else {
                i++;
            }
        } else {
            K = K%26;
            if (s[i]+K > 122) {
                s[i] = 97+(s[i]+K-123);
            } else {
                s[i] = s[i]+K;
            }
            K = 0;
        }
    }
    printf("%s\n", s);
        return 0;

}


Measured memory_bytes: 512
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (int)a; ++i)
#define REP(i, a, b) for (int i = (a); i < (int)b; ++i)

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

using namespace std;
using ll = long long;
using P = pair<ll, int>;

void Main() {
  int n;
	cin >> n;
  vector<int> A(n);
  vector<P> ord;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
    ord.emplace_back(A[i], i);
	}

  vector<ll> dp(n+1, 0);
	sort(ord.begin(), ord.end());
  rep(i, n) {
    rep(l, n - i + 1) {
			int r = l + i;
			const auto &[a, pos] = ord[i];
			dp[l] = max(dp[l] + a * abs(pos - r), dp[l + 1] + a * abs(pos - l));
		}
	}

  cout << dp[0] << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 3736
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;

int main() {
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int n,m,a[200005],b, k, sum = 0, d, w, h;
	long long dp[200005] = {}, memo[200005] = {};
	string str,str2;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	if (n % 2 == 0) {
		for (int i = 1; i < n / 2; i++) {
			sum -= 2 * a[i];
		}
		for (int i = n / 2 + 2; i <= n; i++) {
			sum += 2 * a[i];
		}
		sum += a[n / 2 + 1] - a[n / 2];
	}
	else {
		for (int i = 1; i < n / 2; i++) {
			sum -= 2 * a[i];
		}
		for (int i = n / 2 + 3; i <= n; i++) {
			sum += 2 * a[i];
		}
		sum += max(2 * a[n / 2 + 2] - a[n / 2 + 1] - a[n / 2], a[n / 2 + 2] + a[n / 2 + 1] - 2 * a[n / 2]);
	}
	cout << sum;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define go(i,a,b) for(int i=(a);i<=(b);++(i))
#define com(i,a,b) for(int i=(a);i>=(b);--(i))
#define mem(a,b) memset((a),(b),sizeof(a))
#define inf 0x3f3f3f3f
#define fin freopen("input.txt","r",stdin)
#define fout freopen("output.txt","w",stdout)
typedef long long ll;

void read(int &x){
    int f=1;char s=getchar();x=0;
    while(!isdigit(s)){
    	if(s=='-') f=-1;s=getchar();
    }
    while(isdigit(s)){
   		x=(x<<3)+(x<<1)+s-'0';s=getchar();
    }
    x*=f;
}//读入优化

int main()
{
	//fin;
	int n,k;read(n),read(k);
	printf("%d",n-k+1);
	return 0;
}

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

using namespace std;
vector < ll > d;

int main()
{
    ll a,b;
    cin >> a >> b;
    for(ll i = 1;i*i<=a;i++){
        if(a % i == 0){
            if(b % i == 0)
            d.push_back(i);
            if(a/i != i && b % (a/i) == 0)  d.push_back(a/i);
        }
    }
    sort(d.begin() , d.end());
    int cnt = 0;
    for(int i = d.size() - 1;i>=0;i--){
        bool check = true;
        for(int j = 0;j<i;j++){
            if(__gcd(d[i] , d[j]) > 1)  check = false;
        }
        if(!check)  cnt++;
    }
    cout << d.size() - cnt;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c[50],d[50];
  cin>> a >>b;
  
  for(int i=0; i<b;i++){
    cin >> c[i] >>d[i];
  }
  int e[50];
  
  for(int i=0; i<a ;i++){
  
       e[i] =0;
  }
    for(int j =0; j<b;j++){
        e[c[j]-1] += 1;
        e[d[j]-1] += 1;
    }
      for(int i =0 ;i<a;i++){
    cout << e[i] <<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;
const ll infl = 1e17;

typedef unsigned long long ull;


int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> cnt(n, 0);
    ll t, d;
    vector<pll> sushi(n);
    rep(i,n){
        cin >> t >> d;
        sushi[i] = mp(d, t - 1);
    }
    sort(all(sushi));
    ll now = 0;
    ll var = 0;
    vector<pll> choice;
    rep(i,k){
        pll p = sushi.back();
        choice.push_back(p);
        now += p.F;
        if (cnt[p.S]==0){
            var++;
        }
        cnt[p.S]++;
        sushi.pop_back();
    }
    ll ans = var * var + now;
    bool flag = true;
    while (!(choice.empty()) && !(sushi.empty()))
    {
        /*cout << "A " << endl;
        for (auto x : choice)
            cout << x.F << " " << x.S << " / ";
        cout << endl;
        for (auto x : sushi)
            cout << x.F << " " << x.S << " / ";
    for (auto x:cnt)
        cout << x << " ";
        cout << endl;*/
        flag = false;
        while (!(choice.empty())){
            if (cnt[choice.back().S]>1){
                //cout << "B ";
                now -= choice.back().F;
                cnt[choice.back().S]--;
                flag = true;
                choice.pop_back();
                break;
            }
            choice.pop_back();
        }
        if (!(flag))
            break;
        flag = false;
        while (!(sushi.empty())){
            if (cnt[sushi.back().S]==0){
                //cout << "C ";
                now += sushi.back().F;
                cnt[sushi.back().S]++;
                var++;
                flag = true;
                sushi.pop_back();
                break;
            }
            sushi.pop_back();
        }
        //cout << var << " " <<now<< endl;
        if (flag){
            ans = max(ans, var * var + now);
        }
    }
    cout << ans << endl;
}


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

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

typedef long long ll;
typedef long double ld;


void solve() {
   int n;
   cin >> n;
   vector<int> a(n);
   for (int i = 0; i < n; ++i) {
        cin >> a[i];
   }
   map<int, int> have;
   ll ans = 0;
   for (int i = 0; i < n; ++i) {
        int val = a[i] - i - 1;
        //cout << "val: " << val << endl;
        ans += have[val];
        //cout << "i: " << i << ' ' <<  have[val] << endl;
        ++have[-a[i] - i - 1];
   }
   cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 21084
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  cout << fixed << setprecision(10);
  long double L, ans;
  cin >> L;
  ans=(L*L*L)/27;
  cout << ans << endl;
}

Measured memory_bytes: 3808
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int n = sc.nextInt();
			ArrayList<Integer> use = new ArrayList<Integer>();
			for(int i=0;i<10;i++) {
				if ((n&(1<<i)) > 0) {
					use.add((1<<i));
				}
			}
			System.out.print(use.get(0));
			for(int i=1;i<use.size();i++) {
				System.out.print(" " + use.get(i));
			}
			System.out.println();
		}
	}

}

Measured memory_bytes: 17240
n, k = map(int, input().split())
ans = 0
if k == 0:
    ans = n ** 2
else:
    for b in range(k + 1, n + 1):
        period = n // b
        nokori = n % b
        ans += period * (b - k) + max(nokori - k + 1, 0)
print(ans)


Measured memory_bytes: 2940
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#include <bits/stdc++.h>
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	string s, t, u;
	cin >>s >>t;
	int a, b;
	cin >>a >>b;
	cin >>u;
	if(u == s)
		cout <<a-1 <<" " <<b;
	else 
		cout <<a <<" " <<b-1;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n=0,i;
  char S[100000];
  
  scanf("%s",&S);
  
  for(i=0;S[i+1]!='\0';i++){
    if((S[i]==S[i+1]) && (S[i]=='0')){
      n++;
      S[i+1]='1';
    }
    if((S[i]==S[i+1]) && (S[i]=='1')){
      n++;
      S[i+1]='0';
    }
  }
  printf("%d\n",n);     
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int fg=1;
	int qs=0,qx=0,qy=0;
	for(int i=1;i<=n;i++){
		int s,x,y;
		cin >> s >> x >> y;
		if(s-qs==abs(x-qx)+abs(y-qy)||(s-qs-(abs(x-qx)+abs(y-qy)))%2==0&&s-qs>(abs(x-qx)+abs(y-qy))){
			
		}
		else{
			fg=0;
		}
		qs=s;qx=x;qy=y;
	}
	if(fg)
	cout << "Yes" << endl;
	else
	cout << "No" << endl;
	return 0;
} 

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int, A: int, B: int, C: int, p: "List[int]", q: "List[int]", r: "List[int]"):
    p.sort(reverse=True)
    q.sort(reverse=True)
    r.sort(reverse=True)
    p.append(0)
    q.append(0)
    r.append(0)
    pp = 0
    qq = 0
    rr = 0
    ans = 0
    while pp + qq + rr != X + Y:
        if qq == Y:
            if p[pp] >= r[rr]:
                ans += p[pp]
                pp += 1
            else:
                ans += r[rr]
                rr += 1
            continue
        if pp == X:
            if q[qq] >= r[rr]:
                ans += q[qq]
                qq += 1
            else:
                ans += r[rr]
                rr += 1
            continue

        
        if r[rr] >= q[qq] and r[rr] >= p[pp]:
            ans += r[rr]
            rr += 1
        elif q[qq] >= p[pp]:
            ans += q[qq]
            qq += 1
        else:
            ans += p[pp]
            pp += 1


    print(ans)


        

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(A)]  # type: "List[int]"
    q = [int(next(tokens)) for _ in range(B)]  # type: "List[int]"
    r = [int(next(tokens)) for _ in range(C)]  # type: "List[int]"
    solve(X, Y, A, B, C, p, q, r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 24188
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int tmp(const void* a,const void* b){
  return *(char*)a-*(char*)b;
}
int cmpstr(const void* a, const void* b) {
	return strcmp((char*)a, (char*)b);
}
int main(void){
  long long int n,i,num=1,ans=0;
  scanf("%lld",&n);
  char a[100000][11];
  for(i=0;i<n;i++){
    scanf("%s",a[i]);
  }
  for(i=0;i<n;i++){
     qsort(a[i],10,sizeof(char),tmp);
  }
  qsort(a,n,sizeof(a[0]),cmpstr);
  for(i=0;i<n-1;i++){
    if(strcmp(a[i],a[i+1])==0){
      num++;
    }
    else{
      ans+=(num-1)*num/2;
      num=1;
    }
  }
  ans+=(num-1)*num/2;
  printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 2300
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] dish = new int[Integer.parseInt(sc.next())];
        for (int i = 0; i < n; i++) {
            int num = Integer.parseInt(sc.next());
            for (int j = 0; j < num; j++) {
                dish[Integer.parseInt(sc.next()) - 1]++;
            }
        }
        int cnt = 0;
        for (int tmp : dish) {
            if (tmp == n) cnt++;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 22740
#include <iostream>

using namespace std;
long double a[110],s = 0;
int main(){
    int i,n,m;
    cin >> n >> m;
    for(i=0;i<n;i++){
        cin >> a[i];
        s += a[i];
    }
    int cnt = 0;
    for(i=0;i<n;i++){
        if(a[i]>=s/(4*(long double)m)){
            cnt++;
        }
    }
    if(cnt>=m) cout << "Yes" <<endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int main(void) {
    string s;
    string t = "CODEFESTIVAL2016";
    cin >> s;
    int i, ans = 0;
    REP (i,t.size()) if (s[i] != t[i]) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
n=int(input())
s=[int(i) for i in input().split()]
q=int(input())
t=[int(i) for i in input().split()]

ans=0
for i in t:
    l,r=0,n
    while l<=r:
        m=(l+r)//2
        if s[m]==i:
            ans+=1
            break
        elif s[m]>i:
            r=m-1
        else:
            l=m+1
print(ans)


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

int main(){
  int X;
  cin >> X;
  int k=0;
  while(1){
  	++k;
    if( (X*k)%360 == 0 )
      break;
  
  }
    
  cout << k<< endl;
  
  return 0;
}

Measured memory_bytes: 3188
import math
n, d = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
x = []
sum = 0
ans = 0
for i in range(n):
     for j in range(n):
          if j > i:
               for k in range(d):
                    sum += ((l[i][k] - l[j][k]))**2 
               x.append(math.sqrt(sum))
               sum = 0
for i in range(len(x)):
     if x[i].is_integer() == True:
          ans += 1
print(ans)

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

int main(){
	int n,rank;
	int card[4][13]={0};
	char mark;
	cin >> n;
	for(int i=0;i<n;i++){
		int bangou;
		cin >> mark >> rank;
		switch(mark){
			case 'S': bangou = 0; card[bangou][rank-1] = 1 ;break;
			case 'H': bangou = 1; card[bangou][rank-1] = 1 ;break;
			case 'C': bangou = 2; card[bangou][rank-1] = 1 ;break;
			case 'D': bangou = 3; card[bangou][rank-1] = 1 ;break;
		}
		
	}

	for(int i=0;i<4;i++){
		for(int j=0;j<13;j++){
			card[i][j];
			if(card[i][j]==0){
				switch(i){
					case 0: cout << "S" <<" "<<j + 1<< "\n"; break;
					case 1: cout << "H" <<" "<<j + 1<< "\n"; break;
					case 2: cout << "C" <<" "<<j + 1<< "\n"; break;
					case 3: cout << "D" <<" "<<j + 1<< "\n"; break;

				}
			}
		

		}
	}


	

}

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD =   1000000007;

/// Lib
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}
///

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll lcm = LCM(c, d);
    ll tmp = b/c + b/d - b/lcm;
    ll tmp2 = (a-1)/c + (a-1)/d - (a-1)/lcm;
    ll ans = (b - a+1) - (tmp - tmp2);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int input[200][3];
	int N,i,j;
	
	scanf("%d",&N);//人数を入力
	
	for(i=0;i<N;i++)
		scanf("%d%d%d",&input[i][0],&input[i][1],&input[i][2]);
	
	for(i=0;i<N;i++) {
		int hantei[3]={1,1,1};
		for(j=0;j<N;j++) {
			if(i!=j){
			  if(input[i][0]==input[j][0])hantei[0]=0;
			  if(input[i][1]==input[j][1])hantei[1]=0;
			  if(input[i][2]==input[j][2])hantei[2]=0;
			}
		}
		printf("%d\n",input[i][0]*hantei[0]+input[i][1]*hantei[1]+input[i][2]*hantei[2]);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{

    char c_judgeFlag = 1;
    int i_inputNumCount;
    
    scanf("%d", &i_inputNumCount);

    int i_inputJudgeNumber[i_inputNumCount];

    for (int index = 0; index < i_inputNumCount; index++)
    {
        scanf("%d", &i_inputJudgeNumber[index]);
        if (i_inputJudgeNumber[index] % 2 == 0)
        {
            if (i_inputJudgeNumber[index] % 3 != 0 && i_inputJudgeNumber[index] % 5 != 0)
            {
                c_judgeFlag = 0;
                break;
            }
        }
    }

    if (c_judgeFlag == 1)
    {
        printf("APPROVED");
    }
    else
    {
        printf("DENIED");
    }

}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b&&b==c){
    cout << "No" << endl;
    return 0;
  }
  if(a==b||b==c||c==a){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3576
using System;
using System.Linq;

public class Tree{
  public int value;
  public Tree parent;
  public Tree left;
  public Tree right;
}

class A8{
   static Tree root = new Tree();
  public static void Main(){
    int n = int.Parse(Console.ReadLine());
    int i = 0,k = 0,count = 0;
    string[] str = new string[n];
    for(i = 0;i < n;i++){
      var command = Console.ReadLine().Split(' ');
      if(command[0].Equals("insert")) Insert(root,int.Parse(command[1]));
      else if(command[0].Equals("find")){
       if(Find(int.Parse(command[1])) == null)  str[k++] = "no";
       else str[k++] = "yes";
     }
     if(command[0].Equals("print")){
       for(int j = count;j < k;j++){
         Console.WriteLine(str[j]);
         count++;
       }
     Print(root);
      }else if(i == n - 1){
        for(int j = count;j < k;j++){
          Console.WriteLine(str[j]);
          count++;
        }
      }
    }
  }
  public static Tree Find(int key){
    Tree n = root;
    while(n != null){
      if(n.value > key) n = n.left;
      else if(n.value < key) n = n.right;
      else break;
    }
    return n;
  }
  public static void Insert(Tree tree,int value){
    Tree x = tree;
    Tree y = null;
    while(x != null && x.value != 0){
      y = x;
      if(value < x.value) x = x.left;
      else x = x.right;
    }
    Tree tmp = new Tree();
    tmp.value = value;
    tmp.parent = y;

    if(y == null){
      tree.value = value;
    }else if(value < y.value){
      y.left = tmp;
    }else{
      y.right = tmp;
    }
  }
  public static void Print(Tree tree){
    Inorder(tree);
    Console.WriteLine();
    Preorder(tree);
    Console.WriteLine();
  }

  public static void Inorder(Tree tree){
    if(tree == null) return;
    Inorder(tree.left);
    Console.Write(" " + tree.value);
    Inorder(tree.right);
  }
  public static void Preorder(Tree tree){
    if(tree == null) return;
    Console.Write(" " + tree.value);
    Preorder(tree.left);
    Preorder(tree.right);
  }
}



Measured memory_bytes: 44932
import javax.swing.*;
import java.io.*;
import java.sql.Struct;
import java.text.DecimalFormat;
import java.util.*;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner rd = new Scanner(System.in);
        int n = rd.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = rd.nextInt();
        }
        long[][] dp = new long[n][n];
        long[] values = new long[n];
        values[0] = arr[0];
        for(int i = 0; i<n; i++) {
            for (int j = 0; j < n; j++) {
                if (i == j) {
                    dp[i][j] = 0;
                } else {
                    dp[i][j] = Long.MAX_VALUE;
                }
            }
            if(i > 0) {
                values[i] = values[i - 1] + arr[i];
            }
        }

        for(int i = 2; i <= n; i++) {
            for (int j = 0; j <= n - i; j++) {
               int left = j;
               int right = j + i - 1;
               long min = Long.MAX_VALUE;
               for (int k = j; k <right; k++) {
                   long value = dp[left][k] + dp[k + 1][right] + (values[right] - (left > 0 ? values[left - 1] : 0));
                   if (value < min) {
                       min = value;
                   }
               }
               dp[left][right] = min;
            }
        }
        System.out.println(dp[0][n - 1]);
    }
}

Measured memory_bytes: 25428
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	long long a, b, c;
	cin >> a >> b >> c;

	long long remain = c - a - b;
	if (remain <= 0)
	{
		cout << "No";
		return 0;
	}

	remain *= remain;

	if (remain > 4 * a * b)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

	return 0;
}

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

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

  if(n % 2 == 0) cout << n << endl;
  else cout << n * 2 << endl;

  return 0;
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long llint;
const llint MOD = 998'244'353;

int main() {
    int TH, TS, AH, AS;
    cin >> TH >> TS >> AH >> AS;
    int t = AH / TS;
    if(AH % TS != 0) 
        t++;
    int a = TH / AS;
    if(TH % AS != 0) 
        a++;
    if(t <= a) 
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 3624
import heapq
V, E, root = map(int, input().split())
visited = [False] * V
nodes = [[] for i in range(V)]
cost = [[] for i in range(V)]
for i in range(E):
    s, t, d = map(int, input().split())
    nodes[s].append(t)
    cost[s].append(d)

dist = [float('inf')] * V
dist[root] = 0

h = [(0, root)]
while h:
    c, v = heapq.heappop(h)
    if visited[v]:
        continue
    visited[v] = True
    for i in range(len(nodes[v])):
        t = nodes[v][i]
        if dist[t] > c + cost[v][i]:
            dist[t] = c + cost[v][i]
        if not visited[t]:
            visited[v] = True
            heapq.heappush(h, (c + cost[v][i], t))

for i in range(V):
    if dist[i] == float('inf'):
        print('INF')
    else:
        print(dist[i])

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

using namespace std;

int main() {
    long long n, a, b;
    cin >> n >> a >> b;

    long long ans;
    if (b < a || (n == 1 && a != b)) {
        ans = 0;
    } else {
        ans = (n - 2) * (b - a) + 1;
    }

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

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

//vector…可変長、データの大きさに合わせてサイズを変える
//list…双方向リスト、要素を挿入、削除の多いとき
//forward_list
//array…固定長配列
//set…集合
//multiset
//bitset…2進数、固定長ビット列
//map…連想配列、キーと値を関連付ける
//multimap
//deque
//stack…FILO
//queue…FIFO
//priority_queue
//pair…二つの値を一組
//tuple…複数の値を一組

template<typename T>
void remove(std::vector<T>& vector, char index) {
    vector.erase(vector.begin() + index);
}

template<class T>
T ma(std::vector<T> &v) {
    T maxi = 0;
    for(auto &i:v) maxi = max(maxi, i);
    return maxi;
}

template<class T>
T mi(std::vector<T> &v) {
    T mini = 0;
    for(auto &i:v) mini = min(mini, i);
    return mini;
}

template <class T>
T pow(T x, T y, T n = numeric_limits<T>::max()) {
    if(y == 0) return 1;
    if(y % 2 == 0) return pow((x * x) % n, y / 2);
    return (x * pow(x, y - 1)) % n;
}

#define rep(i, n, m) for (int i = n; i <= m; i++)
#define Rep(i, n, m) for (int i = m; i >= 1; i--)

typedef long long ll;
typedef unsigned long long ull;

ull ans = 0;
/*
int gcd(int x, int y) {
    if (x < y) swap(x, y);
    return !y ? x : gcd(x % y, y);
}
*/
 int main() {
    int a, b;
    cin >> a >> b;
    if (a <= 5) {
        cout << 0 << endl;
    } else if (6 <= a && a <= 12) {
        cout << b / 2 << endl;
    } else {
        cout << b << endl;
    }
}

Measured memory_bytes: 256
class Knapack(object):
    def __init__(self, data, limit):
        self.limit = limit
        data_size = len(data)
        self.C = [[0]*(limit+1) for _ in range(data_size+1)]
        self.data = data[:]

    def solve(self):
        for i in range(1, len(self.data)+1):
            i_value = self.data[i-1][0]
            i_weight = self.data[i-1][1]
            for w in range(1, self.limit+1):
                if i_weight <= w:
                    if i_value + self.C[i-1][w-i_weight] > self.C[i-1][w]:
                        self.C[i][w] = i_value + self.C[i-1][w-i_weight]
                    else:
                        self.C[i][w] = self.C[i-1][w]
                else:
                    self.C[i][w] = self.C[i-1][w]


if __name__ == '__main__':
    # ??????????????\???
    # limit = 50
    # data = [[60, 10], [100, 20], [120, 30], [210, 45], [10, 4]]
    case_no = 1
    while True:
        limit = int(input())
        if limit == 0:
            break
        num_of_items = int(input())
        data = []
        for i in range(num_of_items):
            data.append(list(map(int, input().split(','))))

        # ????????????????????????????§£???
        ks = Knapack(data, limit)
        ks.solve()

        # ???????????¨???
        target = ks.C[len(data)][limit]
        weight = limit
        for w in range(limit, 0, -1):
            if ks.C[len(data)][w] == target:
                weight = w
        print('Case {0}:'.format(case_no))
        print('{0}\n{1}'.format(target, weight))
        case_no += 1

Measured memory_bytes: 19032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;

int main(){
  string s;cin>>s;
  bool flag=1;
  rep(i,s.size()){
    if((i+1)%2){
      if(s[i]=='L')flag=0;
    }
    else{
      if(s[i]=='R')flag=0;
    }
  }
  cout<<(flag?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

int N, M;
int a[200010];
int b[200010];
bool l[200010] = {};

signed main()
{
	cin >> N >> M;
	for (int i = 1; i <= M; i++)
	{
		cin >> a[i] >> b[i];
	}

	for (int i = 1; i <= M; i++)
	{
		if (b[i] == N)
		{
			l[a[i]] = true;
		}
	}

	for (int i = 1; i <= M; i++)
	{
		if (a[i] == 1)
		{
			if (l[b[i]])
			{
				cout << "POSSIBLE" << endl;
				return 0;
			}
		}
	}

	cout << "IMPOSSIBLE" << endl;
}

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

int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v.at(i);
	int count = 0;
	int next = 0;
	rep(i, n) {
		count++;
		if (v.at(next) == 2) {
			cout << count << "\n";
			return (0);
		}
		else
			next = v.at(next) - 1;
	}
	cout << "-1\n";
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

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

//入力変数
int c[] = new int[9];
for(int i = 0;i<9;i++){
c[i]=sc.nextInt();
}

//入力値変換

//出力変数
String ans;

//計算
if(
c[0]-c[1]==c[3]-c[4]&&
c[0]-c[1]==c[6]-c[7]&&
c[2]-c[1]==c[5]-c[4]&&
c[2]-c[1]==c[8]-c[7]&&
c[0]-c[3]==c[1]-c[4]&&
c[0]-c[3]==c[2]-c[5]&&
c[4]-c[7]==c[3]-c[6]&&
c[5]-c[8]==c[3]-c[6]
){
ans="Yes";
}else{
ans="No";
}

//出力
System.out.println(ans);

}
}


Measured memory_bytes: 24788
#include<bits/stdc++.h>
using namespace std;
#define int long long int
std::vector<int> wt;
std::vector<int> val;
std::vector<std::vector<int>> dp;
int w,n;


int helper(int currwt, int index){
	if(currwt > w)
		return INT_MIN;
	if(index == n)
		return 0;
	int res =0;
	if(dp[currwt][index] != -1)
		return dp[currwt][index];

	if(currwt+wt[index] <= w){
		res = max(helper(currwt+wt[index], index+1)+val[index], helper(currwt, index+1));
	}else
	    res = (helper(currwt, index+1));

	 dp[currwt][index] = res;

	 return res;
}

signed main()
{
	cin>>n>>w;
	val.clear();
	val.resize(n);
	wt.clear();
	wt.resize(n);
	dp.clear();
	dp.resize(w+1,std::vector<int>(n+1,-1));
	for(int i =0; i<n; i++){
		cin>>wt[i]>>val[i];
	}
	cout<<helper(0,0);
	/* code */
	return 0;
}

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

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 100 + 17;

int n, a[MAXN], ans;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		cnt++;
		if (a[i] != a[i + 1])
			ans += cnt / 2, cnt = 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
  	int ans=0;
    int now=0;
    string s;
	cin >> s;
    fr(i,s.length()){
      if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C')now++;
      else{
        if(ans<now)ans=now;
        now=0;
      }
    }
  	if(ans<now)ans=now;
  	cout << ans << endl;
}


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

signed main(){
    int N;
    int ans=0;
    cin >>N;
    vector<int>vec(N);
    REP(i,N){
        cin >>vec[i];
    }
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            ans+=vec[i]*vec[j];
        }
    }
    cout <<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(begin(x), end(x)), end(x))
using namespace std;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<pair<int, int>>;
using VTIII = vector<tuple<int, int, int>>;
using Complex = complex<double>;
template<typename T> inline bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a==b)){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a==b)){ a=b; return true; } return false; }
template<typename T> inline bool isin(const T& x, const T& l, const T& r){ return l <= x and x < r; }
inline ostream& fcout(int n = 10){ return cout << fixed << setprecision(n); }
inline ostream& rcout(int n = 2){ return cout << right << setw(n); }
constexpr int64_t INF = numeric_limits<int64_t>::max();
constexpr int32_t INF32 = numeric_limits<int32_t>::max();
constexpr int64_t MOD = 1000000007LL;
constexpr double PI = 3.14159265358979323846264338327950288;
constexpr double EPS = 1e-10;


int H, W, K;


int dfs(VI& row, int p){
    if(p == W) return 0;
    if(p+1 < W and row[p] == row[p+1]) return dfs(row, p+1)+1;
    return 1;
}


int del(VVI& brd){
    int res = 0;
    rep(i, 0, H){
        int j = 0;
        while(j < W){
            int c = dfs(brd[i], j);
            if(c >= K){
                res += brd[i][j]*c;
                rep(k, j, j+c) brd[i][k] = 0;
            }
            j += c;
        }
    }
    return res;
}


void drop(VVI& brd){
    repr(i, H-1, 0) rep(j, 0, W){
        if(brd[i][j] == 0) continue;
        int c = 0;
        rep(k, i+1, H) if(brd[k][j] == 0) c++;
        swap(brd[i][j], brd[i+c][j]);
    }
}


int32_t main(){
    cin >> H >> W >> K;
    VVI brd(H, VI(W));
    rep(i, 0, H){
        string s;
        cin >> s;
        rep(j, 0, W) brd[i][j] = s[j]-'0';
    }

    int ans = 0;
    rep(i, 0, H) rep(j, 0, W){
        int s = 0, c;
        auto b = brd;
        b[i][j] = 0;
        drop(b);
        int p2 = 1;
        while(c = del(b), c) s += c*p2, drop(b), p2 <<= 1;
        chmax(ans, s);
    }

    cout << ans << endl;

    return 0;
}

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

ll power(ll a, ll n, ll mod){
	if(a==1)return 1;
	ll p = 1;
	while(n>0){
		if(n&1){p *= a;}
		a = a*a % mod;
		p %= mod;
		n = n>>1;
	}
	return p;
}


int main(){
	const int MOD = 1e9+7;
	int X,Y;
	cin >> X >> Y;

	ll n = (2*Y-X)/3;
	ll m = (2*X-Y)/3;
	if((X+Y)%3 != 0 || n<0 || m<0){ cout<<0<<endl; return 0; }
	ll fact = 1;
	for(ll i=n+m; i>m; i--){
		fact = fact * i % MOD;
	}

	ll nume = 1;
	for(ll i=n; i>0; i--){
		nume = nume * i % MOD;
	}
	nume = power(nume,MOD-2,MOD);

	cout << fact * nume % MOD << endl;
}


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

bool f() {
    std::vector<int> v(256);
    std::string s;
    std::cin >> s;
    for (auto c : s) {
        if (v[c]) return false;
        v[c] = 1;
    }
    return true;
}

int main() {
    std::cout << (f() ? "yes" : "no") << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rint register int
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
const int mo = 1e9 + 7;
const int N = 3e5 + 233;
struct Point {
  int x, v;
}p[N];
int n, v[N], v_cnt = 0, L[N], R[N], ord[N];

inline bool cmp_x(Point a, Point b) {
  return a.x < b.x || a.x == b.x && a.v < b.v;
}

namespace bit {
  int tr[N];
  inline void add(int x, int val) {
    for (; x <= n + 1; x += x & -x)
      tr[x] = (tr[x] + val) % mo;
  }
  inline int query(int x) {
    int ans = 0;
    for (; x; x -= x & -x)
      ans = (ans + tr[x]) % mo;
    return ans;
  }
  inline int get(int l, int r) {
    if (l > r) return 0;
    ++ l; ++ r;
    return (query(r) - query(l - 1) + mo) % mo;
  }
}

main(void) {
  read(n);
  for (int i = 1; i <= n; i ++) {
    read(p[i].x); read(p[i].v);
    v[++ v_cnt] = p[i].v;
  }
  sort(v + 1, v + v_cnt + 1);
  v_cnt = unique(v + 1, v + v_cnt + 1) - v - 1;
  for (int i = 1; i <= n; i ++)
    p[i].v = lower_bound(v + 1, v + v_cnt + 1, p[i].v) - v;
  sort(p + 1, p + n + 1, cmp_x);
  int mx = 0;
  for (int i = 1; i <= n; i ++) {
    R[i] = mx = max(p[i].v, mx);
  }
  int mn = n;
  for (int i = n; i >= 1; i --) {
    L[i] = mn = min(p[i].v, mn);
  }
  for (int i = 1; i <= n; i ++)
    ord[i] = i;
  auto cmp_LR = [] (int a, int b) {
                  return L[a] < L[b] || L[a] == L[b] && R[a] < R[b];
                };
  sort(ord + 1, ord + n + 1, cmp_LR);
  bit::add(0 + 1, 1);
  for (int i = 1; i <= n; i ++) {
    int p = bit::get(L[ord[i]] - 1, R[ord[i]]);
    bit::add(R[ord[i]] + 1, p);
    // cout << p << "\n";
  }
  cout << bit::get(n, n) << "\n";
  // for (int i = 1; i <= n; i ++)
  //   cout << p[i].x << " " << p[i].v << "\n";
  // puts("");
  // for (int i = 1; i <= n; i ++)
  //   cout << L[i] << " " << R[i] << "\n";
}


Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll MOD = 1000000007;
ll inv[100010];
ll fac[100010];
ll invFac[100010];

void init() {
  inv[1] = 1;
  for (int i = 2; i < 100010; i++) {
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
  }
  fac[0] = invFac[0] = 1;
  for (int i = 1; i < 100010; i++) {
    fac[i] = fac[i-1] * i % MOD;
    invFac[i] = invFac[i-1] * inv[i] % MOD;
  }
}

ll comb(int n, int k) {
  if (n < 0 || k < 0 || n < k) return 0;
  return fac[n] * invFac[k] % MOD * invFac[n-k] % MOD;
}

int n;
int a[100010];
int num[100010];
int m, p, q;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  init();
  cin >> n;
  for (int i = 0; i < n+1; i++) {
    cin >> a[i];
    num[a[i]]++;
    if (num[a[i]] == 2) m = a[i];
  }
  p = q = -1;
  for (int i = 0; i < n+1; i++) {
    if (a[i] == m) {
      if (p < 0) p = i;
      else q = i;
    }
  }
  for (int i = 1; i <= n+1; i++) {
    ll sum = comb(n-1, i);
    sum += 2 * comb(n-1, i-1) % MOD;
    sum %= MOD;
    sum += MOD - comb(p+(n-q), i-1);
    sum %= MOD;
    sum += comb(n-1, i-2);
    sum %= MOD;
    cout << sum << endl;
  }

  return 0;
}

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


public class A
{
    static long mod = 1000000007;
    static long sumXOR(long[] arr, int n)
    {
        long sum = 0;
        for (int i = 0; i < 64; i++)
        {
            // Count of zeros and ones 
            long zc = 0, oc = 0;

            // Individual sum at each bit position 
            long idsum = 0;

            for (int j = 0; j < n; j++)
            {
                if (arr[j] % 2 == 0)
                    zc++;

                else
                    oc++;
                arr[j] /= 2;
            }

            // calculating individual bit sum  
            idsum = (((long)1 << i) % mod);
            idsum =  (idsum * zc) % mod ;
            idsum = (idsum * oc) % mod;

            // final sum  
            sum = (sum + idsum) % mod;
        }
        return sum;
    }
    public static void Main(string[] args)
    {
        int t = 1;
        while (t > 0)
        {
            int n = int.Parse(Console.ReadLine());
            var arr = Console.ReadLine().Trim().Split().Select(x => long.Parse(x)).ToArray();
            
            
            Console.WriteLine(sumXOR(arr,n));
            t--;
        }
    }
}

Measured memory_bytes: 59088
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n;
string s,t;
signed main(){
	cin>>s>>t;
	vector<string> v;
	rep(i,s.size()-t.size()+1){
		int f=1;
		rep(j,t.size()){
			if(t[j]!=s[i+j] && s[i+j]!='?')f=0;
		}
		if(f){
			string r=s;
			rep(j,t.size()){
				r[i+j]=t[j];
			}
			rep(j,r.size()){
				if(r[j]=='?')r[j]='a';
			}
			v.push_back(r);
		}
	}
	sort(v.begin(),v.end());
	if(v.size()==0)cout<<"UNRESTORABLE"<<endl;
	else cout<<v[0]<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;

    map<ll, ll> cnt;
    ll sum = 0;
    F0R(i, N) {
        ll cur; cin >> cur;
        cnt[cur]++; sum += cur;
    }
    int Q; cin >> Q;
    F0R(i, Q) {
        ll B, C; cin >> B >> C;
        sum -= cnt[B] * B;
        sum += cnt[B] * C;
        cnt[C] += cnt[B];
        cnt[B] = 0;
        cout << sum << nl;
    }


	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343


Measured memory_bytes: 9504
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  ll i, j, k, l, q, n, m, sum=0;
  cin>>n;
  int a[100001];
  for(i=0; i<=100000; i++)a[i]=0;
  for(i=0; i<n; i++){
    cin>>j;
    a[j]++;
    sum+=j;
  }
  cin>>q;
  for(i=0; i<q; i++){
    cin>>j>>k;
    sum+=(a[j]*(k-j));
    a[k]+=a[j];
    a[j]=0;
    printf("%lld\n", sum);
  }
  return 0;
}

Measured memory_bytes: 4108
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');     
            int a = Int32.Parse(input[0]); 
            int b = Int32.Parse(input[1]); 
            int c = Int32.Parse(input[2]);

            if((a <= c && c <= b) || (b <= c && c <= a))
            {
                Console.WriteLine("Yes");
                return;
            }

            Console.WriteLine("No");
        } 
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<utility>
#include<cmath>
using namespace std;
#define all(a) a.begin(),a.end()
double calc(double a,double b,double c)
{
	double s=(a+b+c)/2;
	return sqrt(s*(s-a)*(s-b)*(s-c));
}

int main()
{
	int m,n;
	
	while(cin>>m&&m)
	{
		double a=0,b=0;
		double r=2*M_PI;
		for(int i=0;i<m-1;i++)
		{
			double v;cin>>v;
			v*=2.0*M_PI/360;
			r-=v;
			a+=calc(sin(v/2)*2,1,1);
		}
		a+=calc(sin(r/2)*2,1,1);
		cin>>n;
		r=2*M_PI;
		for(int i=0;i<n-1;i++)
		{
			double v;cin>>v;
			v*=2.0*M_PI/360;
			r-=v;
			b+=calc(sin(v/2)*2,1,1);
		}
		b+=calc(sin(r/2)*2,1,1);
		if(fabs(a-b)<1e-15)cout<<0<<endl;
		else if(a>b)cout<<1<<endl;
		else cout<<2<<endl;
	}
}

Measured memory_bytes: 3392
#include<bits/stdc++.h>
#include<stdio.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define pb                  push_back
#define arr                 vector<ll>
#define mem(x,val)          memset(x,val,sizeof(x))
#define vp                 vector<pair<ll,ll>>
#define matrix              vector<vector<ll> >
#define digit(x)            floor(log10(x))+1
#define debug(x)            cerr << #x << " is " << x << endl;
#define all(a)              a.begin(),a.end()
#define fixed               setprecision(15)
// ll dx[]={-1,1,0,0},dy[]={0,0,-1,1}; 4 Sides
//ll dx[]={-1,1,-1,1,0,0,-1,1} , dy[]={-1,1,0,0,-1,1,1,-1};    8 Sides
using namespace std;
arr read(ll n){
    arr a;
    for (ll i=0;i<n;i++){
        ll x;
        cin>>x;
        a.pb(x);
    }
    return a;
}

  int main(){
          double a,b,h,m;
          cin>>a>>b>>h>>m;
          double ma=6*m;
          double ha=30*h + m/2.0;
          double mama = abs(ma - ha);
          if (mama > 180){
               mama = 360 - mama;
          }
          double c = a*a+b*b-2*a*b*cos(mama*3.1415926535897932/180.0);
           double ans = sqrt(c);
            cout<<setprecision(15)<<ans<<endl;
        return 0;
}


Measured memory_bytes: 4172
dice = input().split()
roll = input()
for s in roll:
    if s == "N":
        next = list("263415")
    elif s == "E":
        next = list("421653")
    elif s == "S":
        next = list("513462")
    else:
        next = list("326154")

    tmp = [0] * 6
    for i, n in enumerate(next):
        tmp[i] = dice[int(n) - 1]
    dice = tmp
print(dice[0])



Measured memory_bytes: 5600
def solve():
  D = int(input())
  C = list(map(int, input().split()))
  S = [list(map(int, input().split())) for _ in range(D)]

  ans = [0]*D
  points = [0]*26
  last = [-1]*26
  for d in range(D):
    for i in range(26):
      points[i] = S[d][i]+C[i]*(d-last[i])*(d-last[i]+1)//2
    maxi = 0
    for i in range(26):
        if points[i]>maxi:
            con = i
            maxi = points[i]
    ans[d] = con+1
    last[con] = d
  
  return ans
print(*solve(),sep='\n')

Measured memory_bytes: 9400