akhauriyash/Code-Regression huggingface dataset:
nq = map(int, raw_input().split())
n = nq[0]
q = nq[1]

yn = [[1, 'kogakubu10gokan']]

for i in range(n):
    yn.append(raw_input().split())

yn.append([100,''])

y = 1
k = 0
while y <= q:
    k += 1
    y = int(yn[k][0])

print yn[k-1][1]

Measured memory_bytes: 4224
a,b,c=gets.split.map(&:to_i)
p = 1
rs = []
loop do
  r = (a * p) % b
  if r == c
    puts 'YES'
    exit
  end
  if rs.include?(r)
    puts 'NO'
    exit
  end
  rs.push(r)
  p += 1
end


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

int main(){	
	while (1) {
		int a, b;
		char op;
		cin >> a >> op >> b;
		if (op == '?') break;

		int ans;
		if (op == '+') ans = a + b;
		if (op == '-') ans = a - b;
		if (op == '*') ans = a * b;
		if (op == '/') ans = a / b;
		cout << ans << endl;

	}
	return 0;
}


Measured memory_bytes: 3068
import sys
import math
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(20000000)


def main():
    S = int(input())
    nums = list(map(int, input().split()))

    ans = 0

    for i in range(1, S-1):
        if nums[i-1] < nums[i] < nums[i+1] or nums[i-1] > nums[i] > nums[i+1]:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()



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

using namespace std;

int main(){
    int n, m; cin >> n >> m;
    if(n>m) swap(n, m);
    const long long mod=1000*1000*1000+7;
    long long ans=1;
    if(n==m){
        for(int i=1; i<=n; ++i){
            ans=(ans*i)%mod;
        }
        ans=(ans*ans)%mod;
        ans=(ans*2)%mod;
    } else if(n+1==m){
        for(int i=1; i<=n; ++i){
            ans=(ans*i)%mod;
        }
        long long t=ans*(n+1)%mod;
        ans=(ans*t)%mod;
    } else{
        ans=0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,m,f[N],id[N],a[N],b[N],c[N],tot,head[N],nex[N<<1],to[N<<1];
void add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}
ll dp[N],s[N];
vector<int>e[N];
bool vis[N];
int getf(int x){return f[x]==x?x:f[x]=getf(f[x]);}
bool cmp(int x,int y){return c[x]<c[y];}
void dfs(int u)
{
    s[u]=b[u];
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];
        dfs(v);
        s[u]+=s[v];
    }
    dp[u]=s[u]+c[u];
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];
        dp[u]=min(dp[u],s[u]-s[v]+max(dp[v],(ll)c[u]));
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&a[i],&b[i]);
        c[i]=max(a[i]-b[i],0);
        f[i]=id[i]=i;
    }
    for(int i=1;i<=m;i++)
    {
        int u,v;scanf("%d%d",&u,&v);
        e[u].push_back(v);
        e[v].push_back(u);
    }
    sort(id+1,id+1+n,cmp);
    for(int i=1;i<=n;i++)
    {
        int x=id[i];vis[x]=true;
        for(int j=0;j<e[x].size();j++)
        {
            int y=e[x][j];if(!vis[y]) continue;
            y=getf(y);
            if(x!=y)
            {
                f[y]=x;
                add(x,y);
            }
        }
    }
    dfs(id[n]);
    printf("%lld\n",dp[id[n]]);
}


Measured memory_bytes: 13692
#include<map>
#include<set>
#include<list>
#include<ctime>
#include<cmath>
#include<deque>
#include<queue>
#include<stack>
#include<string>
#include<vector>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
#define _rep(i,s,t) for(register int i=s;i>=t;--i)
#define Rep(i,s,t) for(register int i=s;i<t;++i)
#define go(x) for(register int e=las[x];e;e=nxt[e])
#define re register
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define is insert
#define es erase
#define pii pair<int,int>
#define ms(f,x) memset(f,x,sizeof f)
#define mc(f,x) memcpy(f,x,sizeof f)
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
#define gi(x) read(x)
#define gii(x,y) read(x),read(y)
#define giii(x,y,z) read(x),read(y),read(z)
namespace IO{
    #define gc getchar()
    #define pc(x) putchar(x)
    template<typename T>inline void read(T &x){
        x=0;int f=1;char ch=gc;while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=gc;}
        while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=gc;x*=f;return;
    }
    template<typename T>inline void write(T x=0){
        T wr[51];wr[0]=0;if(x<0)pc('-'),x=-x;if(!x)pc(48);
        while(x)wr[++wr[0]]=x%10,x/=10;while(wr[0])pc(48+wr[wr[0]--]);return;
    }
}
using IO::read;
using IO::write;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
int n,ans,K;
int main(){
	scanf("%d",&K);
	rep(i,1,1e7){
		
		ans=(ans*10+7)%K;
		if(ans==0){
			printf("%d\n",i);
			return 0;
		}
	}
	puts("-1");
	return 0;
}

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

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

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

