akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int A = sc.nextInt();
        // スペース区切りの整数の入力
        int B = sc.nextInt();
        int C = sc.nextInt();
        long K = sc.nextLong();
        if(K%2==0){
            //偶数
            System.out.println(A-B);
        }else{
            System.out.println(B-A);
        }
        
        // 文字列の入力
        //String s = sc.next();
        // 出力

        
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

int main(){
  int n;
  cin>>n;
  vector<pair<int,int> > red(n),blue(n);
  vector<bool> used(n,false);

  r(i,n){
    int x,y;
    cin>>x>>y;
    red[i]=make_pair(y,x);
  }

  r(i,n){
    int x,y;
    cin>>x>>y;
    blue[i]=make_pair(x,y);
  }

  sort(blue.begin(),blue.end());
  sort(red.rbegin(),red.rend());

  int cnt=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(blue[i].first>red[j].second and blue[i].second>red[j].first and used[j]==false){
        used[j]=true;
        cnt++;
        break;
      }
    }
  }

  cout<<cnt<<endl;


  return 0;
}


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

int main(){
    string s; cin >> s;
    stack<char> st;
    int ans=0;
    rep(i,s.size()){
        if(st.empty()){
            st.push(s[i]);
            continue;
        }
        char t = st.top();
        if(t!=s[i]){
            ans+=2;
            st.pop();
        }else{
            st.push(s[i]);
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 512
import Data.List

{- Naive Algorithm:  Time Complexity: O(n*m) -}
as `isSubstringOf` bs = any (as `isPrefixOf`) (tails bs)

{-
The implementation of famous KMP Algorithm is from the following link.
https://www.twanvl.nl/blog/haskell/Knuth-Morris-Pratt-in-Haskell
Time complexity: O(n+m)
-}

data KMP a = KMP
      { done :: Bool
      , next :: (a -> KMP a)
      }

isSubstringOf2 :: Eq a => [a] -> [a] -> Bool
isSubstringOf2 as bs = match (makeTable as) bs
   where  match table []     = done table
          match table (b:bs) = done table || match (next table b) bs

isSubstringOf3 :: Eq a => [a] -> [a] -> Bool
isSubstringOf3 as bs = any done $ scanl next (makeTable as) bs

makeTable :: Eq a => [a] -> KMP a
makeTable xs = table
   where table = makeTable' xs (const table)

makeTable' []     failure = KMP True failure
makeTable' (x:xs) failure = KMP False test
   where  test  c = if c == x then success else failure c
          success = makeTable' xs (next (failure x))

main = do
  p<-getLine
  s<-getLine
  putStrLn (if (s `isSubstringOf3` (p ++ p))  then "Yes" else "No")

Measured memory_bytes: 3572
function Main(prm) {
    var n = parseInt(prm.split(' ')[0], 10);
    var r = parseInt(prm.split(' ')[1], 10);

    if(n>=10){
        console.log(r);
    } else {
        console.log(r+(100*(10-n)));
    }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 11468
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      String S = sc.nextLine();
      
      // 管理会社の取得
      char S0 = S.charAt(0);
      char S1 = S.charAt(1);
      char S2 = S.charAt(2);
      
      // バス運行の可能性チェック
      String result = "Yes";
      if(S0 == S1 && S0 == S2){
        result = "No";
      }
        
      // 出力
      System.out.println(result);
    }
    

}

Measured memory_bytes: 21716
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);

		int ans = 0;
		for (int i = a; i <= b; i++) {
			String s[] = String.valueOf(i).split("");

			if (s[0].equals(s[4])) {
				if (s[1].equals(s[3])) {
					ans++;
				}
			}
		}

		System.out.println(ans);

	}
}

Measured memory_bytes: 57368
n = input()
num = [int(x) for x in n]

if sum(num) == 7:
  print(str(num[0])+"+"+str(num[1])+"+"+str(num[2])+"+"+str(num[3])+"=7")
elif num[0] -num[1] + num[2] + num[3] == 7:
  print(str(num[0])+"-"+str(num[1])+"+"+str(num[2])+"+"+str(num[3])+"=7")
elif num[0] -num[1] - num[2] + num[3] == 7:
  print(str(num[0])+"-"+str(num[1])+"-"+str(num[2])+"+"+str(num[3])+"=7")
elif num[0] -num[1] - num[2] - num[3] == 7:
  print(str(num[0])+"-"+str(num[1])+"-"+str(num[2])+"-"+str(num[3])+"=7")
elif num[0] +num[1] - num[2] - num[3] == 7:
  print(str(num[0])+"+"+str(num[1])+"-"+str(num[2])+"-"+str(num[3])+"=7")
elif num[0] +num[1] + num[2] - num[3] == 7:
  print(str(num[0])+"+"+str(num[1])+"+"+str(num[2])+"-"+str(num[3])+"=7")
elif num[0] - num[1] + num[2] - num[3] == 7:
  print(str(num[0])+"-"+str(num[1])+"+"+str(num[2])+"-"+str(num[3])+"=7")
