akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
	long long n;
	int m, q;
	cin >> n >> m >> q;

	vector<int> a(q);
	for (int i = 0; i < q; i++) {
		cin >> a[i];
	}

	int T = 0;
	for (int i = 1;; i++) {
		if (m * i % 7 == 0) {
			T = i;
			break;
		}
	}
	int H = m * T / 7;
	vector<vector<bool>> check1(H, vector<bool>(7));
	vector<vector<bool>> check2(H * 2, vector<bool>(7));
	for (int i = 0; i < q; i++) {
		for (int j = 0; j < T; j++) {
			int val = a[i] + m * j;
			int y = val / 7;
			int x = val % 7;
			check1[y][x] = true;
			check2[y][x] = true;
			check2[y + H][x] = true;
		}
	}

	function<void(vector<vector<bool>> &, int, int)> dfs = [&](vector<vector<bool>> &check, int y, int x) {
		const int dy[] = { 0, 1, 0, -1 };
		const int dx[] = { 1, 0, -1, 0 };
		check[y][x] = true;
		for (int k = 0; k < 4; k++) {
			int yy = y + dy[k];
			int xx = x + dx[k];
			if (yy < 0 || xx < 0 || yy >= check.size() || xx >= 7) {
				continue;
			}
			if (check[yy][xx]) {
				continue;
			}
			dfs(check, yy, xx);
		}
	};

	auto count = [&](auto v) {
		int ret = 0;
		for (int i = 0; i < v.size(); i++) {
			for (int j = 0; j < 7; j++) {
				if (!v[i][j]) {
					dfs(v, i, j);
					ret++;
				}
			}
		}
		return ret;
	};

	int one = count(check1);
	int two = count(check2);

	int diff = 2 * one - two;
	long long ans = n / H * one - (n / H - 1) * diff;
	cout << ans << endl;
}

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

int main(){
  int n;
  int a[100];
  cin>>n;
  for (int i=0; i<n; i++) cin>>a[i];
  int counter=0;
  
  for (int i=0; i<n; i++){
    int minj=i;
    for (int j=i; j<n; j++){
      if (a[j]<a[minj]){
        minj=j;
      }
    }
    if (a[i]!=a[minj]){
      swap(a[i],a[minj]);
      counter++;
    }
  }
  for (int i=0; i<n; i++){
    if (i) cout<<" ";
    cout<<a[i];
  }
  cout<<endl;
  cout<<counter<<endl;
}
  
        
      


