akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
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;
}

const int mod = 1000000007;
const int max_n = 200005;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
    ll n,k;cin >> n >>k;
    vl a(n);rep(i,n)cin >> a[i];
    vector<vector<mint>> dp(n+1,vector<mint>(k+1)),cum(n+1,vector<mint>(k+2));
    dp[0][0]=1;rep(i,k+2)cum[0][i]=1;cum[0][0]=0;
    rep(i,n){
        rep(j,k+1){
            dp[i+1][j]+=cum[i][j+1];if(j-a[i]>=0)dp[i+1][j]-=cum[i][j-a[i]];
        }
        rep(j,k+1)cum[i+1][j+1]+=cum[i+1][j]+dp[i+1][j];
    }
    /*rep(i,n+1){
        rep(j,k+1){
            cout << dp[i][j] <<" ";
        }
        cout << endl;
    }
    cout << endl;
    rep(i,n+1){
        rep(j,k+2){
            cout << cum[i][j] <<" ";
        }
        cout << endl;
    }*/
    cout << dp[n][k] <<endl;
}

Measured memory_bytes: 161948
#!/usr/bin/python3
# ABC120: C
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline

def debug(*args): print("DEBUG:\t", *args, file=sys.stderr)


def combine(S, i):
    if S[i] != S[i+1]:
        S
        return S[0:i] + S[i+2:]
    else:
        assert False

def main(S, answer=0, _d=False):
    S = [int(x) for x in S]
    return solve(S, answer, _d)

def solve(S, answer=0, _d=False):
    i = 0
    while i < len(S) - 1:
        #debug(S, "i=%d"% i, answer)
        if S[i] != S[i+1]:
            answer += 2
            del S[i:i+2]
            i = max(i - 1, 0)
        else:
            i += 1
    debug("answer", answer)
    return answer

def check(S, expected):
    a = main(S)
    if a != expected:
        print(a)
        print("expected %d" % expected, "but %d" % a, "for", S)

if 1==0:
    check("0011", 4)
    check("101", 2)
    check("111", 0)
    check("010", 1)
    check("0", 0)
    check("11011010001011", 12)

print(main(input().strip()))


Measured memory_bytes: 4092
N, K, Q = map(int, input().split(" "))
As = [int(input()) for i in range(Q)] 
ex = [0]*N

for q in As:
  ex[q-1] += 1

for n in range(N):
  if K - Q + ex[n] > 0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 55896
#include <iostream>
#include <vector>
#include <cmath>
#define REP(i, n) for (ll i = 0; i < (n); i++)
using ull = unsigned long long int;
using ll = long long int;
using namespace std;

ull calc_button(ull a, ull b) { return ceil((double)a / b) * b - a; }