int main() {
  ll A, B, BsubA, lcmCD;
  ll C, D;
  ll divC, divD, divCD;
  cin >> A >> B >> C >> D;
  BsubA = B-A+1;
  lcmCD = lcm(C, D);
  divC = B/C - (A-1)/C;
  divD = B/D - (A-1)/D;
  divCD = B/lcmCD - (A-1)/lcmCD;
  cout << BsubA-divC-divD+divCD << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
 int a,b,c,d,e;
 for(a=1;a<=50;a++){
   scanf("%d %d %d",&b,&c,&d);
   if(b==-1&&c==-1&&d==-1)
   break;
   else if(b<=50&&c<=50&&d<=100){
   e=b+c;
   if(e>=80){
     printf("A\n");}
   else if(e>=65&&e<80){
     printf("B\n");}
   else if(e>=50&&e<65){
     printf("C\n");}
   else if(b==-1||c==-1||e<30){
     printf("F\n");}
   else if(e>=30&&e<50&&d>=50){
     printf("C\n");}
   else if(e>=30&&e<50){
     printf("D\n");}
   }
 }
 return 0;
}


Measured memory_bytes: 2140
from math import factorial

n,a,b = map(int,input().split())
MOD = 10**9 + 7
xa = 1
xb = 1

k1 = pow(2,n,MOD)
A = pow(factorial(a),MOD-2,MOD)
B = pow(factorial(b),MOD-2,MOD) 

for i in range(a):
  xa = xa*(n-i)%MOD
for j in range(b):
  xb = xb*(n-j)%MOD

ans = (k1 - (A*xa) - (B*xb) - 1)%MOD 

print(ans)

Measured memory_bytes: 5476
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	n := readInt()
	a := make([]int, n+2)
	for i := 1; i <= n; i++ {
		a[i] = readInt()
	}
	l := make([]int, len(a))
	r := make([]int, len(a))

	for i := 1; i < len(l); i++ {
		l[i] = gcd(l[i-1], a[i])
	}

	for i := len(r) - 2; i >= 0; i-- {
		r[i] = gcd(a[i], r[i+1])
	}

	var ans int
	for i := 1; i <= n; i++ {
		v := gcd(l[i-1], r[i+1])
		if ans < v {
			ans = v
		}
	}

	println(ans)
}

func gcd(a, b int) int {
	if a == 0 {
		return b
	}
	if b == 0 {
		return a
	}
	return gcd1(a, b)
}

func gcd1(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd1(b, a%b)
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 4736
//

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int a, b, c;

int main() {
    cin >> a >> b >> c;
    if (a == b && b == c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

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

	if (a >= 3200)
		cout << s << endl;
	else
		cout<< "red" << endl;
	return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
typedef long long ll;
using namespace std;

int main(void){
    int n,i;
    int r;
    cin>>n;
    
    int min,ans=-1000000002;
    int t;
    
    cin>>min;
    for(i=1;i<n;i++){
        cin>>r;
        t=r-min;
        if(ans<t)ans=t;
        if(min>r)min=r;
    }
    
    cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3116
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}


int main() {
	IOS;
	int a,b,c;
	cin >> a >> b >> c ;
	cout << (a + b) * c / 2 << endl;
}



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

int main() {

    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;

   for(int i=0; i<s.size(); i++){
       set<char> first,second;
       for(int j=0; j<i; j++){
           first.insert(s[j]);
       }
       for(int j=i; j<s.size(); j++){
           second.insert(s[j]);
       }
       int tmp_ans = 0;
       for(char c : first){
           for(char cc : second){
               if(c == cc){
                   tmp_ans++;
                   break;
               }
           }
       }
       ans = max(ans,tmp_ans);
   }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<cmath>
#include<complex>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<ctime>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int Ans=0;
	int pos=1;
	for(int i=1;i<=n;i++){
		int tmp=0,Now=i;
		while(Now&&Now%2==0){
			Now/=2;
			tmp++;
		}
		if(tmp>Ans){
			Ans=tmp;
			pos=i;
		}
	}
	printf("%d",pos);
}


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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
    nimble
    ll r;
    cin>>r;
    ld x=2*pi*r;
    cout<<preci(2)<<x<<nl;
    return 0;
}


Measured memory_bytes: 3776
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int s = sc.nextInt();
        boolean b = s==Math.pow(10,9);
        for (int i=0;i<k;i++)System.out.println(s+" ");
        for (int i=k;i<n;i++){
            if(b)System.out.println(1+" ");
            else System.out.println(s+1+" ");
        }
    }
}