Measured memory_bytes: 3088
<?php
/*
    URL    : http://kupc2016.contest.atcoder.jp/tasks/kupc2016_b

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

ini_set('error_reporting', E_ALL & ~E_NOTICE);

$ans = 0;
$arrI = array();
$arrExam = array();
$tmpExam = array();

fscanf(STDIN, "%d %d", $N, $K);
for ($i = 0; $i < $N; $i++) {
	fscanf(STDIN, "%s", $P);
	$tmpP = str_split($P);
	$arrI[$tmpP[0]]++;
}

while(true) {
	// sleep(1);
	arsort($arrI);
	// var_dump($arrI);
	$arrIkey = array_keys($arrI);
	$cntI = count($arrI);
	if ($cntI < $K) break;
	for ($i = 0; $i < $K; $i++) {
		// echo $arrIkey[$i] . PHP_EOL;
		if ($arrI[$arrIkey[$i]] > 0) {
			$arrI[$arrIkey[$i]]--;
		} else {
			break;
		}
		if ($arrI[$arrIkey[$i]] == 0) {
			unset($arrI[$arrIkey[$i]]);
		}
	}
	$ans++;
}


echo $ans . PHP_EOL;

Measured memory_bytes: 4088
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  int n;
  long k;
  cin >> n >> k;
  map<int, long> mp;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    mp[a] += b;
  }

  for(auto e : mp) {
    k -= e.second;
    if (k <= 0) {
      cout << e.first << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
 string a,b;
ll dp[3002][3002];
/*ll lcs(ll u,ll v)
{
    if(dp[u][v]!=-1)
    return dp[u][v];
    if(u==0||v==0)
    return 0;
    else
    {
        if(a[u-1]==b[v-1])
        return dp[u][v]=1+lcs(u-1,v-1);
        return dp[u][v]=max(lcs(u-1,v),lcs(u,v-1));
    }
}*/
int main()
{
    
       
       // memset(dp,-1,sizeof(dp));
        cin>>a>>b;
        string ans="";
        ll i,j,u,v;
        u=a.length();
        v=b.length();
        //cout<<lcs(a.length(),b.length())<<endl;
        for(i=0;i<=v;i++)
        dp[0][i]=0;
        for(j=0;j<=u;j++)
        dp[j][0]=0;
        for(i=1;i<=u;i++)
        {
            for(j=1;j<=v;j++)
            {
                if(a[i-1]==b[j-1])
                {
                    dp[i][j]=1+dp[i-1][j-1];
                }
                else 
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
       /* for(i=u;i>0;i--)
        {
            for(j=v;j>0;j--)
            {
                if(a[i-1]==b[j-1])
                {
                    ans+=a[i-1];
                    i--,j--;
                }
                else
                {
                    if(i!=1 && j!=1){
                    if(dp[i-1][j]>dp[i][j-1])
                    i--;
                    else
                    j--;
                }}
            }
        }*/
        i=u,j=v;
        while(i>0&&j>0)
        {
            
                if(a[i-1]==b[j-1])
                {
                    ans+=a[i-1];
                    i--,j--;
                }
                else
                {
                    if(dp[i-1][j]>dp[i][j-1])
                    i--;
                    else
                    j--;
                }
        }
        reverse(ans.begin(),ans.end());
        cout<<ans<<endl;
        
    
}

Measured memory_bytes: 74000
#include <bits/stdc++.h>
using namespace std;
 
#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
 
  int main()
  {
     ll n,i;
     cin>>n;
     ll a,b[1000000]={0};
     for(i=0;i<n-1;i++)
     { cin>>a;
      // a=a-1;
       b[a-1]++;
     }
     for(i=0;i<n;i++)
     cout<<b[i]<<"\n";
  }

Measured memory_bytes: 11448
mod = 10**9+7
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a_to_i = [-1]*(N*M)
b_to_i = [-1]*(N*M)
for i in range(N):
    a_to_i[A[i]-1] = i
for i in range(M):
    b_to_i[B[i]-1] = i
res = 1
covered_a = [False]*N
covered_b = [False]*M
cnt = 0
cnt_a = [0]*N
cnt_b = [0]*M
s_a = 0
s_b = 0
for x in range(M*N)[::-1]:
    ai = a_to_i[x]
    bi = b_to_i[x]
    if ai>=0 and bi>=0:
        if covered_a[ai] or covered_b[bi]:
            res = 0
            break
        cnt+=(s_b-cnt_a[ai])+(s_a-cnt_b[bi])
        s_a+=1
        s_b+=1
    elif ai<0 and bi>=0:
        if covered_b[bi]:
            res = 0
            break
        res*=s_a-cnt_b[bi]
        cnt+=s_a-cnt_b[bi]-1
        s_b+=1
    elif ai>=0 and bi<0:
        if covered_a[ai]:
            res = 0
            break
        res*=s_b-cnt_a[ai]
        cnt+=s_b-cnt_a[ai]-1
        s_a += 1
    else:
        res*=cnt
        cnt-=1
    res%=mod
print(res)
    
    


Measured memory_bytes: 56812
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
#define maxn 4300000
#define N 200005
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define LL long long
const LL mod = 1000000007;
int main()
{
    string s1,s2;
    int n;
   // freopen("myans.txt","w",stdout);
    while(cin>>n)
    {
        cin>>s1>>s2;
        LL ans=1;
        LL last=0;
        int i=0;
        while(i<n)
        {
           if(i==0&&s1[i]==s1[i+1]&&s2[i]==s2[i+1])
           {
               ans=(ans*6)%mod;
               last=2;
               i+=2;
           }
           else if(i==0&&s1[i]==s2[i])
           {
               ans=(ans*3)%mod;
               last=1;
               i++;
           }
           else  if(last==2&&s1[i]==s2[i])last=1,i++;
           else  if(last==1&&s1[i]==s2[i])ans=(ans*2)%mod,i++;
           else  if(last==2&&s1[i]==s1[i+1]&&s2[i]==s2[i+1])
           {
               ans=(ans*3)%mod;
               last=2;
               i+=2;
           }
           else  if(last==1&&s1[i]==s1[i+1]&&s2[i+1]==s2[i])
           {
               ans=(ans*2)%mod;
               last=2;
               i+=2;
           }
        }
        cout<<ans<<endl;
    }
}


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

vector<int> a(5);

int ans = 99999;

vector<bool> used(5, false);
vector<int > perm(5);

int calc(){
    int ans = 0;
    for(int i = 0; i < 5; i++)
    {
        ans += a[perm[i]];
        if(ans % 10 != 0 && i != 4){
            ans = (ans/10)*10 + 10;
        }
    }
    return ans;
}

void permu(int pos){
    if(pos == 5){
        int tmp = calc();
        ans = min(ans, tmp);
        return;
    }
    for(int i = 0; i < 5; i++)
    {
        if(!used[i]){
            perm[pos] = i;
            used[i] = true;
            permu(pos+1);
            used[i] = false;
        }
    }
    return;
}

int main() {
    for(int i = 0; i < 5; i++)
    {
        cin >> a[i];
    }
    
    permu(0);

    cout << ans << endl;
    
}

Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
arr = list(map(int, input().split()))

arr_count = defaultdict(int)

for a in arr:
    arr_count[a] += 1

max_x_count = 0
for x in range(1, 10 ** 5):
    x_count = arr_count[x-1] + arr_count[x] + arr_count[x+1]
    max_x_count = max(max_x_count, x_count)

print(max_x_count)


Measured memory_bytes: 20040
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pii pair<ll, ll> 
#define pb push_back
#define debug(x) cerr<< #x << " is " <<x<<endl;
#define debug2(x) cerr<<#x<< " is\n"; for (auto &i:x) {cout<<i<<' '; } cout<<endl;
#define f first
#define s second
using namespace std;
const int maxn = 405;
const ll inf=1ll<<60;

ll dp[maxn][maxn];
ll ps[maxn];
ll a [maxn];

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    for (int i=0; i<401; i++) for (int j=0; j<401; j++) dp[i][j]=0;
    int n; cin>>n;
	for (int i=0; i<n; i++){
		cin>>a[i];
		ps[i+1]=a[i]+ps[i]; 
	}
    for (int i=1; i<n; i++){ // I is diff
    	for (int j=0; j+i<n; j++){
    		dp[j][i+j]=inf;
    		for (int k=j; k<i+j; k++){
    			dp[j][j+i]=min(dp[j][j+i],ps[i+j+1]-ps[j]+dp[j][k]+dp[k+1][i+j]);

    		}
    	}
    }
    cout<<dp[0][n-1]<<endl;
}

Measured memory_bytes: 1536
#include<iostream>
using namespace std;
int main()
{
    char b;
    cin >> b;
    if(b=='A'){cout << 'T' << endl;}
    if(b=='T'){cout << 'A' << endl;}
    if(b=='C'){cout << 'G' << endl;}
    if(b=='G'){cout << 'C' << endl;}
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M=map(int,input().split())
    A=list(map(int,input().split()))
    ans=N-sum(A)
    if ans<0:
        print(-1)
    else:
        print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 68172
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.Set as Set
import qualified Data.Sequence as Sq
import qualified Data.IntMap as IMap
import qualified Data.Vector as V
import Data.Sequence (ViewL(..),ViewR(..),(><),(<|),(|>),Seq)

bsreadInt :: BC.ByteString -> Int
bsreadInt = fst . fromJust . BC.readInt

sqleft :: Seq a -> a
sqleft q = sqleft_(Sq.viewl q)
sqleft_ :: ViewL a -> a
sqleft_ (x :< xs) = x
sqright :: Seq a -> a
sqright q = sqright_(Sq.viewr q)
sqright_ :: ViewR a -> a
sqright_ (xs :> x) = x
-------------------------------------------------------------
chk :: String -> String -> [Int] -> Bool
chk s t ms = foldr (&&) True [((s!!m == t!!(m-mini)) || (s!!m == '?') )| m <- ms]
             where mini = minimum ms

swap :: String -> String -> Int -> String
swap s t n = (take n s) ++ t ++ (drop (n+tl) s)
               where tl = length t

swapa1 :: Char -> Char
swapa1 s = if (s == '?') then 'a' else s
swapa :: String -> String
swapa sn = map swapa1 sn

main = do
    s <- getLine
    t <- getLine
    let sl = length s
    let tl = length t
    let inter = [[i..(i+tl-1)] | i <-  [0..(sl-tl)]]
    let subable = findIndices (==True) [chk s t ms | ms <- inter]
    let swaping = [swap s t i | i <- subable]
    if (null swaping == True)
    then putStrLn "UNRESTORABLE"
    else putStrLn $ head $ sort $ map swapa swaping
    
    
    

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N,L,R;
  int answer = 0;

  cin >> N;
  for(int i = 0; i < N ; i++){
    cin >> L >> R;
    answer += R-L+1;
  }
  cout << answer <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define END getchar();getchar();return 0
int x[100000];

signed main() {
	int ans = 1;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		x[a]++;
	}
	if (n % 2 == 1) {
		if (x[0] != 1) {
			cout << 0 << endl;
			END;
		}
		else {
			for (int i = 2; i < n; i+=2) {
				if (x[i] != 2) {
					cout << 0 << endl;
					END;
				}
				ans *= 2;
				ans %= 1000000007;
			}
		}
	}
	else {
		for (int i = 1; i < n; i+=2) {
			if (x[i] != 2) {
				cout << 0 << endl;
				END;
			}
			ans *= 2;
			ans %= 1000000007;
		}
	}
	cout << ans << endl;

	END;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

void insertionSort(int A[], int N) { // N個の要素を含む0-オリジンの配列A
    int i, j, v, l;
    for (i = 1; N > i; i++) {   //for i が 1 から N-1 まで
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j + 1] = v;
        cout << A[0];
        for(l =1; l < N; l++){
            cout << " " << A[l];
        }
        cout << endl;
    }
}

int bubbleSort(int A[], int N) { // N 個の要素を含む 0-オリジンの配列 A
    int j, l, t, c=0;
    int flag = 1; // 逆の隣接要素が存在する
    while (flag) {
        flag = 0;
        for(j = N-1; j > 0; j--) {
            if(A[j] < A[j-1]) {
                t = A[j];
                A[j] = A[j-1];
                A[j-1] = t;
                flag = 1;
                c++;
            }
        }
    }
    return c;
}

int main() {
    int A[110];
    int i, l, N, t, f, flg=1, c;
    
    cin >> N;
    for(i =0; i < N; i++){
        cin >> A[i];
    }
/*
    cout << A[0];
    for(i =1; i < N; i++){
        cout << " " << A[i];
    }
    cout << endl;
*/
//    insertionSort(A, N);
    c = bubbleSort(A, N);
    cout << A[0];
    for(i =1; i < N; i++){
        cout << " " << A[i];
    }
    cout << endl;
    cout << c << endl;
    return 0;
}



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

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0);

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	
	int n;
	cin>>n;

	map<string, int> m;

	while(n--){
		string x;
		cin>>x;
		m[x]++;
	}
	cout<<m.size();

	return 0;
}

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

