akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll; 

int N;
const int MAX_N = 10;
int L[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> L[i];
    sort(L, L + N);
    int sum = 0;
    for (int i = 0; i < N - 1; i++) sum += L[i];
    if (sum > L[N-1]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;    
}

Measured memory_bytes: 256
from scipy.sparse.csgraph import floyd_warshall
import itertools

n, m, r = map(int, input().split())
v = list(map(int, input().split()))
v = [i - 1 for i in v]


graph = [[float('inf') for i in range(n)] for i in range(n)]

for i in range(m):
    a, b, c = map(int, input().split())
    graph[a-1][b-1] = c
    graph[b-1][a-1] = c

tip_graph = floyd_warshall(csgraph = graph, directed = False, return_predecessors = False)

ans = 10 ** 9
tmp = 0

for i in list(itertools.permutations(v,r)):
    tmp = 0
    for j in range(r-1):
        tmp += tip_graph[i[j]][i[j+1]]
    ans = min(ans, tmp)
print(int(ans))


Measured memory_bytes: 22992
n=int(input())
a=list(map(int,input().split()))
flag=True
for i in range(n):
  t=a[i]
  if t%2==1 or t%3==0 or t%5==0:
    continue
  else:
    flag=False
    break
if flag:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 9140
package main

import (
	"fmt"
)

func main() {
	var S string
	fmt.Scanf("%s", &S)
	switch S {
	case "SUN":
		fmt.Println(7)
	case "MON":
		fmt.Println(6)
	case "TUE":
		fmt.Println(5)
	case "WED":
		fmt.Println(4)
	case "THU":
		fmt.Println(3)
	case "FRI":
		fmt.Println(2)
	default:
		fmt.Println(1)
	}
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<iostream>
#define INF 1000000
void cWarshall_Floyd();
void tWarshall_Floyd();
int glid_cost[101][101];
int glid_tim[101][101];
int n,m,a,b,tim,cost,qs,p,q,r;
using namespace std;
void cWarshall_Floyd()
{
	int i,j,k;
	for(k=0;k<m;k++) {
		for(i=0;i<m;i++) {
			for(j=0;j<m;j++) {
				glid_cost[i][j]=min(glid_cost[i][j],glid_cost[i][k]+glid_cost[k][j]);
			}
		}
	}
}
void tWarshall_Floyd()
{
	int i,j,k;
	for(k=0;k<m;k++) {
		for(i=0;i<m;i++) {
			for(j=0;j<m;j++) {
				glid_tim[i][j]=min(glid_tim[i][j],glid_tim[i][k]+glid_tim[k][j]);
			}
		}
	}
}
int main(void)
{
	ios::sync_with_stdio(false);
	int i,j,k;
	while(1) {
		cin>>n>>m;
		if(n==0&&m==0) break;
		for(i=0;i<m;i++) {
			for(j=0;j<m;j++) {
				glid_cost[i][j]=INF;
				glid_tim[i][j]=INF;
			}
		}
		for(i=0;i<m;i++) {
			glid_cost[i][i]=0;
			glid_tim[i][j]=0;
		}
		for(i=0;i<n;i++) {
			cin>>a>>b>>cost>>tim;
			a--;b--;
			glid_cost[a][b]=cost;
			glid_cost[b][a]=cost;
			glid_tim[a][b]=tim;
			glid_tim[b][a]=tim;
		}
		cWarshall_Floyd();
		tWarshall_Floyd();
		cin>>qs;
		for(i=0;i<qs;i++) {
			cin>>p>>q>>r;
			p--;q--;
			if(r==0) cout<<glid_cost[p][q]<<endl;
			else cout<<glid_tim[p][q]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T>
void out(T x) { cout << x << endl; }
ll fast_pow(ll a, ll b, ll p) {ll c = 1; while(b) { if(b & 1) c = c * a % p; a = a * a % p; b >>= 1;} return c;}
ll exgcd(ll a, ll b, ll &x, ll &y) { if(!b) {x = 1; y = 0; return a; } ll gcd = exgcd(b, a % b, y, x); y-= a / b * x; return gcd; }
const int N = 2000 + 5;
int sum[N][N], sum_col[N][N], sum_row[N][N];
char str[N][N];
int main()
{
    ios::sync_with_stdio(false);
    int n, m, q;
    cin >> n >> m >> q;
    for(int i = 1; i <= n; i ++)
        cin >> (str[i] + 1);
    memset(sum, 0, sizeof(sum));
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= m; j ++)
        {
            sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + str[i][j] - '0';
            sum_col[i][j] = sum_col[i - 1][j] + sum_col[i][j - 1] - sum_col[i - 1][j - 1] + (str[i][j] - '0') * (str[i][j - 1] - '0'); 
            sum_row[i][j] = sum_row[i - 1][j] + sum_row[i][j - 1] - sum_row[i - 1][j - 1] + (str[i][j] - '0') * (str[i - 1][j] - '0'); 
        }
    while(q --)
    {
        int x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        int ans = sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1];
        int bns = sum_col[x2][y2] - sum_col[x1 - 1][y2] - sum_col[x2][y1] + sum_col[x1 - 1][y1] + sum_row[x2][y2] - sum_row[x1][y2] - sum_row[x2][y1 - 1] + sum_row[x1][y1 - 1];
        cout << ans - bns << endl;
    }
}


Measured memory_bytes: 52864
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int[] num = new int[1000003];
		int i, j, cnt = 0, flg;
		for (i = 2; i <= 1000000; i++) {
			flg = 0;
			for (j = 2; j <= i/j; j++) {
				if (i % j == 0) {
					flg++;
					break;
				}
			}
			if(flg == 0) {
				cnt++;
			}
			num[i] = cnt;
		}
		Scanner scanner = new Scanner(System.in);
		int n=0;
		while(scanner.hasNext()) {
			n = scanner.nextInt();
			System.out.println(num[n]);
			}
		scanner.close();
	}

}



Measured memory_bytes: 30348
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		int N = Integer.parseInt(W);
		W = in.readLine();
		String[] Ws = W.split(" ");
		int[] P = new int[N];

		int count = 0;
		for(int i=0;i<N;i++){
			P[i] = Integer.parseInt(Ws[i]);
			if(i+1 != P[i])
				count++;
		}

		if(count >= 3){
			System.out.println("NO");
		}else{
			System.out.println("YES");
		}



	}

}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main() {
    ll h,w;

    cin >> h >> w;

    vector<vector<bool>> a(h+1, vector<bool>(w+1, true));
    vector<vector<ll>> sol(h+1, vector<ll>(w+1, 0));

    char cell;
    for (ll i=1; i<=h; i++) {
        for (ll j=1; j<=w; j++) {
            cin >> cell;

            if (cell == '.') {
                a[i][j] = true;
            } else {
                a[i][j] = false;
            }
        }
    }

    sol[0][1] = 1;
    for (ll i=1; i<=h; i++) {
        for (ll j=1; j<=w; j++) {
            if (a[i-1][j]) {
                sol[i][j] = ((sol[i][j]%MOD) + (sol[i-1][j]%MOD))%MOD;
            }

            if (a[i][j-1]) {
                sol[i][j] = ((sol[i][j]%MOD) + (sol[i][j-1]%MOD))%MOD;
            }
        }

    }

    cout << sol[h][w] << endl;

    return 0;
}