Measured memory_bytes: 55348
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
using namespace std;

int main(){
  int n;
  cin >> n;
  int cnt = 0;
  while(n > 1){
    n = n / 2;
    cnt++;
  }
  cout << pow(2, cnt) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
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 gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

 string s;
 cin>>s;

 for(int i=0;i<s.size();i +=2)cout<<s[i];

}

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

int main(void) {
    int64_t N,K;
    int64_t digits = 0;
    cin >> N >> K;
    
    while(N) {
        N /= K;
        digits++;
    }

    cout << digits << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<map>

using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から


typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    //a>=b
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

#define MOD ((ll)1e+9 + 7)



//cout<<fixed<<setprecision(10);
int main(){
    int n,d;
    cin>>n>>d;
    int x[10][10];
    rep(i,n){
        rep(j,d){
            cin>>x[i][j];
        }
    }
    int ans=0;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            int sum=0,tmp;
            rep(k,d){
                sum+=pow(x[i][k]-x[j][k],2);
            }
            tmp=sqrt(sum);
            if(sum==pow(tmp,2)) ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 3724
#include <cstdio>
using namespace std;

int N, K;

void solve(){
	for(int st=0; st<K; st++){
		int cur = 0;
		for(int i=0; i<N-1; i++){
			int next = (cur>N/2?N-cur:N-cur-1);
			printf("%d %d\n", (cur+st)%N+1, (next+st)%N+1);
			cur = next;
		}
		puts("");
	}
}

int main(){
	scanf("%d%d",&N,&K);
	if(K > N/2){
		puts("-1");
		return 0;
	}
	solve();
	return 0;
}

Measured memory_bytes: 764
import java.util.Scanner;

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

        if (r - l >= 2019) {
            System.out.print(0);
            return;
        }

        long min = 2019;
        for (long i = l; i <= r - 1; i++) {
            for (long j = i+1; j <= r; j++) {
                long mod = (i * j) % 2019;
                if (min > mod) {
                    min = mod;
                }
            }
        }
        System.out.print(min);
    }
}

Measured memory_bytes: 21716
import sys

def rpn(str):
    r = []
    stack = []
    for i in range(0, len(str)):
        c = str[i]
        if c in "idsu":
            while len(stack) > 0:
                if stack[-1] in "idsuc":
                    a = stack.pop()
                    r.extend(a)
                else:
                    break
            stack.extend(c)
        elif c == "c":
            stack.extend(c)
        elif c == "(":
            stack.extend(c)
        elif c == ")":
            while len(stack) > 0:
                a = stack.pop()
                if a == "(":
                    break
                r.extend(a)
        else:
            r.extend(c)
    while len(stack) > 0:
        a = stack.pop()
        r.extend(a)
    return r

def intersect(a, b):
    r = []
    for e in a:
        if e in b:
            r.extend([e])
    return r

def union(a, b):
    r = list(set(a + b))
    return r

def diff(a, b):
    r = []
    for e in a:
        if e not in b:
            r.extend([e])
    return r

def universal(sets):
    r = []
    for v in sets.values():
        r.extend(v)
    r = list(set(r))
    return r

def calc(rpn, sets):
    stack = []
    U = universal(sets)
    for c in rpn:
        if c in "iuds":
            op2 = stack.pop()
            op1 = stack.pop()
            if c == "i":
                x = intersect(op1, op2)
                stack.append(x)
            elif c == "u":
                x = union(op1, op2)
                stack.append(x)
            elif c == "d":
                x = diff(op1, op2)
                stack.append(x)
            elif c == "s":
                x = diff(op1, op2)
                y = diff(op2, op1)
                z = union(x, y)
                stack.append(z)
        elif c == "c":
            op1 = stack.pop()
            x = diff(U, op1)
            stack.append(x)
        else:
            stack.append(sets[c])
    return stack.pop()
            
lno = 0
sets = {}
name = ""
for line in sys.stdin:
    lno += 1
    if lno % 2 == 1:
        name = line.strip().split()[0]
    elif name != "R":
        elem = list(map(int, line.strip().split()))
        sets[name] = elem
    else:
        e = rpn(line.strip())
        result = calc(e, sets)
        result.sort()
        if len(result) > 0:
            print(" ".join([str(n) for n in result]))
        else:
            print("NULL")
        sets = {}


Measured memory_bytes: 5632
mul [] [] = 0
mul (m:ms) (v:vs) = (m*v) + mul ms vs