int main() {
  ll N;
  cin >> N;
  vector<ull> A(N);
  vector<ull> B(N);
  REP(i, N) {
    cin >> A[i];
    cin >> B[i];
  }
  ull answer = 0;
  for (ll i = N - 1; i >= 0; i--) {
    answer += calc_button(A[i] + answer, B[i]);
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <bitset>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

int main(){
    int D, G;
    cin >> D >> G;

    int p[D], c[D];
    for(int i=0; i<D; i++){
        cin >> p[i] >> c[i];
    }

    int ans = 1000000005;
    // 1のやつをを全部解き、あまったら残りの中で一番点高いやつを解く
    for(int s=0; s<pow(2, D); s++){
        int total = 0;
        int cnt = 0;
        // cout << "---------" << endl;
        // cout << bitset<2>(s) << endl;
        for(int i=0; i<D; i++){
            if(((s>>i)&1) == 0) continue;
            total += 100*(i+1)*p[i] + c[i];
            cnt += p[i];
            // cout << i << " " << 100*(i+1)*p[i] + c[i] << endl;
        }
        if(total >= G){
            ans = min(ans, cnt);
            continue;
        }

        bool fl = false;
        for(int i=D-1; i>=0; i--){
            if(((s>>i)&1) == 1) continue;
            int add = ceil((G-total)/(100*(i+1)));
            if(add == 0) add++;
            if(add < p[i]){
                cnt += add;
                fl = true;
            }
            break;
        }

        if(fl) ans = min(ans , cnt);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define all(x) x.begin(),x.end()
#define ini(x,y) memset(x,y,sizeof(x))
#define cauto const auto &
#define cint const int &
#define F(x, y, z) for (int x = y; x <= z; x++)
#define D(x, y, z) for (int x = y; x >= z; x--)
using namespace std;
const int INF = 0x3f3f3f3f3f3f3f3f;
const int MAXN = static_cast<int>(1e5 + 25);
inline int read()
{
  int x = 0, y = 1, c = getchar();
  while (c > '9' || c < '0')
  {
    if (c == '-')
    {
      y = -1;
    }
    c = getchar();
  }
  while (c >= '0' && c <= '9')
  {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * y;
}
/*
 * 用最短的时间取得胜利！！！！
*/
struct road{
    int to,v;
    road(int to=0,int v=0):to(to),v(v){}
};

static vector<road> edge[MAXN];
struct heapnode{
    int to,val;
    heapnode(int T=0,int V=0):to(T),val(V){}
    bool operator<(const heapnode r)const{
        return val>r.val;
    }
};
static priority_queue<heapnode> q;
static int d[MAXN];
void dijkstra(){
    ini(d,0x3f);
    d[0]=0;
    q.push(heapnode(0,0));
    while(!q.empty()){
        int pos=q.top().to;
        q.pop();
        for(auto to:edge[pos]){

            if(d[pos]+to.v<d[to.to]){
                d[to.to]=d[pos]+to.v;//cout<<pos<<" "<<to.to<<" "<<d[to.to]<<endl;
                q.push(heapnode(to.to,d[to.to]));
            }
        }
    }
}
signed main(){
    int k=read();
    F(i,1,k-1){
        int now=i;
        F(j,1,9){
            edge[(i+j)%k].push_back(road(i,j));
            now*=10;
            edge[now%k].push_back(road(i,0));
        }
    }
    dijkstra();
//    int minn=INF;
    printf("%lld",d[1]+1);
    return 0;
}


Measured memory_bytes: 64624
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   
   //let ans =(xs[0]+xs[1])%2
   //console.log(ans)
  
   if(xs[0]>0 && xs[1]>0){
   console.log('Positive')
   }else if(xs[0]<0 && xs[1]>0){
   console.log('Zero')
   }else if((xs[0]+xs[1])%2 ==-1){
   console.log('Positive')
   }else if((xs[0]+xs[1])%2 ==0){
   console.log('Negative')
   }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));



Measured memory_bytes: 11468
#include <iostream>
using namespace std;
int main() {

	/* 177

	int D, T, S;
	cin >> D >> T >> S;
	int hour = D / S;
	if (D % S != 0)hour++;
	if (hour <= T) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
	
	*/

	/* 175
	string S;
	cin >> S;
	if (S == "RRR") {
		cout << 3 << endl;
	}
	else if (S == "SSS") {
		cout << 0 << endl;
	}
	else if (S == "SRR" || S == "RRS") {
		cout << 2 << endl;
	}
	else {
		cout << 1 << endl;
	}
	*/	

	/* 178
	int x;
	cin >> x  ;
	if (x == 1) {
		cout << 0 << endl;
	}
	if (x == 0) {
		cout << 1 << endl;
	}
	*/ 

	/* 174
	int X;
	cin >> X;
	if(X>=30){
		cout << "Yes"<<endl;
	}
	else{
		cout << "No"<<endl;
	}
	*/

	int N, X, T;
	cin >> N >> X >> T;
	if (N % X == 0) {
		cout << N / X * T << endl;
	}
	else {
		cout << N / X *T +T<<endl;
		return 0;


	}
}



Measured memory_bytes: 3576
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();		
		int N = r.ri();
		long L0 = 2;
		long L1 = 1;
		
		for(int i = 2; i<=N;i++)
		{
			long temp = L0 + L1;
			L0 = L1;
			L1 = temp;
		}
		
		print(L1);		
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}
	
	public static void swap(int[] arr, int pos1, int pos2) {
		int temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	public static void swap(long[] arr, int pos1, int pos2) {
		long temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	
	public static String al(String s) {
		return s + "\n";
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

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

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

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

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
#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++)
#define _GLIBCXX_DEBUG
int main()
{
    int s,m;
    cin>>s;
    int d=1000000;
    vin a(d);
    a[0]=s;
    bool can=false;
    for(int i=1;i<=d;i++){
        if(a[i-1]%2)a[i]=3*a[i-1]+1;
        else a[i]=a[i-1]/2;
        rep(j,i){
            if(a[i]==a[j]){
                m=i+1;
                can=true;
                break;
            }
        }
        if(can)break;
    }
    cout<<m<<endl;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long int ll;
using namespace std;

int main()
{
    int n; cin >> n;
    string s,t; cin >> s >> t;
    for(int i=0;i<n;i++){
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;
int s[110];

int main(){
   int n;
   cin>>n;
   int sum=0;
   for(int i=0;i<n;i++){
      cin>>s[i];
      sum+=s[i];
   }
   sort(s,s+n);
   if(sum%10!=0){
      cout<<sum<<endl;
      return 0;
   }
   else for(int i=0;i<n;i++){
      if(s[i]%10!=0){
         cout<<sum-s[i]<<endl;
         return 0;
      }
   }
   cout<<0<<endl;
   

}

Measured memory_bytes: 256
a,b,c,d,e,f = map(int, input().split())
# + 100a 水
# + 100b 水
# + c 砂糖
# + d 砂糖
# 100gの水にe[g]のsugar
# 水と砂糖の合計はf以下。溶け残し厳禁

def s_max(w):
    ret1 = e*w/100
    ret2 = f-w
    s = min(int(ret1),int(ret2)) #砂糖の最大量
    dp = [False]*(s+1)
    dp[0] = True
    for i in range(s+1):
        for j in range(s+1):
            if j + i*c <= s:
                dp[j+i*c] = dp[j]
    for i in range(s+1):
        for j in range(s+1):
            if j + i*d <= s:
                dp[j+i*d] = dp[j+i*d] or dp[j]
    ret = 0 
    for i in range(s+1):
        if dp[i]: ret = i
    return ret

dp = [False] * ((f//100)+1)
dp[0] = True
for i in range(30):
    for j in range(f+1):
        if j+i*a <= f//100:
            dp[j+i*a] = dp[j]
for i in range(30):
    for j in range(f+1):
        if j+i*b <= f//100:
            dp[j+i*b] = dp[j]

nmax = (0,(a*100,0))
for i in range((f//100)+1):
    if dp[i]:
        w = i*100
        s = s_max(i*100)
        if w+s == 0:
            continue
        if nmax[0] <= s/(s+w):
            nmax = (s/(s+w),(s+w,s))
print(*nmax[1])

Measured memory_bytes: 3064
from collections import deque

n = int(input())
A = deque(map(int,input().split()))
B = deque()

for i in range(n):
    a = A.popleft()
    if i%2==0:
        B.append(a)
    else:
        B.appendleft(a)

if n%2 ==1:
    B.reverse()
print(' '.join(map(str,B)))

Measured memory_bytes: 28996
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 100010
typedef long long ll;
inline 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<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,odd,a[N];
ll sum;
bool dfs(){
	int odd=0;
	bool flag=false;
	for(int i=1;i<=n;++i){
		if(a[i]&1)++odd;
		if(a[i]==1)flag=true;
	}
	if((n-odd)&1)return true;
	if(flag||odd>1)return false;
	int g=0;
	for(int i=1;i<=n;++i){
		if(a[i]&1)--a[i];
		g=__gcd(a[i],g);
	}
	for(int i=1;i<=n;++i){
		a[i]/=g;
	}
	return dfs()^1;
}
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		a[i]=read();
	}
	puts(dfs()?"First":"Second");
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

// ############################################################################################

#define FOREACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define FOR(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define FORE(i, a, n) for (i = (a); i < (int)(n); ++i)
#define Size(n) ((int)(n).size())
#define all(n) (n).begin(), (n).end()

#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair

#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>

#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int> >

#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)

#define mod 1000000007
#define inf 1e18

#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

// ############################################################################################

ll mpow(ll base, ll exp) {
    ll res = 1;
    while (exp > 0) {
        if (exp % 2) res = (res * base) % mod;
        base = (base * base) % mod;
        exp /= 2;
    }
    return res % mod;
}

void a_k_s() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
}

vector<int> gr[100005];
int path[100005]{0};

int solve(int src) {
    path[src] = 1;
    int temp = -1;

    for (auto nbr : gr[src]) {
        if (path[nbr] != 0) {
            temp = max(temp, path[nbr]);
        } else {
            temp = max(temp, solve(nbr));
        }
    }

    path[src] += temp;

    return path[src];
}

int main() {
    a_k_s();

    int n, m, u, v;
    cin >> n >> m;

    FOR(i, 0, m) {
        cin >> u >> v;
        gr[u].pb(v);
    }

    FOR(i, 1, n + 1) {
        if (path[i] == 0) {
            solve(i);
        }
    }

    int ans = -1;

    FOR(i, 1, n + 1) {
        ans = max(ans, path[i]);
    }

    cout << ans << endl;

    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str[] = br.readLine().split(" ");
            double a = Double.parseDouble(str[0]);
            double b = Double.parseDouble(str[1]);
            double temp = (a + b) / 2;
            int ans = (int)temp;
            if (temp > ans) {
                ans++;
            }
            System.out.println(ans);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 19668
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int fc[100001], in[100001];

int pwmd(int a, int n = mod - 2)
{
	if (!n)
		return 1;
	int pt = pwmd(a, n / 2);
	pt *= pt, pt %= mod;
	if (n & 1)
		pt *= a, pt %= mod;
	return pt;
}
int nCr(int n, int r)
{
     fc[0] = in[0] = 1;

	for (int i = 1; i <= 100000; ++i)
	{
		fc[i] = (i * fc[i - 1]) % mod;
		in[i] = pwmd(fc[i]);
	}

	int ans = fc[n];
	ans = (ans * in[r]) % mod;
	ans = (ans * in[n - r]) % mod;

	return ans;
}
double pow(double a,int b)
{
	double ans=1;
	while(b>0)
	{
		if(b&1)
			ans*=a;
		a*=a;
		b=b>>1;
	}
	return ans;
}
vector<pair<int,int>> vec;
bool compare(pair<int,int> v1,pair<int,int> v2)
{
	return v1.ss<v2.ss;
}

vector<int> adj[200005];
int dis[200005];
void dfs1(int par, int u)
{
	for(int x:adj[u])
	{
		if(x==par)
			continue;
		dis[x]=dis[u]+1;
		dfs1(u,x);
	}
}

void dfs(int par, int u,bool *vis)
{
	vis[u]=true;
	for(int x:adj[u])
	{
		if(x==par)
			continue;
		dfs(u,x,vis);
		vis[x]=true;
	}
}

int32_t main()
{       
    FIO;
    int n,k;
    cin>>n>>k;

    int ans=0;
    int a[n];
    memset(a,0,sizeof(a));
    for(int i=0;i<k;i++)
    {
    	int d;
    	cin>>d;
    	for(int j=0;j<d;j++)
    	{
    		int x;
    		cin>>x;
    		x--;
    		a[x]++;
    	}
    }

    for(int i=0;i<n;i++)
    	if(a[i]==0)
    		ans++;

    	cout<<ans<<endl;
   
    


}

Measured memory_bytes: 8340
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    double* s;
    while (cin >> n && n > 0) {
        s = new double[n];
        double t = 0;
        for (int i = 0; i < n; i++) {
            cin >> s[i];
            t += s[i];
        }
        double m = t / n;
        double u = 0;
        for (int i = 0; i < n; i++) {
            u += (s[i] - m) * (s[i] - m);
        }
        cout << fixed << setprecision(8) << sqrt(u/n) << "\n";
        delete s;
    }
}

Measured memory_bytes: 3248
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] map = new int[N];
		for (int i = 0; i < N; i++) {
			map[i] = sc.nextInt();
		}
		
		
		for (int i = N; i > 0; i -=2) {
			System.out.print(map[i - 1]);
			if (N != 1) {
				System.out.print(" ");
			}
		}
		
		for (int i = N % 2; i < N; i += 2) {
			System.out.print(map[i]);
			if (i + 2 < N) {
				System.out.print(" ");
			}
		}
		
	}
}

Measured memory_bytes: 91996
#include<iostream>
using namespace std;
using ll = long long;
ll func(ll a,ll b){
  ll r = a % b;
  if(r==0)return b;
  return func(b,r);
}
int main(){
  ll a,b,c,d,sum,x;
  cin >> a >> b >> c >> d;
  a--;
  sum = b-a;
  sum = sum + (a/c - b/c) +(a/d - b/d);
  //cout << sum << endl;
  if(c > d){
    x = c*d/func(c,d);
  }else{
    x = c*d/func(d,c);
  }
  //cout << x << endl;
  sum -= (a/x - b/x);
  cout << sum;
}


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

int main() {
	int N;
	cin >> N;
	int i = N % 10;
	if (i == 3) {
		cout << "bon" << endl;
		return 0;
	}
	if (i == 2 || i == 4 || i == 5 || i == 7 || i == 9) {
		cout << "hon" << endl;
		return 0;
	}
	cout << "pon" << endl;
	return 0;
}

Measured memory_bytes: 3640
import scala.io.Source

object Main extends App {
  val src: List[Char] = Source.stdin.getLines.toList.map(_.toLowerCase.toList).flatten
  val acc: List[Int] = List.fill(26)(0)

  def counter(acc: List[Int], str: List[Char]): List[Int] = str match {
    case Nil => acc
    case h :: tail => if (122 >= h && h >= 97) counter(acc.updated(h-97, acc(h-97) + 1), tail)
                      else counter(acc, tail)
  }

  val pairs: List[List[AnyVal]] = List(('a' to 'z').toList, counter(acc, src)).transpose

  for {
    pair <- pairs
  } println(s"${pair(0)} : ${pair(1)}")
}

Measured memory_bytes: 46620
N = int(input())
a = list(map(int, input().split()))

a_cum = [a[i] for i in range(N)]
for i in range(1, N):
    a_cum[i] += a_cum[i-1]
a_sum = sum(a)

ans = 10**18
for i in range(N-1):
    left = a_cum[i]
    right = a_sum - a_cum[i]
    if abs(right - left) < ans:
        ans = abs(right - left)

print(ans)

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

int main() {
  	int H, W;
  	cin >> H >> W ;
  	vector<char> Pic(W);
  	char C;
  	//最初の行の出力
  	for(int i = 0; i < W + 2; i++){
    	cout << "#";
    }
  	cout << endl;  	
	for(int i = 0; i < H; i++){
      	//1行分のデータの読み込み
    	for(int j = 0; j < W; j++){
          	cin >> C;
        	Pic.at(j) = C;
        }
		//1行分の出力
      	cout << "#";
      	for(int j = 0; j < W; j++){
        	cout << Pic.at(j);
        }
      	cout << "#" << endl;
    }
  	//最後の行の出力
  	for(int i = 0; i < W + 2; i++){
    	cout << "#";
    }
  	cout << endl;  	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll a, b;
    cin >> a >> b;
    ll c = b-1, d = a-1;
    ll e = c/d;
    if (e*d<c) cout << e+1;
    else cout << e;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,e,i,a=0,b=0;
    vector <long long int> ara,ara1,ara2,ara3;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>e;
        ara.push_back(e);
        ara2.push_back(e);
    }
    for(i=0;i<n;i++)
    {
        cin>>e;
        ara1.push_back(e);
    }
    i=0;
    int c=0;
    sort(ara.begin(), ara.end());
    do {
        i++;
        if(ara==ara2)
        {
            a=i;
            c++;
        }
        if(ara==ara1)
        {
            b=i;
            c++;
        }
        if(c==2)
        {
            break;
        }
    } while (next_permutation(ara.begin(), ara.end()));
    int sum=abs(a-b);
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
c = 0

for i in range(n):
    if A[i] + A[i+1] <= B[i]:
        c += A[i] + A[i+1]
        A[i] = 0
        A[i+1] = 0
    elif A[i]<=B[i]:
        c += A[i]
        A[i+1] = A[i+1] - (B[i] - A[i])
        c += (B[i] - A[i])
        A[i] = 0
    else:
        A[i] = A[i] - B[i]
        c += B[i]
print(c)

Measured memory_bytes: 82148
#!bin/python3
from sys import exit
def check(a, b, c):
	d = a + b + c;
	off = ['ACG', 'AGC', 'GAC']
	if d in off:
		return False
	else:
		return True


n = int(input())

base = 1000000007

c = ['A', 'C', 'G', 'T']
pre = {}
cur = {}
for ch1 in c:
	for ch2 in c:
		for ch3 in c:
			if check (ch1, ch2, ch3):
				pre[ch1 + ch2 + ch3] = 1
for i in range(4, n+1):
	for s in pre.keys():
		for ch in c:
			st = s + ch
			if check(st[1], st[2], st[3]) and st[0] + st[2] + st[3] != 'AGC' and st[0] + st[1] + st[3] != 'AGC':
				key = st[1] + st[2] + st[3]
				if key in cur:
					tmp = cur[st[1] + st[2] + st[3]]
					tmp = (tmp + pre[s]) % base
					cur[st[1] + st[2] + st[3]] = tmp
				else:
					cur[key] = pre[s] 
				#cur[st[1] + st[2] + st[3]] += pre[s]
	pre = cur
	cur = {} 

res = 0
for num in pre.values():
	res = (res + num) % base 

print(res)

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

const int N = 100100;
const int INF = (1 << 30);

int n;
int h[N];
int dp[N];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &h[i]);

    fill(dp, dp + N, INF);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        if (i + 1 < n) {
            dp[i + 1] = min(dp[i + 1], abs(h[i] - h[i + 1]) + dp[i]);
        }
        if (i + 2 < n) {
            dp[i + 2] = min(dp[i + 2], abs(h[i] - h[i + 2]) + dp[i]);
        }
    }

    printf("%d\n", dp[n - 1]);
}



Measured memory_bytes: 1024
# -*- coding: utf-8 -*-

import sys
import math

def main():
    input = sys.stdin.readline
    N = int(input())

    result = 0
    ans_list = [0]*(N+1)
    root_n =int(math.sqrt(N))+1

    for i in range(1,root_n):
        for j in range(1,root_n):
            for k in range(1,root_n):
                f = i**2+j**2+k**2+i*j+i*k+j*k
                if f <= N:
                    ans_list[f] += 1 
    
    for i in range(1,N+1):
        print(ans_list[i])
        
                        

    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 9152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC092C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(int.Parse).ToList();
            A.Insert(0, 0);
            A.Add(0);

            int sum = 0;
            for(int i = 0; i <= N; i++)
            {
                sum += Math.Abs(A[i + 1] - A[i]);
            }

            for(int i = 1; i <= N; i++)
            {
                int ans = sum;
                int Amin = Math.Min(A[i - 1], A[i + 1]);
                int Amax = Math.Max(A[i - 1], A[i + 1]);

                if(A[i] < Amin)
                {
                    ans -= 2 * (Amin - A[i]);
                }
                else if (Amax < A[i])
                {
                    ans -= 2 * (A[i] - Amax);
                }

                Console.WriteLine(ans);
            }
        }
    }
}


Measured memory_bytes: 24668
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <cmath>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9

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

	ll S; cin >> S;

	cout << 0 << " " << 0 << " ";

	ll left = 0, right = INF;
	// N*N < S <= (N+1)*(N+1) を満たすNを探す
	// left*left < S <= right*right
	while (left + 1 != right) {
		ll mid = (left + right) / 2;
		if (mid*mid >= S) right = mid;
		else left = mid;
	}

	ll N = left;
	if (S == (N + 1)*(N + 1)) cout << N + 1 << " " << 0 << " " << 0 << " " << N + 1 << endl;
	else if (N*(N + 1) < S) {
		// このとき(N+1)*(N+1) - S <= INF
		ll d = (N + 1)*(N + 1) - S;
		cout << N + 1 << " " << d << " " << 1 << " " << N + 1 << endl;
	}
	else { // N*N + N >= S
		   // このとき N*N + N - S < N
		if(S==N*N+N) cout << N + 1 << " " << 0 << " " << 0 << " " << N << endl;
		else cout << N + 1 << " " << N * N + N - S << " " << 1 << " " << N << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	float x[4],y[4];
	while(scanf("%f %f %f %f %f %f %f %f",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3]) != EOF){
		if((((x[3] <= x[1]) && (x[3] >= x[0])) || ((x[1] <= x[3]) && (x[1] >= x[2]))) && (((y[3] <= y[1]) && (y[3] >= y[0])) || ((y[1] <= y[3]) && (y[1] >= y[2])))) puts("YES");
		else puts("NO");
	}
	return 0;
}

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