Measured memory_bytes: 8320
from itertools import combinations

n = int(input())
# 先頭文字だけが問題なので先頭文字について辞書で管理
march = ['M', 'A', 'R', 'C', 'H']
d = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}
for _ in range(n):
    s = input()
    if s[0] in march:
        d[s[0]]= d.get(s[0], 0) + 1

cnt = 0
# 'MARCH'から 3 つ選ぶのは 10 通り
for a, b, c in combinations('MARCH', 3):
    cnt += d[a] * d[b] * d[c]

print(cnt)

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

using namespace std;

//#define _FILES
#define PB push_back
#define MP make_pair
#define X first
#define Y second
const int MAXN = 55;
int a[MAXN];
vector< pair<int,int> > ans;
int main()
{
    ios_base::sync_with_stdio(false);

    #ifdef _FILES
        freopen("","r",stdin);
        freopen("","w",stdout);
    #endif // _FILES
    int n;
    cin >> n;
    pair<int,int> mx = MP(-10000000, -1);
    pair<int,int> mn = MP(10000000, -1);

    for (int i=1;i<=n;i++)
    {
        cin >> a[i];
        if (a[i] > mx.X)
        {
            mx = MP(a[i], i);
        }

        if (a[i] < mn.X)
        {
            mn = MP(a[i], i);
        }
    }

    if (mn.X >= 0)
    {
        for (int i=1;i<n;i++)
        {
            ans.push_back(MP(i, i+1));
        }
    }
    else if (mx.X <= 0)
    {
        for (int i=n;i>1;i--)
        {
            ans.push_back(MP(i, i-1));
        }
    }
    else
    {
        if (abs(mn.X) >= mx.X)
        {
            for (int i=1;i<=n;i++)
            {
                if (i != mn.Y) ans.push_back(MP(mn.Y, i));
            }

            for (int i=n;i>1;i--)
            {
                ans.push_back(MP(i, i-1));
            }
        }
        else
        {
            for (int i=1;i<=n;i++)
            {
                if (i != mx.Y) ans.push_back(MP(mx.Y, i));
            }

            for (int i=1;i<n;i++)
            {
                ans.push_back(MP(i, i+1));
            }
        }
    }
    cout << ans.size() << endl;
    for (int i=0;i<ans.size();i++)
    {
        cout << ans[i].X << " " << ans[i].Y << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll INFl = 1e18;
typedef pair<int,int> pii;
typedef vector<int> vi;

ll tab[200005];
ll odl[200005];
bool vis[200005];

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	ll n, k; cin >> n >> k;
	for (int i = 1; i <= n; i ++) {
		cin >> tab[i];
	}
	if (tab[1] == 1) {
		cout << 1 << '\n';
		return 0;
	}
	if (k <= n) {
		int v = 1;
		while (k) {
			v = tab[v];
			k --;
		}
		cout << v << '\n';
		return 0;
	}
	
	ll cnt = 1;
	ll now = tab[1];
	vis[1] = true;
	odl[1] = 0;
	if (now != 1) odl[now] = 1;
	ll x = 1;
	while (true) {
		cnt ++;
		vis[now] = true;
		x = now;
		now = tab[now];
		if (vis[now]) break;
		odl[now] = odl[x] + 1;
	}
	k -= odl[now];
	cnt -= odl[now];
	k %= cnt;
	while (k > 0) {
		now = tab[now];
		k --;
	}
	
	cout << now << '\n';
	return 0;
}


Measured memory_bytes: 7012
#include <stdio.h>

#define min(a, b) a<b ? a : b

long pow(long x, long y){
    long ret = 1;
    for(long i=0;i<y;i++){
        ret *= x;
    }
    return ret;
}

int main(void){

    long n;
    scanf("%ld", &n);

    long x[n];
    for(long i=0;i<n;i++){
        scanf("%ld", &x[i]);
    }

    long ps[100] = {0};
    for(long p=0;p<100;p++){
        for(long i=0;i<n;i++){
            ps[p] += pow((x[i]-p), 2);
        }
    }

    long res = ps[0];
    for(long i=1;i<100;i++){
        res = min(res, ps[i]);
    }
    printf("%ld\n", res);

    return 0;
}

Measured memory_bytes: 128
// Akshit Awasthi
#include <bits/stdc++.h>
#define int long long
#define float long double
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define all(x) x.begin(), x.end()
#define deb(...) cerr << "[" << #__VA_ARGS__ << ": " << (__VA_ARGS__) << "]\n"
#define deb2(x, y) cerr << #x << " = " << x << "\t" << #y << " = " << y << endl
#define fastio                    \
    std::ios::sync_with_stdio(0); \
    std::cin.tie(NULL);           \
    std::cout.tie(NULL)
#define mod1 1000000007
#define mod2 998244353
#define mod mod1
#define MAX 200015
using namespace std;

template <class T>
istream &operator>>(istream &stream, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++)
        stream >> v[i];
    return stream;
}
template <class T1, class T2>
istream &operator>>(istream &stream, pair<T1, T2> &p) {
    return stream >> p.first >> p.second;
}
template <class T>
ostream &operator<<(ostream &stream, const vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++)
        stream << v[i] << ' ';
    stream << '\n';
    return stream;
}
template <class T1, class T2>
ostream &operator<<(ostream &stream, const pair<T1, T2> &pair) {
    return stream << pair.first << ' ' << pair.second;
}
int pow(int a, int n) {
    if (n < 0)
        return 0;
    int ans = 1;
    while (n) {
        if (n & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ans;
}
int __lcm(int a, int b) { return (a / __gcd(a, b)) * b; }
int fact(int n) { return n == 0 ? 1LL : n * fact(n - 1) % mod; }
int inverse(int x, int p = mod) { return pow(x, p - 2); }
int nck(int n, int k, int p = mod) {
    return fact(n) * inverse(fact(k), p) % p * inverse(fact(n - k)) % p;
}

void solve(void) {
    int n;
    cin >> n;
    vector<int> arr(n);
    cin >> arr;
    int ans = 0;
    sort(all(arr));
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                if (arr[i] == arr[j] || arr[j] == arr[k] || arr[i] == arr[k])
                    continue;
                if (arr[i] + arr[j] > arr[k])
                    ans++;
            }
        }
    }
    cout << ans << "\n";
}

