akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	public void run() {
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n == 0 & m == 0) break;
			calc(n, m);
		}
	}

	public void calc(int n, int m){
		int r = sc.nextInt();
		int[][] kiroku = new int[m][721];
		int[][] login = new int[m][n];
		for(int i = 0; i < r; i++){
			int t = sc.nextInt();
			int PCn = sc.nextInt() -1;
			int Stum = sc.nextInt() - 1;
			int s = sc.nextInt();
			if(s == 1){
				login[Stum][PCn] = t;
			}
			else{
				for(int j = login[Stum][PCn] + 1; j < t + 1; j++){
					kiroku[Stum][j - 540] = 1;
				}
			}
		}
		int q = sc.nextInt();
		for(int i = 0; i < q; i++){
			int ts = sc.nextInt();
			int te = sc.nextInt();
			int Stum = sc.nextInt() -1;
			int sum = 0;
			for(int j = ts + 1; j < te + 1; j++){
				sum = sum + kiroku[Stum][j - 540];
			}
			System.out.println(sum);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    ll n,k;
    cin>>n>>k;
    if(n>=k)n%=k;
    cout<<min(abs(n),abs(k-n))<<endl;
}

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

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        long n = in.nextLong();
        long k = in.nextLong();

        long min = n;

        n -= (n / k) * k;

        min = Math.min(min, n);
        n = Math.abs(n - k);
        out.println(Math.min(min, n));
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll H, W, M;
    cin >> H >> W >> M;
    map<ll, ll> row, col;
    vector<P> items(M);
    set<P> used;
    rep(i, M) cin >> items[i].first >> items[i].second;
    rep(i, M) {
        P p = items[i];
        row[p.first]++;
        col[p.second]++;
        used.insert(p);
    }
    ll m = 0;
    rep2(i, 1, W + 1) {
        m = max(m, col[i]);
    }
    vector<ll> tar;
    rep2(i, 1, W + 1) {
        if (col[i] == m) {
            tar.push_back(i);
        }
    }
    ll ans = 0;
    rep2(i, 1, H + 1) {
        if (row[i] + m - 1 < ans)continue;
        for (ll t : tar) {
            ll x = row[i];
            x += m;
            if (used.count({i, t})) {
                x--;
            }
            ans = max(ans, x);
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 68380
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 998244353
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
ll henkan(ll c1, ll c2, ll c3,ll c4){
	ll h1 = 1000000000LL * c1 + 1000000LL * c2 + 1000*c3 + c4;
	ll h2 = 1000000000LL * c2 + 1000000LL * c3 + 1000*c4 + c1;
	ll h3 = 1000000000LL * c3 + 1000000LL * c4 + 1000*c1 + c2;
	ll h4 = 1000000000LL * c4 + 1000000LL * c1 + 1000*c2 + c3;
	return min(h1,min(h2,min(h3,h4)));
}
ll rotate(ll num){
	ll res=0;
	res += num / 1000000000LL;
	res += ( num % 1000000000LL) * 1000;
	return res;
}
signed main(){
	ll n; cin>>n;
	map<ll,ll> mope, mope2;
	vector<ll> v;
	for(ll i=0;i<n;i++){
		ll x,y,z,w;
		cin>>x>>y>>z>>w;
		ll num = henkan(x,y,z,w);
		v.pb(num);
		mope[num]++;
		if( x==y && y==z && z==w ){
			mope2[num] = 4;
		}
		else if( x == z && y == w ){
			mope2[num] = 2;
		}
		else{
			mope2[num] = 1;
		}
	}
	ll ans = 0;
	for(ll i=0;i<n;i++){
		ll cur = v[i];
		ll ii[4];
		for(ll j=0;j<4;j++){
			ii[3-j] = cur % 1000;
			cur /= 1000;
		}
		for(ll j=0;j<n;j++){
			if( i!=j ){
				vector<ll> rots;
				ll cur2 = v[j];
				for(ll k=0;k<4;k++){
					rots.pb(cur2);
					//cout<<"!!!"<<cur2<<endl;
					cur2 = rotate(cur2);
				}
				for(ll k=0;k<4;k++){
					ll tmp = 1;
					ll cur3 = rots[k];
					ll jj[4];
					for(ll p=0;p<4;p++){
						jj[3-p] = cur3 % 1000;
						cur3 /= 1000;
					}
					vector<ll> gds;
					gds.pb( henkan( jj[1],jj[0],ii[1],ii[0] ) );
					gds.pb( henkan( jj[2],jj[1],ii[0],ii[3] ) );
					gds.pb( henkan( jj[3],jj[2],ii[3],ii[2] ) );
					gds.pb( henkan( jj[0],jj[3],ii[2],ii[1] ) );
					//for(ll p=0;p<4;p++){ cout<<i<<" "<<j<<" "<<gds[p]<<" "<<mope[gds[p]]<<endl; }
					mope[v[i]]--;
					mope[v[j]]--;
					for(ll p=0;p<4;p++){
						tmp *= mope[ gds[p] ] * mope2[ gds[p] ];
						mope[ gds[p] ]--;
					}
					for(ll p=0;p<4;p++){
						mope[ gds[p] ]++;
					}
					mope[v[i]]++;
					mope[v[j]]++;
					//if( tmp > 0 ) cout<< i << j << k << endl;
					ans += tmp;
				}
			}
		}
	}
	cout<<ans/6<<endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> vecV(2, vector<int>(100001, 0));
    int v;
    for(int i = 0; i < n; i++)
    {
        cin >> v;
        vecV.at(i % 2).at(v)++;
    }
    int a1 = 0;
    int b1 = 0;
    int cnt_a1 = 0;
    int cnt_a2 = 0;
    int cnt_b1 = 0;
    int cnt_b2 = 0;
    int q,r;
    
    for(int i = 1; i <= 100000; i++)
    {
        q = vecV.at(0).at(i);
        r = vecV.at(1).at(i);
        
        if (q > cnt_a1) {
            a1 = i;
            cnt_a2 = cnt_a1;
            cnt_a1 = q;
        }
        else if (q > cnt_a2){
            cnt_a2 = q;
        }
        
        if (r > cnt_b1) {
            b1 = i; 
            cnt_b2 = cnt_b1;
            cnt_b1 = r;
        }
        else if (r > cnt_b2){
            cnt_b2 = r;
        }
    }
    
    int ans;
    if (a1 == b1) {
        ans = min((n - cnt_a1 - cnt_b2),(n - cnt_a2 - cnt_b1));
    }
    else {
        ans = n - cnt_a1 - cnt_b1;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1408
import java.awt.Point;
import java.io.FileInputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Scanner;
 
public class Main {
     
	static int p, q, a, n;
	
    static int count;
    
    static void dfs(int bunshi, int bunbo, int startnum, int index)
    {
    	if(index == n) return;
    	
    	for (int i = startnum; i <= 12000; i++) {
    		if(bunbo * i > a) return;
    		
			int left = p * bunbo * i;
			int right = q * bunshi * i + q * bunbo;
			
			if(left == right)
			{
				count++;
				continue;
			}
			if(left < right) continue;
			
			dfs(bunshi * i + bunbo, bunbo * i, i, index + 1);
		}
    }
    
    static void start()
    {
    	count = 0;
    	
    	dfs(0, 1, 1, 0);
    	
    	System.out.println(count);
    }
     
    public static void main(String[] args)
    {
        Scanner sca = new Scanner(System.in);
        
        while(true)
        {
        	p = sca.nextInt();
        	q = sca.nextInt();
        	a = sca.nextInt();
        	n = sca.nextInt();
        	
        	if(n == 0) break;
            
            start();
        }
        
    }
}

Measured memory_bytes: 23584
import sys
range = xrange
input = raw_input

ord0 = ord('0')

S = [ord(c)-ord0 for c in input()]

n = len(S)

i = n - 1
while S[i] == 0:
    i -= 1
S = S[:i + 2]

n = len(S)
DP0 = [0]*(n + 1)
DP1 = [0]*(n + 1)

DP1[0] = 1

for i in range(n):
    if S[i] != 0:
        DP0[i + 1] = min(DP1[i] + 1 + min(9 - S[i], S[i]), DP0[i] + S[i])
        DP1[i + 1] = min(DP0[i] + 1 + min(9 - S[i], S[i]), DP1[i] + 9 - S[i])
    else:
        DP0[i + 1] = min(DP1[i] + 1 + min(10 - S[i], S[i]), DP0[i] + S[i])
        DP1[i + 1] = min(DP0[i] + 1 + min(10 - S[i], S[i]), DP1[i] + 10 - S[i])

print DP0[-1]


Measured memory_bytes: 65096
#include<stdio.h>

int main()
{
	int a[3]={1,0,0},i,b[2];
	char c[2],dummy;

	while(scanf("%c,%c",c,c+1)!=EOF)
	{
		scanf("%c",&dummy);
		for(i=0;i<2;i++)
		{
			switch(c[i])
			{
			case 'A':
				b[i]=0;break;
			case 'B':
				b[i]=1;break;
			case 'C':
				b[i]=2;break;
			}
		}
		if(a[b[0]])
		{
			a[b[0]]=0;
			a[b[1]]=1;
		}
		else if(a[b[1]])
		{
			a[b[1]]=0;
			a[b[0]]=1;
		}
	}
	for(i=0;i<3;i++)
	{
		if(a[i])
		{
			printf("%c\n",65+i);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 544
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <stack>
#include <map>

#define ull unsigned long long
#define ll long long

using namespace std;

int main(){
    int n;
    scanf("%d",&n);
    ll sum=0;
    for(int i=1;i<=n;i++){
        if(i%3!=0 && i%5!=0){
            sum+=i;
        }
    }
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 3828
s = list(input())
m = list('zyxwvutsrqponmlkjihgfedcba')
if len(s) < 26:
    for i in m[::-1]:
        if not i in s:
            s.append(i)
            break
    print(''.join(s))
else:
    x = s[-1]

    for i in range(25)[::-1]:
        if x > s[i]:
            y = m.index(s[i])
            s = s[:i]
            for j in range(y)[::-1]:
                if not m[j] in s:
                    s.append(m[j])
                    break
            break
        else:
            x = s[i]
        if i == 0:
            print(-1)
            exit(0)
    print(''.join(s))

Measured memory_bytes: 9076
#include <cstdio>
#include <vector>
#include <algorithm>
int main(){
	int i,n,m,x;
	for(;scanf("%d%d",&n,&m),n;printf("%d\n",x)){
		std::vector<int>v;
		for(i=0;i<n;i++)scanf("%d",&x),v.push_back(x);
		std::sort(v.begin(),v.end());
		for(x=i=0;i<n;i++)x+=(i%m==n%m)?0:v[i];
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}

void solve()
{
 string s;
 cin >> s;

 for(int i=0;i<sz(s);i++)
 {
    cout<<"x";
 }

}


int32_t main()
{
  pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    string s; cin >> s;
    REP(i, 0, s.size()-1){
        if(s[i] == s[i+1]){
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
        else if(i+2 < s.size() && s[i] == s[i+2]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
}

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

using namespace std;

const int N = 1e5 + 5;

int ans[N], last_left[N], last_right[N];

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

    string s;
    cin >> s;

    int n = s.size();

    last_right[0] = 0;
    for (int i = 1; i < n; i ++) {
        if (s[i] == 'R') {
            last_right[i] = i;
        }
        else
            last_right[i] = last_right[i - 1];
    }

    last_left[n - 1] = n - 1;
    for (int i = n - 2; i >= 0; i --) {
        if (s[i] == 'L') {
            last_left[i] = i;
        } else {
            last_left[i] = last_left[i + 1];
        }
    }

    for (int i = 0; i < n; i ++) {
        if (s[i] == 'R') {
            int idx = last_left[i];
            int diff = idx - i;
            if (diff % 2 == 0) {
                ans[idx] ++;
            } else {
                ans[idx - 1] ++;
            }
        } else {
            int idx = last_right[i];
            int diff = i - idx;
            if (diff % 2 == 0) {
                ans[idx] ++;
            } else {
                ans[idx + 1] ++;
            }
        }
    }

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


Measured memory_bytes: 1872
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


signed main() {
    ll n;
    cin >> n;
    vll h(n);
    ll tmp = 0;
    ll r = 0;
    
    
    rep(i, n) {
        cin >> h[i];
        tmp = max(tmp, h[i]);
        if (tmp == h[i]) r++;
    }
    
    mes(r);
    
    
    
}

Measured memory_bytes: 3608
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}

import           Control.Monad
import           Data.IORef
import qualified Data.Text     as T
import qualified Data.Text.IO  as T
import           System.IO

(+.+) = T.append
(!.!) = T.index

main :: IO ()
main = diagonalString

diagonalString :: IO ()
diagonalString = do
  c1 :: T.Text <- T.getLine
  c2 :: T.Text <- T.getLine
  c3 :: T.Text <- T.getLine
  let c11 = T.head c1
      c22 = c2 !.! 1
      c33 = T.last c3
  putStrLn [c11, c22, c33]

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

using namespace std;

#define endl "\n"
#define F first
#define S second
#define B begin()
#define E end()
#define PB push_back
#define int long long

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

const int maxn = 1e4;
const int OO = 1e18;
const int mod = 1e7 + 9;

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

//	freopen("name.in","r",stdin);
//	freopen("name.out","w",stdout);


   int a,b,c;
   cin >> a >> b >> c;
   for(int i=0;i<=a;i++)
   {
       int I = i + b;
       if(I > c)
        break;
       if(I%a==0)
       {
           cout << "OK";
            return 0;
       }
   }
    cout << "NG";

    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
 
using namespace std;
const int maxn=2e5+5;
int dp[3][3000];
char str[maxn];
int main()
{
    scanf("%s", str);
    int i, j, mod=0, x, n=strlen(str);
    long long ans=0;
    for(i=0; i<n; i++)
    {
        x=str[i]-'0';
        for(j=0; j<=2019; j++)
        {
            dp[1][(j*10+x)%2019]+=dp[0][j];
        }
        dp[1][x]++;
        for(j=0; j<=2019; j++)
        {
            dp[0][j]=dp[1][j];
            dp[1][j]=0;
        }
        ans+=dp[0][0];
    }
    cout<<ans<<endl;
    return 0;
}

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

//全探索では遅い
//上手く探索する方法を考える
//xが決まればyも自動的に決まる
int main()
{
    int c[3][3];
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> c[i][j];
        }
    }

    int x[3], y[3];
    x[0] = 0;
    for (int i = 0; i < 3; i++)
    {
        y[i] = c[0][i] - x[0];
    }

    for (int i = 0; i < 3; i++)
    {
        x[i] = c[i][0] - y[0];
    }

    bool good = true;
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            if (x[i] + y[j] != c[i][j])
                good = false;
        }
    }

    cout << (good ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3604
import java.util.*;

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

                while (true) {
                        int N = sc.nextInt();
                        if (N == 0) {
                                return;
                        }
                        double nowmin = 300;
                        int ans = 0;
                        for (int i = 0; i < N; i++) {
                                int j = sc.nextInt(), h = sc.nextInt(), w = sc.nextInt();
                                if (Math.abs(w*10000./h/h - 22) < nowmin) {
                                        ans = j;
                                        nowmin = Math.abs(w*10000./h/h - 22);
                                } else if (Math.abs(w*10000./h/h - 22) == nowmin) {
                                        ans = Math.min(ans, j);
                                }
                        }
                        System.out.println(ans);
                }
        }
}

Measured memory_bytes: 36852
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

class Pair {
    private int first;
    private int second;

    public Pair(int a, int b) {
        first = a;
        second = b;
    }

    public int getFirst() {
        return first;
    }

    public int getSecond() {
        return second;
    }
}

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int h = sc.nextInt();
        int w = sc.nextInt();
        int d = sc.nextInt();
        Pair[] lookup = new Pair[w * h + 1];
        int value;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                value = sc.nextInt();
                lookup[value] = new Pair(i + 1, j + 1);
            }
        }
        int numQueries = sc.nextInt();
        long[] cost = new long[w * h + 1];
        for(int i = 1; i <= w*h; i++){
            if(i > d)
                cost[i] = cost[i - d] + Math.abs(lookup[i].getFirst() - lookup[i - d].getFirst()) +
                        Math.abs(lookup[i].getSecond() - lookup[i - d].getSecond());
        }
        for (int i = 0; i < numQueries; i++) {
            int start = sc.nextInt();
            int end = sc.nextInt();

            System.out.println(cost[end] - cost[start]);
        }
    }
}

Measured memory_bytes: 53204
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

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

  int start = pow(100, d);
  int ans = start * n;
  if (n == 100) ans += start;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define A first
#define B second
#define make_pair MP
#define MOD 1000000007
#define MAXM 100005
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }


int mulmd(ll a, ll b){
    ll ret = (a * b) % MOD;
    return (int)ret;

}

inline int power(ll x, ll y, int p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = mulmd(res,x);
        y = y>>1;
        x = mulmd(x,x);
    }
    return (int)res;
}

int submd(ll a, ll b){
    ll ret = a-b;
    if(ret<0){
        ret+=MOD;
    }
    return (int)ret;
}

int addmd(ll a, ll b){
    ll ret = (a + b) % MOD;
    return (int)ret;
}

int phi(int n){
    int result = n;
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            while(n%i==0){
                n=n/i;
            }
            result-=result/i;
        }
    }
    if(n>1) result-=result/n;
    return result;
}

