akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

// Problem Specific Parameter:
int n;
int a[100010], b[100010], axor = 0, bxor = 0;

bool check(){
	vector<int> ca,cb;
	rep(i,n) ca.push_back(a[i]);
	rep(i,n) cb.push_back(b[i]);
	sort(begin(ca),end(ca));
	sort(begin(cb),end(cb));
	rep(i,n) if(ca[i]!=cb[i]) return false;
	return true;
}

// Description: 素集合を管理するデータ構造 
// TimeComplexity: 初期化$\mathcal{O}(n)$ 更新$\mathcal{O}(\log n)$
// Verifyed: AOJ DSL_1_A

struct Union_find{
	Union_find(int n){par.resize(n),iota(_all(par),0);}
	int find(int x){return (par[x]==x)?x:par[x]=find(par[x]);}
	void unite(int a,int b){a=find(a),b=find(b);par[a]=b;}
	bool same(int a,int b){return find(a)==find(b);}
	vector<int> par;
};


int main(void) {
	cin >> n;
	rep(i, n) cin >> a[i],axor^=a[i];
	rep(i, n) cin >> b[i],bxor^=b[i];

	a[n] = axor;
	b[n] = bxor;
	n++;

	if(check()==false){
		cout << -1 << endl;
		return 0;
	}

	vector<int> val;
	rep(i,n) val.push_back(a[i]);
	uniq(val);
	const int m = val.size();

	Union_find uf(m);

	rep(i,n-1){
		const int ai = getidx(val,a[i]);
		const int bi = getidx(val,b[i]);
		uf.unite(ai,bi);
	}

	map<int,int> group;
	rep(i,n-1){
		const int ai = getidx(val,a[i]);
		const int bi = getidx(val,b[i]);
		if(ai!=bi) group[uf.find(ai)]++;
	}

	int ans = 0;
	
	for(auto &it:group){
		ans+=it.second + 1;
	}

	{
		const int ai = getidx(val,a[n-1]);
		if(group.find(uf.find(ai))!=end(group)) ans--;
	}

	cout << ans << endl;	

	return 0;
}

Measured memory_bytes: 4200
S = input()

T = list("AKIHABARA")

spos = 0

for i, t in enumerate(T):
    if spos < len(S) and S[spos] == t:
        spos += 1
    elif t == "A":
        continue
    else:
        print("NO")
        exit()

print("YES" if spos == len(S) else "NO")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
int main() {
  int N, M, c;
  cin >> N >> M;
  vector<int> city(N);
  for(int i = 0; i < M*2; i++) {
    cin >> c;
    city.at(c-1)++;
  }
  for(int i= 0; i < N; i++)
    cout << city.at(i) << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};

vector<in> par(0);
vector<in> depth(0);
vector<in> siz(0);
void init(in n){
    par.resize(n);
    depth.resize(n,0);
    siz.resize(n,1);
    rep(i,n) par[i]=i;
}

in find(in n){
    if(par[n]==n) return n;
    return par[n]=find(par[n]);
}

void unite(in x,in y){
    x=find(x);
    y=find(y);
    if(par[x]==par[y]) return;
    siz[x]+=siz[y];
    siz[y]=siz[x];
    if(depth[x]<depth[y]) par[x]=par[y];
    else{
        par[y]=par[x];
        if(depth[x]==depth[y]) depth[x] ++;
    }
}

bool same(in x,in y){
    return find(x)==find(y);
}

in size(in x){
    return siz[find(x)];
}

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in n,m;
    cin>>n>>m;
    init(n);
    vector<P> x(m);
    int a,b;
    rep(i,m){cin>>a>>b;a--,b--;x[i]=P(a,b);}
    vector<in> ans(m,0);
    ans[m-1]=n*(n-1)/2ll;
    for(in i=m-1;i>0;i--){
        if(same(x[i].first,x[i].second)) ans[i-1]=ans[i];
        else ans[i-1]=ans[i]-size(x[i].first)*size(x[i].second);
        unite(x[i].first,x[i].second);
    }
    rep(i,m) cout<<ans[i]<<endl;
}

Measured memory_bytes: 6016
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;

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

Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))
p = [(A[i], 1) for i in range(N)]
for j in range(M):
    B, C = map(int, input().split())
    p.append((C, B))
p.sort()
p.reverse()
ans, cnt = 0, N
for (v, s) in p:
    use = min(s, cnt)
    ans += use * v
    cnt -= use
print(ans)

Measured memory_bytes: 28936
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  
  if(U == S){
    A--;
  }
  if(U == T){
    B--;
  }
  cout << A << " " << B << endl;
}

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


int main() {

  int X;
  cin >> X;

  if(X==0){
    cout << "0" << endl;
    return 0;
  }

  int dai5 = X/500;
  int syo5 = (X - dai5*500)/5;

  int uresisa = dai5*1000 + syo5*5;

  cout << uresisa << endl;

  return 0;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+2;
int c[105],d[105],a[105],b[105];
int main()
{
    ft
    int t,i,j,n,m,l,r,x;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
        cin>>b[i];
    }
    c[0]=a[0];
    for(i=1;i<n;i++)
    {
        c[i]=a[i]+c[i-1];
    }
    d[n-1]=b[n-1];
    for(i=n-2;i>=0;i--)
    {
        d[i]=b[i]+d[i+1];
    }
    x=-2e17;
    for(i=0;i<n;i++)
    {
        l=c[i]+d[i];
        x=max(x,l);
    }
    cout<<x<<"\n";
    return 0;
}

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

#define DIV 1000000007
#define MAX 1000001

long long inv[MAX];

int mypow(int x,int n){
    long long ret=1,p;
    int p2=1;
    p=x;
    while(1){
        if(n&p2) ret*=p;
        p*=p;
        ret%=DIV;
        p%=DIV;
        p2*=2;
        if(p2>n) break;
    }
    return ret;
}

