akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{

    int n, m, sz;
    char[] kakko;
    int[] a, bkt, add;

    void solve(){
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        m = sc.nextInt();
        kakko = sc.next().toCharArray();

        sz = Math.max(100, (int)Math.sqrt(n) + 10);
        a = new int[n];
        bkt = new int[n/sz+1];
        add = new int[n/sz+1];
        TreeSet<Integer> set = new TreeSet<Integer>();

        for(int i=0; i<n; i++){
            if(i==0) a[i] = 1;
            else{
                if(kakko[i]=='(') a[i] = a[i-1] + 1;
                else{
                    a[i] = a[i-1] - 1;
                    set.add(i);
                }
            }
            bkt[i/sz] = Math.min(a[i], bkt[i/sz]);
        }

        for(int i=0; i<m; i++){
            int q = sc.nextInt()-1;
            int idx = 0;
            if(kakko[q]=='('){
                kakko[q] = ')';
                set.add(q);
                add(q, n, -2);
                //idx = set.higher(new Integer(-1));
                idx = set.pollFirst();
                kakko[idx] = '(';
                set.remove(idx);
                add(idx, n, 2);
            }else{
                kakko[q] = '(';
                set.remove(q);
                add(q, n, 2);
                idx = search(q);
                kakko[idx] = ')';
                add(idx, n, -2);
                set.add(idx);
            }
            //System.out.println(Arrays.toString(kakko));
            System.out.println(idx+1);
        }
    }

    void add(int start, int last, int num){
        int from = start - start%sz;
        int to = from + sz;
        for(int i=start/sz; i * sz <=last; i++){
            if(start<=from && to<=last){
                add[i] += num;
            }else{
                for(int j=Math.max(from, start); j<to && j<last; j++){
                    a[j] += num;
                }
                int min = Integer.MAX_VALUE;
                for(int j=from; j<to && j<a.length; j++){
                    min = Math.min(min, a[j]);
                }
                bkt[i] = min;
            }
            from = to;
            to += sz;
        }
    }

    int search(int f){        
        int from = f - f%sz;
        int to = from + sz;
            
        for(int i=f/sz; i>=0; i--){
            if(bkt[i]+add[i]<=1){
                for(int j=Math.min(f-1, to-1); j>=from; j--){
                    if(a[j]+add[i]==1) return j+1;
                }
            }
            to = from;
            from -= sz;
        }
        return 0;
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 112200
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;
// auto mod int
const int mod = 1000000007;
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, const 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;

  mint ans;
  for(ll i = k; i <= n+1; ++i){
    mint cnt = 1;
    cnt += i*(n+(n-i+1))/2;
    cnt -= i*(i-1)/2;
    ans += cnt;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
a,b,c,x,y=map(int,input().split())

ans=10**9
for i in range(2*max(x,y)+1):
  s=max(x-i//2,0)
  t=max(y-i//2,0)
  t_ans=s*a+t*b+i*c
  ans=min(ans,t_ans)

print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
int main(){
    int tei[40]={0};
    int i,in;
    for(i=0;i<28;i++){
        scanf("%d",&in);
        tei[in]=1;
    }
    for(i=1;i<=30;i++){
        if (tei[i]==0) {
            printf("%d\n",i);
        }
    }
    return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main() {
	int n, k;
	cin >> n >> k;
	vector<vector<int>> v(n, vector<int> (k));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < k; ++j) {
			cin >> v[i][j];
		}
	}
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		for (int w = i + 1; w < n; ++w) {
			int x = 0;
			for (int j = 0; j < k; ++j) {
				x += abs(v[i][j] - v[w][j]) * abs(v[i][j] - v[w][j]);
			}
			int e = sqrt(x);
			//cout << e << " " << x << " " << i << " " << w << endl;
			if (e * e == x) {
				cnt++;
			}
		}
	}
	cout << cnt;
}



















Measured memory_bytes: 256
(setq li (list (read) (read) (read)))
(setq cnt5 0)
(setq cnt7 0)

(setq num (car li))
(if (= num 5) (setq cnt5 (+ cnt5 1)) ())
(if (= num 7) (setq cnt7 (+ cnt7 1)) ())

(setq num (car (cdr li)))
(if (= num 5) (setq cnt5 (+ cnt5 1)) ())
(if (= num 7) (setq cnt7 (+ cnt7 1)) ())

(setq num (car (cdr (cdr li))))
(if (= num 5) (setq cnt5 (+ cnt5 1)) ())
(if (= num 7) (setq cnt7 (+ cnt7 1)) ())

(princ (if (and (= cnt5 2) (= cnt7 1)) "YES" "NO"))

Measured memory_bytes: 24340
import java.util.*;

public class Main {
	public static void main(String[] args)  {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] W = new int[n]; 
		for (int i = 0; i < n; i++) {
			W[i] = scanner.nextInt();
		}
		System.out.println(minCostSort(W));
	}
	public static int indexOf(int[] A, int x) {
		for (int i = 0; i < A.length; i++) {
			if (A[i] == x) {
				return i;
			}
		}
		return -1;
	}
	public static int minCostSort(int[] W) {
		int sorted[] = W.clone();
		Arrays.sort(sorted);
		int cost = 0;
		for (int i = 0; i < W.length; i++) {
			int a = indexOf(W, sorted[i]);
			int j = 0;
			while (a > i) {
				j++;
				int b = indexOf(W, sorted[a]);
				cost += W[b];
				int t = W[a];
				W[a] = W[b];
				W[b] = t;
				a = b;
			}
			cost += Math.min(sorted[i] * j, sorted[i] * 2 + sorted[0] * (j + 2));
		}
		return cost;
	}
}

Measured memory_bytes: 31596
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#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 all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;
const int mod=998244353;

ll modpow(ll a,ll n,ll m){
    ll res=1;
    while(n){
        if(n&1)res=res*a%m;
        a=a*a%m;
        n>>=1;
    }
    return res;
}

const int MAX=510000;

vll fac(MAX);
vll finv(MAX);
vll inv(MAX);

void combinit(ll m){
    fac[0]=1;fac[1]=1;
    finv[0]=1;finv[1]=1;
    inv[1]=1;
    rep2(i,2,MAX){
        fac[i]=fac[i-1]*i%m;
        inv[i]=m-inv[m%i]*(m/i)%m;
        finv[i]=finv[i-1]*inv[i]%m;
    }
}

ll combi(ll n,ll k,ll m){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%m)%m;
}

int main(){
    ll n,m,k;cin>>n>>m>>k;
    combinit(mod);
    ll sum=0;
    rep(i,k+1){
        sum+=(((m*combi(n-1,i,mod))%mod)*modpow(m-1,n-1-i,mod))%mod;
        sum%=mod;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 14956
from collections import Counter

n= int(input())
a = list(map(int,input().split()))
q = int(input())

b=[0]*q
c=[0]*q
for qq in range(q):
    b[qq] ,c[qq]= map(int,input().split()) 

ans = sum(a)
aa = Counter(a)

# print(aa)

for i in range(q):
    ans += (c[i]-b[i])*aa[b[i]]
    aa[c[i]] += aa[b[i]]
    aa[b[i]] = 0
    print(ans)

Measured memory_bytes: 30148
import bisect
n = int(input())
l_list = list(map(int,input().split()))
l_list.sort()
ans = 0
for i in range(n-2):
    for j in range(i+1 , n-1):
        ans += bisect.bisect_left(l_list,l_list[i] + l_list[j]) -j -1
        
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//データ構造
//隣接リスト用構造体（有向グラフ向け）
struct edge {
  ll to; // E.toでその辺の終点へアクセスできる
  ll cost; // e.costでその辺の重みにアクセスできる
};
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}
//素数判定 
//一つ一つの判定ではこっちの方が速い(一つ当たりO(√N))
//一方100までに何個あるかなどはEratosthenesの篩の方が良い（O(NlogN))
bool PN(int x) {
  if (x <= 1) return false; // 1や0,-1は素数ではない
  if (x == 2) return true; // √2 + 1 > 2 なので下でやると 2 ％ 2 = 0 となり判定できない
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) return false; // 割れたら素数じゃない
  }
  return true;
}
// A^N mod M を計算する。modしたくなかったらM = LINFとかにすればよい。(O(√N))
ll modpow(ll A, ll N, ll M) {
  long long ans = 1;
  while (N > 0) {
    if (N & 1) ans = ans * A % M;
      A = A * A % M;
      N >>= 1;
   }
  return ans;
}
  