int gcd(int a, int b, int& x, int& y){
    if(a==0){
        x=0;
        y=1;
        return b;
    }
    int x1,y1;
    int d = gcd(b%a, a, x1, y1);
    x = y1 - (b/a)*x1;
    y = x1;
    return d;
}

int arr[100005];

int dist(int x1,int y1,int x2,int y2)
{
    int dx=x2-x1;int dy=y2-y1;
    float ans=sqrt(dx*dx+dy*dy);
    return ceil(ans);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h;
    cin>>h;
    ll co=1;ll n=1; ll ans=0;
    if(h==1)
        cout<<1;
    else{
        while(1){
            co = co + pow(2,n);
            if(h<=co)
            {
                ans=co;
                break;
            }
            n++;
        }
        cout<<ans;
    }


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>


using namespace std;


template <class ...Args>
void Input(Args &...args)
{
	(cin >> ... >> args);
}

template <class T>
void InputArray(std::size_t size, T &t)
{
	t.resize(size);
	for (auto &e : t) {
		cin >> e;
	}
}

template <class ...Args>
void InputArray(std::size_t size, Args &...args)
{
	(InputArray(size, args), ...);
}

template <class ...Args>
void InputVerticalArray(std::size_t size, Args &...args)
{
	(args.resize(size), ...);
	for (int i = 0; i < size; i++) {
		((cin >> args[i]), ...);
	}
}

template <class ...Args>
void Output(const Args &...args)
{
	((cout << args << ' '), ...) << endl;
}

template <class ...Args>
void OutputVertical(const Args &...args)
{
	((cout << args << endl), ...);
}

template <class T>
void OutputArray(const T &t)
{
	for (const auto &e : t) {
		cout << e << ' ';
	}
	cout << endl;
}

template <class ...Args>
void OutputArray(const Args &...args)
{
	(OutputArray(args), ...);
}

template <class ...Args>
void OutputVerticalArray(const Args &...args)
{
	for (int i = 0; i < min({ args.size()... }); i++) {
		((cout << args[i] << ' '), ...) << endl;
	}
}


#define inp(type, ...) \
	type __VA_ARGS__; \
	Input(__VA_ARGS__)

#define inpa(type, size, ...) \
	type __VA_ARGS__; \
	InputArray((size), __VA_ARGS__)

#define inpva(type, size, ...) \
	type __VA_ARGS__; \
	InputVerticalArray((size), __VA_ARGS__)

#define otp(...) \
	Output(__VA_ARGS__)

#define otpv(...) \
	OutputVertical(__VA_ARGS__)

#define otpa(...) \
	OutputArray(__VA_ARGS__)

#define otpva(...) \
	OutputVerticalArray(__VA_ARGS__)

#define rep(counter, range) \
	for (int (counter) = 0; (counter) < (range); (counter)++)

#define repi(range) \
	rep(i, range)

#define rrep(counter, range) \
	for (int (counter) = (range) - 1; (counter) >= 0; (counter)--)

#define rrepi(range) \
	rrep(i, range)

#define repc(element, container) \
	for (auto &(element) : (container))

#define repe(container) \
	repc(e, container)

#define all(container) \
	(container).begin(), (container).end()

#ifdef __CCR__
#	define dlog(x) clog << #x " = " << x << endl
#else
#	define dlog(x)
#endif



int main()
{
	inp(int, a, b);
	
	if (a <= 0 && b >= 0) otp("Zero");
	else if (a > 0 || (b - a) % 2) otp("Positive");
	else otp("Negative");
	
	return 0;
}


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

int main(){
	int x,y;
	cin >> x >> y;
	int ans(0);
	if(x <= 3){
		ans += 100000*(4-x);
	}
	if(y <= 3){
		ans += 100000*(4-y);
	}
	if(x == 1 && y == 1){
		ans += 400000;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <complex>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cassert>
using namespace std;
typedef double number;

const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<number> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

typedef vector<P> G;

#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
G convex_cut(const G& p, const L& l) {
  G Q;
  for (int i = 0; i < p.size(); ++i) {
    P A = curr(p, i), B = next(p, i);
    if (ccw(l[0], l[1], A) != -1) Q.push_back(A);
    if (ccw(l[0], l[1], A)*ccw(l[0], l[1], B) < 0)
      Q.push_back(crosspoint(L(A, B), l));
  }
  return Q;
}

number area2(const G& P) {
  number A = 0;
  for (int i = 0; i < P.size(); ++i) 
    A += cross(curr(P, i), next(P, i));
  return A;
}

int main(){
	G poly;
	P p;
	int n;
	double x1,y1,x2,y2;
	for(scanf("%d",&n);n--;poly.push_back(p))scanf("%lf%lf",&x1,&y1),p=P(x1,y1);
	for(scanf("%d",&n);n--;){
		scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
		L l(P(x1,y1),P(x2,y2));
		G cut=convex_cut(poly,l);
		printf("%f\n",area2(cut)/2);
	}
}

Measured memory_bytes: 1112
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
	int a, b, d, r;
	double f;
	cin >>a >>b;
	d=a/b;
	r=a%b;
	f=(double)a/b;
	cout <<d <<" " <<r <<" ";
	printf("%.8lf\n", f);
	return 0;
}

Measured memory_bytes: 1240
// ABC088.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
#include <iostream>
using namespace std;

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

	int m = N % 500;
	if (A >= m) cout << "Yes";
	else cout << "No";

    return 0;
}



Measured memory_bytes: 256
from bisect import bisect_left
N, K = map(int, input().split())
Points = []
X, Y = [], []
for i in range(N):
    x, y = map(int, input().split())
    Points.append([x, y])
    X.append(x)
    Y.append(y)

# 座標圧縮
X.sort()
Y.sort()
Points_compressed = []
for x, y in Points:
    cx, cy = bisect_left(X, x), bisect_left(Y, y)
    Points_compressed.append([cx, cy])


class Ruisekiwa2D:
    def __init__(self, h, w):
        self.H = h
        self.W = w
        self.G = [[0] * w for _ in range(h)]

    def load(self, points):
        # 問題によってイメージしやすいよう書き換えてください
        for x, y in points:
            self.G[x][y] += 1

    def load_imos(self, points):
        # pointsは[[左上h, 左上w, 右下h, 右下w], ...]であること
        for i1, j1, i2, j2 in points:
            self.G[i1][j1] += 1  # 左上
            if j2 + 1 < self.W:  # 右上
                self.G[i1][j2+1] -= 1
            if i2 + 1 < self.H:
                self.G[i2+1][j1] -= 1  # 左下
            if j2 + 1 < self.W and i2 + 1 < self.H:  # 右下
                self.G[i2+1][j2+1] += 1

    def calc(self):
        for y in range(self.W):
            for x in range(1, self.H):
                self.G[x][y] += self.G[x-1][y]

        for y in range(1, self.W):
            for x in range(self.H):
                self.G[x][y] += self.G[x][y-1]

    def get(self, i1, j1, i2, j2):
        if i1 > i2 or j1 > j2 or i1 < 0 or j1 < 0 or i2 < 0 or j2 < 0:
            return 0
        elif i1 > 0 and j1 > 0:
            return self.G[i2][j2] - self.G[i1-1][j2] - self.G[i2][j1-1] + self.G[i1-1][j1-1]
        elif i1 <= 0 < j1:
            return self.G[i2][j2] - self.G[i2][j1-1]
        elif j1 <= 0 < i1:
            return self.G[i2][j2] - self.G[i1 - 1][j2]
        else:
            return self.G[i2][j2]


# 二次元累積和
R2D = Ruisekiwa2D(N, N)
R2D.load(Points_compressed)
R2D.calc()


ans = float('inf')
for yi in range(N):
    for yj in range(N):
        for xi in range(N):
            for xj in range(N):
                cx1, cx2 = Points_compressed[xi][0], Points_compressed[xj][0]
                cy1, cy2 = Points_compressed[yi][1], Points_compressed[yj][1]

                x1, x2 = Points[xi][0], Points[xj][0]
                y1, y2 = Points[yi][1], Points[yj][1]

                # 二次元累積和で高速に長方形内部に含まれる点の数を数える
                inside = R2D.get(cx1, cy1, cx2, cy2)
                if inside >= K:
                    ans = min(ans,  abs(x2 - x1) * abs(y2 - y1))

print(ans)


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

int main(void){
    using namespace  std;
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    string ret(2 * N, ' ');
    for (int i = 0; i < N;i++){
        ret[2 * i] = S[i];
        ret[2 * i + 1] = T[i];
    }
        cout << ret << endl;

    return 0;
}

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

const static unsigned int MODULO = 1e9 + 7;
const static unsigned int DEFAULT_SIZE = 1e6;

unsigned long long int* fact;
unsigned long long int* inv;
unsigned long long int* fact_inv;

// 階乗の計算
void Initialize(int size) {
    fact = new unsigned long long int [size];
    inv = new unsigned long long int [size];
    fact_inv = new unsigned long long int [size];
    fact[0] = 1;
    fact[1] = 1;
    inv[1] = 1;
    fact_inv[0] = 1;
    fact_inv[1] = 1;
    for (unsigned int i = 2; i < size; ++i) {
        fact[i] = fact[i - 1] * i % MODULO;
        inv[i] = MODULO - inv[MODULO % i] * (MODULO / i) % MODULO;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MODULO;
    }
    return;
}
// nCkを求める
const long long unsigned int Combination(const unsigned int n, const unsigned int k) {
    return fact[n] * (fact_inv[k] * fact_inv[n - k] % MODULO) % MODULO;
}

int main(void) {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    Initialize(h + w);
    long long int result = 0;
    for (int i = b; i < w; ++i) {
        result += (Combination(i + h - a - 1,  i) * Combination(a + w - i - 2 , a - 1) % MODULO);
        result %= MODULO;
    }
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 8240
#include<cstdio>
#include<cstring>
#include<algorithm>

#define reps(i,f,n) for(int i = f; i < int(n); i++)
#define rep(i,n) reps(i,0,n);

using namespace std;


int ans;
int J,O,I;
	

int main(void){
	
	char input
	;
	
	
	while(scanf("%c", &input), input!='\n'){
		if(input == 'J'){
			if(0<O)J=0;
			J++;
			O=0;
			I=0;
		}else if(0<J && input == 'O'){
			O++;
		}else if(0<O && input == 'I'){
			I++;
			if(0<J && J < O)O = 0;
			J=0;
			
			if(I>=O)ans=max(ans, min(I,O));
		}else{
			J=0;
			O=0;
			I=0;
		}
//		printf("j,%d,o ,%d,i,%d\n", J, O, I);
	}
	
	printf("%d\n", ans);
	
	return 0;
	
}

Measured memory_bytes: 968
#include <stdio.h>

int CanMove(int *books, int n, int key, int m)
{
    int i;
    int left;
    
    i = 0;
    while (m-- && i != n){
        left = key;
        while (left >= books[i] && i != n){
            left -= books[i++];
        }
    }
    
    if (i != n){
        return (0);
    }
    return (1);
}

int main(void)
{
    int i;
    int n, m;
    int books[101];
    int min, max, search;
    
    while (1){
        scanf("%d%d", &m, &n);
        
        if (m + n == 0){
            break;
        }
        
        for (i = 0; i < n; i++){
            scanf("%d", &books[i]);
        }
        
        min = 0;
        max = 1500000;
        while (min != max){
            search = (min + max) / 2;
            
            if (CanMove(books, n, search, m)){
                max = search;
            }
            else {
                min = search + 1;
            }
        }
        
        printf("%d\n", min);
    }
    
    return (0);
}

Measured memory_bytes: 0
using System;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Text;

namespace Fish.aizu
{
	public static class AizuOnlineJudge
	{
		public static int[] SplitToInts(string line)
		{
			return line.Split(' ').Select(x => int.Parse(x)).ToArray();
		}
		public static double[] SplitToDoubles(string line)
		{
			return line.Split(' ').Select(x => double.Parse(x)).ToArray();
		}
		public static long[] SplitToLongs(string line)
		{
			return line.Split(' ').Select(x => long.Parse(x)).ToArray();
		}
		public static int Main()
		{
			Compute(Console.In, Console.Out);
			return 0;
		}
		
		public static void Compute(TextReader reader, TextWriter writer)
		{
			while (true)
			{
				var v = SplitToInts(reader.ReadLine());
				var n = v[0];
				var x = v[1];
				var count = 0;
				
				if (n == 0 && x == 0) return;
				
				for (var a = 1; a <= n; a++)
				{
					if (x - a < x / 3) break;
					for (var b = a + 1; b <= n; b++)
					{
						if (x - b <= b) break;
						for (var c = b + 1; c <= n; c++)
						{
							if (a + b + c == x)
							{
								count++;
							}
						}
					}
				}
				writer.WriteLine(count);
			}
		}
	}
}

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

int main() {
	int n, a, ss; string s;
	a = ss = 0;
	cin >> n; cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == ')') a -= 1;
		if (s[i] == '(') a += 1;

		if (a < 0) {
			ss += 1;
			a = 0;
		}
	}

	for (int i = 0; i < ss; i++) cout << '(';
	cout << s;
	for (int i = 0; i < a; i++) cout << ')';
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<math.h>
using namespace std;

int main()
{
	double a,b,x;
	cin>>a>>b>>x;
	double rad;
	double degree;
	if(x<a*a*b/2.0)
		{
			rad = b*b*a/(x*2.0);
			degree = atan(rad)*180.0/3.1415926;
		}
	else if(x==a*a*b/2.0)
		{
			degree = 45;
		}
	else
		{
			rad = 2.0*b/a-2.0*x/(a*a*a);
			degree = atan(rad)*180.0/3.1415926;
		}
	printf("%.8lf",degree);
	return 0;
}

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

#include <atcoder/all>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
using namespace atcoder;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    auto sa = suffix_array(s);
    auto lcp = lcp_array(s, sa);
    lint ans = n - sa[0];
    rep(i, n - 1) ans += n - sa[i + 1] - lcp[i];
    printf("%lld\n", ans);
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int lgsz = 62, nsz = 2e2;
int ts, n;
num a[nsz + 5];
string s;

struct linear_basis {
	num d[lgsz + 5];
	
	void inline clear() {
		memset(d, 0, sizeof(d));
	}
	
	void inline ins(num w) {
		circ (i, 0, lgsz) {
			if (!(w >> i & 1)) continue;
			if (!d[i]) { d[i] = w; break; }
			w ^= d[i];
		}
	}
	
	bool inline chk(num w) {
		circ (i, 0, lgsz) {
			if (!(w >> i & 1)) continue;
			w ^= d[i];
		}
		return w == 0;
	}
};
linear_basis b;

void inline solve() {
	b.clear();
	cin >> n;
	cont (i, n) cin >> a[i];
	cin >> s;
	s = ' ' + s;
	bool f = 1;
	for (int i = n; i >= 1; --i) {
		if (s[i] == '0') b.ins(a[i]);
		f &= b.chk(a[i]);
		if (!f) break;
	}
	cout << !f << ln;
}

int main() {
	ios::sync_with_stdio(0);
	cin >> ts;
	cont (cs, ts) {
		solve();
	}
}

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

using namespace std;
using i64 = std::int_fast64_t;

template <typename T>
T gcd(T a, T b) {
  while (a) {
    b %= a;
    swap(a, b);
  }
  return b;
}

template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  i64 A, B, C, D;
  cin >> A >> B >> C >> D;
  A--;
  i64 L = lcm(C, D);
  cout << (B - A) - (B / C + B / D - (A / C + A / D) - (B / L - A / L)) << '\n';
  return 0;
}


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