void init(){
    inv[0]=1;
    for(int i=1; i<MAX; i++){
        inv[i]=mypow(i,DIV-2)%DIV;
    }
}

void pf_init(vector<int> &pf,int maxsize){
    bool flag;
    pf.resize(0);
    for(int i=2; i*i<=maxsize; i++){
        flag=1;
        for(int j=0; j<pf.size(); j++){
            if(i%pf.at(j)==0){
                flag=0;
                break;
            }
        }
        if(flag){
            pf.push_back(i);
        }
    }
}

void pf_make(int n, vector<int> &ret, vector<int> &pf){
    if(ret.size()!=pf.size()) ret.resize(pf.size());
    for(int i=0; i<pf.size(); i++){
        ret.at(i)=0;
        while(1){
            if(n%pf.at(i)==0){
                n/=pf.at(i);
                ret.at(i)++;
            }else{
                break;
            }
        }
    }
    if(n>1){
        pf.push_back(n);
        ret.push_back(1);
    }
}

int main(){
    init();
    vector<int> pf;
    pf_init(pf,MAX);
    int N;
    cin >> N;
    int A[N];
    vector<vector<int>> pf_done_A(N,vector<int>(pf.size()));
    for(int i=0; i<N; i++){
        cin >> A[i];
        pf_make(A[i],pf_done_A.at(i),pf);
        
    }
    vector<int> LCM(pf.size(),0);
    for(int i=0; i<N; i++){
        for(int j=0; j<pf_done_A.at(i).size(); j++){
            LCM.at(j) = max(LCM.at(j),pf_done_A.at(i).at(j));
        }
    }
    long long L=1;
    for(int i=0; i<pf.size(); i++){
        L*=mypow(pf.at(i),LCM.at(i));
        L%=DIV;
    }
    long long ans=0;
    for(int i=0; i<N; i++){
        ans+=L*inv[A[i]];
        ans%=DIV;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 269440
import java.util.ArrayList;
import java.util.Scanner;
class Main{


	static char[][] map;

	static long[][] c;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0;i < n;i++){
			a[i] = sc.nextInt();
		}

		ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>();
		int ans = 0;
		
		for(int i = 0;i < n;i++){
			if(list.size() == 0){
				ArrayList<Integer> sub = new ArrayList<Integer>();
				sub.add(a[i]);
				list.add(sub);
			}else{
				int vail = -1;
				int candidate = -1;
				int candidatenum = -1;
				
				int left = 0;
				int right = list.size()-1;
//				System.out.println(i + " i ");
				
				int count = 0;
				while(right - left > 0){
//					System.out.println(right + " right ");
					
					int mid = (left + right)/2;
					if(list.get(mid).get(0) >= a[i]){
						left = mid+1;
					}else{
						right = mid;
					}
					count++;
//					if(count >= 4){
//						System.out.println("aa");
//						return;
//					}
				}
//				
//				
//				for(int j = 0;j < list.size();j++){
//					if(list.get(j).get(0) < a[i] &&  candidatenum <list.get(j).get(0) ){ 			//a[i] < a[j} でかつその中から最大の値をpeakをもつstackを見つける
// 						candidate = j;
//						candidatenum = list.get(j).get(0);
//						vail = 0;
//					}
//				}
				
				if( list.get(left).get(0) < a[i]){					//候補がいればそこにa[i]を追加
					list.get(left).set(0,a[i]);
				}else{							//候補がなければ新しくstackを追加
					ArrayList<Integer> sub = new ArrayList<Integer>();
					sub.add(a[i]);
					list.add(sub);
				}
			}
			
		}
			
		System.out.println(list.size());

	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   end- otherpair.end;
	}








}






Measured memory_bytes: 58560
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    a = list(map(int, input().split()))

    max_ = a[0]
    max_ind = 0
    min_ = a[0]
    min_ind = 0
    for i in range(len(a)):
        if max_ < a[i]:
            max_ = a[i]
            max_ind = i
        if min_ > a[i]:
            min_ = a[i]
            min_ind = i
    ans = []
    if abs(max_) >= abs(min_):
        all_sei = True
        for i in range(N):
            ans.append((max_ind+1, i+1))
    else:
        all_sei = False
        for i in range(N):
            ans.append((min_ind+1, i+1))
    
    if all_sei:
        for i in range(N-1):
            ans.append((i+1, i+2))
    else:
        for i in range(N-1, 0, -1):
            ans.append((i+1, i))
    
    print(len(ans))
    for i in range(len(ans)):
        s, t = ans[i]
        print(s, t)

    


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
L,R = map(int,input().split())
s = 2019
ans = 2019
if R <= L + 2019:
  for i in range(L,R):
    for j in range(i+1,R+1):
      a = i%2019
      b = j%2019
      s = min(s,a*b%2019)
    ans = min(ans,s)
else:
  ans = 0
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    string s;
    vector<int> p;
    void solve(){
        cin >> s;
        p.push_back(0);
        for(int i=1; i<(int)s.size(); ++i){
            if(s[i]!=s[i-1])p.push_back(i);
        }
        int ans = INF;
        for(auto && i : p){
            ans=min(ans,max((int)s.size()-i,i));
        }
        cout << ans <<"\n";
    }
};

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

    Problem p;
    p.solve();
    return 0;
}



Measured memory_bytes: 720
#include <iostream>

#include <utility> 
using namespace std;