using namespace std;

int main()
{
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if (s == u)
    {
        cout << a - 1 << " " << b << endl;
    }
    else
    {
        cout << a << " " << b - 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int maxn = 103;
const int magic = 4040;
const int mod = 1000000007;
long long o[maxn][maxn*maxn];
int main(){
	int n, k;
	scanf("%d %d", &n, &k);
	o[n+1][0] = 1;
	for(int e = n; e >= 1; e--){
		for(int s = 0; s < magic; s++){
			if(o[e+1][s] == 0) continue;
			for(int f = 0; f <= k; f++){
				if(f <= e){
					o[e][s + (f + s)/e] += o[e+1][s];
					o[e][s + (f + s)/e] %= mod;
				} else {
					o[e][s] += o[e+1][s];
					o[e][s] %= mod;
				}
			}
		}
	}
	long long comb = k * (k + 1) / 2;
	comb *= n; comb %= mod;
	for(int e = 0; e < n-1; e++) comb *= (k + 1), comb %= mod;
	long long ans = comb;
	for(int e = 0; e < magic; e++) ans += mod - (e * o[1][e] % mod), ans %= mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6656
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <iomanip>
using ll = long long;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;

int main() {
    ll N;
    cin >> N;
    vector<pair<double,double>> p;
    for (int i = 0; i < N; ++i) {
        double x,y;
        cin >> x >> y;
        p.push_back(make_pair(x,y));
    }
    double l = 0;
    double r = 2048;
    for(int x = 0; x < 100; x++){
        double m = (l + r) / 2.0;
        bool enoughCircle = false;
        vector<pair<double,double>> cands;
        vector<pair<ll,ll>> candIds;
        for (int ai = 0; ai < N - 1; ++ai) {
            for (int bi = ai + 1; bi < N; ++bi) {
                double delta[2];
                delta[0] = p[ai].first - p[bi].first;
                delta[1] = p[ai].second - p[bi].second;
                double normal[2];
                double deltaLength = sqrt(delta[0] * delta[0] + delta[1] * delta[1]);

                float additional = sqrt(m * m - deltaLength * deltaLength / 4.0);
                if(m - deltaLength / 2.0 < 0){
                    //cout << "ERROR" << endl;
                    continue;
                }
                normal[0] = -delta[1] / deltaLength;
                normal[1] = delta[0]/ deltaLength;
                double middle[2];
                middle[0] = (p[ai].first + p[bi].first)/2.0;
                middle[1] = (p[ai].second + p[bi].second)/2.0;
                double cand[2];
                cand[0] = middle[0] + normal[0] * additional;
                cand[1] = middle[1] + normal[1] * additional;
                cands.push_back(make_pair(cand[0],cand[1]));
                candIds.push_back(make_pair(ai,bi));
                cand[0] = middle[0] - normal[0] * additional;
                cand[1] = middle[1] - normal[1] * additional;
                cands.push_back(make_pair(cand[0],cand[1]));
                candIds.push_back(make_pair(ai,bi));
            }
        }
        for (int i = 0; i < cands.size(); ++i) {
            auto current = cands[i];
            auto id = candIds[i];
            bool judge = true;
            double EPS = 1.00000;
            for (int j = 0; j < N; ++j) {
                if(id.first == j || id.second == j){
                    //continue;
                    EPS = 1.0000001;
                }
                if((m * EPS) * (m * EPS) <= (current.first - p[j].first) * (current.first - p[j].first) + (current.second - p[j].second) * (current.second - p[j].second)){
                    judge = false;
                }
            }
            if(judge){
                enoughCircle = true;
                break;
            }
        }
        
        if(enoughCircle){
            r = m;
        }else{
            l = m;
        }
        //cout << l << "," << r << endl;
    }
    cout << fixed;
    cout << setprecision(10) << (l  + r) / 2.0 << endl;

}


Measured memory_bytes: 452
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6+5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
 
int main(){
	ll n,m;
	cin>>n>>m;
		if(n>=m){
			if(n%m==0) cout<<"0"<<endl;
			else{
				ll x=(n/m)+1;
				ll y=(n/m);
 
				cout<<min(x*m-n,abs(y*m-n))<<endl;
			}
			
		}
		else {
			ll x=abs(n-m);
			cout<<min(x,n)<<endl;
		}
}

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

int main() {
    int k; cin >> k;
    queue<ll> que;
    for(int i=1; i<10; i++) que.push(i);
    for(int i=0; i<k-1; i++) {
        ll n = que.front();
        que.pop();
        for(int j=-1; j<2; j++) {
            ll m = (n % 10) + j;
            if(m >= 0 && m <= 9) {
                que.push(n * 10 + m);
            }
        }
    }
    cout << que.front() << endl;
}

Measured memory_bytes: 5148
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  int a, b, d;
  while(cin>>a>>b>>d,a){
	// ax+by = d || |ax-by|=d
	// by=d-ax || by=ax-d, by=ax+d
	LL ans_x = 50001, ans_y = 50001;
	REP(x,50010){
	  LL y[] = {(d-a*x)/b, (a*x-d)/b, (d+a*x)/b};
	  REP(i,3){
		if((a*x+b*y[i] == d || abs(a*x-b*y[i]) == d) && y[i] >= 0)
		  if(ans_x+ans_y > x+y[i]
			 || (ans_x+ans_y == x+y[i] && a*ans_x+b*ans_y > a*x+b*y[i]))
			ans_x = x, ans_y = y[i];
	  }
	}
	cout << ans_x << " " << ans_y << endl;
  }
  
  return 0;
}

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

vector<ll> lun;

void dfs(ll x) {
	string t = to_string(x);
	if(t.size() > 10)
		return;

	lun.push_back(x);

	for(ll i=t.at(t.size()-1)-'0'-1; i<=t.at(t.size()-1)-'0'+1; ++i)
		if(i>=0 && i<=9)
			dfs(x*10+i);
}

int main() {
	ll K,c=0;
	cin >> K;

	for(ll i=1; i<=9; ++i)
		dfs(i);
	sort(lun.begin(), lun.end());

	cout << lun.at(K-1) << endl;
}

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	// debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, left, right)  (a).begin()+(left),(a).begin()+(right)	// left to (right-1)

int main() {
	ll k, a, b;
	cin >> k >> a >> b;
	ll res;
	if (b-a>=2) {
		k -= (a - 1);
		if (k < 2) {
			pv(a + k);
		}
		else {
			k -= 2;
			res = b;
			ll loop = k / 2;
			ll remini = k % 2;
			res += (b-a) * loop;
			res += remini;
			pv(res);
		}
	}
	else {
		pv(1 + k);
	}
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int N;
long mod=1e9+7;
string s;
main()
{
	cin>>N>>s;
	long ans=1,cnt=0;
	for(int i=0;i<2*N;i++)
	{
		if(s[i]=='B')
		{
			if(cnt%2==1)ans=ans*cnt--%mod;
			else cnt++,ans*=cnt<=N;
		}
		else
		{
			if(cnt%2==1)cnt++,ans*=cnt<=N;
			else ans=ans*cnt--%mod;
		}
	}
	if(cnt!=0)ans=0;
	for(int i=1;i<=N;i++)ans=ans*i%mod;
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#include <utility>
#include <cctype>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#define LL long long
#define LB long double
#define x first
#define y second
#define Pair pair<int,int>
#define pb push_back
#define pf push_front
#define mp make_pair
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=1e9+7;
const LL LINF=2e16;
const int INF=2e9;
const int magic=348;
const double eps=1e-10;
const double pi=3.14159265;

inline int getint()
{
    char ch;int res;bool f;
    while (!isdigit(ch=getchar()) && ch!='-') {}
    if (ch=='-') f=false,res=0; else f=true,res=ch-'0';
    while (isdigit(ch=getchar())) res=res*10+ch-'0';
    return f?res:-res;
}

int n;
int a[58],b[58];
bool Dp[58][58];
int valid[58],vtot;
int anslist[58],tot;

inline bool judge()
{
	int res=-1;
	int i,j,k,cc;
	for (i=1;i<=n;i++)
	{
		memset(Dp,false,sizeof(Dp));
		Dp[0][a[i]]=true;
		for (j=0;j<=vtot-1;j++)
			for (k=0;k<=50;k++)
				if (Dp[j][k])
				{
					Dp[j+1][k]=true;
					Dp[j+1][k%valid[j+1]]=true;
				}
		if (!Dp[vtot][b[i]]) return false;
	}
	return true;
}

int main ()
{
	n=getint();int i,calc;
	for (i=1;i<=n;i++) a[i]=getint();
	for (i=1;i<=n;i++) b[i]=getint();
	for (i=1;i<=n;i++) if (b[i]*2+1>a[i] && b[i]!=a[i]) {printf("-1\n");return 0;}
	tot=0;
	for (calc=50;calc>0;calc--)
	{
		vtot=0;for (i=1;i<=tot;i++) valid[++vtot]=anslist[i];
		for (i=calc-1;i;i--) valid[++vtot]=i;
		if (judge()) continue;
		anslist[++tot]=calc;
	}
	LL ans=0;for (i=1;i<=tot;i++) ans+=(1ll<<anslist[i]);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,m,n) for(int i=(m); i<(n); ++i)

int main() {
  int n; cin>>n;
  int dp[10][10]={};
  int ans=0;
  for (int i=1; i<=n; i++) {
    string s = to_string(i);
    dp[s[0]-'0'][s.back()-'0']++;
  }

  FOR(i,1,10)FOR(j,1,10) ans += dp[i][j]*dp[j][i];
  cout << ans << endl;
}


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

long long A, B;

long long gcd(long long A, long long B) {
    if (A % B == 0) return B;
    return gcd(B, A % B);
}

int main() {
    cin >> A >> B;
    long long D = gcd(A, B);
    long long f = 2;
    long long ans = 1;
    while (f * f <= D) {
        if (D % f == 0) {
            while (D % f == 0) D /= f;
            ans++;
        }
        f++;
    }
    if (D > 1) ans++;
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


vector<string> split(string str, string delim)
{
    vector<string> result;
    int cutAt;
    while( (cutAt = str.find_first_of(delim)) != str.npos )
    {
        if(cutAt > 0)
        {
            result.push_back(str.substr(0, cutAt));
        }
        str = str.substr(cutAt + 1);
    }
    if(str.length() > 0)
    {
        result.push_back(str);
    }
	return result;
}


int main()
{
	string str;
	getline(cin, str);

	vector<string> ss = split(str, " ");

	sort(ALL(ss));

	int res = 1, buf = 1;
	string sres = ss[ss.size()-1];

	rep(i, ss.size()-1)
	{
		if(ss[i] == ss[i+1])
		{
			buf++;
		}
		else
		{
			if(res < buf)
			{
				res = buf;
				sres = ss[i];
			}
			buf = 1;
		}

		if(i == ss.size() - 2 && res < buf)
			sres = ss[i];

	}
	cout << sres << " ";

	res = 0;
	rep(i, ss.size())
	{
		if(res < ss[i].size())
		{
			sres = ss[i];
			res = ss[i].size();
		}
	}
	cout << sres << endl;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#define ll long long
using namespace std;
static const int INF = (1 << 21);

int main() {
	int N;
	cin >> N;
	map<int,int> a;
	int it = 0;
	for (int i = 0;i < N;i++) {
		int A;
		cin >> A;
		if (a.find(A) != a.end()) {
			a.erase(A);
		}
		else {
			a.emplace(A,it);
			it++;
		}
	}
	cout << a.size() << endl;

}

Measured memory_bytes: 4864
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int n,a[100],max=0,min=1000000000;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	for(int i=0;i<n;i++){
		if(max<a[i]){
			max=a[i];
		}
		
	}
	
	for(int i=0;i<n;i++){
		if(min>=a[i]){
			min=a[i];
		}
	}
	
	cout<<max-min<<endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
#define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<int, int, int> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<int> > vvi;
typedef vector<char> vc;

const int INF = 1e9;
const ll INFLL = 1e16;
const int MOD = 1000000007;
const int MAXN = 3e5;
//const ld eps = 1e-6;
const ld eps2 = 1e-9;
const int MOD2 = 998244353;
const int dosz = 5e5;
const int SZ = (1<<18);
const ld PI = atan2l(0, -1);


void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
        // freopen("a.in", "r",stdin);
#else
       // freopen("substrcmp.in", "r", stdin);
       // freopen("substrcmp.out", "w", stdout);
#endif
}

void solve(){
    string s;
    cin >> s;
    for(char &c:s){
        c = 'x';
    }
    cout << s;
}

signed main() {
    fast_io();
    int q = 1;
    // cout << fixed << setprecision(6);
    // cin >> q;
    // cout << 1 << endl;
    while(q--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int Node[31];
void swap(int a,int b);

int main(){

	int W;
	int n;
	int a,b;
	int i;

	scanf("%d",&W);
	scanf("%d",&n);
	for(i=1;i<=W;i++)Node[i]=i;
	for(i=1;i<=n;i++){
		scanf("%d,%d",&a,&b);
		swap(a,b);
	}

	for(i=1;i<=W;i++){
		printf("%d\n",Node[i]);
	}

	return 0;
}

void swap(int a,int b){

	int c;
	c=Node[a];
	Node[a]=Node[b];
	Node[b]=c;

}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int main() {
	ll n, f[110][11], p[110][11], ans = -1e15;
	cin >> n;
	for (int i = 0; i < n; i++) for (int j = 0; j < 10; j++)cin >> f[i][j];
	for (int i = 0; i < n; i++)for (int j = 0; j <= 10; j++)cin >> p[i][j];
	for (int i = 1; i < 1024; i++) {
		ll num = 0;
		for (int j = 0; j < n; j++) {
			ll cnt = 0;
			for (int k = 0; k < 10; k++) {
				if ((i&(1 << k))&&f[j][k])cnt++;
			}
			num += p[j][cnt];
		}
		ans = max(num, ans);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/aising2020/tasks/aising2020_a
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>

using namespace std;
#define lli long long int
#define numberofdigits(x) floor(log10(x)) + 1

int main()
{
    lli l,r,d,c=0;
    cin>>l>>r>>d;
    for(lli i=l;i<=r;i++)
        if(i%d==0)
            c++;
    cout<<c<<"\n";
    return 0;
}

Measured memory_bytes: 3560