akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String buffer[] = new String[3];
        int array[] = new int[3];
        String ans;
 
        while(true){
 
 
            try {
                buffer = br.readLine().split("\\s+");
                for(int i = 0; i < buffer.length; i++){
                    array[i] = Integer.parseInt(buffer[i]);
                }
                if(array[0] == -1 && array[1] == -1 && array[2] == -1)break;
 
                if(array[0] == -1 || array[1] == -1){
                    ans = "F";
                }else if(array[0]+array[1] >= 80){
                    ans = "A";
                }else if(array[0]+array[1] >= 65){
                    ans = "B";
                }else if(array[0]+array[1] >= 50){
                    ans = "C";
                }else if(array[0]+array[1] >= 30){
                    if(array[2] >= 50){
                        ans = "C";
                    }else{
                        ans = "D";
                    }
                }else{
                    ans = "F";
                }
 
                System.out.printf("%s\n", ans);
 
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}


Measured memory_bytes: 24644
tax = []
a,b = map(int, input().split())
for i in range(1,10000):
  tax8 = int(i * 0.08)
  if tax8 == a:
    if int(i * 0.1) == b:
      tax.append(i)
if tax == []:
  print(-1)
else:
  print(tax[0])

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <algorithm>

int main() {
	int N, M, X, Y;
	int x, y, a, b;
	bool judge = false;
	std::deque<int>A;
	std::deque<int>B;
	std::cin >> N >> M >> X >> Y;
	for (int i = 0; i < N; i++) {
		std::cin >> x;
		A.push_back(x);
	}

	for (int i = 0; i < M; i++) {
		std::cin >> y;
		B.push_back(y);
	}
	std::sort(A.begin(), A.end());
	std::sort(B.begin(), B.end());

	a = B[0] - A[N - 1];
	b = A[N - 1];

	for (int i = 0; i < a; i++) {
		b++;
		if (b > X && b <= Y) {
			judge = true;
		}
	}

	if (judge == true) {
		std::cout << "No War" << std::endl;
	}
	else if (judge == false) {
		std::cout << "War" << std::endl;
	}
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define drrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	rep(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int MOD = 1'000'000'000 + 7;
const int INF = 1'000'000'000 + 5;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(16);

	int m; std::cin >> m;
	ll sum = 0, dcnt = 0;
	rep(i, m) {
		ll d, c; std::cin >> d >> c;
		sum += d * c;
		dcnt += c;
	}
	std::cout << ((sum + 8) / 9) - 1 + dcnt - 1 << "\n";
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
//#include <bits/stdc++.h>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007


#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(int a,int b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 

 
int main() {
    ll S;
    int ans=0;
    cin >> S;

    if(S==3||S==5||S==7){
  cout<<"YES"<<endl;
    }else{
  cout<<"NO"<<endl;
    }

  return 0;
}





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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main()
{
    int N; cin >> N;
    vvi v(N, vi(N, -1));

    rep(i, N) {
        int A; cin >> A;
        rep(j, A) {
            int x, y; cin >> x >> y;
            x--;
            v[i][x] = y;
        }
    }

    // rep(i, N) {
    //     cout_h(v[i]);
    // }

    int ans = 0;
    for (int n = 0; n < (1<<N); n++) {
        bool ok = true;
        rep(i, N) {
            rep(j, N) {
                if (n & (1<<i)) {
                    if (v[i][j]==1) {
                        if (n & (1<<j)) {
                        } else {
                            ok = false; break;
                        }
                    } else if (v[i][j]==0) {
                        if (n & (1<<j)) {
                            ok = false; break;
                        } else {
                        }
                    }
                }
                // else {
                //     if (v[i][j]==1) {
                        
                //     } else if (v[i][j]==0) {
                        
                //     }
                    
                // }
            }
            if (!ok) break;
        }
        if (ok) {
            chmax(ans, __builtin_popcount(n));
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
function bsearch(T::Array{Int},x::Int)
	L=0
	R=length(T)+1
	while R-L>1
		M=(L+R)>>1
		if T[M]<x
			L=M
		else
			R=M
		end
	end
	R
end
function calc(A::Array{Int},B::Array{Int},T::Int)
	cnt=0
	for a=A
		cnt+=bsearch(B,2T-a)-bsearch(B,T-a)+bsearch(B,4T-a)-bsearch(B,3T-a)
	end
	cnt%2
end
f(A::Array{Int},mod::Int)=[x%mod for x=A]
function main()
	N=parse(Int,readline())
	A=map(x->parse(Int,x),split(readline()))
	B=map(x->parse(Int,x),split(readline()))
	ans=0
	for k=0:28
		T=2^k
		ans+=calc(f(A,2T),sort(f(B,2T)),T)*T
	end
	println(ans)
end
main()


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

int main(){
  int x;
  cin >> x;
  
  if(x >= 400 && x <= 599) cout << 8 << endl;
  else if(x >= 600 && x <= 799) cout << 7 << endl;
  else if(x >= 800 && x <= 999) cout << 6 << endl;
  else if(x >= 1000 && x <= 1199) cout << 5 << endl;
  else if(x >= 1200 && x <= 1399) cout << 4 << endl;
  else if(x >= 1400 && x <= 1599) cout << 3 << endl;
  else if(x >= 1600 && x <= 1799) cout << 2 << endl;
  else cout << 1 << endl;
  
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1e9 + 7;
typedef pair<int,int> P;// pair型は２つの値の組を表せる

int main(){
    int N; cin >> N;
    map<string,int> P;
    vector <string> T(N);
    
    int ans=0;
    rep(i,N) cin >> T[i];
    sort(T.begin(),T.end());
    
    rep(i,N){
        P[T[i]]++;
        ans=max(ans,P[T[i]]);
    }
    
    rep(i,N){
        if (ans==P[T[i]]){
            cout << T[i] << endl;
            P[T[i]]=0;
        }
    }
}

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

public class Main {
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));		
		
		char[] letters = sc.next().toCharArray();
		int[] numbers = new int[letters.length];
		
		for (int i = 0; i < letters.length; i++) {						
			String string = String.valueOf(letters[i]);
			numbers[i] = Integer.parseInt(string);
		}
		
		int N = letters.length-1;
		
		for (int i = 0; i < 1<<N; i++) {
			int total = numbers[0];
			String backup = String.valueOf(numbers[0]);
			for (int j = 0; j < N; j++) {
				if ((1&i>>j)==1) {
					backup+="+" + String.valueOf(numbers[j+1]);
					total += numbers[j+1];
					
				}else {
					backup+="-" + String.valueOf(numbers[j+1]);
					total -= numbers[j+1];
				}
			}
			if (total==7) {
				backup+="=7";
				out.println(backup);
				break;
			}
			
		}
		out.close();
	}

	//-----------http://codeforces.com/blog/entry/7018---------------------------------
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

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

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

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

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

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

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

	}
	//--------------------------------------------------------

}


Measured memory_bytes: 23124
#include<stdio.h>

int main(void){
  long long i,j;
  int n,prime[50001];

  prime[0]=1;
  prime[1]=1;

  for(i=2;i<50001;i++)
    prime[i]=0;

  for(i=2;i*i<50001;i++){
    if(prime[i]==0){
      for(j=2*i;j<50001;j+=i)
	prime[j]=1;
    }
  }

  while(1){
    int count=0;
    scanf("%d",&n);
    if(n==0)break;    

    for(i=0;i<n/2+1;i++)
      if(prime[i]==0 && prime[n-i]==0)count++;
    
    printf("%d\n",count);
  }
  return 0;
}

Measured memory_bytes: 600
MOD = 10**9+7
L = input()

DP1 = [0]
DP2 = [1]

for i in L:
    if i == '1':
        x = (DP1[-1]*3+DP2[-1])%MOD
        y = (DP2[-1]*2)%MOD
        DP1.append(x)
        DP2.append(y)
    else:
        x = (DP1[-1]*3)%MOD
        DP1.append(x)
print((DP1[-1]+DP2[-1])%MOD)


Measured memory_bytes: 11084
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int W, a, b;
  cin >> W >> a >> b;
  if (b > a + W) {
    cout << b - a - W << endl;
  } else if (b + W < a) {
    cout << a - b - W << endl;
  } else
    cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int w, h, x, y, r;
  cin >> w >> h >> x >> y >> r;
  if((x-r) >= 0 && (x+r) <= w){
    if((y-r) >= 0 && (y+r) <= h){
      cout << "Yes\n";
    }else{
      cout << "No\n";
    }
  }else{
    cout << "No\n";
  }
}

Measured memory_bytes: 1128
#include<iostream>
#include<algorithm>

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

using namespace std;
int main(){
	int a[28];
	int f[31];
	rep(i,28)scanf("%d",&a[i]);
	
	fill(f,f+31,0);
	f[0]=1;
	
	rep(i,28)f[a[i]]=1;
	
	rep(i,30)if(f[i+1]==0)printf("%d\n",i+1);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int INF = 0x7fffffff;
const ll LINF = 0x7fffffffffffffff;
const int maxn = 1e6;
const int modn = 1e9 + 7;



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

	string s;
	int a,b;
	bool f1,f2;
	cin>>s;
	a=(s[0]-'0')*10+s[1]-'0';
	b=(s[2]-'0')*10+s[3]-'0';
	if (a>=1 && a<=12) f1=true;
	else f1=false;
	if (b>=1 && b<=12) f2=true;
	else f2=false;
	if (f1 && !f2) cout<<"MMYY"<<endl;
	else if (!f1 && f2) cout<<"YYMM"<<endl;
	else if (f1 && f2) cout<<"AMBIGUOUS"<<endl;
	else cout<<"NA"<<endl;

	return 0;
}


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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};
bool dp[100010];

int main(){
  string S;
  cin >> S;
  
  dp[0] = 1;
  for (int i=0; i<S.size(); i++){
    if (!dp[i])continue;
    for (string s : divide){
      if (S.substr(i, s.size()) == s){
        dp[i + s.size()] = 1;
      }
    }
  }
  cout << (dp[S.size()] ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

int N, M, Q;

int main() {
	cin >> N >> M >> Q;
	vector<vector<int>> imos;
	imos.resize(N+1, vector<int>(N+1, 0));
	for (int m = 0; m < M; m++) {
		int l, r;
		cin >> l >> r;
		imos[l][r]++;
	}
	for (int x = 1; x <= N; x++) {
		for (int y = 1; y <= N; y++) {
			imos[x][y] += imos[x - 1][y] + imos[x][y - 1] - imos[x - 1][y - 1];
		}
	}
	for (int query = 0; query < Q; query++) {
		int p, q;
		cin >> p >> q;
		cout << imos[q][q] - imos[p-1][q] - imos[q][p-1] + imos[p - 1][p - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

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

#define fi first
#define se second
#define p_b push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define all(x) x.begin(),x.end()
#define sset ordered_set
#define sqr(x) (x)*(x)
#define pw(x) (1ll << x)
#define delete _delete

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
const ll MAXN = 1123456;
const ll N = 1e6;
const ll mod = 1e9 + 7;
mt19937_64 rnd(chrono::system_clock::now().time_since_epoch().count());

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T> void vout(T s){cout << s << endl;exit(0);}

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

    ll n;
    cin >> n;

    vector <ll> a(n + 1), b(n + 1);

    for(int i = 1; i <= n; i++)cin >> a[i];

    vector <ll> ans;

    for(int i = n; i > 0; i--){
        ll sc = 0;
        for(int j = 2 * i; j <= n; j += i)sc += b[j];
        if(sc % 2 != a[i])b[i] = 1;
        if(b[i])ans.p_b(i);
    }

    cout << ans.size() << "\n";
    for(auto i : ans)cout << i << " ";
    cout << "\n";

    cerr << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
    return 0;
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var L = input[1];
            var eat = int.MaxValue;
            var ans = 0;
            for (int i = 0; i < N; i++)
            {
                ans += L + i;
                if (Math.Abs(L + i) < Math.Abs(eat)) eat = L + i;
            }

            Console.WriteLine(ans - eat);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <sstream>
#include <complex>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <limits>
#include <numeric>

using namespace std;
#define all(a) begin(a), end(a)

using ll = long long;
using ull = unsigned long long;
template <typename T>
using vec = vector<T>;
template <typename T>
using vec2 = vector<vec<T>>;

template <typename V, typename H>
void resize(vector<V> &vec, const H h)
{
    vec.resize(h);
}

template <typename V, typename H, typename... T>
void resize(vector<V> &vec, const H &h, const T... t)
{
    vec.resize(h);
    for (auto &v : vec)
    {
        resize(v, t...);
    }
}

template <typename V, typename T>
void fill(V &x, const T &val)
{
    x = val;
}

template <typename V, typename T>
void fill(vector<V> &vec, const T &val)
{
    for(auto &v:vec)
    {
        fill(v, val);
    }
}

struct pre_
{
    pre_()
    {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(6);
    }
} pre__;

int main(void)
{
    while(1){

        string g;
        int y,m,d;
        cin>>g; 
        if(g == "#"){break;}
        cin >> y >> m >> d;
        if(y >31){
            g = "?";
            y -= 30;
        }
        else if(y == 31 && m>4){
            g = "?";
            y -= 30;
        }
        cout << g << " " << y << " " << m <<" "<< d << endl;
    }

    return 0;

}



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

//#include <unordered_map>

//#include <iostream>//POJ
//#include <vector>
//#include <string>
//#include <iomanip>
//#include <math.h>
//#include <algorithm>
//#include <cstring>
using namespace std;
#define setc cin.tie(0);ios::sync_with_stdio(0)
#define dd(n) cout<<fixed<<setprecision(n)
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define repir(i,a,b) for(int i=(a)-1, i##_first=(b); i>=i##_first; --i)
#define repr(i,n) repir(i,n,0)
#define repir_(i,a,b) for(int i=(a), i##_first=(b); i>=i##_first; --i)
#define repr_(i,n) repir_(i,n,0)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
//template<typename T> T vpop(vector<T> *v) {
//	T res = v->back();
//	v->pop_back();
//	return res;
//}
//char vpop(string *v) {
//	char res = v->back();
//	v->pop_back();
//	return res;
//}
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define contain(q) !q.empty()
#define cont(q) !q.empty()
//#define qpop(q, a, b) a=q.back().first;b=q.back().second;q.pop()
//#define pqpop(p, a, b) a=q.top().first;b=q.top().second;q.pop()
#define el "\n"
#define sp " "
#define pi 3.14159265358979
#define co(x) cout<<x<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#define wildcard(T) numeric_limits<T>::min()

#define pb push_back
#define pq priority_queue
#define np next_permutation

#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

#define lint long long
typedef vector<int> ivec; typedef vector<string> svec;
typedef vector<lint> lvec;
typedef vector<vector<int>> ivvec;
typedef pair<int, int> P;

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

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

int main(){
	setc;

	lint k,s;cin>>k>>s;
	lint ans=0;
	int l;

	rep_(i,k){
		rep_(j, k){
			l=s-i-j;
			if(0<=l&&l<=k)++ans;
		}
	}
	co(ans);
	gc();
}

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

int n, m, l, r, d1;
string s;

int main() {
	cin>>s;
	n = s.length();
	int ans = 100000000;
	for(int i = 0;i<n;i++){
		if(s[i] != s[i+1]){
		int t = max(i+1,n-i-1);
		ans = min(ans,t);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 512
import java.io.*;
import java.math.BigInteger;
import java.util.*;

import javax.transaction.xa.Xid;

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static int n, m;
	static long mod = 998244353;
	static int[][] memo;
	static String s;
	static HashSet<Integer> nodes;
	static HashSet<Integer>[] ad, tree;
	static boolean[] vis, taken;
	static int[] a;
	static TreeSet<Long> al;
	static long[] val;
	static ArrayList<String> aa;
	static char[] b;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		int n=sc.nextInt();
		long ans=0;
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				for(int k=1;k<=n;k++) {
					int d=(int)gcd(i,j);
					ans+=gcd(d, k);
				}
		System.out.println(ans);
		out.flush();
	}

	static long gcd(long a, long b) {

		if (b == 0)
			return a;
		return gcd(b, a % b);
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

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

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public int[] nextArrInt(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 32892
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int long long

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, a, b;
    cin >> n >> a >> b;
    int dt = (abs(a - b));
    if (dt % 2 == 0) {
    	cout << dt / 2 << endl;
    } else {
    	int ans = 2 * n;
    	if (a > b) {
    		swap(a, b);
    	}
    	int wa = a;
    	int wb = b;
    	{
    		b -= a;
    		a = 1;
    		ans = min(ans, wa + (b - a) / 2);
    	}
    	a = wa;
    	b = wb;
    	{
    		int dl = n - b + 1;
    		b = n;
    		a += dl;
    		ans = min(ans, dl + (b - a) / 2);
    	}
    	cout << ans << endl;
    }
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
using Graph = vector<vector<ll>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 1 << 29;
/****** define constant end ********/

/****** define variable start ******/
ll k, n;
vl a;
/******* define variable end *******/
ll solve()
{
    cin >> k >> n;
    a.resize(n);
    REP(i, n)
    {
        cin >> a[i];
    }
    //a[0]から
    ll ans = a[n - 1] - a[0];
    REP(i, n - 1)
    {
        ll tmp = a[i] + (k - a[i + 1]);
        if (tmp < ans)
        {
            ans = tmp;
        }
    }
    for (ll i = 1; i < n; i++)
    {
        ll tmp = (k - a[i]) + a[i - 1];
        if (tmp < ans)
        {
            ans = tmp;
        }
    }
    cout << ans << endl;
    return 0;
}
int main()
{
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */

    return (int)end_solve;
}


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

const int END = -1;
struct StNod
{
  int m_nParnt;
  int m_nLeft;
  int m_nRigt;

  StNod() :
     m_nParnt(END), m_nLeft(END), m_nRigt(END)
  { }
};

enum EnDir
{
  D_Left,
  D_Right,
};

void fnInput(vector<int> &rvnPodr, vector<int> &rvnIodrSeq)
{
  int nMaxSiz;

  cin >> nMaxSiz;
  rvnPodr.resize(nMaxSiz);
  rvnIodrSeq.resize(nMaxSiz + 1);

  for (int i = 0; i < nMaxSiz; i++)
    cin >> rvnPodr[i];

  for (int i = 1; i < nMaxSiz + 1; i++)
  {
    int nNode;
    cin >> nNode;
    rvnIodrSeq[nNode] = i;
  }
}

void fnStructTree(const vector<int> &cnrvnPodr, const vector<int> &cnrvnIodrSeq, vector<StNod> &rvoNod)
{
  for (int i = 1; i < cnrvnPodr.size(); i++)
  {
    int nParnt = END;
    int nx = cnrvnPodr[0];
    EnDir enDir;
    while (nx != END)
    {
      nParnt = nx;
      if (cnrvnIodrSeq[ cnrvnPodr[i] ] < cnrvnIodrSeq[nx])
      {
        nx = rvoNod[nx].m_nLeft;
        enDir = D_Left;
      }
      else
      {
        nx = rvoNod[nx].m_nRigt;
        enDir = D_Right;
      }
    }

    rvoNod[ cnrvnPodr[i] ].m_nParnt = nParnt;
    if (enDir == D_Left)
      rvoNod[nParnt].m_nLeft = cnrvnPodr[i];
    else
      rvoNod[nParnt].m_nRigt = cnrvnPodr[i];
  }
}

void fnPostOrder(const vector<StNod> &cnrvoNod, int nx)
{
  static int stnPrt = 0;
  if (nx == END)  return;

  fnPostOrder(cnrvoNod, cnrvoNod[nx].m_nLeft);
  fnPostOrder(cnrvoNod, cnrvoNod[nx].m_nRigt);

  if (stnPrt++) cout << " ";
  cout << nx;
}

void fnResult(const vector<StNod> &cnrvoNod)
{
  int nx = 1;
  while (cnrvoNod[nx].m_nParnt != END)
    nx = cnrvoNod[nx].m_nParnt;

  fnPostOrder(cnrvoNod, nx);
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnPodr, vnIodrSeq;
  fnInput(vnPodr, vnIodrSeq);

  StNod oNod;
  vector<StNod> voNod(vnIodrSeq.size(), oNod);
  fnStructTree(vnPodr, vnIodrSeq, voNod);
  
  fnResult(voNod);
  return 0;
}

Measured memory_bytes: 1204
import math
def LCM(A):
    X = A[0]
    for I in range(1,len(A)):
        X = (X*A[I])//math.gcd(X,A[I])
    return X
  
N = int(input())
A = [int(I) for I in input().split()]
MAX = LCM(A)-1
FA  = [MAX%I for I in A]
print(sum(FA))

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

using namespace std;

typedef long long int ll;
int MAX = 1e6 +  5;

ll spf[1000006];

void sieve()
{
    for(ll i = 2; i * i <= MAX; i++)
    {
        if(spf[i] == 0)
        {
            spf[i] = i;
            for(ll j = i*i; j <= MAX; j += i) spf[j] = i;
        }
    }
    for(int i = 0; i < MAX; i++) if(spf[i] == 0) spf[i] = i;
}

unordered_map <int,int> mp1;

ll dp[1000005]={0};
map <int,vector<int> > mp4;

void solve()
{
	int n;
	cin >> n;
	int arr[n+1];
	int cnt = 0;
	for(int i = 0; i < n; i++) 
	{
		cin >> arr[i + 1];
		mp1[arr[i + 1]]++;
	}
	int flag = 0;
	for (int i = 1; i <= n; i++) 
	{
		for (int j = 1; j * j <= arr[i]; j++) 
		{
			if (arr[i] % j == 0) 
			{
				if (j == arr[i] && mp1[j] >= 2 || j != arr[i] && mp1[j] >= 1 || arr[i]/j == arr[i] && mp1[arr[i]/j] >= 2 || arr[i]/j != arr[i] && mp1[arr[i]/j] >= 1) 
				{
					goto a;
				}
			}
		}
		cnt++;
		a:;
	}
	cout << cnt;
}

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
//	cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}



Measured memory_bytes: 32488
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int Inf = 1000000000;
const ll INF= 1e18;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int A,B,C;
    cin >> A >> B >> C;
    if(A == B && A != C) {
        cout << "Yes" << endl;
    }
    else if(A == C && A != B) {
        cout << "Yes" << endl;
    }
    else if(B == C && B != A) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>
#include <cstdint>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const long long MOD = 1000000007;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
constexpr auto PI = 3.14159265358979323846264338327950L;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, K, W;
    cin >> H >> W >> K;
    
    vector<vector<char>> c(H, vector<char>(W));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> c[i][j];
        }
    }
    int ans = 0;
    for (int bit = 0; bit < (1 << H); ++bit) {
        for (int bit2 = 0; bit2 < (1 << W); ++bit2) {
            int count = 0;
            for (int i = 0; i < H; ++i) {
                for (int j = 0; j < W; ++j) {
                    if ((bit&(1 << i)) && (bit2&(1 << j)) && c[i][j] == '#')count++;
                }
            }
            if (count == K)ans++;
        }
    }
    cout << ans << endl;
    return 0;

}


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

int main(){
    int n, i, j, k;
    cin >> n;
    int b[n] = {}, c[n] = {};
    for(i=0; i<n; i++){
        cin >> b[i];
    }
    for(i=0; i<n; i++){
        j = n-i-1;
        while(j>=0){
            if(b[j] == j+1){
                break;
            }
            j--;
        }
        if(j == -1){
            cout << -1;
            return 0;
        }
        c[n-i-1] = b[j];
        for(k=j; k<n-i; k++){
            b[k] = b[k+1];
        }
    }
    for(i=0; i<n; i++){
        cout << c[i] << '\n';
    }
    return 0;
}

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

int main(){
    string S;cin>>S;
    if(S[2]==S[3] && S[4]==S[5]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
// Author: 23forever
#include <bits/stdc++.h>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define fi first
#define se second
typedef long long LL;
const int MAXN = 200000;
using namespace std;

inline int read() {
  int x = 0, w = 1;
  char c = ' ';
  
  while (!isdigit(c)) {
    c = getchar();
    if (c == '-') w = -1;
  }

  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }

  return x * w;
}

int main() {
#ifdef forever23
  freopen("test.in", "r", stdin);
  //freopen("test.out", "w", stdout);
#endif
  int ans = 100000, l = read(), r = read();
  
  if (r - l >= 2018) {
    puts("0");
    return 0;
  }

  l %= 2019, r %= 2019;

  if (l > r) swap(l, r);

  for (int i = l; i <= r; ++i) {
    for (int j = i + 1; j <= r; ++j) {
      ans = min(i * j % 2019, ans);
    }
  }

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

Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
	static String[] map;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext()) {
			map = new String[8];
			for(int i = 0; i < 8; i++) {
				map[i] = stdIn.next();
			}
			int ans = solv();
			System.out.println(B[ans]);
		}
	}
	
	public static int solv() {
		for(int i = 0; i < 8; i++) {
			for(int j = 0; j < 8; j++) {
				CON:for(int k = 0; k < A.length; k++) {
					if(i + A[k].length > 8) {
						continue CON;
					}
					for(int l = 0; l < A[k].length; l++) {
						if(j + A[k][0].length() > 8) {
							continue CON;
						}
						if(!map[i+l].substring(j, j+A[k][0].length()).equals(A[k][l])) {
							continue CON;
						}
					}
					return k;
				}
			}
		}
		return -1;
	}
	static String[][] A = new String[][]{{"11","11"},{"1","1","1","1"},{"1111"},{"01","11","10"},{"110","011"},{"10","11","01"},{"011","110"}};
	static String[] B = new String[]{"A","B","C","D","E","F","G"};
	
	

	
}

Measured memory_bytes: 20552
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert
#define fh(x,v) for(auto x:v)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

bool ym,my;

main(){
	string s;cin>>s;
	string f,l;
	f+=s[0];
	f+=s[1];
	l+=s[2];
	l+=s[3];
	//dump(f,l);
	if(toInt(l)>=1&&toInt(l)<=12)ym=1;
	if(toInt(f)>=1&&toInt(f)<=12)my=1;
	if(ym&&my)dump("AMBIGUOUS");
	else if(ym)dump("YYMM");
	else if(my)dump("MMYY");
	else dump("NA");
}





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

int main(){
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	
	string s1,s2;
	int a,b;
	string s;
	cin>>s1>>s2;
	cin>>a>>b;
	cin>>s;

	if(s1 == s)
		a--;
	else
		b--;
	cout<<a<<' '<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
# region header
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
import copy
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7
# endregion
# region input function


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])

# endregion


class osa_k():
    def __init__(self, n):
        """高速素因数分解

        Args:
            n (int): n以下全ての値について素因数分解できるようにする
        """
        self.n = n
        self.minFactor = list(range(0, n + 1))
        self.prime = []

    def factorize(self, i):
        if not self.prime:
            self.get_sieve_of_eratosthenes()
        factor = []
        while i != 1:
            p = self.minFactor[i]
            factor.append(p)
            i //= p
        return factor

    def get_sieve_of_eratosthenes(self):
        """エラトステネスの篩
        """
        limit = math.sqrt(self.n)
        for prime in range(2, self.n + 1):
            if prime >= limit:
                break
            if self.minFactor[prime] == prime:
                self.prime.append(prime)
                for composite in range(2 * prime, self.n + 1, prime):
                    if self.minFactor[composite] == composite:
                        self.minFactor[composite] = prime


n = inp()
a = inpl()
factorizer = osa_k(10**6)
tmp = collections.defaultdict(int)
for i in a:
    p = set(factorizer.factorize(i))
    for j in p:
        tmp[j] += 1
if not tmp.values():
    print("pairwise coprime")
    exit()
max_val = max(tmp.values())
if max_val == 1:
    print("pairwise coprime")
elif max_val == n:
    print("not coprime")
else:
    print("setwise coprime")


Measured memory_bytes: 216856
from fractions import gcd

A, B, C, D = map(int, input().split())
G = gcd(C, D)
L = C * D // G
ca = (A - 1) // C
cb = B // C
da = (A - 1) // D
db = B // D
la = (A - 1) // L
lb = B // L
div = cb + db - (ca + da) - (lb - la)
print(B - (A - 1) - div)


Measured memory_bytes: 5688
#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>;

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	vector<vector<int>> X(N);
	vector<vector<int>> Y(N);
	rep(i, N) {
		cin >> A[i];
		rep(j, A[i]) {
			int x, y;
			cin >> x >> y;
			X[i].push_back(x-1);
			Y[i].push_back(y);
		}
	}
	
	int mx = 0;
	for (int tmp = 0; tmp < (1 << 15); tmp++) {
		if (tmp > pow(2, N)) {
			break;
		}
		bitset<15> a(tmp);
		bool valid = true;
		int ans = 0;
		
		rep(j, N) {
			if (a.test(j) == 1) {
				rep(k, A[j]) {
					if (Y[j][k] != a.test(X[j][k])) {
						valid = false;
						break;
					}
				}
				if (!valid) {
					break;
				}
				ans++;
			}
			
		}
		if (valid) {
			mx = max(ans, mx);
		}
	}

	cout << mx << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main(){
	int n , i , j=0 , x[100001];
	cin >> n ;
	for( i=0 ; i<n ; i++ ){
		cin >> x[i] ;
		int total=0;
		if( x[i]%2==0 && x[i] != 2 ) continue ;
		int N=sqrt( x[i] );
		for( int k=1; k<=N ; k++ ){
			if(x[i]%k ==0 )
				total++;
		}
		if( total == 1 ){
			j++;
		}
	}
	cout << j<< endl;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n), c(n);
    cin >> v >> c;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        ans += max(0, v[i] - c[i]);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    string S;
    cin >> S;
    stack<char> st;

    int res = 0;
    for (int i = 0; i < S.size(); i++) {
        if (st.empty()) {
            st.push(S[i]);
        }
        else {
            if ((st.top() == '0' && S[i] == '1') || (st.top() == '1' && S[i] == '0')) {
                st.pop();
                res += 2;
            } else {
                st.push(S[i]);
            }
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int gcd(int x,int y){
	int r,tmp;
	if(x < y){
		tmp=x;
		x=y;
		y=tmp;
	}
	while(y > 0){
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
int main(){
	int x,y,d;
	scanf("%d%d",&x,&y);
	d=gcd(x,y);
	printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 2720
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, a;
	cin >> n >> a;
	vector<int> x(n);
	rep (i, n) cin >> x[i];
	ll dp[n + 1][2501] = {1}, ans = 0;
	rep (i, n) {
		reprev (k, n) {
			rep (y, 2501) {
				dp[k + 1][y + x[i]] += dp[k][y];
			}
		}
	}
	rep (k, n) {
		ans += dp[k + 1][(k + 1) * a];
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1280
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N, M = MAP()
SHOP = [MAP() for _ in range(N)]
SHOP.sort()

A = [s[0] for s in SHOP]
B = [s[1] for s in SHOP]

#print(A, B)

bought = 0
money = 0
for i in range(N):
	if bought+B[i] < M:
		money += A[i]*B[i]
		bought += B[i]
	else:
		money += A[i]*(M-bought)
		bought += M-bought

print(money)

Measured memory_bytes: 63324
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
ll N;
void solve(ll N){
  for (ll h = 1; h <= 3500; h++){
    for (ll w = 1; w <= 3500; w++){
      ll a = h * w * N;
      ll b = 4 * h * w - N * w - N * h;
      if (b == 0){
        continue;
      }
      if (a <= 0 or b <= 0){
        continue;
      }
      if (a % b == 0){
        cout << h << " " << w << " " << a / b << endl;
        return ;
      }
    }
  }
}
int main() {
  cin >> N;
  solve(N);
  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main()
{
    int H, W, N;
    cin >> H >> W >> N;

    int mx = max(H, W);
    int cnt = 0;
    while (N > 0)
    {
        N -= mx;
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256