//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  int X, A, B;
  cin >> X >> A >> B;
  cout << (X - A) % B << endl;
}

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

int main(){
    int64_t A,B,C,D ;
    cin >> A >> B >> C >> D ;
    int64_t kazu = B - A + 1 ;
    int64_t nc = B / C - (A-1) / C ;
    int64_t nd = B / D - (A-1) / D ;
    
    /* 自然数 a > b を確認・入替 */
  if(D<C){
    int64_t tmp = C;
    C = D;
    D = tmp;
  }
 
  /* ユークリッドの互除法 */
  int64_t a = C ;
  int64_t b = D ;
  int64_t r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  int64_t LCM = C * D / b ;

    int64_t ncd = B / LCM - (A-1) / LCM ;
    cout << kazu - nc - nd + ncd << endl ;
}

Measured memory_bytes: 256
def moji(x,ans):
    if ans == 0:
        return
    if x == 1:
        if(ans%5==1):
            str = '.'
        elif(ans%5==2):
            str =','
        elif(ans%5==3):
            str='!'
        elif ans%5==4:
            str='?'
        else:
            str = ' '
    if x == 2:
        if(ans%3==1):
            str = 'a'
        elif(ans%3==2):
            str = 'b'
        else:
            str = 'c'
    if x == 3:
        if(ans%3==1):
            str = 'd'
        elif(ans%3==2):
            str = 'e'
        else:
            str = 'f'
    if x == 4:
        if(ans%3==1):
            str = 'g'
        elif(ans%3==2):
            str = 'h'
        else:
            str = 'i'
    if x == 5:
        if(ans%3==1):
            str = 'j'
        elif(ans%3==2):
            str = 'k'
        else:
            str = 'l'
    if x == 6:
        if(ans%3==1):
            str = 'm'
        elif(ans%3==2):
            str = 'n'
        else:
            str = 'o'
    if x == 7:
        if(ans%4==1):
            str = 'p'
        elif(ans%4==2):
            str = 'q'
        elif(ans%4==3):
            str ='r'
        else:
            str = 's'
    if x == 8:
        if(ans%3==1):
            str = 't'
        elif(ans%3==2):
            str = 'u'
        else:
            str = 'v'
    if x == 9:
        if(ans%4==1):
            str = 'w'
        elif(ans%4==2):
            str = 'x'
        elif ans%4==3:
            str = 'y'
        else:
            str = 'z'
    print(str,end="")