elif num[0] +num[1] - num[2] + num[3] == 7:
  print(str(num[0])+"+"+str(num[1])+"-"+str(num[2])+"+"+str(num[3])+"=7")





Measured memory_bytes: 9288
#include <iostream>
#include <map>

using namespace std;

int main() {
    int s;
    cin >> s;
    int ans = 1;

    map<int,bool> mp;
    while(!mp[s]) {
        mp[s] = true;
        s = (s%2? 3*s+1 : s/2);
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string sa, sb, sc;
  cin >> sa >> sb >> sc;
  int pa = 0, pb = 0, pc = 0;
  char q = 'a';
  string winner;
  while(1){
    if(q == 'a'){
      if(pa == sa.length()){
        winner = "A";
        break;
      }
      q = sa[pa];
      pa++;
    }
    else if(q == 'b'){
      if(pb == sb.length()){
        winner = "B";
        break;
      }
      q = sb[pb];
      pb++;
    }
    else if(q == 'c'){
      if(pc == sc.length()){
        winner = "C";
        break;
      }
      q = sc[pc];
      pc++;
    }
  }
  cout << winner << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define STDIO
#define MOD 1000000007
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define INF MOD
using namespace std;
int n;
int a[200100];
int cnt[200100];
long long f[200100];
long long ff[200100];
long long res;
int main(){
	#ifndef STDIO
		freopen("input.in","r",stdin);
		freopen("output.out","w",stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		cnt[a[i]]++;
	}
	for(int i=1;i<=n;i++){
		f[i]=(long long)(cnt[i])*(long long)(cnt[i]-1)/2LL;
		ff[i]=(long long)(cnt[i]-1)*(long long)(cnt[i]-2)/2LL;
		res+=f[i];
	}
	for(int i=1;i<=n;i++){
		cout<<res-f[a[i]]+ff[a[i]]<<endl;
	}
	return 0;
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;
        Solver s = new Solver();
        for (int i = 1; i <= t; i++) {
            s.solve(i, in, out);
        }
        out.close();
    }

}

class Solver {

    void solve(int test, InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = in.nextInt();
        Arrays.sort(a);
        int s1 = 0, s2 = 0;
        for (int i = n - 1; i >= 0; i -= 2) s1 += a[i];
        for (int i = n - 2; i >= 0; i -= 2) s2 += a[i];
        out.println(s1 - s2);
    }
}

class InputReader {
    BufferedReader br;
    StringTokenizer st;

    public InputReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
        st = null;
    }

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

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

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

    public String nextLine() throws IOException {
        return br.readLine();
    }

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

Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
#define mod 1000000007
using namespace std;

void solve()
{
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
    ll n;
    cin>>n;
    vector<ll> spf(n + 1, 0);
    spf[1] = 1;
    for(ll i=2; i<=n; i+=2)
    {
        spf[i] = 2;
    }
    for(ll i=3; i<=n; i+=2)
    {
        if(spf[i] == 0)
        {
            spf[i] = i;
            for(ll j=i*2; j<=n; j+=i)
            {
                if(spf[j] == 0)
                {
                    spf[j] = i;
                }
            }
        }
    }
    ll ans = 1;
    for(ll i=2; i<=n; i++)
    {
        ll t = i;
        ll val = 1;
        while(t > 1)
        {
            ll p = spf[t];
            ll cnt = 0;
            while(t%p == 0)
            {
                t = t/p;
                cnt++;
            }
            val = val*(cnt+1);
        }
        ans = ans + i*val;
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 81336
<?php
$N = (int) trim(fgets(STDIN));
$c = str_split(trim(fgets(STDIN)), 1);

// r[i] = count(from $c[0 to i], element === 'R')
// count of W ($c[0 to i]) = i - r[i]
// R = r[$N] - r[i] ↑大きい方？
// ずらして最小でいけそう
$r = [0];
$curR = 0;
for($i = 1; $i <= $N; $i++) {
  if($c[$i - 1] === 'R') $curR++;
  $r[$i] = $curR;
}

$cnt = 1e9;
for($i = 0; $i <= $N; $i++) {
  $cnt = min($cnt, max($i - $r[$i], $curR - $r[$i]));
}

echo $cnt, "\n";


Measured memory_bytes: 35652
#include <stdio.h>
#include <math.h>
#define PI 3.14159265359
int main(){
  int a,b,h,w,m; //0<=w<=11  0<=m<=59 0<=a,b<=1000
  double rad;//角度
  double tmp;
  double rength; // a^2
  double ans;
  scanf("%d %d %d %d",&a,&b,&h,&m);
  rad = 2*PI*((h/12.0+m/(12.0*60.0))-(m/60.0)); //2*PI:円一周の角度(360℃)　短針の角度：360(H/12+M/(12*60))長針：m/60
if(rad<0){
  tmp=rad*(-1);
  rad = tmp;
}
if(rad>=180){
  tmp = 360 - rad;
  rad = tmp;
}
//printf("rad = %f\n",rad);
rength = a*a+b*b-2*a*b*cos(rad);
//printf("rength = %f\n",rength);
ans = sqrt(rength);
printf("%.20f\n",ans);

  return 0;
}


Measured memory_bytes: 2596
N = int(input())
t,a = map(int,input().split())
for _ in range(N-1):
    T,A = map(int,input().split())
    b = 1
    if t>T:
        if t%T==0:
            b = t//T
        else:
            b = t//T+1
    T0 = T*b
    A0 = A*b
    c = 1
    if a>A0:
        if a%A0==0:
            c = a//A0
        else:
            c = a//A0+1
    T0 = T0*c
    A0 = A0*c
    c = 1
    if a>A:
        if a%A==0:
            c = a//A
        else:
            c = a//A+1
    T1 = T*c
    A1 = A*c
    b = 1
    if t>T1:
        if t%T1==0:
            b = t//T1
        else:
            b = t//T1+1
    T1 *= b
    A1 *= b
    if T0<=T1:
        t,a = T0,A0
    else:
        t,a = T1,A1
print(t+a)

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

int main() {
    int m, M, k;
    cin >> m >> M >> k;
  	
  	if((M-m+1) > k * 2) {
      //cout << "up" << endl;
      rep(i, k) cout << m + i << endl;
      rep(i, k) {
        cout << M + 1 - k + i;
        if(i!=k-1) cout << endl;
      }
    }else{
      //cout << "under" << endl;
      rep(i, M-m+1) {
        cout << m + i ;
        if(i!=M-m) cout << endl;
      }
    }
  
  	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;

long long int gcd(long long int l, long long int r) {
	if (l > r)return gcd(r, l);
	else {
		if (r%l) {
			return gcd(l, r%l);

		}
		else {
			return l;
		}
	}
}

int main() {
	long long int N, X; cin >> N >> X;
	long long int agcd( gcd(N, X));
	N /= agcd; X /= agcd;
	cout << (N - 1) * 3 * agcd << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a[3];
    rep(i,3){
        cin>>a[i];
    }
    sort(a,a+3);
    cout<<a[2]-a[0]<<endl;

    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long n;
	cin>>n;
	map <string, long long> word;
	string x;
	for (int i=0; i<n; i++){
		cin>>x;
		sort(x.begin(),x.end());
		word[x]++;
	}
	long long  ans=0, k;
	for (auto aux: word){
		k=aux.second;
		ans+=((k-1)*(k))/2;
	}
	cout<<ans<<'\n';
	return 0;
}

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

using namespace std;

int main(){
    int a, b; cin >> a >> b;
    if (1LL * a * b <= 0) cout << "Zero";
    else if ((b - a + 1) % 2 == 0) cout << "Positive";
    else if (a > 0) cout << "Positive";
    else cout << "Negative"; 
    return 0;
}

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

int main(){
  long i=0;
  long N;
  long a;
  int count=0;
  std::vector<long> v;
  cin >> N;
  for(i=0;i<N;i++){
    cin >> a;
    v.push_back(a-1);
  }
  for(i=0;i<N-1;i++){
    if(v[i]==i){
        swap(v[i],v[i+1]);
        count++;
      }
  }
  if(v[N-1]==N-1)count++;
  cout << count;
  return 0;
}


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

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

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() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s.size() != 6) {
        cout << "No" << endl;
    } else if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int H,W;
  cin>>H>>W;
  vector<string> totori(H);
  for(int i=0;i<H;i++){
  cin>>totori.at(i);
  }
  for(int i=0;i<W+2;i++){
    if(i==W+1){cout<<"#"<<endl;}
    else{cout<<"#";}
  }
    for(int i=0;i<H;i++)
    cout<<"#"<<totori.at(i)<<"#"<<endl;
    for(int i=0;i<W+2;i++){
    if(i==W+1) {cout<<"#"<<endl;}
    else {cout<<"#";}
    }
}

Measured memory_bytes: 256
n = int(input())
s = input()
need_L = 0
cnt = 0
for c in s:
    if c == ')':
        cnt += 1
        if 0 < cnt:
            need_L += 1
            cnt -= 1
    elif c == '(':
        cnt -= 1
need_R = max(-cnt, 0)
print('('*need_L + s+')'*need_R)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define endl "\n"
#ifdef ONLINE_JUDGE
#define DEBUG(x)
#else
#define DEBUG(x) cout<<#x<<" : {"<<x<<"}"<<endl;
#endif
using namespace std;
typedef long long int lli;
inline lli binexp(lli a, lli b, lli m){
	lli res = 1LL;
	while(b != 0){
		if(b & 1){
			res *= a;
			if(res > m)
				return -1LL;
			b--;
		}
		else{
			a = a * a;
			b /= 2;
		}
	}
	return res;
}

 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m;
	cin >> n >> m;
	vector<int> v(n);
	for(int i=0; i<n; ++i)	cin >> v[i];
	int factors = 0;
	bool possible = true;
	for(int i=0; i<n; ++i){
		int ele = v[i]/2;
		if(!possible)	break;
		if(ele%2 == 0){
			int cnt = 0;
			while(ele%2 == 0){
				cnt++;
				ele /= 2;
			}
			if(i != 0 && cnt != factors){
				possible = false;
				break;
			}
			factors = cnt;
		}
	}
	if(!possible){
		cout << 0 << endl;
		return 0;
	}
	lli prod = 1LL;
	
	if(!possible)
		cout << 0 << endl;
	else{
		lli l = (lli)v[0]/2;
		for(int i=1; i<n; ++i){
			l = (l * (v[i]/2)) / (__gcd(l, (lli)v[i]/2));
			if(l > m){
				possible = false;
				break;
			}
		}
		if(!possible){
			cout << 0 << endl;
		}
		else{
			lli num = m / (int)l;
			cout << (num + 1)/2 << endl;			
		}

	}
	
	return 0;
}


Measured memory_bytes: 3688
N = int(input())
ans=""
for i in range(1,15):
    if N<=26**i:
        N=N-1
        for j in range(i):
            # print(N)
            ans=ans+(chr(N%26+ord("a")))
            N=int(N/26)
        break
    else:
        N=N-26**i
print(ans[::-1])

Measured memory_bytes: 9116
#include <stdio.h>
#define M 2000000

int a,in[M+1];


void Max_retu(int x){
  int R,L,change,s;
  L=2*x;
  R=2*x+1;
  
  if(L<=a && in[x]<in[L]){
    s=L;
  }
  else s=x;
  if(R<=a && in[s]<in[R]){
    s=R;
  }
  if(s!=x){
    change=in[x];
    in[x]=in[s];
    in[s]=change;
    Max_retu(s);
  }
}

int ext(){
  int x;
  x=in[1];
  in[1]=in[a--];
  Max_retu(1);
  return x;
}


void inc(int k){
  int c,x;
  x=a;
  in[x]=k;
  while(x>1 && in[x/2]<in[x]){
    c=in[x];
    in[x]=in[x/2];
    in[x/2]=c;
    x=x/2;
  }
}

int main(){
  int k;
  char order[10];

  while(1){
    scanf("%s",order);
    if(order[0]=='i'){
      scanf("%d",&k);
      a++;
      inc(k);
    }
    else if(order[1]=='x'){
      printf("%d\n",ext());
    }
    else break;
  }
return 0;
}



Measured memory_bytes: 5636
#include <iostream>

using namespace std;

int main() {
	
	int N,a[120000];
	
	cin >> N;
	
	int ans = 0;
	
	for(int i = 0;i < N;i++)
	{
		cin >> a[i];
		
		if(a[i] - 1 < i)
			if(a[a[i] - 1] - 1 == i)
				ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}

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

k = []
s = []
for i in range(M):
  kari = list(map(int, input().split()))
  k.append(kari.pop(0))
  s.append(kari)
p = list(map(int, input().split()))

ans = 2**N
for n in range(2**N):
  # 2**N通りのケースをすべて試す
  # nは0から2**N-1まで（10進法）
  
  for i in range(M):
    # M個のスイッチ（i）がすべて点灯しているかチェック
    
    hantei = 0
    for j in range(k[i]):
      hantei = hantei + ((n >> (s[i][j]-1))&1)

    if hantei%2 != p[i]:
      ans += -1
      break
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;

template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (int i = 0; i < v.size(); ++i)
    {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    for (int i = 0; i < v.size() - 1; ++i)
    {
        os << v[i] << " ";
    }
    if (v.size() > 0)
    {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

ll gcd(ll a, ll b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main()
{
    int n;
    cin >> n;
    vll a(n), b(n);
    REP(i,n){
        cin >> a[i] >> b[i];
        if (b[i] < 0){
            b[i] *= -1;
            a[i] *= -1;
        }
        if (a[i] == 0 && b[i] != 0){
            b[i] = 1;
        }else if (a[i] != 0 && b[i] == 0){
            a[i] = 1;
        }
        ll val = gcd(abs(a[i]), abs(b[i]));
        if (val > 0)
        {
            a[i] /= val;
            b[i] /= val;
        }
    }
    map<pair<ll, ll>, int> ma;
    REP(i, n)
    {
        ma[make_pair(a[i], b[i])]++;
    }
    vll twopar(300000, 1);
    REP(i,300000-1){
        twopar[i + 1] = twopar[i] * 2 % MOD;
    }
    ll ans = 1;
    set<pll> seen;
    ll add = 0;
    for (auto elem : ma)
    {
        pll now = elem.first;
        if (now.first == 0 && now.second == 0){
            add = elem.second;
            continue;
        }
        if (seen.find(now) != seen.end()){
            continue;
        }
        pll val{-now.second, now.first};
        if (val.second == 0) val.first = 1;
        else if (val.second < 0)
        {
            val.first *= -1;
            val.second *= -1;
        }
        seen.insert(val);
        ans = (ans * (((twopar[elem.second] + twopar[ma[val]]) % MOD - 1 + MOD) % MOD)) % MOD;
    }
    cout << (ans + add + MOD - 1) % MOD << endl;
}


Measured memory_bytes: 46144
#include <bits/stdc++.h>
using namespace std;
#define _for(i,a,b) for(int i = (a);i <= (b);++i)
typedef long long ll;
const int maxn = 1e5+5;
const int mod = 1e9+7;
ll qpow(ll a,ll b){ll res = 1;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int main()
{

	double a,b,c;
	cin>>a>>b>>c;
	double tmp = a/c;
	if(b<tmp)printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll cnt0 = 0, cnt1 = 0;
    string S;
    cin >> S;
    rep(i,S.size()){
        if (S[i] == '0') cnt0++;
        else
            cnt1++;
    }
    cout << 2*min(cnt0, cnt1) << endl;
}

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

using namespace std ;

class Bigint {
	vector<int> digit ;//一桁ずつ格納する
	
public:
	Bigint(){}
	Bigint(string) ;
	Bigint operator + (Bigint &) ;
	friend ostream& operator << (ostream& os, const Bigint& obj) ;
};

Bigint::Bigint(string str)
{
	for(string::iterator it = str.begin() ;
		it != str.end() ;
		it++){
		this->digit.push_back(*it - '0');//一桁ごとに切り分ける
	}
}
Bigint Bigint::operator + (Bigint &obj)
{
	Bigint *domina ;//dominant
	Bigint *depend ;//dependent
	
	if(this->digit.size() >= obj.digit.size()){
		domina = this ;//大きい方が支配的である
		depend = &obj ;
	}else{
		domina = &obj ;
		depend = this ;
	}
	
	int diff = domina->digit.size() - depend->digit.size() ;
	for(int i=0 ; i < diff ; i++){//zero fill (zero padding)
		depend->digit.insert(depend->digit.begin(),0) ;// .unshift(0)　前から詰めるのがunshiftである。しかし、c++は融通も気も効かないので、perlなどで見られるunshiftなる命令があるわけが無く、わざわざ面倒な長い書き方をして、unshiftの代理とせねばならない。しかも、c++11でも無い限りは、back()もfront()も使えない。通常のc++では様々な語が使えないので、ストレスは極限まで上昇する。vectorとstringでこれらの便利極まりない用語が使えないので、c++での文字列操作はperlよりも数段階も悪化した劣悪な環境に置かれている。splitすらも無いというギリギリの状況で、プログラマは一体何をすればいいのか。全く以て深い霧に覆われている。
	}
	
	Bigint temp ;
	int carry = 0 ;
	for(vector<int>::reverse_iterator it = domina->digit.rbegin(),
		jt = depend->digit.rbegin() ;
		it != domina->digit.rend() ;
		it++, jt++){// reverseであることに注意
		int sum = *it + *jt + carry ;
		if(sum >= 10){
			carry = sum/10 ;
			sum = sum%10 ;
		}else{
			carry = 0 ;
		}
		temp.digit.insert(temp.digit.begin(),sum) ;// unshift
	}
	if(carry > 0){
		temp.digit.insert(temp.digit.begin(),carry) ;// unshift
	}
	
	return temp ;
}
ostream& operator << (ostream& os, const Bigint& obj)
{
	if(obj.digit.size() > 80){
		os << "overflow" ;
		return os ;
	}
	
	for(typeof(obj.digit.begin()) it = obj.digit.begin() ;
		it != obj.digit.end() ;
		it++){
		os << *it ;
	}
	
	return os ;
}
int main(void)
{
	int N;
	string str_a, str_b;
	
	cin >> N;
	
	for (int i = 0; i < N; i++){
		cin >> str_a >> str_b ;
		Bigint a(str_a), b(str_b);
		cout << a+b << endl ;
	}
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  while (cin >> n) {
    if (n != 0) {
      vector <double> data(n);
      double sum = 0.0;
      rep(i, n) {
        cin >> data.at(i);
        sum += data.at(i);
      }
      sum /= (double)n;
      double v = 0;
      rep(i, n) {
        v += pow(data.at(i)-sum, 2);
      }
      v /= (double)n;
      cout << fixed << setprecision(10);
      cout << pow(v, 0.5) << endl;
    }
  }
}


Measured memory_bytes: 3432
h, w, K = map(int, input().split())

mod = 10**9+7
dp = [[0] * w for _ in range(h+1)]
dp[0][0] = 1

for i in range(1, h+1):
    for j in range(w):
        left, center, right = 0, 0, 0

        for k in range(2**(w-1)):
            invalid = False
            for l in range(1, w-1):
                if k >> l & 1 and k >> (l-1) & 1:
                    invalid = True

            if invalid:
                continue

            no_line = True

            if j > 0:
                if k >> (j-1) & 1:
                    left += 1
                    no_line = False

            if j < w-1:
                if k >> j & 1:
                    right += 1
                    no_line = False

            if no_line:
                center += 1

        if j > 0:
            dp[i][j] += dp[i-1][j-1] * left

        if j < w-1:
            dp[i][j] += dp[i-1][j+1] * right

        dp[i][j] += dp[i-1][j] * center
        dp[i][j] %= mod

print(dp[h][K-1])


Measured memory_bytes: 68764
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

ll power(ll x, ll y) {
	if (y==0) return 1;
	else if (y==1) return x%MOD;
	else if (y%2==0) {ll pow=power(x,y/2); return (pow*pow)%MOD;} 
	else {ll pow=power(x,y/2); return ((pow*pow)%MOD)*x%MOD;}
}

int main() {
	int n, k; cin >> n >> k;
	VI s(k+1,0);
	ll ans=0;
	for(int i=k;i>=1;i--){
		int p=k/i;
		s[i]=power(p,n);
		for(int j=2;i*j<=k;j++){
			s[i]-=s[i*j];
			s[i]+=MOD;
			s[i]%=MOD;
		}
		ans+=(s[i]*i)%MOD;
		ans%=MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4048
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main(){
    int A, B;
    cin >> A >> B;
    if(A <= 9 and B <= 9) cout << A * B << endl;
    else puts("-1");
}


Measured memory_bytes: 3592
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int M = sc.nextInt();
        
        int ans = (int)M/N;
        
        while( M % ans != 0 ){
            ans--;
        }
        
        System.out.println(ans);
        
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> arr(n);
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	sort(arr.begin(), arr.end());
 	long long int x = 0, y = 0;
	for(int i = n - 1; 0 < i; i--) {
		if(arr[i] == arr[i - 1]) {
			if(x == 0) {
				x = arr[i];
				i--;
			} else if(y == 0) {
				y = arr[i];
				break;
			}
		}
	}
	cout << x * y << endl;

	return 0;
}

Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
ab = [LIST() for _ in range(N)]
cd = [LIST() for _ in range(N)]

check = [0]*N
ab.sort(key = lambda x: (-x[0],-x[1]))
cd.sort(key = lambda x: (x[0], x[1]))

for c, d in cd:
	idx = -1
	tmp = INF
	for i in range(N):
		if check[i] == 0 and ab[i][0] < c and ab[i][1] < d and tmp > d-ab[i][1] :
			tmp = d-ab[i][1]
			idx = i
	if idx != -1:
		check[idx] = 1

print(sum(check))


Measured memory_bytes: 10488
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int n,d,i,j,k,ans=0,a[10][10];
    scanf("%d%d",&n,&d);
    for(i=0;i<n;i++){
        for(j=0;j<d;j++) scanf("%d",&a[i][j]);
    }
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            int sum=0;
            for(k=0;k<d;k++){
                int tmp=abs(a[i][k]-a[j][k]);
                sum+= tmp*tmp;
            }
            int flag=0;
            for(k=0;k<=sum;k++){
                if(k*k==sum) flag=1; 
            }
            if(flag) ans++;
        }
    }
    printf("%d",ans);
    return 0;
}

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

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

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

    ll n, a, b;
    cin >> n >> a >> b;

    ll A = 0;
    ll B = 0;
    ll cnt = n/(a+b);
    ll ost = n%(a+b);
    A = cnt*a;
    B = cnt*b;
    if(ost < a) A += ost;
    else
    {
        A += a;
        ost -= a;
        B += ost;
    }
    cout << A;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
long long int dp[20001];
int main() {
	for (int i = 0; i < 20001; ++i) {
		dp[i] =1e18;
	}
	dp[0]= 0;
	int N, M, K; cin >> N >> M >> K;
	vector<long long int>ws(N);
	for (int i = 0; i < N; ++i) {
		cin >> ws[i];
	}
	for (int i = 0; i < N; ++i) {
		long long int amin = 1e18;
		long long int amax = 0;
		long long int cost = K;
		for (int j = 0; j < min(N-i,M); ++j) {
			amin = min(amin, ws[i + j]);
			amax = max(amax, ws[i + j]);
			dp[i + j + 1] = min(dp[i + j + 1], dp[i] + cost + (j+1)*(amax - amin));
		}
	}
	cout << dp[N] << endl;
	return 0;
}

Measured memory_bytes: 3268
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, m;
vector<int> s[10];

ll bfs(int a, int sum, bool c[8]) {
  if(sum >= n) return 1;
  ll ans = 0;
  REP(i, s[a].size()) {
    if(c[s[a][i]]) {
      bool c_c[10];
      memcpy(c_c, c, sizeof(c));
      c_c[s[a][i]] = false;
      ans += bfs(s[a][i], sum + 1, c_c);
    }
  }
  return ans;
}

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

  cin >> n >> m;
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    s[a].push_back(b);
    s[b].push_back(a);
  }

  bool c[10];
  fill(c, c + n + 1, true);
  c[0] = false;
  cout << bfs(0, 1, c) << endl;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))

l = sorted(l)

import bisect
ans = 0

for i in range(n - 1):
    for j in range(i + 1, n):
        a = l[i]
        b = l[j]
        c = bisect.bisect_left(l,a+b)
        ans += c - j - 1

print(ans)

Measured memory_bytes: 9320
#include <bits/stdc++.h>
using namespace std;
string ans="";
string N;
void calc(int pos,int sum, string s){
  if(pos==4){
    if(sum==7&&ans==""){
      ans=s.substr(5);
      ans += "=7";
    }
    return;
  }
  calc(pos+1,sum+(N[pos]-'0'),s+'+'+N[pos]);
  calc(pos+1,sum-(N[pos]-'0'),s+'-'+N[pos]);
}

int main() {
  cin>>N;
  calc(0,0,N);
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli k, n,m=0;
    cin >> k >> n;
    vi a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(all(a));
    for (lli i = 1; i < n;i++){
        m = max(m, a[i] - a[i - 1]);
    }
    m = max(m, a[0] + k - a[n - 1]);
    out(k - m);
}

Measured memory_bytes: 4908
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;

int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

int main(){
    int A=read(),B=read();
    printf("%d",max(A+B,max(A-B,A*B)));
}


Measured memory_bytes: 128
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: AcCepted
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

bool check(string &s) {
  if (s[0] != 'A') return false;

  int n = s.size(), cf = -1;
  for (int i = 1; i < n; i++) {
    if (s[i] == 'C') {
      if (i < 2 || i > n - 2 || cf >= 0) return false;
      cf = i;
    }
    else if (s[i] < 'a' || s[i] > 'z') return false;
  }

  return (cf >= 0);
}

/* main */

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

  if (check(s)) puts("AC");
  else puts("WA");
  return 0;
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const int MAX_N = 100000;
int n;
ll s[MAX_N];

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n;
  forn(i,n) cin >> s[i];

  ll res = 0;
  for (int c = 1; c < n; c++) {
    ll score = 0;
    for (int i = 0; i*c < n-1; i++) {
      if (i*c == (n-1)-i*c || (i-1)*c == (n-1)-i*c || i*c == (n-1)*(i-1)*c)
        break;
      int a = (n-1)-i*c;
      if (a <= 0 || a-c <= 0) continue;
      score += s[i*c];
      score += s[(n-1)-i*c];
      chmax(res,score);
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll mod=1e9+7;
ll inf=1e18;


int main(void){
	ll n,m,ans=1;
	cin>>n>>m;
	// コメントアウトされたコードで何故WAなのかが分かってない
	// reg(i,2,min(m/n,(ll)100010)){
	// 	if(m%i==0)g1=max(g1,(ll)i);
	// }
	// m/=g1;
	// if(m>100010){
	// 	//mは素数
	// 	ans=g1;
	// 	if(n!=1)ans=m*g1;
	// }else{
	// 	ll g2=1;
	// 	reg(i,2,m/n){
	// 		if(m%i==0)g2=max(g2,(ll)i);
	// 	}
	// 	ans=g1*g2;
	// }
	reg(i,1,sqrt(m)){
		if(m%i==0){
			if(i <= m/n)ans=max(ans,(ll)i);
			if(m/i <= m/n)ans=max(ans,m/i);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

vector<ll> res;

int r(ll n) {
    for(ll i =0;i<res.size()-1;i++) {
        if(n >= res[res.size()-1-i] && res[res.size()-1-i] == 8+res[res.size()-4-i] && res[res.size()-1-i] == 6+res[res.size()-3-i] && res[res.size()-1-i] == 2+res[res.size()-2-i]) {
            return res[res.size()-1-i];
        }
    }
    return 13;
}

int main() {
    vector<ll> is_prime(10000000,true);
    ll fp = 13;
    ll num;
    ll point = 2;
    while(cin >> num) {
        if(num == 0)break;
        if(point > num) {
            cout << r(num) << endl;
            continue;
        }
        for(ll p = point; p <= 10000000; p++) {
            if (!is_prime[p]) {
                if(num == point) {
                    cout << fp << endl;
                    point++;
                    break;
                }
                point++;
                continue;
            }
            for (ll k = p * 2; k <= 10000000; k += p) is_prime[k] = false;
            res.push_back(p);
            if(p >= 13 && res[res.size()-1] == 8+res[res.size()-4] && res[res.size()-1] == 6+res[res.size()-3] && res[res.size()-1] == 2+res[res.size()-2]) {
                fp = res[res.size()-1];
            }
            if(num == point) {
                cout << fp << endl;
                point++;
                break;
            }
            point++;
        }
    }
}



Measured memory_bytes: 89284
#include<iostream>
#include <stdio.h>
#include <string.h>
#include <string>

using namespace std;
int main()
{
	int N, A, Ans;

	cin >> N;
	cin >> A;

	N = N % 500;

	Ans = N - A;

	if (Ans > 0)
		cout << "No";

	else
		cout << "Yes";

	return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  char a[3];
  cin >> a;
  for(int i=0; i<3; i++){
    if(a[i]=='1') cout << 9;
    else cout << 1;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int R;
    scanf("%d",&R);
    if(R<1200)
    {
        printf("ABC");
    }
    else if(R<2800)
    {
        printf("ARC");
    }
   else if(R<=4208)
    {
        printf("AGC");
    }
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

ll dp[55][2];

void solve()
{
    int n, p;
    scanf("%d%d", &n, &p);
    vector<int> a(n);
    dp[0][0] = 1;
    int i,k;
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        for (k = 0; k < 2; k++) {
            dp[i + 1][k] += dp[i][k];
            dp[i + 1][(k + a[i]) % 2] += dp[i][k];
        }
    }
    printf("%lld\n", dp[n][p]);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
void selectionSort(int *,int);
int main(){
    int i,A[100];
    int N;
    scanf("%d",&N);
    for(i=0; i<N; i++){
        scanf("%d",&A[i]);
    }
    selectionSort(A, N);
    return 0;
}
void selectionSort(int *A, int N){
    int v=0,j=0,i,t;
    int cnt=0;
    int minj;
    for(i=0; i<=N-1; i++){
        minj = i;
        for(j=i; j<=N-1; j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        if(i!=minj){
            cnt++;
        }
        v = A[minj];
	    A[minj] = A[i];
	    A[i] = v;
    }   
    for(t=0; t<N-1; t++){
        printf("%d ",A[t]);
    }
    if(t==N-1){
        printf("%d",A[t]);
    }
    printf("\n");
    printf("%d\n",cnt);
}



Measured memory_bytes: 2108
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC170D
//ABC170C
//ABC170B
//ABC170A

int main(void) {
  int n, k, i, cou=0, tmp;

  for(i=0; i<5; i++){
    scanf("%d", &n);
    if(n==0)printf("%d", i+1);
  }

}

Measured memory_bytes: 1732
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
 
int N, A, B, C;
vector<string>op;
vector<char>ans;
 
void err() {
	puts("No");
	exit(0);
}
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
 
	cin >> N >> A >> B >> C;
	op.resize(N);
	for (int i = 0; i < N; i++)cin >> op[i];
 
 
	for (int i = 0; i < N; i++) {
		if (op[i] == "AB") {
			if (A == 0) {
				if (B == 0)err();
				A++;
				B--;
				ans.pb('A');
			}
			else if(B == 0){
				A--;
				B++;
				ans.pb('B');
			}
			else {
				if (i == N - 1) {
					A++;
					B--;
					ans.pb('A');
				}
				else if (op[i + 1] == "AC") {
					A++;
					B--;
					ans.pb('A');
				}
				else {
					A--;
					B++;
					ans.pb('B');
				}
			}
		}
		else if (op[i] == "BC") {
			if (B == 0) {
				if (C == 0)err();
				B++;
				C--;
				ans.pb('B');
			}
			else if (C == 0) {
				B--;
				C++;
				ans.pb('C');
			}
			else {
				if (i == N - 1) {
					B++;
					C--;
					ans.pb('B');
				}
				else if (op[i + 1] == "AB") {
					B++;
					C--;
					ans.pb('B');
				}
				else {
					B--;
					C++;
					ans.pb('C');
				}
			}
		}
		else if(op[i] == "AC"){
			if (C == 0) {
				if (A == 0)err();
				A--;
				C++;
				ans.pb('C');
			}
			else if (A == 0) {
				A++;
				C--;
				ans.pb('A');
			}
			else {
				if (i == N - 1) {
					A--;
					C++;
					ans.pb('C');
				}
				else if (op[i + 1] == "AB") {
					A++;
					C--;
					ans.pb('A');
				}
				else {
					A--;
					C++;
					ans.pb('C');
				}
			}
		}
	}
	puts("Yes");
	fore(x, ans)puts(x);
 
	return 0;
}

Measured memory_bytes: 5484
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,k;cin>>n>>k;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    for(int i=k;i<n;i++){
        if(a[i-k]<a[i])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 4788
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String string;
		while(!(string = reader.readLine()).equals("0 0")){
			for(int i = 0; i < Integer.parseInt(string.split(" ")[0]); i++){
				for(int j = 0; j < Integer.parseInt(string.split(" ")[1]); j++){
					if(i % 2 == 0){
						if(j % 2 == 0){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}else{
						if(j % 2 == 0){
							System.out.print(".");
						}else{
							System.out.print("#");
						}
					}
				}
				System.out.println();
			}
			System.out.println();
		}
		reader.close();
	}
}

Measured memory_bytes: 46508
#include <iostream>
#include <string>
#include <cmath>
#include <set>
#include <utility>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

constexpr long long mod = 1000000007;
constexpr double eps = 0.00001;

int main() {
    int n;
    scanf("%d",&n);
    vector<pair<int,int>> r(n);
    for(int i = 0;i < n;i++) scanf("%d %d",&r[i].first,&r[i].second);
    sort(r.begin(),r.end(),[](auto& i,auto& j){return i.second < j.second;});
    int t = 0,p = 1;
    for(auto& e:r) {
        t += e.first;
        if(e.second < t) p = 0;
    }
    cout << (p ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1920