int32_t main(void) {
#ifdef AKSHIT_PC
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
    fastio;
    // cout.setf(std::ios::unitbuf);
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        solve();
    }
    return 0;
}

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

int tmp[1000010] = {};
int main(){
  int s;
  cin >> s;

  int ans = 1;
  while(tmp[s] == 0){
    ans++;
    tmp[s] = 1;
    if(s % 2 == 0){
      s /= 2;
    }else{
      s = s*3+1;
    }
  }

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




Measured memory_bytes: 256
N,K= list(map(int, input().split()))
A= list(map(int, input().split()))
AA=sorted(A)
num=0
for i in A:
    num+=AA.index(i)
num2=0
for i in range(N-1):
    for j in range(i+1,N):
        if A[i]>A[j]:
            num2+=1
hoge=(K-1)*K//2%1000000007
hoge=hoge*num%1000000007
hoge2=num2*K%1000000007
hoge=(hoge+hoge2)%1000000007
print(hoge)

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

char s[1000000];
int main()
{
	cin >> s; 
	for(int i=0; i<strlen(s); ++i)
	{
		if(i%2==0)
			cout << s[i];
	}
	cout << endl;
	
	
	return 0;
}

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

#define int long long

const int N = 1e2 + 10;
int n, k, dp[N][N];

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	cout << n - k + 1;
}

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