def solve(str):
    x = '-1'
    ans =0
    for s in str:
        if s == '0':
            moji(int(x),ans)
            ans = 0
        else:
            x = s
            ans +=1

N = int(input())
for i in range(N):
    solve(input())
    print()



Measured memory_bytes: 5632
program main
    implicit none
    integer:: l, i,j,k
    character(100):: s
    read*, s
    l = len_trim(s)

    do i = 1,l
        if ((mod(i,2) == 0).and. (s(i:i) == 'R'))then
            print*, 'No'
            stop
        else if((mod(i,2) == 1) .and. (s(i:i) == 'L'))then
            print*, 'No'
            stop
        end if
    enddo

    print*, 'Yes'

    
end program

Measured memory_bytes: 768
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

#define MAXN (1 << 20)

ll a[MAXN];
int n;

int main() {
	cout << fixed << setprecision(12);	
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	ll ret = 0;
	for (int i = 0; i <= n; i++) {
		ret += llabs(a[i] - a[i + 1]);
	}
	for (int i = 1; i <= n; i++) {
		cout << ret - llabs(a[i] - a[i - 1]) - llabs(a[i + 1] - a[i]) + llabs(a[i + 1] - a[i - 1]) << endl;
	}
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



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

using namespace std;

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  
  cout << (char)toupper(s1[0]);
  cout << (char)toupper(s2[0]);
  cout << (char)toupper(s3[0]);

  cout << endl;
  // for (int i = 0; i < 3; i++) {
  //   cin >> haha[i];
  // }

  // for (int i = 0; i < 3; i++) {
  //   cout << putchar (toupper(haha[i][0]));
  // }

  // cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define mod 1000000007
#define dd double
#define ld long double
#define f(i,a,b) for(ll i = a; i < b; i++)
#define fr(i,a,b) for(ll i = b;i>=a;i--)
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define vpll vector< pii >
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define Sort(v) sort(v.begin(), v.end(), sortbysec)
#define MEM(a, b) memset(a, (b), sizeof(a))

ll power(ll x, ll y, ll p)  
{  
    ll res = 1;      
    x = x % p; 
                
    while (y > 0)  
    {   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}  

 

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

ll n;
cin>>n;

vll v(n);
f(i,0,n)
cin>>v[i];

ll f= 0;
f(i,0,n)
{
    if(i==0 && v[i])
    v[i]--;
    else if(i > 0 && v[i] > v[i-1])
    v[i]--;

    if(i > 0 && v[i] < v[i-1])
    {
        f = 1;
        break;
    }
    
}

if(f)
cout<<"No"<<endl;
else
cout<<"Yes"<<endl;






}


Measured memory_bytes: 3972
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << endl;}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << endl;}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll a, b;
	cin >> a >> b;
	a--;

	ll m = 1, p, q, r, s;
	ll ans = 0;
	while(m < b*2){
		if(m == 1){
			if(b%4 == 1 || b%4 == 2) ans ^= m;
			if(a%4 == 1 || a%4 == 2) ans ^= m;
			m <<= 1;
			continue;
		}
		p = m&b;
		if(p){
			r = b%m;
			if(r%2 == 0) ans ^= m;
		}
		q = m&a;
		if(q){
			s = a%m;
			if(s%2 == 0) ans ^= m;
		}
		m <<= 1;
	}
	co(ans);

	return 0;
}


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