struct RollingHash {
	int n;
	static const unsigned P = 1000000007U;
	vector<unsigned long long> pow, phash;
	RollingHash() : n(0) {}

	template<typename T>
	RollingHash(const T& s, unsigned long long Q = 1) {
		n = s.size();
		pow.resize(n + 1); phash.resize(n + 1);
		pow[0] = Q; phash[0] = 0;
		for(int i = 0; i < n; i++) {
			pow[i + 1] = pow[i] * P;
			phash[i + 1] = s[i] + phash[i] * P;
		}
	}
	unsigned long long get(int i) const { return phash[i]; }
	unsigned long long get(int i, int j) const { return get(j) - get(i) * pow[j - i]; }
};

int H, W, P;
struct Pat {
	string b[100];
};

string b[1000];
RollingHash h[1000];

Pat ps[8];
RollingHash hs[8][100];

Pat rotate(Pat p) {
	Pat r;
	for(int i = 0; i < P; i++) {
		r.b[i] = string(P, '0');
	}
	for(int i = 0; i < P; i++) {
		for(int j = 0; j < P; j++) {
			r.b[j][P - 1 - i] = p.b[i][j];
		}
	}
	return r;
}

Pat mirror(Pat p) {
	Pat r;
	for(int i = 0; i < P; i++) {
		r.b[i] = string(P, '0');
		for(int j = 0; j < P; j++) {
			r.b[i][P - 1 - j] = p.b[i][j];
		}
	}
	return r;
}