mult :: [[Int]] -> [[Int]] -> [[Int]]
mult [] _ = []
mult a b =
  let t = transpose b
  in 
    map (\a0 -> map (mul a0) t) a

transpose :: [[Int]] -> [[Int]]
transpose ([]:_) = []
transpose matrix =
  let row  = map (head) matrix
      rows = transpose $ map (drop 1) matrix
  in
    row:rows

to_str :: [Int] -> String
to_str [] = []
to_str (x:[]) = show x
to_str (x:xs) =
  (show x)++(' ':(to_str xs))

main = do
  c <- getContents
  let c' = map (map read) $ map words $ lines c :: [[Int]]
      (m:n:l:_) = c'!!0
      mat1 = take m $ drop 1 c'
      mat2 = take n $ drop (1+m) c'
      res  = mult mat1 mat2
  mapM_ putStrLn $ map to_str res
  
  

Measured memory_bytes: 12196
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

signed main(){
  int N, M;
  long long a[51];
  long long b[51];
  long long c[51];
  long long d[51];
  
  scanf("%d %d", &N, &M);

  for(int i = 0 ; i < N ; i++){
    scanf("%lld %lld", &a[i], &b[i]);
  }
  
  for(int i = 0 ; i < M ; i++){
    scanf("%lld %lld", &c[i], &d[i]);
  }
  
  for(int j = 0 ; j < N ; j++){
    long long min = 1<<30;
    int idx_m = -1;
    
    for(int i = 0 ; i < M ; i++){
      if(abs(c[i]-a[j]) + abs(d[i]-b[j]) < min){
	min = abs(c[i]-a[j]) + abs(d[i]-b[j]);
	idx_m = i;
      }
    }
    printf("%d\n", idx_m+1);
  }

}


Measured memory_bytes: 256
n,m=map(int,input().split())
h=list(map(int,input().split()))
high=[1]*n
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]>h[b-1]:
    high[b-1]=0
  elif h[a-1]<h[b-1]:
    high[a-1]=0
  else:
    high[a-1]=0
    high[b-1]=0
print(sum(high))

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

using namespace std;

int main() {
  char m[3][3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> m[i][j];
    }
  }
  cout << m[0][0] << m[1][1] << m[2][2] << endl;

  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (even, odd) = readLine()!!.split(" ").map(String::toInt)
    var a = 0
    var b = 0
    if (even > 1) {
        a = even * (even - 1) / 2
    }
    if (odd > 1) {
        b = odd * (odd - 1) / 2
    }
    println(a + b)
}

Measured memory_bytes: 37872
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}

signed main() {
	string s;
	int a=0, b=0;
	cin >> s;
	rep(i, s.size()) {
		if (s[i] != '1' && i % 2 == 1) {
			a++;
		}
		if (s[i] != '0' && i % 2 == 0) {
			a++;
		}
	}
	rep(i, s.size()) {
		if (s[i] != '1' && i % 2 == 0) {
			b++;
		}
		if (s[i] != '0' && i % 2 == 1) {
			b++;
		}
	}
	cout << min(a, b) << endl;
}


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

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

int main(){
	
	while(true){
		int a,b;
		cin >> a >> b;
		
		if(cin.eof()) break;
		
		int g = gcd(a,b);
		cout << g << ' ' << a/g*b << endl;
		
	}
	
	return 0;
	
}

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

typedef long long ll;
typedef pair<int,int> PII;
#define CINSPEED std::ios::sync_with_stdio(false),std::cin.tie(0),std::cout.tie(0)
#define fi first
#define se second
#define pb push_back

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


const int N = 10010,M = 1000010;
int h,n;
int dp[N],a[N],b[N];


void solved()
{
    cin >> h >> n;
    
    for(int i = 0;i < n;i++)cin >> a[i] >> b[i];
    memset(dp,0x3f,sizeof dp);
    
    dp[0] = 0;
    for(int i = 0;i < n;i++)
    {
        for(int j = 0;j < h;j++)    
        {
            int target = j + a[i];
            target = target >= h ? h : target;
            dp[target] = min(dp[target],dp[j] + b[i]);
        }
    }
    cout << dp[h];

}

int main()
{
    //CINSPEED;
    solved();
#ifdef LOCAL
    system("pause");
#endif
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	double r;
	double are,circ;
	
	scanf("%lf", &r);
	
	are = r*r*3.141592653589;
	circ = r*2*3.141592653589;
	
	printf("%f %f\n", are, circ);
	
	return 0;
}


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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    vector<int>v;
    for(int i=a; i<=b; i++)
    {
        if(i%c==0){
            v.push_back(i);
        }
    }
    cout<<v.size()<<endl;

}