signed main(){
 lint X; cin >> X;
 for(lint a = -1000; a <= 1000; a++){
	 for(lint b = -1000; b <= 1000; b++){
		 if(a*a*a*a*a - b*b*b*b*b ==X){
			 cout << a << " " << b << endl;
			 return 0;
		 }
	 }
 }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
const ll mod = 1e9 + 7;

int main() {
  ll s, c;
  cin >> s >> c;
  ll ans = 0;
  while (s >= 1 && c >= 2) {
    if (min(s, c/2) == s) {
      ans += s;
      c -= 2*s;
      s = 0;
    } else {
      ans += c/2;
      s -= c/2;
      c %= 2;
    }
  }
  if (c >= 4) ans += c/4;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string n;
	cin>>n;
	int a=0,b=0;
	for(int i=0;i<n.size();i++)
	{
		if(i%2==0)
		{
			if(n[i]=='0')
			    ++b;
			else
			    ++a;
		}
		else
		{
			if(n[i]=='1')
			    ++b;
			else
			    ++a;
		}
	}
	if(a<b)
	{
		cout<<a;
	}
	else
	{
		cout<<b;
	}
	cout<<endl;
	return 0;
}

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

int N, M, i, P_tmp, Y_tmp;

int main(void) {
    cin >> N >> M;
    pair<int, int> city[M]; // 第１要素：年, 第２要素：市番号
    int id[M];
    int pref[N];
    for (i=0; i<N; i++) {
        pref[i] = 0;
    }
    int P[M], Y[M];
    
    for (i=0; i<M; i++) {
        cin >> P[i] >> Y[i];
        city[i] = make_pair(Y[i], i);
    }
    sort(city, city + M);
    
//    for (i=0; i<M; i++) {
//        cout << "city[" <<  i << "]=(" << city[i].first << ", " << city[i].second << ")" << endl;
//        cout << "P[" << i << "]=" << P[i] << endl;
//    }
    
    for (i=0; i<M; i++) {
        pref[P[city[i].second] - 1]++;
        id[city[i].second] = pref[P[city[i].second] - 1];
    }
    
    for (i=0; i<M; i++) {
        printf("%06d%06d\n", P[i], id[i]);
    }
    
    
//    for (i=0; i<N; i++) {
//        cout << pref[i] << endl;
//    }
//
//    for (i=0; i<M; i++) {
//        cout << id[i] << endl;
//    }
 
    return 0;
}


Measured memory_bytes: 3840
#include<stdio.h>
int main(void){
	int n,k,a,flg[100001],i,ii,cnt[100001],max,kai,J,c,cc;
	while(1){
		scanf("%d %d",&n,&k);
		if(n==0) break;
		for(i=0;i<=n;i++){
			flg[i]=0;
			cnt[i]=0;
		}
		for(i=0;i<k;i++){
			scanf("%d",&a);
			flg[a]=1;
		}
		ii=0;
		c=0;
		cc=0;
		for(i=1;i<=n;i++){
			if(ii==0&&flg[i]==1){
				if(c>=2) cc-=c-1;
				c=0;
				ii=i+cc;
			}
			if(flg[i]==1){
				cnt[ii]++;
				c++;
			}
			else ii=0;
		}
		max=0;
		for(i=0;i<n;i++){
			if(max<cnt[i])max=cnt[i];
		}
		if(flg[0]!=0){
			for(i=1;i<=n;i++){
				if(cnt[i]==0){
					if(i==1) kai=cnt[i+1]+1;
					if(i!=1) kai=cnt[i-1]+1+cnt[i+1];
					if(max<kai) max=kai;
				}
			}
		}
		printf("%d\n",max);
	}
	return 0;
}

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

#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++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    string n;
    cin >> n;
    rep(i, 3) n[i] == '1' ? n[i] = '9' : n[i] = '1';

    OP(n);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6,inf=1e9;
double aa[N+2],qm[N+2];
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n,k;cin>>n>>k;
  for(int i=1;i<=n;i++)
  {
    int x;cin>>x;
    aa[i]=(1.0*((x*(x+1))/2))/(1.0*x);
    qm[i]=qm[i-1]+aa[i];
  }
  double mx=0;
  for(int i=k;i<=n;i++)
    mx=max(mx,qm[i]-qm[i-k]);
  cout<<setprecision(10)<<fixed<<mx<<endl;

  return 0;
}

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

int kaijou(int n) {
  long j = 1;
  for (int i = 1; i <= n; i++) {
    j *= i;
  }
  return j;
}
int nCr(int n, int r) {
  if (n - r == 0 || r == 0) {
    return 1;
  } else {
    return kaijou(n) / (kaijou(n - r) * kaijou(r));
  }
}

int test(int n) { return (n * (n - 1)) / 2; }

int main() {
  int N, M;
  cin >> N >> M;
  if (N == 1 && M == 1) {
    cout << 0 << endl;
  } else if (N < 2) {
    cout << test(M) << endl;
  } else if (M < 2) {
    cout << test(N) << endl;
  } else {
    cout << test(N) + test(M) << endl;
  }
}


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

const int maxn=100;
int n,m,cnt;
vector<int> G[maxn];
int dfn[maxn],low[maxn];
int ans;

void tarjan(int u,int fa){
	dfn[u]=low[u]=++cnt;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==fa)	continue;
		if(dfn[v]==0){
			tarjan(v,u);
			low[u]=min(low[u],low[v]);
			if(low[v]>dfn[u])	ans++;
		}
		else	low[u]=min(low[u],dfn[v]);
	}
}