int main()
{
  int N;
  cin>>N;
  bool flag=false;
  pair <int,int>m[101];
  if(N>=3 && N<=100)
  {
      for(int i=1;i<=N;i++)
      {
          cin>>m[i].first>>m[i].second;
      }
      int count=0;
     
      
          for(int i=1;i<=N;i++)
            {
                if(m[i].first>=1 && m[i].first<=6 && m[i].second>=1 && m[i].second<=6)
                {
                    if(m[i].first==m[i].second)
                    {
                        count++;
                        if(count==3)
                        flag=true;
                       
                    }
                    else
                    {
                        count=0;
                    }
                }
                
                
            }
            if(flag==true)
            cout<<"Yes";
            else
            cout<<"No";
            
            
        
      
      
  }
   return 0;
}

Measured memory_bytes: 3576
n = int(input())
m = list(map(int,input().split()))
m.sort()

ans = 0
for i in range(n):
    for j in range(i+1,n):
        l = j
        r = n
        while r-l>1:
            mid = (r+l)//2
            if m[mid] < m[i]+m[j] and m[i] < m[mid]+m[j] and m[j] < m[mid]+m[i]:
                l = mid
            else:
                r = mid
        ans += l-j

print(ans)

Measured memory_bytes: 74080
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main(){

    int n,k;
    cin >> n >> k;
    vector <int> l(n);
    REP(i,n)
    {
        cin >> l[i];
    }
    sort(l.begin(),l.end(), greater<int>());

    int res = 0;
    REP(i,k)
    {
        res += l[i];
    }
    cout << res << endl;
    return 0;    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1000000000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repM(i, n) for (int i = n; i > 0; i--)

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i,N)cin >> a[i];
    int x = 1;
    int ans = 0;
    rep(i,N){
        if(a[i]==x){
            x++;
        }else{
            ans ++;
        }
    }
    if(ans == N)cout << "-1" << endl;
    else cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

// j - i = Ai + Aj
// i + Ai = j - Aj