int conv(char c) {
	if('A' <= c && c <= 'Z') return c - 'A';
	if('a' <= c && c <= 'z') return 26 + c - 'a';
	if(isdigit(c)) return 52 + c - '0';
	if(c == '+') return 62;
	return 63;
}

int check(int x, int y, int k) {
	for(int i = 0; i < P; i++) {
		if(h[y + i].get(x, x + P) != hs[k][i].get(0, P)) return false;
	}
	return true;
}

void solve() {
	int cnt = 0;
	for(int i = 0; i < H - P + 1; i++) {
		for(int j = 0; j < W - P + 1; j++) {
			for(int k = 0; k < 8; k++) {
				if(check(j, i, k)) {
					cnt++;
					break;
				}
			}
		}
	}
	cout << cnt << endl;
}

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

	while(cin >> W >> H >> P, W | H | P) {
		for(int i = 0; i < H; i++) {
			b[i] = "";
			string s;
			cin >> s;
			for(int j = 0; j < s.size(); j++) {
				int x = conv(s[j]);
				for(int k = 0; k < 6; k++) {
					b[i] += char('0' + ((x >> (5 - k)) & 1));
				}
			}
			h[i] = RollingHash(b[i]);
		}

		Pat p;
		for(int i = 0; i < P; i++) {
			string s;
			cin >> s;
			for(int j = 0; j < s.size(); j++) {
				int x = conv(s[j]);
				for(int k = 0; k < 6; k++) {
					p.b[i] += char('0' + ((x >> (5 - k)) & 1));
				}
			}
		}

		int cnt = 0;
		for(int i = 0; i < 4; i++) {
			Pat m = mirror(p);
			ps[cnt] = p;
			for(int j = 0; j < P; j++) {
				hs[cnt][j] = RollingHash(p.b[j]);
			}
			cnt++;
			ps[cnt] = m;
			for(int j = 0; j < P; j++) {
				hs[cnt][j] = RollingHash(m.b[j]);
			}
			cnt++;
			p = rotate(p);
		}

		solve();
	}

}

Measured memory_bytes: 24236
import Control.Arrow (second)
import Data.List
import qualified Data.Vector.Unboxed as V
import qualified Data.ByteString.Char8 as B

solve :: V.Vector Int -> Int
solve xs = V.foldl' gcd (V.minimum xs) xs

main = do
  Just n <- fmap fst . B.readInt <$> B.getLine
  xs <- V.unfoldrN n (fmap (second B.tail) . B.readInt) <$> B.getLine
  print $ solve xs



Measured memory_bytes: 3708
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define sz(x) (int)x.size()

int main() {
	int n;
	cin >> n;
	int k;
	cin >> k;
	vector <pair<int, int>> td(n);
	for (int i = 0; i < n; i++) {
		cin >> td[i].second >> td[i].first;
	}
	sort(td.rbegin(), td.rend());
	//~ for (int i = 0; i < n; i++) {
		//~ cout << td[i].first << " " << td[i].second << endl;
	//~ }
	//~ cout << endl;
	vector <int> un;
	vector <ll> nun;
	ll un_sum = 0;
	vector <bool> used(n + 1);
	ll ans = 0;
	nun.push_back(0);
	for (int i = 0; i < n; i++) {
		if (used[td[i].second]) {
			if (nun.empty()) nun.push_back(td[i].first);
			else nun.push_back(td[i].first + nun.back());
		} else {
			used[td[i].second] = true;
			un.push_back(td[i].first);
			un_sum += td[i].first;
		}
		int x = un.size();
		int need = k - x;
		if (sz(nun) > need && need >= 0) {
			ll total = (ll)x * x;
			total += un_sum;
			total += nun[need];
			ans = max(ans, total);
		}
	}
	cout << ans;
	return 0;
}


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