int main(){
	while(scanf("%d%d",&n,&m)==2){
		memset(dfn,0,sizeof(dfn));
		memset(low,0,sizeof(low));
		cnt=0;
		for(int i=1;i<=n;i++)	G[i].clear();
		for(int i=0;i<m;i++){
			int u,v;	scanf("%d%d",&u,&v);
			G[u].push_back(v);
			G[v].push_back(u);
		}
		ans=0;
		for(int i=1;i<=n;i++){
			if(dfn[i]==0)	tarjan(i,-1);
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const ll INF = 1LL << 60;
const ll MOD = (ll) 1e9 + 7;

int main(){
    int n, y;
    cin >> n >> y;
    bool found = false;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            int k = n - i - j;
            if (k < 0) continue;
            int r = 10000 * i + 5000 * j + 1000 * k;
            if (r == y) {
                cout << i << " " << j << " " << k << "\n";
                found = true;
                break;
            }
        }
        if (found) break;
    }
    if (!found) cout << "-1 -1 -1" << "\n";
}

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

int main(){
    int n,k;
    cin>>n>>k;
    vector<ll> h(n);
    for(int i = 0;i < n;i++){
        cin>>h[i];
    }
    sort(h.begin(),h.end());
    ll ans=1000000000,now=0;
    for(int i=0;i<n-k+1;i++){
        now=h[i+k-1]-h[i];
        if(now<ans){
            ans=now;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String... args) {
		new Main().solve().forEach(System.out::println);
	}
	public List<String> solve() {
		List<String> result = new ArrayList<>();
		try(Scanner sc = new Scanner(System.in)) {
		    int n = sc.nextInt();
		    int[] t = new int[n];
		    for(int i = 0; i < n; i++) {
		    	t[i] = sc.nextInt();
		    }
		    int sum = IntStream.of(t).sum();
		    int m = sc.nextInt();
		    for(int i = 0; i < m; i++) {
		    	int p = sc.nextInt();
		    	int x = sc.nextInt();
		    	result.add(Integer.toString(sum - t[p - 1] + x));
		    }
		}
		return result;
	}
}


Measured memory_bytes: 27092
#include<stdio.h>


int main() {
    int A[1001], N;
    scanf("%d",&N);
    for (int i = 0; i < N; i++) scanf("%d",&A[i]);
    int v,j;
    
    for (int i = 1; i < N; i++)
    {
        for (int k = 0; k < N; k++)
        {
            {if (k>=1) printf(" ");}
            printf("%d",A[k]);
        }
        printf("\n");
        
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v)
        {
            A[j + 1] = A[j];
            j--;
        }
        A[j+1] = v;
        
    }

    for (int k = 0; k < N; k++)
        {
            {if (k>=1) printf(" ");}
            printf("%d",A[k]);
        }
        printf("\n");
        
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
A = list(map(int,input().split()))
flag = 0
for i in range(N-1,0,-1):
  if A[i] >= A[i-1]:
    continue
  else:
    if A[i-1]-A[i] == 1:
      A[i-1] -= 1
    else:
      flag += 1
      print("No")
      break
if flag == 0:
  print("Yes")

Measured memory_bytes: 14396
#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

const int e = 2e6 + 69;
const ll mod = 1e9 + 7;

ll a[e];

int main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    for(int i=0; i<n; i++){
        if(i == k-1){
            s[i] = char(s[i] - 'A' + 'a');
        }
    }
    cout << s;
}


Measured memory_bytes: 3596
import sys

# N 宿泊数
n = int(input())

# K 最初のX円までの宿泊数
k = int(input())

# X 最初のK日までの金額
x = int(input())

# Y K+1日以降の金額
y = int(input())

# X円, Y円での宿泊数
if n > k:
    day_x = k
    day_y = n - k
else:
    day_x = n
    day_y = 0
    
print(x * day_x + y * day_y)

Measured memory_bytes: 3060
a = int(input())
b = int(input())

ans = []
ans.append(a)
ans.append(b)

if 1 in ans and 2 in ans:
    print(3)
elif 2 in ans and 3 in ans:
    print(1)
elif 1 in ans and 3 in ans:
    print(2)

Measured memory_bytes: 3060
#[allow(unused_imports)]
use std::io;

#[allow(unused_macros)]
macro_rules! get {
    ($i:ident) => {
        let mut $i = String::new();
        io::stdin().read_line(&mut $i).ok();
    };
}

#[allow(unused_macros)]
macro_rules! to_vec {
    ($s:ident, $t:ty) => {
        $s.split_whitespace().map(|i| i.parse().ok().unwrap()).collect::<Vec<$t>>()
    }
}

#[allow(unused_macros)]
macro_rules! parse {
    ($s:ident, $t:ty) => {
        $s.trim().parse::<$t>().ok().unwrap()
    }
}

#[allow(unused_macros)]
macro_rules! max {
    ($v:ident) => {
        $v.iter().max().unwrap()
    };
}

#[allow(unused_mut)]
fn main() {
    get!(s);
    let n = parse!(s, i32);

    println!("{}", n * n * n);
}

Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(){
    int A = 0;
    int B = 0;
    cin>>A>>B;
    
    int res = 0;
    
    for(int i =0;i < 2;i++){
        if(A > B){
            res += A;
            A--;
        }else{
            res += B;
            B--;
        }
    }
    
    cout<<res;
    
    return 0;
}


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

class Program
{
    private int N;
    private int A;
    private void Scan()
    {
        N=int.Parse(Console.ReadLine());
        A=int.Parse(Console.ReadLine());
    }
    
    
    public void Solve()
    {
        Scan();
        Console.WriteLine(N*N-A);
    } 
    
    static void Main()
    {
        new Program().Solve();
    }
}

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

const int DIM = 300;

string str;
int hz[DIM], cnt[DIM];

int main( void ) {
    
    int n;
    cin >> n;
    
    for( int i = 'a'; i <= 'z'; i ++ )
        cnt[i] = numeric_limits<int> :: max();
    
    for( int i = 1; i <= n; i ++ ) {
        cin >> str;
        
        for( int i = 'a'; i <= 'z'; i ++ )
            hz[i] = 0;
        
        for( char ch : str )
            hz[ch] ++;
        
        for( int i = 'a'; i <= 'z'; i ++ )
            cnt[i] = min( cnt[i], hz[i] );
    }
    
    for( int i = 'a'; i <= 'z'; i ++ )
        for( int j = 1; j <= cnt[i]; j ++ )
            cout << (char) i;
            
    return 0;
}

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

int main(){
	//入力
	int N;
	cin >> N;
	vector<vector<int>> g(N,vector<int>(N, -1));		//有向グラフ
	rep(i,N){
		int a;
		cin >> a;
		rep(j,a){
			int x, y;
			cin >> x >> y;
			g[i][x-1] = y;
		}
	}

	int ans=0;
	//2^(n)回総当たり
	rep(i,1<<N) {
		vector<int> d(N);														//iを二進数で保存
		rep(j,N) if(i>>j&1) d[j] = 1;							//iを二進数で保存
		bool ok = true;
		//iとgをビット単位で比較
		rep(j,N) {
			//j番目が正直者か検討
			if(d[j]) {
				rep(k,N) {
					if(g[j][k] == -1) continue;
					//嘘をついていたらfalseを代入
					if(g[j][k] != d[k]) ok = false;
				}
			}
		}
		if(ok) ans = max(ans, __builtin_popcount(i));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
let lcs (x, y) =
  let m = String.length x in
  let n = String.length y in
  let s = Array.make (n + 1) 0 in
  let t = Array.copy s in
  for i = 1 to m do
    for j = 1 to n do
      t.(j) <-
        if x.[i-1] = y.[j-1] then s.(j-1) + 1
        else if s.(j) > t.(j-1) then s.(j)
        else t.(j-1);
    done;
    Array.iteri (fun i e -> s.(i) <- e) t;
  done;
  t.(n)

let () =
  let q = read_int () in
  for _ = 0 to q - 1 do
    let x = read_line () in
    let y = read_line () in
    lcs (x, y)
    |> Printf.printf "%d\n"
  done

Measured memory_bytes: 3292
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
using namespace std;
class CExceptionHandling {

public:
	void solve(std::istream& cin, std::ostream& cout) {
	    int n;
	    cin >> n;
	    int a[200100] = {};
	    int ma=-1,ma2=-1;
	    int ia = -1,ia2=-1;
	    for(int i=0;i<n;i++) {
	        cin >> a[i];
	        if(ma <= a[i]) ma2 = ma, ma=a[i],ia2=ia,ia=i;
	        else if(ma2 <= a[i]) ma2=a[i],ia2 = i;
	    }

	    for(int i=0;i<n;i++) {
        if(ia == i) cout << ma2 << endl;
        else cout << ma << endl;
	    }
	}
};


int main() {
	CExceptionHandling solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std; 
int main() 
{long long n,a,b;
 cin>>n>>a>>b; 
 
 long long x=n/(a+b);
 long long y=n%(a+b);
 cout<<(x*a)+min(y,a)<<"\n";
 /*if(a==0)cout<<0<<"\n"; 
 else if(b==0)cout<<min(n,a)<<"\n";
 else if(n<(a+b))cout<<min(n,a)<<"\n"; 
 else cout<<((n/(a+b))*a)+min((n%(a+b)),a)<<"\n"; */ 
 return 0; 
}


Measured memory_bytes: 256
N = int(input())

ans = 0
for i in range(1, N + 1):
    ans += i * (N + 1 - i)

for i in range(N - 1):
    u, v = map(int, input().split())
    u, v = min(u, v), max(u, v)
    ans -= (N - v + 1) * u

print(ans)


Measured memory_bytes: 9176
/*
 Author : Alokit Kumar
  */
 #include<bits/stdc++.h>
 using namespace std;
 #define int long long
 
 int32_t main()
 {
   int t,n,i,j,k,l;
   cin>>n;
   char ch;bool hi=false;
   for(i=1;i<=n;i++)
   {
     cin>>ch;
     if(ch=='Y')
     {
       hi=true;
     }
   }
   if(hi) cout<<"Four";
   else cout<<"Three";
 }

Measured memory_bytes: 3580
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String ans = "Yes";
    for(int i = 0; i < s.length(); i++) {
      if(s.charAt(i) != s.charAt(s.length() - 1 - i)) {
        ans = "No";
        break;
      }
    }
    for(int i = 0; i < (s.length() - 1) / 2; i++) {
      if(s.charAt(i) != s.charAt((s.length() - 1) / 2 - 1 - i)) {
        ans = "No";
        break;
      }
    }
    for(int i = (s.length() + 1) / 2; i < s.length(); i++) {
      if(s.charAt(i) != s.charAt(s.length() - 1 - (i - (s.length() + 1) / 2))) {
        ans = "No";
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include <queue>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;


int main(){
    string s; cin >> s;
    int ans = 0;
    int n = s.size();
    for(int i = 0; i < n / 2; i++){
        if(s[i] != s[n - 1 - i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>

#include<cmath>
#include<string>
#include <algorithm> 

using namespace std;

# define p(s) cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) cout << (j ? "Yes" : "No") << endl;

string lpad(string l,int s,int n){
    string temp = to_string(n);
    string res = "";
    int loop = s - temp.size();
    while(loop--) res+=l;

    return res+temp;
}

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

    printIf (n%k==0,0,1)
}

Measured memory_bytes: 256
"use strict"
function Main(stdin){
stdin = stdin.trim().split("\n").reverse();
let stdout = [];
function input(){return stdin.pop()};
function maput(){return input().split(" ").map(n=>parseInt(n))};
function print(x){stdout.push(x)};
function exist(x, xs){return new Set(xs).has(x)}
function max(x){return x.reduce(function(a,b){ return Math.max(a,b) }) }
function min(x){return x.reduce(function(a,b){ return Math.min(a,b) }) }
function sum(x){return x.reduce(function(a,b){ return a+b }) }
function sorting(x, index){x.sort((a, b) => a[index] - b[index])}
function all(x){return x.reduce(function(a,b){ return a && b }) }
function any(x){return x.reduce(function(a,b){ return a || b }) }
function list(iterable){return Array.from(iterable)}
function vint(iterable){return Array.from(iterable, x => parseInt(x))}
function tile(val, len){return Array(len).fill(val)}
const range = (start, stop, step) => Array.from(
    { length: (stop - start) / step }, (_, i) => start + (i * step));
/*START*/

let n = parseInt(input())
let ans = 0
for (let i = 0; i < n; i++){
    let tmp = maput()
    ans += (tmp[1] - tmp[0] + 1)
}
print(ans)


/*END*/
stdout = stdout.join("\n");
console.log(stdout);
return stdout
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] i = Console.ReadLine().Split(' ');

            if (int.Parse(i[0]) < int.Parse(i[2]) && int.Parse(i[1]) > int.Parse(i[2]))
            {
                Console.WriteLine("Yes");
            }
            else if (int.Parse(i[1]) < int.Parse(i[2]) && int.Parse(i[0]) > int.Parse(i[2]))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }





        }
    }
}


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

int main(){
  int N;
  cin >> N;
  int a[N];
  for(int i=0;i<N;i++) cin >> a[i];
  int count=0;
  for(int j=0;j<N-2;j++){
    if((a[j]<a[j+1] && a[j+1]<a[j+2]) || (a[j]>a[j+1] && a[j+1]>a[j+2])) 
      count++;
  }
  cout << count << endl;
  
}


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

using namespace std;


int main() {
	set<int> seen;
	int a, b, c;
	cin >> a >> b >> c;

	seen.insert(a);
	seen.insert(b);
	seen.insert(c);

	cout << seen.size();
}


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

using namespace std;

int main(){
    int N,M,X;
    cin >> N >> M >> X;

    vector<vector<int>> book(N, vector<int>(M));
    vector<int> value(N);

    for(int i=0; i<N; i++){
        cin >> value.at(i);
        for(int j=0; j<M; j++){
            cin >> book.at(i).at(j);
        }
    }

    vector<int> skills(M);
    int res = 1e9;
    for(int bit=0; bit<(1<<12); bit++){
        skills = vector<int>(M, 0);
        int sum=0;
        for(int i=0; i<N; i++){
            if(bit & (1<<i)){
                for(int j=0; j<M; j++)skills.at(j) += book.at(i).at(j);
                sum += value.at(i);
            }
        }

        bool flag = true;
        for(int i=0; i<M; i++){
            if(skills.at(i) < X){
                flag = false;
                break;
            }
        }

        bitset<12> b(bit);
        if(flag)res = min(res, sum);
    }

    if(res == 1e9)cout << -1;
    else cout << res;
}

Measured memory_bytes: 3636
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner v = new Scanner(System.in);
		int a = v.nextInt();
		int b = v.nextInt();
		int c = v.nextInt();
		int z = a;
		a = b;
		b = z;
		z = a;
		a = c;
		c = z;
		System.out.printf("%d %d %d",a,b,c);
	}
}


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

#define scd second
#define fst first
#define pb push_back
#define mkp make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vint> vvint;
typedef vector<vlong> vvlong;
typedef list<int> lint;
typedef list<ll> llong;
typedef list<pii> lpii;
typedef list<pll> lpll;
typedef list<lint> llint;
typedef list<llong> lllong;

int const N=1e6+100;
ll const LINF=numeric_limits<long long int>::max();
int const INF=numeric_limits<int>::max();
int const BN = 31;

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

ll pow_mod(ll a, ll e, ll m){
	ll res=1;
	while(e){
		if(e&1) res=res*a%m;
		a=a*a%m;
		e>>=1;
	}
	return res;
}

ll inv_mod(ll b, ll m){
	b%=m;
	ll x=0, y=1, r, q, a=m;
	while(b){
		q=a/b;
		r=a%b;
		a=b;
		b=r;
		r=x;
		x=y;
		y=r-q*y;
	}
	x+=m;
	return x%m;
}

void dfs(int r, vint gr[], vlong &xsum, vlong &ans, ll psum, vint &vst){
	psum+=xsum[r];
	ans[r]=psum;
	vst[r]=0;
	for(auto x : gr[r]){
		if(vst[x]==1){
			dfs(x,gr,xsum,ans,psum,vst);
		}
	}
}

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

	string s, t;
	cin>>s>>t;
	int n=s.length(), m=t.length();
	vvint pos(26);
	vint cnt(26,0);
	for(int i=0; i<n; i++){
		pos[s[i]-'a'].pb(i);
	}
	for(auto x : t) cnt[x-'a']++;
	bool f=true;
	for(int i=0; i<26; i++){
		if(cnt[i] && pos[i].empty()){
			f=false;
			break;
		}
	}
	if(f){
		ll curr=0, tcurr=-1, r=0;
		while(curr<m){
			while(curr<m){
				int id=t[curr]-'a';	
				auto itr=upper_bound(all(pos[id]),tcurr);
				if(itr==pos[id].end()){
					break;
				}
				tcurr=*itr;
				// cout<<"("<<t[curr]<<","<<tcurr<<") ";
				curr++;
			}
			// cout<<endl;
			if(curr<m){
				r++;
				tcurr=-1;
			}
		}
		// cout<<r<<" "<<tcurr<<endl;
		cout<<r*n+tcurr+1<<endl;
	} else {
		cout<<-1<<endl;
	}
}

Measured memory_bytes: 1228
n = int(input())
L = [i for i in range(100,2001,100)]
#print(L)
LL = []
for i in L:
    n1 = int(str(i)[0])
    n2 = int(str(i)[0]+str(i)[1])
    len1 = len(str(i))
    if len1 == 3:
        LL.append((n1*100+5*n1+1,(n1+1)*100-1))
    else:
        LL.append((n2*100+5*(n2)+1,(n2+1)*100-1))
LL = [(1,99)] + LL
LL.pop()
#print(LL)
for i in range(len(LL)):
    if LL[i][0] <= n <= LL[i][1]:
        print(0)
        exit()
print(1)

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

var (
	finv, inv, fac [510000]int
)

func COM(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func init() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < MAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

const (
	MOD = 1000000007
	MAX = 510000
)

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	a, b       int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

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

func LCM(a, b int) int {
	return a * b / GCD(a, b)
}

type P struct {
	l, r int
}

func main() {
	var N, K int
	fmt.Scanf("%d %d\n", &N, &K)

	for i := 1; i <= K; i++ {
		fmt.Println(COM(N-K+1, i) * COM(K-1, i-1) % MOD)
	}
}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


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

using namespace std;

int a = 0, b = 0, c = 0;

void input()
{
  scanf("%d %d %d", &a, &b, &c);
}

void solve()
{
  printf((c <= a + b) ? "Yes" : "No");
}

int main()
{
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
fun main(args:Array<String>) {
    val shopCount = readLine()!!.toInt()
    (1..shopCount).map { num-> readLine()!!.split(" ").let { item(num, it[0], it[1].toInt()) } }.sortedBy { it.price * -1 }.sortedBy { it.city }.forEach { println(it.id) }
}

class item(val id:Int, val city:String, val price:Int)


Measured memory_bytes: 35900
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
a, b = map(int, input().split())

print(a*b)


Measured memory_bytes: 9144
from itertools import combinations_with_replacement
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]
ans = 0
for x in combinations_with_replacement(range(1, M+1), N):
    point = 0
    for a, b, c, d in abcd:
        if x[b-1] - x[a-1] == c:
            point += d
    if ans < point:
        ans = point
print(ans)


Measured memory_bytes: 9108
#include<stdio.h>
#include<list>
#include<algorithm>
class s{
 public:
  int num;
  int i;
  s(int n,int j){
    num=n;
    i=j;
  }
};
int main(){
  using namespace std;
  int p,q,pn,i,pr,j;
  char ans[1000];
  list
 memo;
  list
::iterator it;
  pn=1;
  while(scanf("%d %d",&p,&q)!=EOF){
    for(pr=0,p*=10,i=0;p%q;i++,p*=10){
      it=memo.begin();
      while(it!=memo.end()){
	if(it->num==p) break;
	it++;
      }
      if(memo.end()==it){
	memo.push_back(*(new s(p,i+1)));
      }else{
	pr=it->i;
	ans[i]='\0';
	goto find;
      }
      if(p>q){
	ans[i]=(int)(p/q)+(int)'0';
	p=p%q;
      }else{
	ans[i]='0';
      }
    }
    ans[i]=(int)'0'+(int)(p/q);
    ans[i+1]='\0';
  find:;
    printf("%s\n",ans);
    if(pr){
      for(j=0;j<pr-1;j++){
	printf(" ");
      }
      while(j++<i) printf("^");
      printf("\n");
    }
    pn++;
    memo.clear();
  }
  return 0;
}

Measured memory_bytes: 0