#define mod 1000000007;

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    long long int ans=INT_MAX;
    for(long long int i=0;i<=s.size()-t.size();i++){
    	long long int c=0;
    	for(long long int j=0;j<t.size();j++){
    		if(s[j+i]!=t[j]){
    			c++;
			}
		}
		ans=min(ans,c);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
# define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;


int main() {
    int n, m; cin >> n >> m;
    long long ans = pow(2, m) * ((1900*m) + 100*(n-m));
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 888
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static ConsoleApp.Util;
using static System.Math;

namespace ConsoleApp
{
    class Program
    {

        static void Main(string[] args)
        {
            string s = ReadLine();
            s.Reverse();
            //
            int[,] dp = new int[s.Length+10,2];
            for (int i = 0; i < s.Length + 10;i++)
                for (int j = 0; j <= 1;j++)
                    dp[i, j] = 10000000;
            //最大の枚数は9*99 = 891枚に十分収まるはず

            //下から一つも桁が決まっていないときの Sum(A) +Sum(B) は0
            dp[0, 0] = 0;

            for (int i = 0; i < s.Length+1;i++)
            {
                for (int j = 0; j <= 1;j++)
                {
                    int b = 0;

                    int ni = (i < s.Length ? s[i] - '0':0);

                    for (int a = 0; a <= 9;a++)
                    {
                        int tmpA = a;
                        
                        if (j >= 1)
                        {
                            if(i == s.Length && a == 0)continue;
                            tmpA = a - 1;
                        }
                        if(tmpA >= ni){
                            b = tmpA - ni;
                            ChMin(ref dp[i + 1, 0] , a + b + dp[i,j]);
                        }
                        else{
                            b = tmpA - ni + 10;
                            ChMin(ref dp[i+1,1],a + b + dp[i,j]);
                        }
                    }
                }
            }

            WriteLine(dp[s.Length+1,0]  );
        }

    }


    static class Util
    {
        public static void ChMin(ref int a, int b)
        {

            if (a > b)
            {
                a = b;
            }
        }


        public static void ChMax(ref long a, long b)
        {
            if (a < b)
            {
                a = b;
            }
        }




    }
}


Measured memory_bytes: 22752
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    char c; cin>>c;
    cout << (char)(c+1) << endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll s, ans=1; cin>>s;
	set<ll> a;
	a.insert(s);
	ll la = s;
	while(true){
		ans++;
		ll f = (la%2==0)?(la/2):(3*la+1);
		if (a.count(f) == 1){
			break;
		}
		la = f;
		a.insert(f);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {

    ll h;
    cin >> h;

    ll cnt = 0;
    ll res = 1;
    ll ans = 0;
    while(h >= 1){
        h /= 2;
        cnt++;
        ans += res;
        res *= 2;
    }
    cout << ans << endl;
        
    return 0;
}

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

int main(){
    int n,temp;
    cin >> n;
    int n1 = 0;
    int n2 = 0;
    int n4 = 0;
    for(int i=0;i<n;i++){
        cin >> temp;
        if(temp%4==0)n4++;
        else if(temp%2==0)n2++;
        else n1++;
    }
    if(n4>=n1)cout << "Yes" << endl;
    else if(n1==n4+1&&n2==0)cout << "Yes" << endl;
    else{
        //cout << n1 << " " << n2 << " " << n4 << endl;
      cout << "No" << endl;   
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int   //used int to avoid mle
#define ulli unsigned long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define spl set<pll>
#define msl multiset <lli>
#define msp multiset <pll>
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define fbo find_by_order //returns iterator
#define fok order_of_key //return index
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
lli mod=998244353;
//string s=bitset<32>(n).to_string();
typedef tree<lli,null_type,less<lli>,rb_tree_tag, // change both to lli if set is req insted of multiset
tree_order_statistics_node_update> indexed_set;
int main()
{
	lli n;cin>>n;
	string s;
	cin>>s;
	lli r=0,g=0,b=0;
	for(lli i=0;i<n;i++){
		if(s[i]=='R')r++;
		else if(s[i]=='G')g++;
		else b++;
	}
	lli temp=r*g*b;
	//lli temp2=0;
	for(lli i=0;i<n;i++){
		for(lli j=i+1;j<n;j++){
			if(s[i]==s[j])continue;
			lli k=j+(j-i);
			if(k>=n)continue;
			if(s[k]==s[i] || s[k]==s[j])continue;
			temp--;
		}
	}
	cout<<temp;
	
    return 0;
}

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

int main(){
    int n, x;
    cin >> n >> x;
    if(x == 1 || x == 2*n-1){
        cout << "No" << endl;
    }else{
        deque<int> dq;
        dq.push_front(x);
        dq.push_front(x-1);
        dq.push_back(x+1);

        int m = 1;
        for(int i = 1;i <= 2*n-1;i++){
            if(abs(x-i) > 1){
                if(m > 0){
                    dq.push_front(i);
                }else{
                    dq.push_back(i);
                }
                m *= -1;
            }
        }

        cout << "Yes" << endl;
        for(int i = 0;i < 2*n-1;i++){
            cout << dq[i] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 2304
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#ifndef U_L_LONG
typedef unsigned long long U_L_LONG;
#endif
#ifndef L_LONG
typedef long long L_LONG;
#endif


static void B_eeee();

int main()
{
	B_eeee();
	
	fflush(stdout);
	return 0;
}

static void B_eeee()
{
	int N = 0, K = 0;
	char szS[16] = { 0 };

	scanf(" %d %s %d", &N, szS, &K);

	char target = szS[K - 1];

	for (int i = 0; i < N; i++) {
		if (szS[i] != target) {
			szS[i] = '*';
		}
	}

	printf("%s\n", szS);

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#include <atcoder/all>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N, Q;
	cin >> N >> Q;
	dsu d(N);
	rep(i, Q) {
		int t, u, v, ans;
		cin >> t >> u >> v;
		switch (t)
		{
		case 0:
			d.merge(u, v);
			break;
		case 1:
			ans = (d.same(u, v) ? 1 : 0);
			cout << ans << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 4004
#include<stdio.h>
int main(void){
    int a,b,c;
    int cnt;
    int cnt2=0;
    scanf("%d %d %d",&a,&b,&c);
    for(cnt=a;cnt<=b;cnt++){
        if(c%cnt==0)
            cnt2++;
    }
    printf("%d\n",cnt2);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define mod 1000000007

using namespace std;

int dp[101][4][4][4];

bool check(int i,int j,int k,int l)
{
    if(j==0 && k==2 && l==1)
        return 0;
    if(j==0 && k==1 && l==2)
        return 0;
    if(j==1 && k==0 && l==2)
        return 0;
    if(i==0 && k==1 && l==2)
        return 0;
    if(i==0 && j==1 && l==2)
        return 0;
    return 1;
}

int main()
{
    IOS;
    int n;
    cin>>n;
    dp[0][3][3][3]=1;
    for(int y=0;y<n;y++)
    {
        for(int i=0;i<4;i++)
        {
            for(int j=0;j<4;j++)
            {
                for(int k=0;k<4;k++)
                {
                    for(int l=0;l<4;l++)
                    {
                        if(check(i,j,k,l))
                        {
                            dp[y+1][j][k][l]+=dp[y][i][j][k];
                            dp[y+1][j][k][l]%=mod;
                        }
                    }
                }
            }
        }
    }
    int ans=0;
    for(int x=0;x<4;x++)
    {
        for(int y=0;y<4;y++)
        {
            for(int z=0;z<4;z++)
            {
                ans+=dp[n][x][y][z];
                ans%=mod;
            }
        }
    }
    cout<<ans<<"\n";
	return 0;
}


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


int main()
{

   int a,b,t,i,j,m,n=0;
   cin>>a>>m;

   for(i=22;i<=m;i++)
   {
       t=i/10;

        j=i%10;


       if(t>1 && j>1 && j*t<=a)
        n++;


   }


   cout<<n<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  int k=1,l=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]==k){
      l++;
      k++;
    }
  }
  if(k==1){
    cout << -1;
    return 0;
  }
  cout << n-k+1;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,d,cnt=0;
  int a,ans[105]={};
  cin>>n>>k;
  for(int i=0; i<k; i++){
    cin>>d;
    for(int j=0; j<d; j++){
      cin>>a;
      ans[a]=1;
    }
  }

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

  cout<<cnt<<'\n';
  return 0;
}


Measured memory_bytes: 3624
//
//AtCoder Beginner Contest 176
//A
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int n, x, t;
    cin >> n >> x >> t;

    int i = (n%x==0) ? 0 : 1;
    cout << ((n/x) + i) * t << endl;
    return 0;
}


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

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main()
{
    ll n;
    cin >> n;
    for(ll i = pow(n, 0.5); i >= 0; i--){
        if(n%i == 0){
            cout << i + n/i - 2 << endl;
            return 0;
        }
    }
    return 0;
}


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

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

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

using ll = long long;

ll C[51][51];
void comb(int n){
  REP(i,n+1) REP(j,i+1) {
    if (j == 0 || j==i) C[i][j] = 1;
    else C[i][j] = C[i-1][j-1] + C[i-1][j];
  }
}

int main() {
  ll n, a, b; cin >> n >> a >> b;
  vector<ll> v(n); REP(i,n) cin >> v[i];
  whole(sort,v,greater<ll>());
  comb(n);
  double ave = 0.0; REP(i,a) ave += v[i];
  ave /= (double)a;
  ll cnt1 = 0, cnt2 = 0;
  REP(i,n) {
    if (v[i] == v[a-1]) {
      cnt1++;
      if (i < a) cnt2++;
    }
  }
  ll ans = 0;
  if (cnt2 == a) {
    FOR(i,a,b+1) ans += C[cnt1][i];
  } else {
    ans += C[cnt1][cnt2];
  }
  cout << setprecision(20);
  cout << ave << endl;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    Node[] nodes = new Node[N];
    for (int i = 0; i < N; i++) nodes[i] = new Node(i);
    for (int i = 0; i < M; i++) {
      int a = scanner.nextInt() - 1;
      int b = scanner.nextInt() - 1;
      nodes[a].adjacent.add(nodes[b]);
    }

    List<Node> minLoop = null;
    for (int i = 0; i < N; i++) {
      Node src = nodes[i];
      int[] prev = new int[N];
      Arrays.fill(prev, -1);
      Queue<Node> queue = new LinkedList<>();
      for (Node n : src.adjacent) {
        prev[n.id] = src.id;
        queue.add(n);
      }
      while (!queue.isEmpty()) {
        Node n = queue.poll();
        if (n.id == src.id) {
          List<Node> path = restorePath(n, nodes, prev);
          if (minLoop == null || minLoop.size() > path.size()) minLoop = path;
          break;
        }
        for (Node a : n.adjacent) {
          if (prev[a.id] < 0) {
            prev[a.id] = n.id;
            queue.add(a);
          }
        }
      }
    }
    if (minLoop == null) {
      System.out.println(-1);
    } else {
      System.out.println(minLoop.size());
      for (Node n : minLoop) System.out.println(n.id + 1);
    }
  }

  private static List<Node> restorePath(Node node, Node[] nodes, int[] prev) {
    List<Node> res = new ArrayList<>();
    int src = node.id;
    do {
      res.add(node);
      node = nodes[prev[node.id]];
    } while (node.id != src);
    return res;
  }

  private static class Node {
    private final int id;
    private final List<Node> adjacent = new ArrayList<>();

    private Node(int id) {
      this.id = id;
    }
  }
}


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

	public static void main(String[] args) {
		int i1, i2;
		String op;
		Scanner sc = new Scanner(System.in);
		while(true){
			i1 = sc.nextInt();
			op = sc.next();
			i2 = sc.nextInt();
			if(op.equals("?"))
				break;
			else if(op.equals("+"))
				System.out.println(i1 + i2);
			else if(op.equals("-"))
				System.out.println(i1 - i2);
			else if(op.equals("*"))
				System.out.println(i1 * i2);
			else if(op.equals("/"))
				System.out.println(i1 / i2);
		}
	}

}

Measured memory_bytes: 18028
#include <stdio.h>
#include <string.h>

int main(void)
{
    int i,tmp=-1;
    char S[100001];
    int count[100001];
    int L_guusuu=0,L_kisuu=0,R_guusuu=0,R_kisuu=0;

    for(i=0; i<100001; i++) count[i] = 0;

    gets(S);

    int N;
    N = strlen(S);
    //printf("%d\n",N);

    for(i=0; i<N-1; i++){
        if(S[i] == 'L'){
            if(i%2 == 0){
                L_guusuu++;
            } else {
                L_kisuu++;
            }
        } else {
            if(i%2 == 0){
                R_guusuu++;
            } else {
                R_kisuu++;
            }
        }
        
        if(S[i] == 'R' && S[i+1] == 'L'){

            if(tmp != -1){
                if(tmp%2 == 0){
                    count[tmp] += L_guusuu;
                    count[tmp+1] += L_kisuu;
                } else {
                    count[tmp] += L_kisuu;
                    count[tmp+1] += L_guusuu;
                }
               
            }
        
            tmp = i;


            if(i%2 == 0){
                count[i] += R_guusuu;
                count[i+1] += R_kisuu;
            } else {
                count[i] += R_kisuu;
                count[i+1] += R_guusuu;
            }
            //printf("R_guusuu = %d\n",R_guusuu);
            //printf("R_kisuu = %d\n",R_kisuu);
            //printf("L_guusuu = %d\n",L_guusuu);
            //printf("L_kisuu = %d\n\n",L_kisuu);
            R_guusuu = 0;
            R_kisuu = 0;
            L_guusuu = 0;
            L_kisuu = 0;
            //for(int j=0; j<N; j++) printf("%d ",count[j]);
            //printf("\n");
        }
    }

     if(tmp%2 == 0){
        count[tmp] += L_guusuu;
        count[tmp+1] += L_kisuu;
    } else {
        count[tmp] += L_kisuu;
        count[tmp+1] += L_guusuu;
    }


    if((N-1)%2 == tmp%2){
        count[tmp]++;
    } else {
        count[tmp+1]++;
    }

       

    //for(i=0; i<N; i++) printf("%c",S[i]);
    for(i=0; i<N; i++) printf("%d ",count[i]);
    printf("\n");

    return 0;
}

Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, a, b) for (int64_t i = (a); i < (b); ++i)
const int MOD = 1e9 + 7;
typedef long long ll;
const long long INF = 1LL << 60;

int n, m;

struct UnionFind {
  vector<int> par;

  UnionFind(int N) : par(N) {
    for (int i = 0; i < N; i++) par[i] = i;
  }

  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
  }

  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    UnionFind d(n);
    for (int j = 0; j < m; j++) {
      if (j != i) d.unite(a[j], b[j]);
    }
    bool bridge = false;
    if (!d.same(a[i], b[i])) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

#define N 200001

int parent[N];
int visited[N];
ll num[N];
vector<vector<int>> edge(N, vector<int>(0));
int findroot(int a){
  if (parent[a] == a)
    return a;

  int newparent = findroot(parent[a]);
  parent[a] = newparent;
  return newparent;
}

void dfs(int cur){
  if (visited[cur])
    return;

  visited[cur] = 1;
  for (int i = 0; i < edge[cur].size(); i++){
    int u = findroot(cur);
    int v = findroot(edge[cur][i]);
    if (u != v){
      parent[v] = u;
      num[u] = num[u] + num[v];
    }
    dfs(edge[cur][i]);
  }
}

void init(){
  for (int i = 0; i < N; i++){
    parent[i] = i;
    num[i] = 1;
  }
}

int main(void){
  ll n, m;
  cin >> n >> m;
  
  for (int i = 0; i < m; i++){
    ll a, b;
    cin >> a >> b;
    
    a--; b--;
    edge[a].emplace_back(b);
    edge[b].emplace_back(a);
  }
  init();

  for (int i = 0; i < n; i++){
    dfs(i);
  }

  ll ans = 0;
  for (int i = 0; i < n; i++){
    ans = max(ans, num[i]);
  }
  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 32816
while(1):
    a, op, b = input().split()
    if op == '?':
        break
    elif op == '+':
        print(int(a) + int(b))
    elif op == '-':
        print(int(a) - int(b))
    elif op == '*':
        print(int(a) * int(b))
    elif op == '/':
        print(int(int(a) / int(b)))

Measured memory_bytes: 7660
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a, b;
  cin >> a >> b;
  vl x(3, 0);
  x[a - 1] = 1;
  x[b - 1] = 1;
  rep(i, 3) {
    if (x[i] == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        string s = NextString();
        //決め打ちでどうにかする
        if (Menagerie(s, N, 1, 1)) return;
        if (Menagerie(s, N, 1, -1)) return;
        if (Menagerie(s, N, -1, 1)) return;
        if (Menagerie(s, N, -1, -1)) return;
        Console.WriteLine(-1);
    }
    public static bool Menagerie(string s, int N, int a, int b)
    {
        int[] ans = new int[N + 1];
        ans[0] = a;
        ans[1] = b;
        for (int i = 1; i < N; i++)
        {
            if (ans[i] == 1)
            {
                if (s[i] == 'o') ans[i + 1] = ans[i - 1];
                else ans[i + 1] = -ans[i - 1];
            }
            else
            {
                if (s[i] == 'o') ans[i + 1] = -ans[i - 1];
                else ans[i + 1] = ans[i - 1];
            }
        }
        for (int i = 0; i < N; i++)
        {
            int n0 = (i - 1 + N) % N;
            int n1 = (i + 1 + N) % N;
            if (ans[i] == 1)
            {
                if (s[i] == 'o' && ans[n0] != ans[n1]) return false;
                else if (s[i] == 'x' && ans[n0] == ans[n1]) return false;
            }
            else
            {
                if (s[i] == 'o' && ans[n0] == ans[n1]) return false;
                else if (s[i] == 'x' && ans[n0] != ans[n1]) return false;
            }
        }
        if (ans[0] == ans[N])
        {
            for (int i = 0; i < N; i++) Console.Write(ans[i] == 1 ? "S" : "W");
            Console.WriteLine();
            return true;
        }
        else return false;
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13536
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.*;
 
public class Main {
	int S,z;
	long[] n;
	public void solve() {
		S = nextInt();
		z = S;
		while(z--> 0){
			n = new long[9];
			for(int i = 0;i < 9;i++){
				n[i] = Long.parseLong(next(),16);
			}
			long N9 = 0;
			for(int i = 0;i < 8;i++){
				N9 += n[i];
			}
			long K = 0;
			int a = (int)((N9&1)^1);
			int b = (int)((n[8]&1)^1);
			
			if(a == b){
				K = 0;
			}else{
				K = 1;
			}
			
			for(int i = 1;i < 32;i++){
				long zero = K;
				N9= 0;
				int xor = 0;
				for(int j = 0;j < 8;j++){
					N9 += (n[j] ^ zero);
				}
				
				a = (int)((N9 >> i)&1);
				b = (int)((n[8] >> i)&1);
				
				if(a == b){
					xor = 0;
				}else{
					xor = 1;
				}
				K = (K | ((long)xor << i));
			}
			
			out.println(Long.toHexString(K));
		}
	}
 
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}
 
	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;
 
	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}
 
	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}
 
	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}
 
	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}
 
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}
 
	public int nextInt() {
		return Integer.parseInt(next());
	}
 
	public long nextLong() {
		return Long.parseLong(next());
	}
 
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 25572
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX_N = 50;
int main(){
  int N,K;
  cin >> N >> K;
  int l[MAX_N];
  for(int i=0;i<N;i++){
    cin >> l[i];
  }
  sort(l, l+N, greater<int>());

  int ans=0;
  for(int i=0;i<K;i++){
      ans += l[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
#define ck(a,b) (0<=(a)&&(a)<(b))

using namespace std;

int main(){
	int N;
	cin>>N;
	REP(i,0,N){
		int y,m,d;
		int ans=0;
		cin>>y>>m>>d;
		while(y!=1000||m!=1||d!=1){
			d++;
			if(y%3){
				if(d>20-(m+1)%2) d=1,m++;
				if(m>=11) m=1,y++;
			}else{
				if(d>=21) d=1,m++;
				if(m>=11) m=1,y++;
			}
			ans++;
		}
		p(ans);
	}
	return 0;
}

Measured memory_bytes: 2996
#include <iostream>
#include <cstdio>
using namespace std;
long long n, a, b, d, s, x[100005];
int main() {
	cin>>n>>a>>b>>x[0];
	for(int i=1; i<n; i++) {
		scanf("%d", &x[i]);
		d = x[i] - x[i-1];
		if(d*a < b) s += d*a;
		else s += b;
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,k,res=1;
vi a;

void f(int x){
	vi b(n);
	for(int i=0;i<n;i++) b[i]=a[i]%x;
	sort(b.begin(),b.end());
	int I=0,J=n-1,S=0,T=0;
	while(I<n&&S+b[I]<=k) S+=b[I++];
	while(J>=0&&T+x-b[J]<=k) T+=x-b[J--];
	if(J<I) res=max(res,x);
}

int main(){
	cin>>n>>k;
	a=vi(n);
	int S=0;
	for(auto &i:a) cin>>i,S+=i;
	for(int i=1;i*i<=S;i++) if(S%i==0){
		f(i);
		if(i*i!=S) f(S/i);
	}
	cout<<res<<endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }
  int M;
  cin >> M;
  vector<string> t(M);
  for (int i = 0; i < M; i++) {
    cin >> t.at(i);
  }

  vector<string> s_orig = s;
  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());
  
  int score = 0;
  for (int i = 0; i < s.size(); i++) {
    int blue = count(s_orig.begin(), s_orig.end(), s.at(i));
    int red = count(t.begin(), t.end(), s.at(i));
    int tmp = max(blue -red, 0);
    if (i == 0) {
      score = tmp;
      continue;
    } 
    score = max(score, tmp);
  }
  cout << score << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1e9+5;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    int k;
    cin >> k;
    int a[n+1];
    for (int i=1; i<=n; i++) {
        cin >> a[i];
    }
    vector<bool> dp(k+1);
    for (int i=0; i<=k; i++) {
        for (int j=1; j<=n; j++) {
            if (i>=a[j] && !dp[i-a[j]])
                dp[i] = true;
        }
    }
    dp[k] ? (cout << "First") : (cout << "Second");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int H, W;
    cin >> H >> W;
    char a[H][W];
    int i, j;
    
    for(i=0; i<H; i++){
        for(j=0; j<W; j++){
            cin >> a[i][j];
        }
    }
    
    for(i=0; i<W+2; i++){
        cout << "#";
    }
    cout << endl;
    
    for(i=0; i<H; i++){
        for(j=0; j<W; j++){
            if(j==0){
                cout << "#";
            }
            cout << a[i][j];
            if(j==W-1){
                cout << "#" << endl;
                
            }
        }
    }
    for(i=0; i<W+2; i++){
        cout << "#";
    }
    cout << endl;
}


Measured memory_bytes: 256