using namespace std;

int main() {
  int n;cin>>n;
  int t=n;
  int cnt=0;
  while(t>0){
    cnt+=t%10;
    t/=10;
  }
  if(n%cnt==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>

using namespace std;

int R, n, data[3];

int main(void) {
    while(1) {
        scanf("%d%d%d", &data[0], &data[1], &data[2]);
        if(data[0] == 0 && data[1] == 0 && data[2] == 0) break;

        sort(data, data + 3);

        scanf("%d", &n);

        while(n > 0) {
            scanf("%d", &R);
            if(R * 2 > sqrt(data[0] * data[0] + data[1] * data[1])) {
                printf("OK\n");
            } else {
                printf("NA\n");
            }
            n--;
        }
    }
    return 0;
}

Measured memory_bytes: 0
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))

N=int(input())
for i in range(N):
  b=int(input())
  if(a1[0]==b):
    a1[0]=0
  if(a1[1]==b):
    a1[1]=0
  if(a1[2]==b):
    a1[2]=0
  if(a2[0]==b):
    a2[0]=0
  if(a2[1]==b):
    a2[1]=0
  if(a2[2]==b):
    a2[2]=0
  if(a3[0]==b):
    a3[0]=0
  if(a3[1]==b):
    a3[1]=0
  if(a3[2]==b):
    a3[2]=0                                   
l1=[a1[0],a2[0],a3[0]]
l2=[a1[1],a2[1],a3[1]]
l3=[a1[2],a2[2],a3[2]]
l4=[a1[0],a1[1],a1[2]]
l5=[a2[0],a2[1],a2[2]]
l6=[a3[0],a3[1],a3[2]]
l7=[a1[0],a2[1],a3[2]]
l8=[a1[2],a2[1],a3[0]]
if(sum(l1)==0 or sum(l2)==0 or sum(l3)==0 or sum(l4)==0 or sum(l5)==0 or sum(l6)==0 or sum(l7)==0 or sum(l8)==0):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3192
#include<stdio.h>
#define max(p,q)((p)>(q)?(p):(q))
int n,m,q,a[51],b[51],c[51],d[51],A[51],ans;
	
	void dfs(int N){
			if(N==n+1){
				int sum=0;
				for(int i=0;i<q;i++){
					if(A[b[i]]-A[a[i]]==c[i]){ //A[0]は必ず１なので、A[b[i]-1]とはしない
					sum+=d[i];
					}
				}
				ans=max(ans,sum);
			}else{
				for(int i=A[N-1];i<=m;i++){
					A[N]=i;
					dfs(N+1);
				}
	}
}

int main(){
	
	scanf("%d %d %d",&n,&m,&q);
	for(int i=0;i<q;i++){
		scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
	}
	ans=0;
	A[0]=1;
	dfs(1);
	printf("%d\n",ans);
}

Measured memory_bytes: 1736
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define inc(a) scanf("%c", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    ll N, K, X[100], ans=0;
    in2(N, K);
    rep(i, N) in(X[i]);
    rep(i, N) ans += 2*min(X[i], abs(X[i]-K));
    put(ans);
    return 0;
}


