akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n; cin >> n;
  int a[n],b[n],c[n];
  REP(i,n) { cin >> a[i]; a[i]--; }
  REP(i,n) cin >> b[i];
  REP(i,n-1) cin >> c[i];

  int ans = 0;
  REP(i,n) ans += b[a[i]];
  REP(i,n-1) {
    if (a[i] + 1 == a[i+1]) ans += c[a[i]];
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 256
N, M = list(map(int, input().split()))
A = [0]*N
K = [0]*N
for i in range(N):
    tmp = list(map(int, input().split()))
    K[i] = tmp[0]
    A[i] = tmp[1:]

if N == 1:
    print(len(A[0]))
else:
    ans = 0
    idx = K.index(max(K))
    max_len = A.pop(idx)
    for j in max_len:
        flg = 0
        for vals in A:
            if j in vals:
                flg += 1
        else:
            if flg == len(A):
                ans += 1
    else:
        print(ans)


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

int main(){
	int n,m,x;
	cin >> n >> m >> x;
	int a[n+1],k;
	for(int i=0;i<=n;++i)a[i]=0;
	
	for(int i=0;i<m;++i){
		cin >> k;
		a[k]++;
	}
	
	int ans;
	k=0;
	for(int i=0;i<x;++i){
		if(a[i]==1)++k;
	}
	ans=k;
	k=0;
	for(int i=x;i<=n;++i){
		if(a[i]==1)++k;
	}
	
	if(k<ans)ans=k;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(dead_code,unused_variables,unused_imports)]
use proconio::{fastout, input};
use proconio::marker::Chars;
use std::cmp::max;

#[fastout]
fn main() {
    input!(n:usize,mut x:[usize;n]);

    let mut p = x.clone();
    p.sort();

    let r = p[n/2];
    let l = p[n/2 - 1];
    // println!("{} {}",l,r);
    let mut ans = vec![0;n];
    for i in 0..n{
        if x[i] <= l{
            ans[i] = r;
        }else{
            ans[i] = l;
        }
    }

    for e in ans{
        println!("{}",e);
    }

}//https://github.com/rust-lang-ja/ac-library-rs



Measured memory_bytes: 9028
//To debug :  g++ -g heal.cpp -o code
//to flush output : fflush(stdout) or cout.flush()
//cout<<setprecision(p)<<fixed<<var
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 INT_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 INT_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<int>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

long long powt[64];
long long sumpow2(long long num,long long *arr)
{
	long long i,j;
	if(powt[0] == 0)
	{
		powt[0]=1;
		for(i=1;i<64;++i)
			powt[i]=powt[i-1]*2;
	}
	i=0;
	j=0;
	while(num>0)
	{
		if(powt[i]==num)
		{
			arr[j]=i;
			num-=powt[i];
			++j;
		}
		else if(powt[i]>num)
		{
			arr[j]=i-1;
			num-=powt[i-1];
			i=0;
			++j;
		}
		else
			++i;
	
	}

	return j;	
}


long long modinv(long long num,long long prime)
{
	long long var = prime-2,j,i;
	
	ll arr[100];

	j=sumpow2(var,arr);

	long long ans[100];

	ans[0]=num%prime;

	for(i=1;i<=arr[0];++i)
	{
		ans[i] = (ans[i-1]*ans[i-1])%prime;
	}

	for(i=1;i<j;++i)
	{
		ans[arr[0]+i] = (ans[arr[0]+i-1]*ans[arr[i]])%prime;
	}

	return ans[arr[0]+j-1];
}


int main()
{

	ll n,i,an,dn;
	cin>>n;
	ll a[n+1];
	ll num[n+1];
	ll den[n+1];

	rep(i,1,n+1)
		cin>>a[i];

	num[1] = 1;
	den[1] = 1;

	rep(i,2,n)
	{
		num[i] = ((i*num[i-1])%mod + den[i-1])%mod;
		den[i] = (den[i-1]*i)%mod;
	}

	an = 0;
	dn = 1;


	rep(i,1,n)
	{
		an = ((an*den[i])%mod) + (((((a[i+1]-a[i])%mod)*num[i])%mod)*dn)%mod; 
		dn = (den[i]*dn)%mod;
	}

	rep(i,1,n)
	{
		an = (an*i)%mod;
	}


	cout<<(an*modinv(dn,mod))%mod<<"\n";








	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main() {
    long long N,A,B;
    cin >> N >> A >> B;
    long long sum = 0;
    long long X1,X2;
    cin >> X1;
    rep(i,N-1){
        cin >> X2;
        sum += min((X2-X1) * A,B);
        X1 = X2;
    } 
    cout << sum;

    return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int A;
    scanf("%d",&A);
    
    int B;
    scanf("%d",&B);
    
    if(A==1){
        if(B==2){
            printf("3");
        }
        else if(B==3){
            printf("2");
        }
    }
    if(A==2){
        if(B==1){
            printf("3");
        }
        else if(B==3){
            printf("1");
        }
    }
    if(A==3){
        if(B==1){
            printf("2");
        }
        else if(B==2){
            printf("1");
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
S = list(input())

x = len(S) #Sの長さ
y = x-1 #切れる場所の数
#print ('y', y)
S = [int(s) for s in S] #Sを文字列のリストから、数値のリストに変換

#print (S)
ans = 0
for i in range(0, x): #i番目の数に着目
    #print ('i', i)
    j=1
    a =S[i] #i番目の数をメモ
    while y-j >= i:
        #print('j', j)
        ans += a * (10 ** (j-1)) * (2**(y-j))
        j += 1
    if y-j < i:
        ans += a * (10 ** (j-1)) * (2 ** i)

print (ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int n, d, c=0;
  cin >> n >> d;
  int x[n][d];
  for(int i = 0;i<n;i++)
  {
      for(int j = 0;j<d;j++)
      {
          cin >> x[i][j];
      }
  }
  for(int i = 0;i<n;i++)
  {

      for(int j = i+1;j<n;j++)
      {
          int s = 0;
          for(int k = 0;k<d;k++)
          {
              s += (x[i][k]-x[j][k]) * (x[i][k]-x[j][k]);
          }
          for(int l = 0;l <= s;l++)
      {
          if(l * l == s)
          {
              c++;
              break;
          }
      }
      }
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int main(void){
    ll n;
    cin>>n;
    if(n==1)cout<<1<<endl;
    else{
        ll cnt=0,ans=1;
        while(n!=1){
            n/=2;
            cnt++;
            ans+=pow(2,cnt);
        }
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    h,w=map(int, input().split())
    t=[["."]*(w+2)]+[["."]+list(input())+["."] for _ in range(h)]+[["."]*(w+2)]
    for i in range(1,h+1):
        for j in range(1,w+1):
            if t[i][j]==".":continue
            if t[i-1][j]=="." and t[i+1][j]=="." and t[i][j-1]=="." and t[i][j+1]==".":
                print("No")
                exit()
    print("Yes")

main()

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    string s;
    cin >> s;
    if(s=="Sunny") cout<<"Cloudy"<<endl;
    else if(s=="Cloudy")cout<<"Rainy"<<endl;
    else if(s=="Rainy") cout<<"Sunny"<<endl;
    return 0;
}

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

using namespace std;

int main(void){
	string state[10];
	int n;
	
	state[0] = "0111111";
	state[1] = "0000110";
	state[2] = "1011011";
	state[3] = "1001111";
	state[4] = "1100110";
	state[5] = "1101101";
	state[6] = "1111101";
	state[7] = "0100111";
	state[8] = "1111111";
	state[9] = "1101111";
	
	while(cin >> n && n != -1){
		string cur = "0000000";
		string out = "0000000";
		int t;
		for(int i=0;i<n;i++){
			cin >> t;
			for(int i=0;i<7;i++){
				cur[i] == state[t][i]?out[i]='0':out[i]='1';
			}
			cout << out <<endl;
			cur = state[t];
		}
	}
}

Measured memory_bytes: 0
n_=10**5+3
mod=10**9+7
fac=[1]*(n_+1)
for i in range(1,n_+1):
    fac[i]=fac[i-1]*i%mod
inv =[1]*(n_+1)
inv[n_]=pow(fac[n_],mod-2,mod)
for i in range(n_-1,0,-1):
    inv[i]=inv[i+1]*(i+1)%mod
def nCr(n,r):
    if n<=0 or r<0 or r>n:
        return 0
    return fac[n]*inv[r]%mod*inv[n-r]%mod

n,k=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
ans=0
for i in range(n-k+1):
    ans=(ans+(A[n-i-1]-A[i])*nCr(n-i-1,k-1))%mod
print(ans)

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

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


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();

    sc.close();

    int[] primeNumber  = new int[1001];

    long mod = 1000000000 + 7;

    for (int i = 2; i <= N; i++) {
      
      int j = i;

      while (j > 1) {
        for (int k = 2; k <= j; k++) {
          if (j % k == 0) {
            primeNumber[k]++;
            j = j / k;
            break;
          }
        }
      }

    }

    long ans = 1;

    for (int i = 2; i <primeNumber.length; i++) {
      ans =  ans * (primeNumber[i]+1) % mod;
    }

    System.out.println(ans);

  }

}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
using namespace std;

int main()
{
    int64_t n;
    cin>>n;
    vector<int64_t>w(n);
    int64_t sum=0;
    REP(i,n){cin>>w.at(i);sum+=w.at(i);}
    int64_t mini=sum;
    int64_t s1=0;
    REP(i,n)
    {
        s1+=w.at(i);
        mini=min(mini,abs(s1-(sum-s1)));
    }
    cout<<mini<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

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

Measured memory_bytes: 256
use std::env;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let N = read::<i32>();
    println!("{}", N/3);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn = 1010;
int n,sz;
LL x[maxn],y[maxn],bs[35],ans[35];
inline int ABS(int x) {if(x<0) x=-x;    return x;}
void work(){
    cin >> n;
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
    int sum = (x[0] ^ y[0]) & 1;
    for (int i = 0; i < n; i++) if ( ((x[i] ^ y[i]) & 1 ) ^ sum) {cout<<"-1"<<endl;return;}

    sz = 0;
    for (int i=30;i>-1;i--) ans[sz++] = bs[i];
    if (sum == 0) ans[sz++] = 1;

    cout<<sz<<endl;
    for (int i=0;i<sz;i++) cout<<ans[i]<<" ";cout<<endl;

    for (int i = 0; i < n; i++) {
        int u = x[i], v = y[i];
        for (int j = 0 ; j < sz ; j++) {
            if (ABS(u) > ABS(v)){
                if (u < 0) cout<<"L", u += ans[j];
                else cout<<"R", u -= ans[j];
            }else{
                if (v < 0) cout<<"D", v += ans[j];
                else cout<<"U", v -= ans[j];
            }
        }
        cout<<endl;
    }
}
int main(){
    bs[0] = 1;
    for (int i=1;i<32;i++) bs[i] = bs[i-1] << 1;
    work();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 200001
#define MOD 1000000007

typedef long long int lli;


// 優先度付きキュー Priority Queue

typedef struct
{
  long long int pri;
  long long int val;
} que;

que pq[MAX];
int pq_size = 0; // 最大要素

void PQadd(long long int pri, long long int val)
{
  int last = ++pq_size;
  que new;
  new.pri = pri;
  new.val = val;
  pq[pq_size] = new;

  while (last > 1 && pq[last].pri < pq[last / 2].pri)
    {
      que temp;
      temp = pq[last];
      pq[last] = pq[last / 2];
      pq[last / 2] = temp;
      last /= 2;
    }
  return;
}

que PQget(void)
{
  que root = pq[1];
  pq[1] = pq[pq_size--];

  int last = 1, bigger_child;
  while (last * 2 <= pq_size)
    {
      if (last * 2 == pq_size)
	bigger_child = last * 2;
      else
	bigger_child = pq[last * 2].pri < pq[last * 2 + 1].pri ? last * 2 : last * 2 + 1;

      if (pq[last].pri > pq[bigger_child].pri)
	{
	  que temp;
	  temp = pq[last];
	  pq[last] = pq[bigger_child];
	  pq[bigger_child] = temp;
	  last = bigger_child;
	}
      else
	break;
    }
  return root;
}


int main(void) {
  int n;
  int p[MAX];
  scanf("%d", &n);

  rep(i, 0, n) scanf("%d", &p[i]);

  int cnt = 1;
  rep(i, 1, n) {
    PQadd(p[i - 1], 0);
    if (pq[1].pri > p[i]) cnt++;
  }
  printf("%d\n", cnt);
  return 0;
}


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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

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


string s[3];

int main(){
	char ans[3] = {'A', 'B', 'C'};
	for(int i = 0; i < 3; i++){
		cin >> s[i];
		s[i].push_back(ans[i]);
	}
	
	int a = -1, b = -1, c = -1;
	char d = 'a';
	while(1){
		if(d == 'a'){ a++; d = s[0][a];}
		if(d == 'b'){ b++; d = s[1][b];}
		if(d == 'c'){ c++; d = s[2][c];}
		if(d == 'A' || d == 'B' || d == 'C') break;
	}
	cout << d << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        ll t, x, y;
        t = x = y = 0;
        ll nt, nx, ny;
        rep(i, 0, N) {
                cin >> nt >> nx >> ny;
                ll tdiff = nt - t;
                ll diff = abs(nx - x) + abs(ny - y);
                if (diff > tdiff or odd(diff - tdiff)) {
                        cout << "No" << endl;
                        return 0;
                }
                t = nt;
                x = nx;
                y = ny;
        }
        cout << "Yes" << endl;
}

Measured memory_bytes: 3532
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
h, w = [int(i) for i in input().split()]
if h == 1 or w == 1:
    print(1)
else:
    n = h*w/2
    print(Decimal(n).quantize(Decimal('0'), rounding=ROUND_HALF_UP))


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

int main(void){
	int N,K;
	cin >> N >> K;
	double ans = 0;
	for(int i=1;i<=N;i++){
		double cnt = 1;
		int score = i;
		while(score<K){
			cnt*=0.5;
			score*=2;
		}
		ans += cnt;
	}
	ans /= N;
	cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()
 
using namespace std;		
	
vector <ll> dp[60][40][30][300];	
	
int T;
ll n, A, B, C, D;	
	
int main() {
	scanf ("%d", &T);
	while (T--) {
		scanf ("%lld%lld%lld%lld%lld", &n, &A, &B, &C, &D);
		ll answer = 1e18;
		rep(i, 0, 59)
			rep(j, 0, 39)
				rep(g, 0, 29)
					rep(f, 0, 299)
						dp[i][j][g][f].clear();
		dp[0][0][0][0].pb(n);
		rep(i, 0, 59) {
			rep(j, 0, 38) {
				rep(g, 0, 29) {
					rep(f, 0, 200) {
						if (dp[i][j][g][f].empty()) continue;
						ll cost = i * A + j * B + g * C + f * D;
						if (cost > answer) break;
						for (auto it : dp[i][j][g][f]) {
							if (it <= 1e18 / D) {
								answer = min(answer, cost + it * D);
							}
							if (it <= 1) continue;
							int mod2 = it % 2;
							int L = mod2;
							int R = (2 - L) % 2;
							
							if (ss(dp[i + 1][j][g][f + L]) <= 30)
								dp[i + 1][j][g][f + L].pb((it - L) / 2);
								
							if (R != 0 && ss(dp[i + 1][j][g][f + R]) <= 30)
								dp[i + 1][j][g][f + R].pb((it + R) / 2);
							
							int mod3 = it % 3;
							L = mod3;
							R = (3 - mod3) % 3;
							
							if (ss(dp[i][j + 1][g][f + L]) <= 30)
								dp[i][j + 1][g][f + L].pb((it - L) / 3);
								
							if (R != 0 && ss(dp[i][j + 1][g][f + R]) <= 30)
								dp[i][j + 1][g][f + R].pb((it + R) / 3);
							
							int mod5 = it % 5;
							L = mod5;
							R = (5 - mod5) % 5;
							
							if (ss(dp[i][j][g + 1][f + L]) <= 30)
								dp[i][j][g + 1][f + L].pb((it - L) / 5);
								
							if (R != 0 && ss(dp[i][j][g + 1][f + R]) <= 30)
								dp[i][j][g + 1][f + R].pb((it + R) / 5);
						}
					}
				}
			}
		}
		printf ("%lld\n", answer);
	}
							
								
		
	return 0;
}	


Measured memory_bytes: 534616
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  ll A,	B, C, K;
  cin>>A>>B>>C>>K;
  ll ans = 0;
  if(K % 2L == 0LL) {
    ans	= A - B;
  } else {
    ans	= B - A;
  }
  cout << ans << endl;
  return 0;
}



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

int main(){
  int N;cin >> N;
  int M; cin >> M;
  vector<long long> h(M + 1), dp(N + 1);
  for(int i = 1; i <= M; i++){
    cin >> h[i];
  }
  dp[0] = 1; 
  vector<bool> xrow(N + 1, true);
  for(int i = 1; i <= M; i++){
    xrow[h[i]] = false;
  }
  for(int i = 1; i <= N; i++){
    if(!xrow[i]) dp[i] = 0;
    else{
      if(i == 1) dp[i] = 1;
      else{
        dp[i] = (dp[i - 1] + dp[i - 2])%mod;
      }
    }
  }
  cout << dp[N] << endl;
}
      

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double
 
#define x first
#define y second
 
int block=700;
bool cmp(pair<pair<int,int>,int> p, pair<pair<int,int>,int> q) {
    if (p.first.first / block != q.first.first / block)
        return p < q;
    return (p.first.first / block & 1) ? 
        (p.first.second < q.first.second) : (p.first.second > q.first.second);
}
 
int clrs[1000007];
int ans[1000006];
int32_t main() 
{
    IOS
    int n,qq;
    cin>>n>>qq;
    int arr[n+2]={0};
    memset(arr,0,sizeof(arr));
    for(int i=1;i<=n;i++)
        cin>>arr[i];
    vector<pair<pair<int,int>,int>>v;
    for(int i=0;i<qq;i++)
    {
        int a,b;
        cin>>a>>b;
        v.push_back({{a,b},i});
    }
    sort(v.begin(),v.end(),cmp);
    int cur_l = 1;
    int cur_r = 0;
    int sum=0;
    for(auto q:v)
    {
        while (cur_l > q.x.x) 
        {
            cur_l--;
            clrs[arr[cur_l]]++;
            if(clrs[arr[cur_l]]==1)
                sum++;
        }
        while (cur_r < q.x.y) 
        {
            cur_r++;
            clrs[arr[cur_r]]++;
            if(clrs[arr[cur_r]]==1)
                sum++;
        }
        while (cur_l < q.x.x) 
        {
            clrs[arr[cur_l]]--;
            if(clrs[arr[cur_l]]==0)
                sum--;
            cur_l++;
        }
        while (cur_r > q.x.y) 
        {
            clrs[arr[cur_r]]--;
            if(clrs[arr[cur_r]]==0)
                sum--;
            cur_r--;
        }
        ans[q.y] = sum;
    }
    for(int i=0;i<qq;i++)
        cout<<ans[i]<<endl;
}   

Measured memory_bytes: 27384
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
ll cal(ll x, ll y, ll z)
{
    return x * x + y * y + z * z + x * y + y * z + x * z;
}
ll n;
map<ll, int> cnt;

void solve()
{
    cin >> n;
    for (ll x = 1; x <= 100; ++x)
    {
        for (ll y = 1; y <= 100; ++y)
            for (ll z = 1; z <= 100; ++z)
                cnt[cal(x, y, z)]++;
    }
    for (int i = 1; i <= n;++i)
        cout << cnt[i] << endl;
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 5936
import           Control.Monad
import           Data.List
import           Data.Maybe
import qualified Data.ByteString.Char8         as C8

getInts :: IO [Int]
getInts = fmap (map (fst . fromJust . C8.readInt) . C8.words) C8.getLine

main :: IO ()
main = do
    [n, m] <- getInts
    cs     <- replicateM n $ getInts
    print . purchase m $ sortOn fst . map (\[a, b] -> (a, b)) $ cs

purchase :: Int -> [(Int, Int)] -> Int
purchase m ((a, b) : cs) | m <= b    = m * a
                         | otherwise = a * b + purchase (m - b) cs
purchase _ [] = 0


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

using namespace std;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end())); }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    cums(T& v){ T r; r.push_back(v[0]); for(int i=1; i<v.size(); i++) r.push_back(r[i-1] + v[i]); return r; }
TEMP_T void maxe(T& v, T m){ v = max(v, m); }
TEMP_T void mine(T& v, T m){ v = min(v, m); }

static inline int in(){ int x; scanf("%d", &x); return x; }

struct Solver {
  int pattern[64];
  int n;
  Solver(int n) : n(n) {
    memset(pattern, 0, sizeof(pattern));
  }
  void solve(int it=0, int c=0, int s=0){
    if (it == 10){
      if (c == n){
        pattern[s]++;
      }
      return;
    }
    solve(it + 1, c + 1, s + it);
    solve(it + 1, c, s);
  }
};

int main()
{
  int n, s;
  while (n = in(), s = in(), !(n == 0 && s == 0)){
    Solver solver(n);
    solver.solve();
    if (s < 64){
      printf("%d\n", solver.pattern[s]);
    }
    else puts("0");
  }

  return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    long n=3,x_max =7;
    cin >> n >> x_max;
    vector<long> A;
    for (long i=0;i<n;i++){
        long tmp;
        scanf("%ld",&tmp);
        A.push_back(tmp);
    }

    if(x_max == 0){
        long sum=0;
        for(int i=0;i<n;i++){
            sum += A.at(i);
        }
        printf("%ld\n",sum);
        return 0;
    }

    int C[40]={};
    for(int l=0;l<40;l++){
        for(long i=0;i<n;i++){
            if(A.at(i) & (long)1<<l){
                C[l]++;
            }
        }
    }

    long sum[40] ={};

    for(long i=0;i<40;i++){
        if(!(x_max+1 & ((long)1<<i))){
            continue;
        }else{
            sum[i] += ((long)1<<i) * C[i];
        }

        for(long j=0;j<i;j++){
            if(C[j] > n - C[j]){
                sum[i] += ((long)1<<j) * C[j];
            }else{
                sum[i] += ((long)1<<j) * (n-C[j]);
            }
        }

        for(long long j=i+1;j<40;j++){
            if((x_max+1 & ((long)1<<j))){
                sum[i] += ((long)1<<j) * (n-C[j]);
            }else{
                sum[i] += ((long)1<<j) * C[j];
            }
        }
    }
    printf("%ld\n",*max_element(sum,sum+40));
}


Measured memory_bytes: 1400
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

const int M = 2000;

vector<bool> bad_ab(16001, false);
vector<bool> bad_ac(16001, false);
vector<bool> bad_bc(16001, false);

bool match(char c1, char c2)
{
	return (c1 == '?' || c2 == '?' || c1 == c2);
}

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

	string a;
	string b;
	string c;

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

	int A = a.size();
	int B = b.size();
	int C = c.size();

	for (int i = 0; i < A; i++)
	{
		for (int j = 0; j < B; j++)
		{
			if (!match(a[i], b[j])) bad_ab[i - j + 8000] = true;
		}
	}

	for (int i = 0; i < A; i++)
	{
		for (int j = 0; j < C; j++)
		{
			if (!match(a[i], c[j])) bad_ac[i - j + 8000] = true;
		}
	}

	for (int i = 0; i < B; i++)
	{
		for (int j = 0; j < C; j++)
		{
			if (!match(b[i], c[j])) bad_bc[i - j + 8000] = true;
		}
	}

	int result = 3 * M;
	for (int i = -2 * M; i <= 2 * M; i++)
	{
		for (int j = -2 * M; j <= 2 * M; j++)
		{
			if (!bad_ab[i + 8000] && !bad_ac[j + 8000] && !bad_bc[j - i + 8000])
			{
				int L = min(0, min(i, j));
				int R = max(A, max(B + i, C + j));
				result = min(result, R - L);
			}
		}
	}

	cout << result;

	return 0;
}

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


int main() {
    int n;
    int nn;
    int64_t m = 0;

    cin >> n;
  	nn = 3*n;
    vector<int> a(nn);

    for(int i = 0; i < nn; i++){
        cin >> a.at(i);
    }

     sort(a.begin(), a.end(), greater<int>());  // a[0:N] を大きい順にソート

    for(int i = 0; i <= n*2; i++){
        if(i%2 == 1) m += a.at(i);
    }
    cout << m << endl;

}



Measured memory_bytes: 1408
#include <stdio.h>
#include <math.h>
int main(void) {
    int n, d, x[100][100], i, j, k, s=0;
    double a, b, c;
    
    scanf("%d%d",&n,&d);
    for(i=0;i<n;i++){
        for(j=0;j<d;j++) scanf("%d",&x[i][j]);
    }
    
    for(i=0;i<n;i++){
        for(k=i+1;k<n;k++){
            b=0;
            for(j=0;j<d;j++){
                a=pow(x[i][j]-x[k][j],2);
                b+=a;
            }
            c=sqrt(b);
            if(ceil(c)==floor(c)) s++;
        }
    }
    printf("%d\n",s);
    return 0;
}

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

int main() {
    int N, K;
    while (cin >> N >> K && (N || K)) {
        vector<int> S(K);
        for (int i=0; i<K; ++i) cin >> S[i];
        int t;
        bool ok = true;
        for (int i=0; i<N; ++i) {
            for (int j=0; j<K; ++j) {
                cin >> t;
                S[j] -= t;
                if (S[j] < 0) {
                    ok = false;
                }
            }
        }
        cout << (ok ? "Yes" : "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int n, k;
vll a;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    a.resize(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    ll ans = HIGHINF;
    for (int state = 0; state < (1 << n); state++) {
        if (__builtin_popcount(state) < k) continue;

        ll tmpa = 0;
        ll maxa = 0;
        for (int i = 0; i < n; i++) {
            if ((state >> i) & 1) {
                if (maxa >= a[i]) {
                    tmpa += maxa + 1 - a[i];
                    maxa++;
                }
            }
            chmax(maxa, a[i]);
        }
        chmin(ans, tmpa);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ls rt << 1
#define rs rt << 1 | 1
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define rep(i, x, y) for(int (i) = (x); (i) <= (y); (i) ++)
#define eps 1e-9
using namespace std;

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int n, k, mx;
int a[100010];

int gcd(int a, int b)
{
	while(a)
	{
		int c = a;
		a = b % a;
		b = c;
	}
	return b;
}

int main()
{
	n = read();
	k = read();
	rep(i, 1, n) a[i] = read(), mx = max(a[i], mx);
	rep(i, 2, n) a[1] = gcd(a[1], a[i]);
	puts(k % a[1] == 0 && k <= mx ? "POSSIBLE" : "IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int nxt[100005];
int dist[100005];

void dfs(int v,int d){
    dist[v]=d;
    if(dist[nxt[v]]!=-1) return;
    dfs(nxt[v],d+1);
}

signed main()
{   
    int N; cin>>N;
    REP(i,N){ 
        cin>>nxt[i]; nxt[i]--;
        dist[i]=-1;
    }
    dfs(0,0);

    cout<<dist[1]<<endl;
 
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}

int main(void){
	int n=in(),m=in(),k=in(),i,j;
	rep(i,n+1){
		rep(j,m+1){
			if(i*m+j*n-2*i*j==k){
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
	return 0;
}

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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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

    if( N[0] == '7' || N[1] == '7' ||N[2] == '7') cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 3616
def main():
    N, M = map(int, input().split())
    citys = []
    for _ in range(M):
        p, y = map(int, input().split())
        citys.append((p, y))
    
    ### citysdict作成
    temp= [[] for _ in range(N)]
    for city in citys:
        p, y = city
        temp[p-1].append((p, y))
    sortedcitys = []
    for pre in temp:
        sortedcitys.append(sorted(pre, key=lambda x:x[1]))
    citysdict = {}
    for pre in sortedcitys:
        ban = 1
        for city in pre:
            citysdict[city] = ban
            ban += 1
    
    ## 出力
    for city in citys:
        up = city[0]
        down = citysdict[city]
        print('{:0>6}'.format(up) + '{:0>6}'.format(down))

if __name__ == '__main__':
    main()

Measured memory_bytes: 55740
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define vi vector <int>
#define endl "\n"
#define vvi vector <vector<int> >
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>=b;i--)
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define gcd __gcd
#define init(i,k) memset(i,k,sizeof i)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define setBits(x) __builtin_popcountll(x)
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
int solve()
{
	int n,w;
	cin>>n>>w;
	int v[n][2];
	for(int i=0;i<n;i++)
	{
		cin>>v[i][0];
		cin>>v[i][1];
	}
	int m=n*1000;
	int dp[n+1][m+1];
	for(int i=0;i<=m;i++)
	{
		dp[0][i]=10e9+1;
	}
	dp[0][0]=0;
	dp[0][v[0][1]]=v[0][0];
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(v[i][1]>j)
			{
				continue;
			}
			dp[i][j]=min(dp[i][j],v[i][0]+dp[i-1][j-v[i][1]]);
		}
	}
	int ans=0;
	for(int i=0;i<=m;i++)
	{
		if(dp[n-1][i]<=w)
		{
			ans=i;
		}
	}
	return ans;
}
signed main()
{
    speed;
    int t=1;
    //cin>>t;
    while(t--)
    {
    	cout<<solve()<<endl;
    }
    return 0;
}

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

typedef pair<int, int> p;
vector<p> g[100000];
bool arrived[100000];
long long d[100000];
bool ok = true;

long long min_d;
long long max_d;

void dfs(int cur, int prev) {
  arrived[cur] = true;
  for (auto i: g[cur]) {
    int to = i.first;
    int cost = i.second;
    if (to == prev) {
      continue;
    }
    if (arrived[to]) {
      if (d[cur] + cost != d[to]) {
        ok = false;
        break;
      }
    } else {
      d[to] = d[cur] + cost;
      min_d = min(d[to], min_d);
      max_d = max(d[to], max_d);
      if (max_d - min_d > 1e9) {
        ok = false;
      } else {
        dfs(to, cur);
      }
    }
  }
}
int main() {
  int n, m;
  cin>>n>>m;
  for (int i=0; i<m; i++) {
    int l, r, d;
    cin>>l>>r>>d;
    --l;
    --r;
    g[l].push_back({r, d});
    g[r].push_back({l, -d});
  }
  for (int i=0; i<n; i++) {
    arrived[i] = false;
    d[i] = 0;
  }
  for (int i=0; i<n; i++) {
    if (!arrived[i]) {
      min_d = 0;
      max_d = 0;
      dfs(i, -1);
    }
  }
  if (ok) {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 13440
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-6;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int n;

int main(){
	cin>>n;
	ll ans=2;
	for(int i=0;i<n;i++) ans=2*ans+2;
	cout<<ans<<endl;
}

Measured memory_bytes: 384
x,y=map(int,input().split())
a=-1
p=10**9+7
for i in range(x//2+1):
  if i+2*(x-2*i)==y:
    a=i
    break
if a==-1:
  print(0)
  exit()
elif a==0:
  print(1)
  exit()
else:
  gyaku=[0,1]
  for i in range(2,a+1):
    gyaku.append(((p//i)*-gyaku[p%i])%p)
  com=[1]
  for i in range(1,a+1):
    com.append(com[-1]*gyaku[i]*(x-a+1-i)%p)
print(com[-1])


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

const int N = (1e5) + 5;
vector<int> adj[N];
int n, u, v;
bool vis[N];

void dfs(int u, int h, bool paint, int p = -1) {
  if (h >= 0) {
    vis[u] = paint;
  }
  for (int i = 0; i < (int) adj[u].size(); ++i) {
    int v = adj[u][i];
    if (v != p) {
      dfs(v, h - 1, !paint, u);
    }
  }
}

void dfs2(int u, int h, bool paint, int p = -1) {
  if (h >= 0) {
    vis[u] = 0;
  }
  for (int i = 0; i < (int) adj[u].size(); ++i) {
    int v = adj[u][i];
    if (v != p) {
      dfs2(v, h - 1, !paint, u);
    }
  }
}

ll f(ll x) {
  memset(vis, 0, sizeof(bool) * n);
  dfs(u, x, !(x & 1));
  int cnt = 0;
  dfs2(v, x, 1);
  for (int u = 0; u < n; ++u) {
    cnt += !vis[u];
  }
  if (cnt != n) {
    memset(vis, 0, sizeof(bool) * n);
    dfs(u, x + 1, !((x + 1) & 1));
    int cnt = 0;
    dfs2(v, x, 1);
    for (int u = 0; u < n; ++u) {
      cnt += !vis[u];
    }
    return cnt == n;
  }
  return 1;
}

bool predicate(ll mid, ll y) {
  return (y <= f(mid));
}

ll bs(ll lo, ll hi, ll y = 1) {
  if ( predicate(lo, y)) return lo;
  if (!predicate(hi, y)) return hi + 1;
  while (hi - lo > 1) {
    ll mid = lo + ((hi - lo) >> 1);
    if (predicate(mid, y)) hi = mid;
    else lo = mid;
  }
  return hi;
}

int main() { // claudio van
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  cin >> n >> u >> v;
  --u; --v;
  for (int i = 0; i < n - 1; ++i) {
    int u, v; cin >> u >> v;
    --u; --v;
    adj[u].emplace_back(v);
    adj[v].emplace_back(u);
  }
  cout << bs(0, n) << "\n";
  return 0;
}

Measured memory_bytes: 12288
D, G = map(int, input().split())
from itertools import chain

S = []
for i in range(D):
  p, c = map(int, input().split())
  S.append((p, c))

L = []
for i in range(2**D):
  T = []
  for j in range(D):
    if (i>>j) & 1:
      T.append(j)
  L.append(T)

X = []
for l in L:
  score, count = 0, 0
  for m in l:
    p, c = S[m]
    score += c + (m+1) * 100 * p
    count += p
  else:
    X.append((score,count,l))

ans = float("inf")
for l in X:
  score, count, indexes = l

  if score >= G:
    ans = min(ans, count)
    continue
  
  end = False
  for i in list(range(D))[::-1]:
    if i in indexes:
      continue

    if end:
      break
    
    p, c = S[i]
    for _ in range(p):
      count += 1
      score += (i+1) * 100
      if score >= G:
        ans = min(ans, count)
        end = True
        break

print(ans)

Measured memory_bytes: 3316
#include<iostream>

using namespace std;

int main(){
  int H,W;
  cin >> H >> W; 
  while(H!=0 || W!=0){
    for(int i=0;i<H;++i){
      for(int j=0;j<W;++j){
	cout << "#";
      }
      cout << endl;
    }
    cout << endl;  
    cin >> H >> W;
  }    
  return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


int main(){
  map<int,int> mp;
  int n,m;
  cin >> n >> m;
  REP(i,m){
    int a,b;
    cin >> a >> b;
    mp[a]++;mp[b]++;
  }
  FOR(i,1,n+1){
    cout << mp[i] << endl;
  }

}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main(){

    int N,X,Y,ans[2020]={};

    cin>>N>>X>>Y;

    for(int i=1;i<=(N-1);i++){
        for(int k=i+1;k<=N;k++){
            //すべての2点の組み合わせ

            //暫定
            int A = abs(k-i);

            //X-Yを通るケース

            int diff =0;
            diff = abs(X-i);
            diff +=1;
            diff += abs(Y-k);

            //最短距離を計算

            A = min(A,diff);

            //最短距離が添字のansを++
            ans[A]++;
        }
    }

    for(int i=1;i<=(N-1);i++){
        cout<<ans[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n; cin>>n;
    string s; cin>>s;
    int l=0,r=0,cnt=0;
    rep(i,n){
        if(s[i]=='('){
            cnt++;
        }
        else{
            cnt--;
        }
        l=min(l,cnt);
    }
    rep(i,-l) cout<<"(";
    cout<<s;
    rep(i,cnt-l) cout<<")";
    cout<<endl;
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<math.h>

int main(void){
	int n,m;
	double x,h,s,t;
	
	while(1){
		scanf("%d %d",&n,&m);
		if(n==0 && m==0)break;
		
		s=0.0;
		
		x=(double)n;
		h=(double)m;
		
		t=sqrt(pow(x/2.0,2)+pow(h,2));
		
		s=x*x+4*x*t/2;
		
		
		
		printf("%.6lf\n",s);
	}
	
	return 0;
}

Measured memory_bytes: 636
#include <stdio.h>

int main(void)
{
        int i,c=0;
        char s[4],t[4];

        scanf("%s%s",s,t);
        for(i=0;i<3;i++)
                if(s[i]==t[2-i])c++;
        if(c==3)printf("YES\n");
        else printf("NO\n");
        return 0;
}


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

using namespace std;

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


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

    int N;
    cin >> N;
    vector<int> a(N);
    int mi = 0, ma = 0, miat, maat;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        if (a[i] < mi) {
            miat = i;
            mi = a[i];
        }
        if (a[i] > ma) {
            maat = i;
            ma = a[i];
        }
    }

    vector<P> ops;
    if (mi < 0 && ma > 0) {
        if (abs(ma) > abs(mi)) {
            for (int i = 0; i < N; i++) {
                if (i != maat) {
                    ops.push_back(P(maat, i));
                    a[i] += a[maat];
                }
            }
        } else {
            for (int i = 0; i < N; i++) {
                if (i != miat) {
                    ops.push_back(P(miat, i));
                    a[i] += a[miat];
                }
            }
        }
    }

    bool ispos = true;
    for (int i = 0; i < N; i++) {
        if (a[i] < 0)
            ispos = false;
    }

    if (ispos) {
        ma = 0;
        for (int i = 0; i < N; i++) {
            if (a[i] >= ma) {
                maat = i;
                ma = a[i];
            }
        }
        ops.push_back(P(maat, 0));
        for (int i = 1; i < N; i++) {
            ops.push_back(P(i - 1, i));
        }
    } else {
        mi = 0;
        for (int i = 0; i < N; i++) {
            if (a[i] <= mi) {
                miat = i;
                mi = a[i];
            }
        }
        ops.push_back(P(miat, N - 1));
        for (int i = N - 1; i >= 1; i--) {
            ops.push_back(P(i, i - 1));
        }
    }

    cout << ops.size() << endl;
    for (P p : ops) {
        cout << p.first + 1 << " " << p.second + 1 << endl;
    }

    return 0;
}


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

int main(){
    int a;
    cin >> a;
    int b;
    cin >> b;
    int c;
    cin >> c;
    int d;
    cin >> d;

    int ab;
    if(a > b){
        ab = b;
    }else{
        ab = a;
    }
    
    int cd;
    if(c > d){
        cd = d;
    }else{
        cd = c;
    }

    int ans = ab + cd;
    cout << ans << endl;
    return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    auto dfs = [&](auto &&dfs, int cur, int bit) -> int {
        if(bit == (1 << N) - 1) return 1;
        int res = 0;
        for(auto &to : G[cur]) {
            if(bit & (1 << to)) continue;
            res += dfs(dfs, to, bit | (1 << to));
        }
        return res;
    };
    cout << dfs(dfs, 0, 1) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#define LL long long
using namespace std;
int n,A,B;
LL ans;
const int N=5010;
LL f[N],p[N];
int main()
{
	cin>>n>>A>>B;memset(f,0x3f,sizeof(f));ans=f[0];f[0]=0;
	for(int i=1,x;i<=n;++i)
	{
		scanf("%d",&x);
		for(int j=0;j<=n;++j)
			if(!j)p[j]=f[j];
			else p[j]=min(p[j-1],f[j]);
		for(int j=0;j<=x;++j)f[j]+=A;
		for(int j=x+1;j<=n;++j)f[j]+=B;
		f[x]=min(f[x],p[x]);
	}
	for(int i=0;i<=n;++i)ans=min(ans,f[i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){

  int a,b;
  scanf("%d %d",&a,&b);
  if(a<b){
    printf("a < b\n");
  }
  if(a>b){
    printf("a > b\n");
  }
  if(a==b){
    printf("a == b\n");
  }
  return 0;

}


Measured memory_bytes: 1976