int main() {

    ll n; cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
    }

    map<ll, ll> mp;
    ll ans = 0;
    for (ll i = 0; i < n; ++i) {
        ll r = i - a[i]; //j - Ajを計算
        //rに等しいi + Aiの個数をansに足し算
        ans += mp[r];
        ll l = i + a[i];
        mp[l]++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 27460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const ll oo = 1e18;
const int MOD = 1000000007;
const int BASE = 26;
const int N = 200001;
#define pb push_back
#define mp make_pair
#define x first
#define y second

int n, q, a, b, dp[N];
ll seg[2][4 * N], lazy[2][4 * N], x[N];
void build(int n , int s , int e) {
	if (s == e) {
		seg[0][n] = dp[s] + s;
		seg[1][n] = dp[s] - s;
		return;
	}
	build(2 * n, s, (s + e) / 2);
	build(2 * n + 1, (s + e) / 2 + 1, e);
	seg[0][n] = min(seg[0][2 * n], seg[0][2 * n + 1]);
	seg[1][n] = min(seg[1][2 * n], seg[1][2 * n + 1]);
}
void push(int type , int n , int s , int e) {
	if (lazy[type][n]) {
		seg[type][n] += lazy[type][n];
		if (s != e) {
			lazy[type][2 * n] += lazy[type][n];
			lazy[type][2 * n + 1] += lazy[type][n];
		}
		lazy[type][n] = 0;
	}
}

ll get(int type , int n , int s , int e , int l, int r) {
	push(type, n, s, e);
	if (s > r || e < l)return oo;
	if (s >= l && e <= r)return seg[type][n];
	return min(get(type, 2 * n, s, (s + e) / 2, l, r), get(type, 2 * n + 1, (s + e) / 2 + 1, e, l, r));
}
int l , r , ut;
ll val;

void update(int type , int n , int s , int e) {
	push(type,n,s,e);
	if (s > r || e < l)return;
	if(s >= l && e <=r ){
		if(ut == 1){
			seg[type][n] = val;
		}else{
			lazy[type][n] += val;
		}
		push(type,n,s,e);
		return;
	}
	update(type,2 * n, s, (s + e) / 2);
	update(type,2 * n + 1, (s + e) / 2 + 1,e);
	seg[type][n] = min(seg[type][2 * n], seg[type][2 * n + 1]);
}
void go(int type , int _l , int _r , int _ut , ll _val){
	l = _l,r=_r,ut=_ut,val=_val;
	update(type,1,1,n);
}
int main() {
	scanf("%d%d%d%d", &n, &q, &a, &b);
	for (int i = 1; i <= q; ++i) {
		scanf("%lld", &x[i]);
	}
	for (int i = 1; i <= n ; ++i) {
		dp[i] = min(abs(x[1] - a) + abs(b - i), abs(x[1] - b) + abs(a - i));
	}
	build(1,1,n);
	for (int i = 2; i <= q ; ++i) {
		ll newVal = min(-x[i]+get(0,1,1,n,x[i],n),x[i]+get(1,1,1,n,1,x[i]));
		go(0,1,n,0,abs(x[i]-x[i-1]));
		go(1,1,n,0,abs(x[i]-x[i-1]));
		newVal = min(get(0,1,1,n,x[i],x[i])-x[i],newVal);
		go(0,x[i-1],x[i-1],1,newVal+x[i-1]);
		go(1,x[i-1],x[i-1],1,newVal-x[i-1]);
	}
	ll newVal = oo;
	for(int i = 1;i <= n ; ++i){
		newVal = min(newVal,get(1,1,1,n,i,i)+i);
	}
	printf("%lld\n", newVal);
	return 0;
}


Measured memory_bytes: 27648
import math

tax_8, tax_10 = map(int, input().split())

price_8_min = tax_8 / 0.08
price_8_max = (tax_8 + 0.99) / 0.08

price_10_min = tax_10 / 0.1
price_10_max = (tax_10 + 0.99) / 0.1

if max(price_8_min, price_10_min) <= min(price_8_max, price_10_max):
    print(math.ceil(max(price_8_min, price_10_min)))
else:
    print('-1')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int A, B, K;
  cin >> A >> B >> K;

  for (int i = A; i <= B; i++){
    if (A <= i && i <= A + K - 1 || B - K + 1 <= i && i <= B){
      cout << i << endl;
    }
  }
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;
	cin >> s >> t;
	int n =s.size();
	vector<int> cnt(26,-1);
	for(int i=0;i<n;i++){
		int x = s[i] -'a';
		if(cnt[x]==-1){
			cnt[x] = t[i] - 'a';
		}else{
			if(cnt[x] != t[i]-'a'){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cnt = vector<int>(26,-1);
	for(int i=0;i<n;i++){
		int x = t[i] -'a';
		if(cnt[x]==-1){
			cnt[x] = s[i] - 'a';
		}else{
			if(cnt[x] != s[i]-'a'){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 916
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(l[k-1])

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

/* 繰り返し自乗法. */
int modPow(long long a, long long n, long long p) {
	if (n == 0) return 1; // 0乗にも対応する場合.
	if (n == 1) return a % p;
	if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
	long long t = modPow(a, n / 2, p);
	return (t * t) % p;
}

signed main() {
	string S;
	int N;
	int cnt = 0;
	cin >> N >> S;
	rep (i, N-2) {
		if ((S[i] == 'A') && (S[i+1] == 'B') && (S[i+2] == 'C')) {
			cnt++;
		}
	}
	cout << cnt << endl;
}


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

using namespace std;

int main() {
	string s;
	cin >> s;
	long long int sz = s.size();
	long long int c = 1;
	long long int w, l;
	w = l = 0;
	for (long long int i = 1; i < sz; i++) {
		if (s[i] == 'g') {
			if (c > 0) {
				w++;
				c--;
			} else {
				c++;
			}
		} else {
			if (c > 0) {
				c--;
			} else {
				l++;
				c++;
			}
		}
	}
	cout << w-l << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

#define MAX_N 100000

int n,m;
vector<int> G[MAX_N];
bool visited[MAX_N];
vector<int> ans;

void dfs(int now){
    ans.emplace_back(now);
    visited[now] = true;
    for(auto v : G[now]){
        if(!visited[v]){
            dfs(v);
            return;
        }
    }
}

signed main(){
    cin >> n >> m;
    REP(i,m){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    dfs(0);
    reverse(ALL(ans));
    ans.pop_back();
    dfs(0);
    cout << ans.size() << endl;
    for(auto a : ans){
        cout << a + 1 << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 9720
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <tuple>
#include <vector>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

class DICE {
  public:
    int T, S, E, W, N, B;

    DICE(vector<int> tmp) {
        if(tmp.size() != 6)
            exit(1);
        T = tmp[0];
        S = tmp[1];
        E = tmp[2];
        W = tmp[3];
        N = tmp[4];
        B = tmp[5];
    }
    DICE(int T0, int S0, int E0, int W0, int N0, int B0) {
        tie(T, S, E, W, N, B) = make_tuple(T0, S0, E0, W0, N0, B0);
    }

    void turn(char dir) {
        if(dir == 'S')
            tie(T, B, S, N) = make_tuple(N, S, T, B);
        else if(dir == 'N')
            tie(T, B, N, S) = make_tuple(S, N, T, B);
        else if(dir == 'E')
            tie(T, B, E, W) = make_tuple(W, E, T, B);
        else if(dir == 'W')
            tie(T, B, W, E) = make_tuple(E, W, T, B);
        else if(dir == 'B')
            tie(T, B, W, E) = make_tuple(B, T, E, W);
        else if(dir == 'R')
            tie(N, E, S, W) = make_tuple(W, N, E, S);
        else
            cout << "err" << endl;
    }

    char revc(char r) {
        switch(r) {
        case 'T':
            return 'B';
        case 'B':
            return 'T';
        case 'N':
            return 'S';
        case 'E':
            return 'W';
        case 'W':
            return 'E';
        case 'S':
            return 'N';
        }
        return 'X';
    }

    int rig(int to, int fr) {
        if(T != to) {
            if(to == B) {
                turn('B');
            } else if(to == E) {
                turn('W');
            } else if(to == W) {
                turn('E');
            } else if(to == S) {
                turn('N');
            } else if(to == N) {
                turn('S');
            }
        }
        while(fr != S) {
            turn('R');
        }
        return E;
    }
};

int main() {
    vector<int> di(6);
    rep(i, 6) cin >> di[i];
    DICE d = di;
    int q, f, t;
    cin >> q;
    rep(i, q) {
        cin >> f >> t;
        cout << d.rig(f, t) << endl;
    }
}


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

int main(){
    bool ans = true;
    int a,b,c;
    cin >>a>>b>>c;
    cout << max(0, (b+ c- a)) << endl;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define mod 1000000007

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

int n,m,x ;
int mat[15][15] ;
int cost[15] ;
int dp[15][(1<<12)+5] ;
int temp[15] ;
int hf(int i,int mask)
{
    if(i == n+1)
    {
        memset(temp,0,sizeof(temp)) ;
        for(int k=1 ; k<=n ; k++)
        {
            if((1<<k)&mask)
            {
                for(int j=1 ; j<=m ; j++)
                {
                    temp[j] += mat[k][j] ;
                }
            }
        }
        for(int j=1 ; j<=m ; j++)
        {
            if(temp[j]<x)
                return 1e17 ;
        }
        return 0 ;
    }
    if(dp[i][mask]!=-1)
        return dp[i][mask] ;
    int a = hf(i+1,mask) ;
    int b = cost[i] + hf(i+1,(mask|(1<<i))) ;
    return dp[i][mask] = min(a,b) ;
}
void solve()
{
    cin >> n >> m >> x ;
    memset(dp,-1,sizeof(dp)) ;
    for(int i=1 ; i<=n ; i++)
    {
        for(int j=0 ; j<=m ; j++)
        {
            if(j == 0)
                cin >> cost[i] ;
            else
                cin >> mat[i][j] ;
        }
    }
    set<int> s ;
    int ans = hf(1,0) ;
    if(ans > 1e10)
        cout << "-1" ;
    else
        cout << ans ;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int tt = 1;
	//cin >> tt ;
	while(tt--)
	{
	     solve() ;
	}
}


Measured memory_bytes: 4092
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> vec(9, 0);
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (a < 400)
      ++vec[0];
    else if (a < 800)
      ++vec[1];
    else if (a < 1200)
      ++vec[2];
    else if (a < 1600)
      ++vec[3];
    else if (a < 2000)
      ++vec[4];
    else if (a < 2400)
      ++vec[5];
    else if (a < 2800)
      ++vec[6];
    else if (a < 3200)
      ++vec[7];
    else
      ++vec[8];
  }

  int cnt = 0;
  for (int i = 0; i < 8; ++i)
    cnt += vec[i] != 0;

  int vmin = cnt != 0 ? cnt : 1;
  int vmax = cnt + vec[8];
  cout << vmin << " " << vmax << endl;
}


Measured memory_bytes: 3532
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	int N, M;
	cin >> N >> M;

	vector<int> P( M ), Y( M );
	vector<vector<int>> py( N+1 );

	for( int i = 0; i < M; ++i ) {
		cin >> P[i] >> Y[i];
		py[P[i]].push_back( Y[i] );
	}

	for( int i = 1; i <= N; ++i ) {
		sort( py[i].begin(), py[i].end() );
	}

	for( int i = 0; i < M; ++i ) {
		auto& x = py[P[i]];

		int a = P[i];
		int b = lower_bound( x.begin(), x.end(), Y[i] ) - x.begin() + 1;
		cout << setw( 6 ) << setfill( '0' ) << a;
		cout << setw( 6 ) << setfill( '0' ) << b << '\n';
	}

	return 0;
}


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

#define int long long
typedef pair <int, int> pii;

const int N = 1e5 + 10;
int n, a, b;
pii ar[N];

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> ar[i].first >> ar[i].second;
	sort(ar, ar + n, [&] (pii p1, pii p2) { return p1.first + p1.second > p2.first + p2.second; });
	
	for (int i = 0; i < n; i++)
		if (i & 1)
			b += ar[i].second;
		else
			a += ar[i].first;
	cout << a - b;
}

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

int main() {
  int A, B; cin >> A >> B;
  string S; cin >> S;
  
  bool can = true;
  for (int i=0; i<S.size(); i++) {
    if (i==A) {
      if (S[i]!='-') can = false;
    } else {
      if (S[i] == '-') can = false;
    }
  }
  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
	int n;
	scanf("%d", &n);

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

	int L[n];
	L[0] = A[0];
	int length = 1;
	for (int i = 1; i < n; ++i) {
		if (L[length - 1] < A[i]) {
			L[length++] = A[i];
		} else {
// L[j] (j ??? 0 ?????? lengh-1) ????????§ A[i] ??\?????¨??????????????? j ????????? = A[i]
			int left = 0;
			int right = length - 1;
			int mid = (left + right) / 2;

			while (left < right) {
				if (L[mid] >= A[i]) {
					right = mid;
				} else {
					left = mid + 1;
				}
				mid = (left + right) / 2;
			}
			L[mid] = A[i];
		}
	}

	cout << length << endl;

	return 0;
}

Measured memory_bytes: 3912
from collections import deque
s = deque(input())
q = int(input())
query = [list(input().replace(' ','')) for _ in range(q)]

r = False
for i in range(q):
    if r:
        if len(query[i]) == 1:
            r = False
        elif query[i][1] == '1':
            s.append(query[i][2])
        else:
            s.appendleft(query[i][2])
    else:
        if len(query[i]) == 1:
            r = True
        elif query[i][1] == '1':
            s.appendleft(query[i][2])
        else:
            s.append(query[i][2])

if r:
    s = reversed(s)
    t = ''.join(s)
    print(t)
else:
    t = ''.join(s)
    print(t)

Measured memory_bytes: 137864
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)	   for(int i = 0; i < (n); ++i)
#define all(c)		   begin(c), end(c)
#define rall(c)		   rbegin(c), rend(c)
#define SZ(a)		   ((ll) a.size())

typedef long long		   ll;
typedef unsigned long long ull;


int main(){
	ll N;
	scanf("%lld",&N);
	ll x=1;
	ll ans=1;
	while(x*x<=N){
		ans = x * x;
		x = x+1;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

ans = [0, 0]
ans_abs = 10**200

A_sum = sum(A)
A_1 = 0
A_2 = A_sum

for i in range(N - 1):
    A_1 += A[i]
    A_2 -= A[i]
    ans_abs = min(ans_abs, abs(A_1 - A_2))

print(ans_abs)

Measured memory_bytes: 105352
#include <iostream>
#include <vector>

using namespace std;

class Split{
public:
    int left, right;
    int k;
    vector<int> w;

    Split(int k, vector<int> w){
        left = 0;
        right = 100000 * 10000;
        this->k = k;
        this->w = w;
    };

    bool ifCanLoad(int p){
        //与えられたpでトラックに積むことができるかチェックする．
        int track=1;
        int tmp=0;
        for(int i=0; i<w.size(); i++){
            if (p<w[i]) return false;
            if (p >= tmp + w[i]){
                tmp += w[i];
            }else{
                tmp = w[i];
                track++;
            }
            //cout << "track:" << track << endl;
            //cout << "w[i]:" << w[i] << endl;
            //cout << "tmp:" << tmp << endl;
            if (this->k < track)  {
                //cout << "track is " << track << endl;
                return false;
            }
        }
        return true;
    }

    int binarySearch(){
        int middle;
        while(right - left != 1){
            middle = (left + right) / 2;
            //cout << "[right:left]" << right << ":" << left << endl;
            //cout << "middle:" << middle << endl;
            //this_thread::sleep_for(std::chrono::seconds(2));

            if (ifCanLoad(middle)){
                //cout << "iam right" << endl;
                right=middle;
            }else{
                //cout << "iam left" << endl;
                left=middle;
            }
        }
        return right;
    }
};

int main(){
    int n, k;
    vector<int> w;
    //cout << "start" << endl;
    cin >> n;
    cin >> k;
    int tmp;
    for (int i=0; i<n; i++){
        cin >> tmp;
        w.push_back(tmp);
    }
    //cout << "finish" << endl;
    Split spl(k, w);
    cout << spl.binarySearch() << endl;
    return 0;
}


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

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

int main() {
  ll h, w, k, ans = 0;
  cin >> h >> w >> k;
  string s;
  char masu[h][w];
  rep(i, h) {
    cin >> s;
    rep(j, w) masu[i][j] = s[j];
  }

  ll cnt = 0;
  for (int i = 0; i < (1 << h); ++i) {
    for (int j = 0; j < (1 << w); ++j) {
      cnt = 0;
      rep(k, h) {
        rep(l, w) {
          if (masu[k][l] == '#' && ((i >> k) & 1) && ((j >> l) & 1)) cnt++;
        }
      }
      if (cnt == k) ans++;
    }
  }

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


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

typedef long long ll;
typedef pair<ll,ll> P;

const int INF = 1001001001;

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

int N,A,B,C,ans;
vector<int> v(8);

int dfs(int a,int b, int c,int x,int r){
  if (x==N){
    if (a==0 or b==0 or c==0)return INF;
  return abs(a-A)+abs(b-B)+abs(c-C)+r-30;
  }
  int r1,r2,r3,r4;
  r1=dfs(a,b,c,x+1,r);
  r2=dfs(a+v[x],b,c,x+1,r+10);
  r3=dfs(a,b+v[x],c,x+1,r+10);
  r4=dfs(a,b,c+v[x],x+1,r+10);
  r1=min(r1,r2);
  r1=min(r1,r3);
  r1=min(r1,r4);
  return r1;
}


int main() {
  cin>>N>>A>>B>>C;
  rep(i,N)cin>>v[i];
  int ans=dfs(0,0,0,0,0);
  cout<<ans;
}


Measured memory_bytes: 256
import sys
readlines = sys.stdin.readlines
write = sys.stdout.write
def solve():
    C = {}
    for line in readlines():
        a, b = line.strip().split(",")
        C[b] = C.get(b, 0) + 1
    write("%d\n" % C.get("A", 0))
    write("%d\n" % C.get("B", 0))
    write("%d\n" % C.get("AB", 0))
    write("%d\n" % C.get("O", 0))
solve()


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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		int z=sc.nextInt();
		System.out.println((x-z)/(y+z));
	}

}

Measured memory_bytes: 21844
import java.util.*

fun main(args: Array<String>) {
    val (h : Long,n : Long) = readLine()!!.split(" ").map { it.toLong() }
    val a = readLine()!!.split(" ").map { it.toLong() }
    var sum = a.reduce{ acc,it -> acc + it}
    if(sum >= h) println("Yes") else println("No")
}

Measured memory_bytes: 50420
x,n = map(int, input().split())
p = list(map(int, input().split()))

if x not in p:
    print(x)
    exit()

ans = -1
i = 1

while True:
    temp = x -i
    if temp not in p:
        ans = temp
        break
    temp = x + i
    if temp not in p:
        ans = temp
        break
    i += 1

print(ans)

Measured memory_bytes: 9180
input_s = gets.chomp.split("")
input_t = gets.chomp.split("")
s_length = input_s.length
t_length = input_t.length

margin = (s_length - t_length) + 1

nomatch_times = []	

margin.times do |index|
  nomatch = 0
  input_t.each do |t|
    if input_s[index] != t
      nomatch += 1
    end
    index += 1
  end
  nomatch_times << nomatch
end

puts nomatch_times.min

Measured memory_bytes: 14292
#include<stdio.h>
#include<math.h>
int main()
{
double a,b,H,M,ans,X;
  
  scanf("%lf %lf %lf %lf",&a,&b,&H,&M);
  
double pi=M_PI;
double rad=(30*H-5.5*M)*pi/180;
  
X=a*a+b*b-2*a*b*cos(rad);
  
  ans=sqrt(X);
  
  
  printf("%.10lf",ans);
  
return 0;
}

Measured memory_bytes: 2664
n = int(input())
x = list(map(int, input().split()))
x_sort = sorted(x)
med_minus = x_sort[n//2-1]
med_plus = x_sort[n//2]
for i in range(n):
    if x[i] <= med_minus:
        print(med_plus)
    elif x[i] >= med_plus:
        print(med_minus)


Measured memory_bytes: 93780
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	input := strings.Split(sc.Text(), " ")
	a, _ := strconv.Atoi(input[0])
	b, _ := strconv.Atoi(input[1])
	bitsA := toBitSet(a)
	bitsB := toBitSet(b)

	for i, v := range bitsA {
		if v == 1 && bitsB[i] == 1 {
			fmt.Printf("%d", 1)
		} else {
			fmt.Printf("%d", 0)
		}
	}
	fmt.Println("")

	for i, v := range bitsA {
		if v == 1 || bitsB[i] == 1 {
			fmt.Printf("%d", 1)
		} else {
			fmt.Printf("%d", 0)
		}
	}
	fmt.Println("")

	for i, v := range bitsA {
		if v == bitsB[i] {
			fmt.Printf("%d", 0)
		} else {
			fmt.Printf("%d", 1)
		}
	}
	fmt.Println("")

}

func toBitSet(d int) [32]int {
	result := [32]int{}
	for i := 0; i < 32; i++ {
		j := int(math.Pow(2, float64(31-i)))
		if d >= j {
			d = d - j
			result[i] = 1
		}
	}
	return result
}



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

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

	string s;
	cin >> s;

	char c = '!';
	int ans = 0;
	rep(i, n){
		if(s[i] != c) ans++;
		c = s[i];
	}

	cout << ans << endl;
}


Measured memory_bytes: 512
N = int(input())
C = list(input())
"""
白、赤の順で並んでいる箇所

べき論を求めるのがよさそう。
赤石が全て左半分に来るようにすればよい。
赤石の数を求める⇒赤石はi番目より左になくてはいけない、と定義する。
i番目より右にある赤石の数を求める
"""
RCnt = C.count("R")
#赤石はRCnt-1番目(0-indexed)より左になくては行けない
RCnt2 = C[:RCnt].count("R")
print(RCnt-RCnt2)

Measured memory_bytes: 77896
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int[] x = new int[5];
      
      for(int i = 0; i < 5; i++){
        x[i] = sc.nextInt();
      }
      
      // 判定
      int result = 0;
      for(int i = 0; i < 5; i++){
        if(x[i] == 0){
          result = i+1;
        }
      }
      
      // 出力
      System.out.println(result);
    }

}

Measured memory_bytes: 35848
#include<iostream>
#include<algorithm>
#include<vector>
#include<climits>
using namespace std;

static const int MAX=300;
static const long long INFTY = 9223372036854775807;

int n;
long long d[MAX][MAX];
long long d_[MAX][MAX];

void floyd(){
  for ( int k = 0; k< n;k++ ){
    for ( int i = 0; i< n; i++){
      if ( d[i][k]== INFTY)continue;
      for ( int j = 0;j < n; j++){
        if ( d[k][j] == INFTY )continue;
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

void floyd_(){
  for ( int k = 0; k< n;k++ ){
    for ( int i = 0; i< n; i++){
      if ( d_[i][k]== INFTY)continue;
      for ( int j = 0;j < n; j++){
        if ( d_[k][j] == INFTY )continue;
        d_[i][j] = min(d_[i][j], d_[i][k] + d_[k][j]);
      }
    }
  }
}


int main(){
  int e,u,v,c,l;
  cin >> n >> e >> l;
  
  for ( int i = 0; i < n; i++){
    for ( int j= 0; j < n; j++){
      d[i][j]=((i==j)? 0 : INFTY);
    }
  }
  
  for ( int i= 0; i < e; i++) {
    cin >> u >>v >> c;
    d[u-1][v-1] = c;
    d[v-1][u-1] = c;
  }
  
  floyd();
  
  for ( int i = 0; i < n; i++){
    for ( int j= 0; j < n; j++){
      if (d[i][j]<=l){
        d_[i][j]=1;
      }else{
        d_[i][j]=INFTY;
      }
    }
  }
  
  floyd_();

  int q,s,t;
  cin >> q;
  for(int i=0;i<q;i++){
    cin>>s>>t;
    if (d_[s-1][t-1]==INFTY){
      cout<<-1<<endl;
    }else{
      cout<<d_[s-1][t-1]-1<<endl;
    }
  }
  return 0;
  
} 

Measured memory_bytes: 1920
INF = float('inf')

def dfs(i, C):
    if i == N:
        if min(C[1:]) >= X:
            return C[0]
        else:
            return INF
    res = INF
    tmp = [0 for _ in range(M+1)]
    for bit in range(2):
        for j in range(M+1):
            tmp[j] = C[j] + A[i][j] * bit
        res = min(res, dfs(i+1, tmp))
    return res

N, M, X = map(int, input().split())
A = [[int(x) for x in input().split()] for _ in range(N)]

ans = dfs(0, [0 for _ in range(M+1)])
if ans == INF:
    ans = -1
print(ans)

Measured memory_bytes: 9244
n = int(input())
a = list(map(int, input().split()))

def printAns(array1,array2=[]):
    curr1 = array1[0]
    for i in range(1, len(array1)):
        print(curr1, array1[i])
        curr1 -= array1[i]

    if len(array2)>0:
        curr2 = array2[0]
        for i in range(1, len(array2)):
            print(curr2, array2[i])
            curr2 -= array2[i]
            
        print(curr1, curr2)
        curr1 -= curr2
        
    return curr1

plus = []
minus = []
zero = []
for it in a:
    if it == 0:
        zero.append(it)
    elif it > 0:
        plus.append(it)
    else:
        minus.append(it)

# solve problem
if len(plus) == 0:
    minus += zero
    minus.sort(key=lambda x:abs(x))
    max_value = abs(sum(minus[1:]))-abs(minus[0])
    print(max_value)
    printAns(minus)
elif len(minus) == 0:
    plus += zero
    plus.sort(key=lambda x:abs(x))  
    max_value = sum(plus[1:])-plus[0]
    print(max_value)
    printAns([plus[-1]], plus[:-1])
else:
    plus += zero
    array1 = [plus.pop()]
    array2 = []
    for i, it in enumerate(minus):
        if i==0:
            array2.append(it)
        else:
            array1.append(it)
    # plus
    array2+=plus
    
    max_value = sum(map(abs, a))
    print(max_value)
    tmp = printAns(array1, array2)

Measured memory_bytes: 14008
import sys
input=sys.stdin.readline
from bisect import bisect_left, bisect_right

Q=int(input())
llr=[]
maxr=1
for i in range(Q):
    l,r=map(int,input().split())
    if r>maxr:
        maxr=r
    llr.append([l,r])
def isprime(n):
    if n==1:
        return 0
    m=int(n**(1/2))
    for i in range(2,m+1):
        if n%i==0:
            return 0
            break
    return 1
l2017=[]
for i in range(1,maxr+1,2):
    if isprime(i) and isprime((i+1)/2):
        l2017.append(i)
for i in range(Q):
    il=bisect_left(l2017,llr[i][0])
    ir=bisect_right(l2017,llr[i][1])
    print(ir-il)

Measured memory_bytes: 21620
#include<stdio.h>

int main()
{
    int n, i, j, tmp, min,k,l,f=1;
    int a[36],b[36],s[36],t[36];
    char ch;
    scanf("%d",&n);
    for(i = 0; i < n; i++)
    {
        scanf(" %c%d ",&ch,&a[i]);
        s[i] = a[i];
        switch(ch){
            case 'S': b[i] = 1;t[i] = 1;break;
            case 'H': b[i] = 2;t[i] = 2;break;
            case 'D': b[i] = 3;t[i] = 3;break;
            case 'C': b[i] = 4;t[i] = 4;break;
            default : b[i] = 0;t[i] = 0;
        }
    }
    //bubble
    for(i = 0; i < n; i++)
    {
        for(j = n-1; j > i; j--)
        {
            if(a[j] < a[j-1])
            {
                tmp = a[j];
                a[j] = a[j-1];
                a[j-1] = tmp;
                tmp = b[j];
                b[j] = b[j-1];
                b[j-1] = tmp;
            }
        }
    }
    for(i = 0; i < n; i++)
    {
        switch(b[i]){
            case 1: printf("S");break;
            case 2: printf("H");break;
            case 3: printf("D");break;
            case 4: printf("C");break;
            default: printf("N");
        }
        printf("%d",a[i]);
        if(i != n-1) printf(" ");
        else printf("\n");
    }
    printf("Stable\n");
    //selsection
    for(i = 0; i < n; i++)
    {
        min = i;
        for(j = i; j < n; j++)
        {
            if(s[j] < s[min])
            {
                min = j;
            }
        }
        tmp = s[i];
        s[i] = s[min];
        s[min] = tmp;
        tmp = t[i];
        t[i] = t[min];
        t[min] = tmp;
    }
    for(i = 0; i < n; i++)
    {
        switch(t[i]){
            case 1: printf("S");break;
            case 2: printf("H");break;
            case 3: printf("D");break;
            case 4: printf("C");break;
            default : printf("N");
        }
        printf("%d",s[i]);
        if(i != n-1) printf(" ");
        else printf("\n");
    }
    for(i = 0; i < n; i++)
    {
        /*for(j = i+1; j < n; j++)
        {
            for(k = 0; k < n; k++)
            {
                for(l = k+1; l < n; l++)
                {
                    if(s[i] == s[j] && s[i] == a[l] && s[j] == a[k])
                    {
                        f = 0;
                    }
                }
            }
        }*/
        if(b[i] != t[i]) f = 0;
    }
    if(f) printf("Stable\n");
    else printf("Not stable\n");
    return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,i,x;
    x=0;
    string S;
    cin >> N >> S;
    for(i=0;i<N/2;i++){
        if(S[i]==S[i+(N/2)]){
            x++;
        }
    }
    if(N%2==1){
        cout << "No" << endl;
    }
    if(x==N/2 && N%2!=1)cout << "Yes" << endl;
    else if(x!=N/2 && N%2!=1){
        cout << "No" << endl;}
    return 0;
}


Measured memory_bytes: 256
#Xの目が出た時、1/2のceil(log2(K/X))乗の確率でうまくいく
import math
N,K=map(int,input().split())
print(sum([
    (1/2)**max(0,math.ceil(math.log2(K)-math.log2(x)))
    for x in range(1,N+1)])/N)

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

int main() {
  int n, k;
  cin >> n >> k;
  
  int ans = 1;
  for(int i = 0; i < n; i++){
    if(ans < k) ans *= 2;
    else ans += k;
  }
  
  cout << ans << endl;
}

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

using namespace std;
using ll = long long;
 
int main() {
cout<<fixed<<setprecision(10);

  ll A,B,K;
  cin >>A>>B>>K;
  ll aoki=B;
  if (A<K) aoki=max(0LL,B-K+A);
  cout << max(0LL,A-K)<<' '<<aoki;

	
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include<ios>
using namespace std;
using ll = long long;

int main(){
     ios::sync_with_stdio(false);
     ll N, K;
     ll modn = 1000000007;
     cin >> N >> K;
     ll ans=0;
     for(ll i = K; i <= N+1; ++i){
         ans +=  N*i - i*(i-1) +1;
     }
     ans %= modn;
    cout << ans%modn << "\n";
}

Measured memory_bytes: 3644
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int Type = sc.nextInt();
		int Comd = sc.nextInt();
		double sum = 0;
		int cnt =0;
		double[] product = new double[Type];
		for(int i = 0; i < Type; i++) {
			product[i] = sc.nextInt();
		}
		for(int t = 0; t< Type ;t++) {
			sum += product[t];
		}
		for(int num = 0; num < product.length;num++) {
			if(product[num] >= sum / (4*Comd)) {
				cnt++;
			}
		}
		if(cnt >= Comd) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}


	}
}


Measured memory_bytes: 35884
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    int n;
    cin >> n;

    vector<P> red(n), blue(n);
    rep(i, n){
        int a, b;
        cin >> a >> b;
        red[i] = make_pair(a, b);
    }
    rep(i, n){
        int a, b;
        cin >> a >> b;
        blue[i] = make_pair(a, b);
    }

    sort(blue.begin(), blue.end());

    vector<P> edge;
    int ans = 0;
    rep(i, n){
        int rr = -1;
        for(int j = 0; j < (int)red.size(); j++){
            if(blue[i].first > red[j].first && blue[i].second > red[j].second){
                if(rr == -1 || red[rr].second < red[j].second){
                    rr = j;
                }
            }
        }
        if(rr != -1){
            red.erase(red.begin()+rr);
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384