Measured memory_bytes: 3552
#include <iostream>

using namespace std;

int main(){
  int n,x;
  cin >> n >> x;
  long long d = 0,cnt = 0;
  for (int i = 0;i < n; i++){
    int temp;
    cin >> temp;
    d += temp;
    if(d <= x)
      cnt ++;
  }

  cout << cnt + 1 ;
  return 0;
}


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

int main(){
  int a , b , c;
  cin >> a >> b >> c;
  if(a == b + c || b == a + c || c == a + b){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int abs(int x){
  return(x<0?-x:x);
}
int main(){
  string S;
  cin>>S;
  int min=-1;
  for(int i=0;i<S.length()-2;i++){
    string Sb=S.substr(i,3);
    int Si=stoi(Sb);
    if(min==-1||abs(753-Si)<min)min=abs(753-Si);
  }
  cout<<min<<endl;
  return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int N;
	cin>>N;
	long long int A[N];
	map <long long int,int> m;
	for (int i=0;i<N;i++){
	    cin>>A[i];
	    m[i-A[i]]++;
	}
	long long int ans=0;
	for (int i=0;i<N;i++){
	    m[i-A[i]]--;
	    ans+=m[i+A[i]];
	}
	cout<<ans<<"\n";
	return 0;
}

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

bool isPrime(int n) {
  for (int i = 2; i < n; i++) {
    if (i * i > n) break;
    if (n % i == 0) return false;
  }
  return n != 1;
}

int main() {
  int x;
  cin >> x;

  while (!isPrime(x)) {
    x++;
  }

  cout << x << endl;

  return 0;
}

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

typedef long long ll;

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

int main() {
ll N;   cin >> N;
vector<ll> A(N);    cin >> A[0];
ll ans = A[0];
for (int i = 1; i < N; i++) {
    cin >> A[i];
    ans = gcd(ans, A[i]);
}

cout << ans << endl;

}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m; cin >> n >> m;
  map<int, int> mp;
  REP(i, n) {
    int a; cin >> a;
    ++mp[a];
  }
  while (m--) {
    int b, c; cin >> b >> c;
    auto itr = mp.lower_bound(c);
    int cnt = 0;
    vector<int> kesu;
    for (auto it = mp.begin(); it != itr && cnt < b; ++it) {
      int val = (*it).first;
      // cout << val << '\n';
      if (cnt + mp[val] > b) {
        mp[val] -= b - cnt;
        cnt = b;
      } else {
        kesu.emplace_back(val);
        cnt += mp[val];
      }
    }
    for (int e : kesu) mp.erase(e);
    mp[c] += cnt;
    // for (auto it = mp.begin(); it != mp.end(); ++it) {
    //   int val = (*it).first;
    //   cout << val << ' ' << mp[val] << '\n';
    // }
    // cout << "--\n";
  }
  long long ans = 0;
  for (auto it = mp.begin(); it != mp.end(); ++it) {
    int val = (*it).first;
    ans += (long long)val * mp[val];
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 5632
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

ans = 0

card = set(s + t)

for i in card:
    tmp = 0
    tmp += s.count(i)
    tmp -= t.count(i)
    ans = max(tmp, ans)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>
#include <stack>

using namespace std;

int a;
int b;
int c;

int main(void) {

	cin >> a;
	cin >> b;
	cin >> c;

	vector<int> t;
	t.push_back(a);
	t.push_back(b);
	t.push_back(c);

	sort(t.begin(), t.end());
	int ans = abs(t.at(0) - t.at(2));
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
ans = 0
MOD = 10 ** 9 + 7
digit = 0

while A.any():
    one = np.count_nonzero(A & 1)
    ans += (one * (N - one) * pow(2, digit, MOD)) % MOD
    ans %= MOD
    A >>= 1
    digit += 1

print(ans)


Measured memory_bytes: 49928
import scala.io.StdIn

object Main {

  case class Point(x: Double = 0, y: Double = 0) {

    def +(p: Point): Point = Point(this.x + p.x, this.y + p.y)

    def -(p: Point): Point = Point(this.x - p.x, this.y - p.y)

    def *(a: Double): Point = Point(this.x * a, this.y * a)

    def /(a: Double): Point = {
      assert(a == 0)
      Point(this.x / a, this.y / a)
    }

    def norm(): Double = this.x * this.x + this.y * this.y

    def abs(): Double = scala.math.sqrt(norm())

    def <(p: Point): Boolean = this.x < p.x && this.y < p.y

    private val EPS = 1 ^ (-10)

    def ==(p: Point): Boolean = scala.math.abs(this.x - p.x) < EPS && scala.math.abs(this.y - p.y) < EPS


  }

  case class Segment(p1: Point, p2: Point)

  type GeoVector = Point

  object Cgl0A {

    // 内積
    def dot(a: Point, b: Point): Double = a.x * b.x + a.y * b.y

    def isOrthogonal(a: GeoVector, b: GeoVector): Boolean = dot(a, b) == 0.0

    def isOrthogonal(a1: Point, a2: Point, b1: Point, b2: Point): Boolean = {
      isOrthogonal(a1 - a2, b1 - b2)
    }

    def isOrthogonal(s1: Segment, s2: Segment): Boolean = {
      dot(s1.p2 - s1.p1, s2.p2 - s2.p1) == 0.0
    }

    // 外積
    def cross(a: Point, b: Point): Double = a.x * b.y - a.y * b.x

    def isParallel(a: GeoVector, b: GeoVector): Boolean = cross(a, b) == 0.0

    def isParallel(a1: Point, a2: Point, b1: Point, b2: Point): Boolean = {
      isParallel(a1 - a2, b1 - b2)
    }

    def isParallel(s1: Segment, s2: Segment): Boolean = {
      cross(s1.p2 - s1.p1, s2.p2 - s2.p1) == 0.0
    }

    def project(s: Segment, p: Point): Point = {
      val base: GeoVector = s.p2 - s.p1
      val r: Double = Cgl0A.dot(p - s.p1, base) / base.norm()
      s.p1 + base * r
    }
  }


  def main(args: Array[String]): Unit = {
    val a = StdIn.readLine().split(' ').map(_.toDouble)
    val p1 = Point(a(0), a(1))
    val p2 = Point(a(2), a(3))
    val base = Segment(p1, p2)

    val q = StdIn.readLine().toInt
    (0 until q).foreach { i =>
      val ai = StdIn.readLine().split(' ').map(_.toDouble)
      val qi = Point(ai(0), ai(1))

      val r = Cgl0A.project(base, qi)
      println(f"${r.x}%.8f  ${r.y}%.8f")

    }

  }

}


Measured memory_bytes: 54420
#include<iostream>
#include<string>
using namespace std;
 
int main(){
    int n,s;
    string str;
    cin >> n;
    getline(cin,str);
    for(int i=0;i<n;i++){
        getline(cin,str);
        s=str.size();
        for(int i=0;i<s;i++){
            if(str[i]=='H'&&str[i+1]=='o'&&str[i+2]=='s'&&
                   str[i+3]=='h'&&str[i+4]=='i'&&str[i+5]=='n'&&str[i+6]=='o'){
                str[i+6]='a';
            }
        }
        cout << str << endl;
    }
    return 0;
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n, k;
  cin >> n >> k;
  int count = 0;
  int a[n];
  for(int i = 0; i < n; i++)
  {
    cin >> a[i];
  	if(a[i] >= k) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

struct BIT{
    int N;
    vector<int> bit;

    BIT(int n = 0){
        N = n;
        bit.resize(n + 1);
    }

    int sum(int i){
        int s = 0;
        while(i > 0){
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }

    void add(int i, int x){
        while(i <= N){
            bit[i] += x;
            i += i & -i; 
        }
    }

    int ser_sum(int val){
        int lb = -1, ub = N + 1;
        while(ub - lb > 1){
            int mid = (ub + lb) / 2;
            if(sum(mid) >= val) ub = mid;
            else lb = mid;
        }
        return ub;
    }
};

int N;
ll res = 0;
int P[100010];
vector<pii> ps;//val, idx
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> P[i];
        ps.push_back({P[i], i + 1});
    }
    sort(ps.rbegin(), ps.rend());
    BIT bit(N);
    for(int i = 0; i < N; i++){
        ll val = ps[i].first;
        ll idx = ps[i].second;
        bit.add(idx, 1);
        int s1 = bit.sum(idx);
        ll r1 = bit.ser_sum(s1 + 1);
        ll r2 = bit.ser_sum(s1 + 2);
        ll l1 = bit.ser_sum(s1 - 1);
        ll l2 = bit.ser_sum(s1 - 2);
        res += val * ((r2 - r1) * (idx - l1) + (l1 - l2) * (r1 - idx));
    }
    cout << res << endl;
    return 0;
}

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

int sod(int n) {
  int sum = 0;
  while (n) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

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

  cout << ((N % sod(N) == 0) ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin>>s;
  int cnt1=0;
  int cnt0=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0')cnt0++;
    if(s[i]=='1')cnt1++;
  }
  
  
  
  
  
  cout<<2*min(cnt0,cnt1)<<endl;
}

Measured memory_bytes: 512
while True:
    num = [int(x) for x in input().rstrip().split()]
    if num[0] ==0 and num[1] == 0:
        break
    num.sort()
    ans = " ".join(str(x) for x in num)
    print(ans)



# <?php

# while ($line = trim(fgets(STDIN))) {
#     $num = explode(" ",$line);
#     if ($num[0] == 0 && $num[1] == 0) {
#         exit();
#     }
#     sort($num);
#     $line = implode(" ",$num);
#     echo $line . PHP_EOL;
# }

# ?>


Measured memory_bytes: 5620
# -*- coding:utf-8 -*-
A,B,C = map(int,input().split())

cnt = 0

if A==B==C==1:
    pass
elif A==B==C:
    cnt = -1
else:
    while A%2 == 0 and B%2 == 0 and C%2 == 0:
        A,B,C = (B+C)//2,(C+A)//2,(A+B)//2 
        cnt += 1

print(cnt)


Measured memory_bytes: 9124
class Queue:
    res=0
    def __init__(self):
        self.li = []
        self.top = 0
    def push(self,value):
        self.li.insert(0,value)
        #self.li.append(int(value))
        self.top += 1
    def pop(self):
        self.top -= 1
        return self.li.pop()
    def isEmpty(self):
        return len(self.li)==0
    def __str__(self):
        return str(self.li)

n,q = map(int,input().split())
save = Queue()

for i in range(n):
    name,time = map(str,input().split())
    save.push([name,int(time)])

while(not save.isEmpty()):
    # print(save)
    tmp = save.pop()
    if tmp[1] <= q:
        Queue.res += tmp[1]
        print(tmp[0],Queue.res)
    else:
        Queue.res += q
        save.push([tmp[0],tmp[1]-q])
    



Measured memory_bytes: 13012
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	//全探索ver
	Int D, N;
	cin >> D >> N;

	Int cnt = 0;
	Int temp;
	Int res;
	for (Int i = 1; i < 2000000; i++) {//整数iを考える
		temp = i;
		res = 0;
		while (true) {
			if (temp%100==0) {
				res++;
				temp /= 100;
			}
			else {
				break;
			}
		}

		if (res==D) {
			cnt++;
			if (cnt==N) {
				cout << i << "\n";
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
n = int(input())
s = input()
s_total = s.count('R')*s.count('B')*s.count('G')
cnt=0
for i in range(n-2):
    for j in range(i+1,n-1):
        k = 2*j - i
        if k > n-1:
            continue
        elif s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            cnt += 1
print(s_total-cnt)

Measured memory_bytes: 73672
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int d[10],n,m;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	memset(d,-1,sizeof(d));
	forn(i,m)
	{
		int s,c;
		cin>>s>>c;
		s--;
		if(s==0&&c==0&&n!=1)
		{
			cout<<-1;
			return 0;
		}
		if(d[s]!=-1&&d[s]!=c)
		{
			cout<<-1;
			return 0;
		}
		d[s]=c;
	}
	forn(i,n)
	{
		if(d[i]==-1&&i==0&&n!=1)cout<<1;
		else if(d[i]==-1)cout<<0;
		else cout<<d[i];
	}
	return 0;
}


Measured memory_bytes: 256
N,X = map(int,input().split())
ans=0
f=0
for i in range(N,1,-1):
    center = 2*pow(2,i)-1
    
    if X>center:
        X-=center
        ans+=pow(2,i)
    elif X==center:
        ans+=pow(2,i)
        f=1
        break
    elif X<center:
        X-=1

if f==0:
    ans+="BQQQB"[:X].count("Q")
print(ans)

Measured memory_bytes: 61952
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < int(n); ++(i))
#define repeat_reverse(i, n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i, m, n) for (int i = (n)-1; (i) >= int(m); --(i))
#define whole(x) begin(x), end(x)
#define unittest_name_helper(counter) unittest_ ## counter
#define unittest_name(counter) unittest_name_helper(counter)
#define unittest __attribute__((constructor)) void unittest_name(__COUNTER__) ()
using ll = long long;
using namespace std;
template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
bool solve(int h, int w, array<int, 26> cnt) {
    int r1 = (h % 2) * (w % 2);
    int r2 = (h % 2) * (w / 2) + (w % 2) * (h / 2);
    assert  ((h * w - 2 * r2 - r1) % 4 == 0);
    int r4 = (h * w - 2 * r2 - r1) / 4;
    for (int c = 0; r4 --; ) {
        while (c < 26 and cnt[c] < 4) ++ c;
        if (c == 26) return false;
        cnt[c] -= 4;
    }
    for (int c = 0; r2 --; ) {
        while (c < 26 and cnt[c] < 2) ++ c;
        if (c == 26) return false;
        cnt[c] -= 2;
    }
    return true;
}
int main() {
    // input
    int h, w; scanf("%d%d", &h, &w);
    array<int, 26> cnt = {};
    repeat (y, h) repeat (x, w) {
        char c; scanf(" %c", &c);
        cnt[c - 'a'] += 1;
    }
    // solve
    bool result = solve(h, w, cnt);
    // output
    printf("%s\n", result ? "Yes" : "No");
    return 0;
}


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

int main(void){
    
    int A,B,C,K;
    cin >> A >> B >> C >> K;
    
    if(K < A)cout << K << endl;
    else if(A <= K&& K <= A+B)cout <<A<<endl;
    else if(A+B < K && K <= A+B+C) cout << A-(K-B-A)<<endl;
    else if(A+B+C < K)cout << A-C<<endl;
    

}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <cassert>
using namespace std;

//common
// using i32=int;using i64=long long;using ll =i64;
// using uint=unsigned int;using ull=unsigned long long;
// template<typename T> using matrix=vector<vector<T> >;

#define BR "\n"
#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

//config
//#undef NDEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef NDEBUG
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#else
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}

template<class T> inline string toString(const vector<vector<T> >& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

string BITtoString(int bit){
    stringstream ss;
    while(bit!=0){ss<<(bit%2);bit/=2;}
    string res=ss.str();reverse(ALL(res));
    return res;
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

class Main{
public:
	void run(){

		while(true){
			int N;cin >> N;if(N==0)break;
			map<char,char> m;
			REP(i,N){
				char f,t;cin >>f  >> t;
				m[f]=t;
			}
			int M;cin >>M;
			string res="";
			REP(i,M){
				char c;cin >> c;
				if(m.count(c))res+=m[c];
				else res+=c;
			}
			cout << res <<endl;

		}
	}
};
int main(){
  	Main().run();
  	return 0;
 }

Measured memory_bytes: 1344
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <stack>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <cmath>

using namespace std;

const int N = 3e5 + 50;

long long n, d, a;
pair<long long, long long> g[N], b[N];
long long cnt;
int main()
{
    ios::sync_with_stdio(false);

    cin >> n >> d >> a;
    for (int i = 1; i <= n; i++)
        cin >> g[i].first >> g[i].second;
    sort(g + 1, g + n + 1);
    long long l = 1, sum = 0, ans = 0;
    for (int i = 1; i <= n; i++)
    {
        while (l <= cnt)
        {
            if (b[l].first + d >= g[i].first)
                break;
            sum -= b[l].second;
            l++;
        }
        if (g[i].second <= sum)
            continue;
        g[i].second -= sum;
        long long num = (g[i].second + a - 1) / a, v = num * a;
        b[++cnt] = make_pair(g[i].first + d, v);
        sum += v;
        ans += num;
    }
    cout << ans;
}

Measured memory_bytes: 9728
#include<stdio.h>
int main(void)
{
	int h, w, H, W;

	while (1) {
		scanf("%d %d", &H, &W);
		for (h = 1; h <= H; h++) {
			for (w = 1; w <= W; w++) {
				if ((h != 1 && h != H) && (1 < w && w < W))
					printf(".");
				else
					printf("#");
			}
			printf("\n");
		}
		if (H == 0 && W == 0) break;
		printf("\n");
	}
		return 0;
	
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie();
    ll n, k;
    cin>>n>>k;
    ll ans;
    ans = min(n%k, abs(n%k-k));
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std; 
int main()
{
    int h,w;
    cin>>h>>w;
    long long int dp[h][w];
  char a[h][w];
  for(int i=0;i<h;i++)
    {
          for(int j=0;j<w;j++)
        {
         cin>>a[i][j];
        }  
    }
    for(int i=0;i<h;i++)
    {
          for(int j=0;j<w;j++)
        {
          if(a[i][j]=='.')
          dp[i][j]=1;
          else
          dp[i][j]=0;
        }  
    }
     for(int i=0;i<h;i++)
    {
          for(int j=0;j<w;j++)
        {
           if(i==0 &&j-1>=0 && dp[i][j-1]==0)
           {
               dp[i][j]=0;
           }
           if(j==0 && i-1>=0 && dp[i-1][j]==0)
           {
               dp[i][j]=0;
           }
           if(i>0 && j>0 && dp[i][j]!=0)
           dp[i][j]=(dp[i][j-1]+dp[i-1][j])%1000000007;
           
        }  
    }
    
    cout<<(dp[h-1][w-1])%1000000007;
}

Measured memory_bytes: 9088