Measured memory_bytes: 128
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (declare #.OPT)
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (sb-impl::ansi-stream-read-byte in nil #.(char-code #\Nul) nil))))
    (let* ((minus nil)
           (result (loop (let ((byte (%read-byte)))
                           (cond ((<= 48 byte 57)
                                  (return (- byte 48)))
                                 ((zerop byte) ; #\Nul
                                  ;; (return-from read-fixnum 0)
                                  (error "Read EOF or #\Nul."))
                                 ((= byte #.(char-code #\-))
                                  (setf minus t)))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
        (let* ((byte (%read-byte)))
          (if (<= 48 byte 57)
              (setq result (+ (- byte 48) (* 10 (the (integer 0 #.(floor most-positive-fixnum 10)) result))))
              (return (if minus (- result) result))))))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (declare #.OPT)
  (let* ((n (read))
         (as (make-array n :element-type 'int32)))
    (dotimes (i n) (setf (aref as i) (read-fixnum)))
    (let* ((snuke (reduce #'+ as :start 1))
           (racoon (aref as 0))
           (res (abs (- snuke racoon))))
      (declare (fixnum snuke racoon res))
      (loop for i from 1 below (- n 1)
            do (decf snuke (aref as i))
               (incf racoon (aref as i))
               (setf res (min res (abs (- snuke racoon)))))
      (println res))))

#-swank(main)


Measured memory_bytes: 21864
import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;

public class Main{

	public static void reversePolishNotation() {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] characters = line.split(" ");
		
		Stack<Integer> numbers = new Stack<Integer>();
		
		for(int i = 0; i < characters.length; i++) {
			//if i is a number
			try {
				int number = Integer.parseInt(characters[i]);
				numbers.push(number);
			//if i is an operator
			}catch(Exception NumberFormatException) {
				int x = numbers.pop();
				int y = numbers.pop();
				String operator = characters[i];
				if(operator.equals("+")) {
					numbers.push(y + x);
				}else if(operator.equals("-")) {
					numbers.push(y - x);
				}else if(operator.equals("*")) {
					numbers.push(y * x);
				}else if(operator.equals("/")) {
					numbers.push(y / x);
				}
			}
		}
		System.out.println(numbers.pop());
	}
	
	public static void main(String[] args) {
		reversePolishNotation();
	}
}


Measured memory_bytes: 26312
N = int(input())
hlist = list(map(int, input().split()))
ans = 0
tmp_max = 0
for i in range(N-1):
  if hlist[i] >= hlist[i+1]:
    tmp_max += 1
  else:
    if ans < tmp_max:
      ans = tmp_max
    tmp_max = 0

print(max(ans,tmp_max))

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    int n;cin>>n;
    map<int,int>a;
    for(int i=1;i<=200;++i){
        for(int j=1;j<=200;++j){
            for(int k=1;k<=200;++k){
                a[i*i+j*j+k*k+i*j+j*k+k*i]++;
            }
        }
    }
    for(int i=1;i<=n;++i){
        cout<<a[i]<<endl;
    }
}

Measured memory_bytes: 11400
def isOne_sort(array):
    n = len(array)
    sort_count = 0
    for i in range(0, n-1):
        if(sort_count>1):
            return 'NO'
        # 最小値のインデックスを保持
        min = i
        for j in range(i+1, n):
            if array[min] > array[j]:
                min = j
        # 見つけた最小値を未整列末尾要素と交換
        if(i!=min):
            tmp = array[min]
            array[min] = array[i]
            array[i] = tmp
            sort_count+=1
    return 'YES'

N = int(input())
P = [int(i) for i in input().split()]
print(isOne_sort(P))

Measured memory_bytes: 38256
#include<iostream>
#include<string>
#include <bits/stdc++.h>
#include<vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <math.h>
#include <iomanip>
using namespace std;
using ll = long long;

int main(){
  int n,i,j,k;
  ll l[105],count=0;
  cin >>n;
  for(i=1;i<=n;i++){
    cin >> l[i];
  }
  for(i=1;i<=n-2;i++){
    for(j=i+1;j<=n-1;j++){
      for(k=j+1;k<=n;k++){
        if(l[i]!=l[j] && l[j]!=l[k] && l[k]!=l[i] && l[i]+l[j]>l[k] && l[j]+l[k]>l[i] && l[k]+l[i]>l[j]){
          count++;
        }
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3600
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll x; cin>>x;
    for(ll i=199;;i--){
        for(ll j=-199;j<=0;j++){
            if(i*i*i*i*i-(j*j*j*j*j)==x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
}





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

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    set<char>st1,st2;
    for(int i=0;i<n;i++)
    {
        st1.insert(s[i]);
    }
    int max1=st1.size();
    int max2=
    for(int i=0;i<n;i++)
    {
        st1.erase(s[i]);
        st2.insert(s[i]);
        if()
    }
}
*/
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    string s;
    cin>>n;
    cin>>s;
    int e=0,w=0;
    int palat=0;
    for(int i=1;i<n;i++)
    {
        if(s[i]=='E')
            palat++;
    }
    int min=palat;
    for(int i=1;i<n;i++)
    {
        //cout<<"i "<<i<<" "<<s[i]<<" "<<palat<<endl;
        if(s[i]=='E')
        {
            palat--;
        }
        if(s[i-1]=='W')
            palat++;
        if(min>palat) min=palat;
    }
    cout<<min<<endl;
}


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

using namespace std;

#define pb push_back
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define mem(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, int> pli;

const int mn = 5005;
const int maxlog = 19;

int n,k;

vector<int> v[mn];
void calc(int n,int k){
    for(int i=1;i<=k;i++) v[i].pb(1);
    for(int i=k+1;i<=n;i++){
        v[i].pb((i-k-1)/(k-1)+2);
    }
    int cnt=2;
    for(int i=1;i<=k;i++){
        for(int j=1;j<k;j++) v[i].pb(cnt++);
    }
    for(int i=1;i<k;i++){
        for(int j=k;j<=n;j+=k-1){
            v[j+i].pb(v[2][i]);
        }
    }
    for(int i=3;i<=k;i++){
        for(int l=1;l<k;l++)
        for(int j=1;j<=k-1;j++){
            int u=(i+j*(i-2)-3+l)%(k-1)+1;
            //printf("%d %d %d %d\n",i,j,u,j*(k-1)+1+u);
            fflush(stdout);
            v[j*(k-1)+1+u].pb(v[i][l]);
        }
    }
}

int main() {
    //cin.sync_with_stdio(0);
#ifdef trote
    freopen("../1.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
#endif
    k=38;
    n=k*k-k+1;
    calc(n,k);
    printf("%d %d\n",n,k);
    for(int i=1;i<=n;i++) {
        for(int j=0;j<sz(v[i])-1;j++){
            printf("%d ",v[i][j]);
        }
        printf("%d\n",v[i].back());
    }
    return 0;
}

Measured memory_bytes: 1024
class UnionFind:
    def __init__(self, n):
        self.p = [-1]*n
        # union by rank
        self.r = [1]*n
 
    def find(self, x):
        if self.p[x] < 0:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]
 
    def union(self, x, y):
        rx, ry = self.find(x), self.find(y)
 
        if rx != ry:
            if self.r[rx] > self.r[ry]:
                rx, ry = ry, rx
            if self.r[rx] == self.r[ry]:
                self.r[ry] += 1
            self.p[ry] += self.p[rx]
            self.p[rx] = ry
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def count_member(self, x):
        return -self.p[self.find(x)]

n,m=map(int,input().split())
uf=UnionFind(n+1)
ans=n
for i in range(m):
  x,y,z=map(int,input().split())
  if not(uf.same(x,y)):
    uf.union(x,y)
    ans-=1
  uf.union(x,y)

print(ans)



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

map<long long, int> factorize(long long n) {
    map<long long, int> ret;
    for(long long i=2; i * i <= n; ++i) {
        while(n % i == 0) {
            ++ret[i];
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

int main() {
    int n; cin >> n;
    map<int, int> fac;
    for(int i=0; i<n; ++i) {
        int a; cin >> a;
        auto tmp = factorize(a);
        for(auto p : tmp) fac[p.first] = max(fac[p.first], p.second);
    }
    int res = 1;
    for(auto p : fac) {
        for(int i=0; i<p.second; ++i) res *= p.first;
    }
    cout << res << endl;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
//#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}

int main() {
  int n, m;
  cin >> n >> m;
  lvec h(n);
  REP(i, n) cin >> h[i];
  ivec goods(n);
  vector<set<int>> loads(n);
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    int s = loads[a].size();
    loads[a].insert(b);
    loads[b].insert(a);

    if (loads[a].size() == s) continue;

    if (h[a] > h[b])
      goods[a]++;
    else if (h[a] < h[b])
      goods[b]++;
  }
  int ans = 0;
  REP(i, n) {
    if (goods[i] == loads[i].size()) ans++;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 18504
N, M = map(int, input().split())
x = [list(map(int, input().split())) for i in range(N)]

A = [[0] * 8 for i in range(N)]
for i in range(N):
  A[i][0] = x[i][0] + x[i][1] + x[i][2]
  A[i][1] = x[i][0] + x[i][1] - x[i][2]
  A[i][2] = x[i][0] - x[i][1] + x[i][2]
  A[i][3] = x[i][0] - x[i][1] - x[i][2]
  A[i][4] = -x[i][0] + x[i][1] + x[i][2]
  A[i][5] = -x[i][0] + x[i][1] - x[i][2]
  A[i][6] = -x[i][0] - x[i][1] + x[i][2]
  A[i][7] = -x[i][0] - x[i][1] - x[i][2]
  
A0 = sorted(A, key = lambda x:x[0], reverse = True)
ans = 0
for i in range(M):
  ans += A0[i][0]
  
A1 = sorted(A, key = lambda x:x[1], reverse = True)
ans1 = 0
for i in range(M):
  ans1 += A1[i][1]
ans = max(ans, ans1)
  
A2 = sorted(A, key = lambda x:x[2], reverse = True)
ans2 = 0
for i in range(M):
  ans2 += A2[i][2]
ans = max(ans, ans2)

A3 = sorted(A, key = lambda x:x[3], reverse = True)
ans3 = 0
for i in range(M):
  ans3 += A3[i][3]
ans = max(ans, ans3)
  
A4 = sorted(A, key = lambda x:x[4], reverse = True)
ans4 = 0
for i in range(M):
  ans4 += A4[i][4]
ans = max(ans, ans4)

A5 = sorted(A, key = lambda x:x[5], reverse = True)
ans5 = 0
for i in range(M):
  ans5 += A5[i][5]
ans = max(ans, ans5)
  
A6 = sorted(A, key = lambda x:x[6], reverse = True)
ans6 = 0
for i in range(M):
  ans6 += A6[i][6]
ans = max(ans, ans6)
  
A7 = sorted(A, key = lambda x:x[7], reverse = True)
ans7 = 0
for i in range(M):
  ans7 += A7[i][7]
ans = max(ans, ans7)

print(ans)

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

class Program
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split( ' ');
        int h = int.Parse(str[0]);
        int w = int.Parse(str[1]);

        Console.WriteLine(h * w + " " + (2 * h + 2 * w));
    }
}

Measured memory_bytes: 5600
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <random>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define pi 3.141592653589793
#define prique priority_queue
constexpr auto mod=1000000007;
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int n){
    int cnt=0;
    for(int i=1;i<=sqrt(n);i++){
        if(n%1==0)cnt++;
    }
    if(cnt!=1) return false;
    else return n!=1;
}
struct UnionFind{
    vector<int> r;
    UnionFind(int N){
        r=vector<int>(N,-1);
    }
    int root(int x){
        if(r[x]<0) return x;
        return r[x]=root(r[x]);
    }
    bool unite(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y) return false;
        if(r[x]>r[y]) swap(x,y);
        r[x]+=r[y];
        r[y]=x;
        return true;
    }
    int size(int x){
        return -r[root(x)];
    }
};
vector<int> v;
int n,m,cnt=0,ans=0,aa[220000];
pair<int,int> pp[220000];
string s,ss[220000];
queue<int> que;
signed main(){
    cin>>n;
    rep(i,n){
        ans=0;
        while(1){
            ans++;
            if(ans*(i+1)>=n){
                break;
            }
            cnt++;
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 10564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

bool q(ll n){
    cout << "? " << n << endl;
    char ans;
    cin >> ans;
    return ans=='Y';
}
bool nq(ll n){
    cout << "? " << n << endl;
    char ans;
    cin >> ans;
    return ans=='N';
}
void qd(ll n){
    cout << "! " << n << endl;
    exit(0);
}

// [lb, ub] -> ret の範囲
// last-y: BS(1, 10, nq)-1
// first-y: BS(1, 10, q)
ll BS(ll lb, ll ub, function<bool(ll)> f){
    lb--;
    // (lb, ub]
    while(ub - lb > 1){
        ll mid = (lb + ub) / 2;
        if(f(mid)){
            // (lb, mid]
            ub = mid;
        }else{
            // (mid, ub]
            lb = mid;
        }
    }
    return ub;
}

int main(){
    ll ans = 0;
    ll first_y = BS(1e9, 1e10-1, q);
    dump(first_y);
    if(first_y == (ll)1e9){
        ans = 1;
        while(nq(ans*10-1)){
            ans *= 10;
        }
        qd(ans);
    }else{
        ans = first_y;
        while(ans % 10 == 0){
            ans /= 10;
        }
        ll r = 1;
        while(r < ans){
            r *= 10;
        }
        while(q(r)){
            r *= 10;
            ans *= 10;
        }
        qd(ans);
    }
    return 0;
}

Measured memory_bytes: 596
#define LOCAL

#undef _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define LLINF 1e18
#define INF (int)1e9+1

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto& x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}\n";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "\n[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// End of Gennady-Korotkevich's template 

using llong = long long;
using PII = pair<int, int>;

const llong MOD = 998244353LL;

int main() {
	IOS;
	int x; cin >> x; cout << 1 - x;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <algorithm>  
#include <unordered_set>
#include <cmath>
#define ll long long

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll N;

	cin >> N;

	vector<ll> a(N + 1);

	for (ll i = 1; i <= N; i++) {
		cin >> a[i];
	}

	ll num = 0;

	for (ll i = 1; i <= N; i++) {
		if (a[i] % 2 != 0 && i % 2 != 0) {
			num++;
		}
	}

	cout << num << endl;
	return 0;
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
//using namespace atcoder;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;


#define debug(v) cout<<#v<<": ",prt(v);
template <typename A,typename B>
inline void prt(pair<A,B> p){cout<<"("<<p.first<<", "<<p.second<<")\n";}
template <typename A,typename B,typename C>
inline void prt(tuple<A,B,C> p){cout<<"("<<get<0>(p)<<", "<<get<1>(p)<<", "<<get<2>(p)<<")\n";}
inline void prt(bool p){if(p)cout<<"True"<<'\n';else cout<<"False"<<'\n';}
template <typename T> 
inline void prt(vector<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template<typename T> 
inline void prt(vector<vector<T> >& vv){ for(const auto& v : vv){ prt(v); } }
template <typename T> 
inline void prt(deque<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(unordered_map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(set<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(multiset<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}



int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vector<vector<ll> >dp(n+5,vector<ll> (n+5,0));
    for(int i=n-1;i>=0;i--){
        for(int j=i-1;j>=0;j--){
            if(s[i]==s[j])dp[i][j]=dp[i+1][j+1]+1;
        }
    }
    ll ans = 0;
    rep(i,n)rep(j,n){
        chmax(ans,min(abs(j-i),dp[i][j]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 199128
#include<stdio.h>
#include<string.h>
int main()
{
  int i,leng,m,h;
  char ch[250],a[250];

  while(1)
  { 
    scanf("%s",ch);
    if(ch[0]=='-') break;

    leng=strlen(ch);
    scanf("%d",&m);
    while(m--){
      scanf("%d",&h);
      for(i=0;i<leng;i++){
	a[i]=ch[i];
      }
      for(i=h;i<leng;i++){
	ch[i-h]=ch[i];
      }
      for(i=0;i<h;i++){
	ch[i+leng-h]=a[i];
      }
    }
    printf("%s\n",ch);
  }
  return 0;
}



Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int n,d,a;
  cin >> n >> d >> a;
  vector<P> X(n);
  rep(i,n) cin >> X[i].first >> X[i].second;
  sort(X.begin(),X.end());
  queue<P> que;
  int ans = 0;
  d = d*2;
  int tot = 0;
  rep(i,n){
    int x = X[i].first;
    int h = X[i].second;
    while(que.size() > 0 && que.front().first < x){
      tot -= que.front().second;
      que.pop();
    }
    h -= tot;
    if(h > 0){
      int num = (h+a-1)/a;
      ans += num;
      int dmg = num*a;
      tot += dmg;
      que.push(P(x+d,dmg)); 
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin>>N;
int L[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(L[N-1]<sum)cout<<"Yes";
else cout<<"No";
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;  
typedef long long ll;  
const ll mod=1e9+7;  
ll dp[1000003];  
int main()  
{  
    ll n,sum=0;  
    scanf("%lld",&n);  
    dp[1]=n;  
    dp[2]=(n*n)%mod;
    for(int i=3;i<=n;i++)
    {
        sum=(sum+dp[i-3])%mod;
        dp[i]=(dp[i-1]+sum+(n-1)*(n-1)+n-i+2)%mod;
    }
    printf("%lld\n",dp[n]); 
    return 0;  
}  

Measured memory_bytes: 8064