using namespace std;
typedef long long ll;

const int N = int(1e5) + 7;

void init(){

}

void solve(){
    int x, y;
    scanf("%d%d", &x, &y);
    printf("%d", max({x-y, x+y, x*y}));
}

int main(){
    int test_cases_number = 1;
//    scanf("%d", &test_cases_number);
    for(int i = 0; i < test_cases_number; i++)
        solve();
}


Measured memory_bytes: 256
n,k = map(int, input().split())
r, s, p = map(int, input().split())
T = list(str(input()))
ans = 0
S = [-1]*n
for i in range(n):
    if i <= k-1:
        if T[i] == 'r':
            S[i] = 'p'
            ans += p
        elif T[i] == 's':
            S[i] = 'r'
            ans += r
        else:
            S[i] = 's'
            ans += s
    else:
        if T[i] == 'r':
            if S[i-k] != 'p':
                S[i] = 'p'
                ans += p
            else:
                if i+k <= n-1:
                    if T[i+k] == 's':
                        S[i] = 's'
                    elif T[i+k] == 'p':
                        S[i] = 'r'
                    else:
                        S[i] = 'r'
                else:
                    S[i] = 'r'
        elif T[i] == 's':
            if S[i-k] != 'r':
                S[i] = 'r'
                ans += r
            else:
                if i+k <= n-1:
                    if T[i+k] == 'p':
                        S[i] = 'p'
                    elif T[i+k] == 'r':
                        S[i] = 's'
                    else:
                        S[i] = 's'
                else:
                    S[i] = 's'
        else:
            if S[i-k] != 's':
                S[i] = 's'
                ans += s
            else:
                if i+k <= n-1:
                    if T[i+k] == 's':
                        S[i] = 'p'
                    elif T[i+k] == 'r':
                        S[i] = 'r'
                    else:
                        S[i] = 'p'
                else:
                    S[i] = 'p'
print(ans)


Measured memory_bytes: 80896
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll box[5] = {};
    rep(i, n) {
        string s;
        cin >> s;
        switch(s[0]) {
            case 'M':box[0]++;break;
            case 'A':box[1]++;break;
            case 'R':box[2]++;break;
            case 'C':box[3]++;break;
            case 'H':box[4]++;break;
        }
    }

    int num[5];
    rep(i, 5) num[i] = i;
    ll ans = 0;
    do{
        ll now = 1;
        rep(i, 3) now *= box[num[i]];
        ans += now;
    } while(next_permutation(num, num+5));
    cout << (ans/12) << endl;
}

Measured memory_bytes: 3588