akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
using namespace std;
const int N=1e6+5;
string s;
int ans,cnt[N];
int dp[N][2];
int main()
{
	cin>>s;
	reverse(s.begin(),s.end());
	for(int i=0;i<s.size();i++)
	{
		int cost=s[i]-'0';
		dp[i+1][0]=min(dp[i][0]+cost,dp[i][1]+1+cost);
		dp[i+1][1]=min(dp[i][0]+10-cost,(i!=0?dp[i][1]+9-cost:(int)1e9));
//		cout<<dp[i+1][0]<<' '<<dp[i+1][1]<<endl;
	}
/*	for(int i=0;i<s.size();i++)
	{
		if((s[i]<='4'))
		{
			ans+=s[i]-'0';
			f=false;
		}
		else
		{
			if(!f)f=true,ans++,ans+=10-(s[i]-'0');
			else ans+=10-(s[i]-'0')-1;
		}
	}*/
	cout<<min(dp[s.size()][0],dp[s.size()][1]+1)<<endl;
	return 0;
}

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

int main(){
  int D, G;
  cin >> D >> G;
  int problem_count[11];
  int bonus[11];
  int ans = 1e9;
  for(int i=0;i<D;i++){
    cin >> problem_count[i] >> bonus[i];
  }
  
  for(int i=0;i<(1<<D);i++){
    int prob_num = 0;
    int score = 0;
    int rest_max = -1;
    for(int j=0;j<D;j++){
      if((1 & i>>j) == 1){
        prob_num += problem_count[j];
        score += 100*(j+1)*problem_count[j] + bonus[j];
      }else{
        rest_max = j;
      }
    }
    if(score < G){
      int s1 = 100 * (rest_max + 1);
      int need = (G - score + s1 -1) / s1;
      if(need >= problem_count[rest_max]){
        continue;
      }
      prob_num += need;
    }
    ans = std::min(prob_num, ans);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
int main() {
    int k, n;
    cin >> k >> n;
    if(k % 2 == 0) {
        rep(i, n) cout << k / (1 + !i) << "\n";
        return 0;
    }
    vector<int> v(n, k + 1 >> 1);
    int j = n;
    rep(i, n - i - 1) if(--v[--j]) while(++j < n) v[j] = k;
    rep(i, j) cout << v[i] << "\n";
}

Measured memory_bytes: 3456
#include<cstdio>
#include<vector>
#include<cstring>
#define MAXN 200010
using namespace std;
int height[MAXN];
vector<int> map[MAXN];
bool check(int now){
	bool vis[MAXN];
	memset(vis,0,sizeof(vis));
	for(int i = 0;i < map[now].size();i++){
		
		int to = map[now][i];
		if(vis[to])continue;
		vis[to] = 1;
		if(height[to] >= height[now])return 0;
	}
	return 1;
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= n;i++){
		scanf("%d",&height[i]);
	}
	for(int i = 0;i < m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		map[a].push_back(b);
		map[b].push_back(a);
	}
	int ans = 0;
	for(int i = 1;i <= n;i++)
	{
		if(check(i))ans++;
	}
	printf("%d",ans);
 } 

Measured memory_bytes: 11312
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a, b;
  cin >> a >> b;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
  if (a < b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int N, K, happiness, cons;
string line;

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

  happiness = 0;
  cons = 1;

  for (int i = 1; i < line.length(); i++) {
    if (line[i] == line[i - 1])
      cons++;
    else {
      happiness += (cons - 1);
      cons = 1;
    }
  }

  happiness += (cons - 1);

  cout << min(N - 1, happiness + 2 * K) << endl;
}


Measured memory_bytes: 512
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=gets.to_i
ans=1
n.times do|i|
  ans*=(i+1)
  ans%=(10**9+7)
end
puts ans

Measured memory_bytes: 1788
N, M = map(int, input().split())
X = list(sorted(map(int, input().split())))
if N >= M:
  print('0')
else:
  d = []
  ans = X[-1] - X[0]
  for i in range(M - 1):
    d.append(X[i + 1] - X[i])
  ans -= sum(list(sorted(d, reverse=True))[0:N - 1])
  print(ans)

Measured memory_bytes: 13968
#include<stdio.h>

int main(){
    char s[11];
    int i, in1, in2;

    scanf("%d", &in1);
    scanf("%s", s);
    scanf("%d", &in2);

    for(i=0; i<in1; i++){
        if(s[i] != s[in2-1]){
            s[i] = '*';
        }
    }

    printf("%s", s);

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
    long long int h, w, n, m, i, j, max=0, a=0, ww, hh;
    scanf("%lld %lld", &h, &w);
    char s[h][w+1];
    for(i=0; i<h; i++) scanf("%s", s[i]);
    /*for(i=0; i<h; i++){
        printf("%s\n", s[i]);
    }*/
    for(i=0; i<h; i++){
        for(j=0; j<w; j++){
            a = 1;
            if(s[i][j] == '.'){
            for(int ii=j-1; ii>=0; ii--){
                if(s[i][ii]=='#') break;
                else a++;
            }
            for(int ii=j+1; ii<w; ii++){
                if(s[i][ii]=='#') break;
                else a++;
            }
            for(int jj=i-1; jj>=0; jj--){
                if(s[jj][j]=='#') break;
                else a++;
            }
            for(int jj=i+1; jj<h; jj++){
                if(s[jj][j]=='#') break;
                else a++;
            }
            if(a>max) max = a;
            }
        if(max==h+w-1) break;
        }
    if(max==h+w-1) break;
    }
    printf("%lld", max);
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int X;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> X;

    int ans = 1;
    rep(b, 2, X) {
        int x = b * b;
        while (x <= X) {
            ans = max(ans, x);
            x *= b;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define ll long long;

int main()
{
	int x;
	cin >> x;
	string s;
	cin >> s;
	if (s.length() <= x)
	cout << s << endl;
	else
	cout << s.substr(0, x) << "...\n";
}

Measured memory_bytes: 3132
N,D=input().split(' ')
n,d=int(N),int(D)

XY=[input().split(' ') for i in range(n)]
xy=[[int(XY[j][i])for i in range(2)]for j in range(n)]


S=0
for i in range(n):
  x,y=xy[i]
  if x**2+y**2<=d**2:
    S+=1
print(S)

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

#define REP(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define REPS(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define RREP(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define RREPS(i, n) for (int i = ((int)(n)); i > 0; i--)
#define IREP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define IREPS(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVISORT(v) sort(v.begin(), v.end(), greater<int>());
#define ALL(v) v.begin(), v.end()
#define MP(n, m) make_pair(n, m);
#define COUT(d) cout<<std::setprecision(10)<<d<<endl;
#define CIN(n) getline(cin,n);

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using ll = long long;
using ul = unsigned long;

typedef long long ll;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const int mod=1e9+7;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}

map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}

void printv(VI& v){
  REP(i,v.size()) cout << v[i] << " ";
  cout << endl;
}

int vtotal(VI& v){
  int total=0;
  REP(i,v.size()) total+=v[i];
  return total;
}

int ans=0;
int last=10;
int cnt=0;

void f(int x){
  int mod=x%10;
  ans+=x-mod;
  if(mod!=0){
      if(last>mod)last=mod;
      cnt++;
  }
}

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
	
  //init(); // mint初期化
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;

  f(a);
  f(b);
  f(c);
  f(d);
  f(e);

  if(last!=10)ans+=last;
  if(cnt!=0)ans+=10*(cnt-1);

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

Measured memory_bytes: 125568
#include<bits/stdc++.h>
using namespace std;
int vis[30];
map<char,int>pos;
char a[]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
map<char,int>m;
int main()
{
	string s;
	cin>>s;
	int len = s.length();
	for(int i=0;i<26;i++)
	{
		m[a[i]] = i;
	}
	for(int i=0;i<len;i++)
	{
		vis[s[i]-'a'] = 1;
		pos[s[i]] = i;
	}
	for(int i=0;i<26;i++)
	{
		if(!vis[i])
		{
			cout<<s<<(char)(i+'a')<<endl;
			return 0; 
		 } 
	}
	for(int i=len-1;i>=0;i--)
	{
		for(int j=m[s[i]]+1;j<26;j++)
		{
			if(pos[a[j]]>pos[s[i]]&&a[j]>s[i])
			{
				for(int k=0;k<i;k++)
				{
					cout<<s[k];
				}
				cout<<a[j]<<endl;
				return 0;
			}
		}
	}
	cout<<-1<<endl;
	return 0;
} 

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

int main () {

	int n;
	cin >> n;

	int ans = 0;
	int maxi = -1;

	for (int i = 0; i < n; ++i) {
		int x;
		scanf ("%d", &x);
		maxi = max (x, maxi);
		if (x == maxi) ++ans;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#Beginner 088 B-Card Game for Two

N = int(input())
A = list(map(int,input().split()))
b=0

for t in range(N):
    for i in range(N-t):
        if A[t]<A[t+i]:
            b=A[t+i]
            A[t+i]=A[t]
            A[t]=b
Alice = 0
Bob = 0

for i in range(N):
    if i%2==0:
        Alice += A[i]
    else:
        Bob += A[i]
ans = Alice - Bob
print(ans)

Measured memory_bytes: 3064
#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(false);

  string a, b, c;
  cin >> a >> b >> c;

  int ai = 0;
  int bi = 0;
  int ci = 0;

  char next = 'a';
  while (1) {
    if (next == 'a') {
      if (ai < a.size()) {
        next = a[ai];
        ai++;
      } else {
        break;
      }
    } else if (next == 'b') {
      if (bi < b.size()) {
        next = b[bi];
        bi++;
      } else {
        break;
      }
    } else {
      if (ci < c.size()) {
        next = c[ci];
        ci++;
      } else {
        break;
      }
    }
  }

  char ans = toupper(next);

  cout << ans << endl;

  return 0;
}

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

int main(){
    int N,L;
    cin>>N>>L;
    vector<int>apples(N);
    for(int i=0;i<N;i++){
        apples.at(i)=L+i;
    }
    int risou=0;
    for(int i=0;i<N;i++){
        risou+=apples.at(i);

    }
    int h=10000000;
    int unko=0;
    for(int i=0;i<N;i++){
        if(abs(apples.at(i))<h){
            h=abs(apples.at(i));
            unko=risou-apples.at(i);

        }
        else{
            int man=0;
        }
    }
    cout<<unko<<endl;
    

}

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

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
const int  p=31,po=1,N=1e5+1, M=(ll)1e9+1 ;
const int mod = (ll)1e9 +7;
// struct node{
//   ll prefixsum,suffixsum,bettersum,totalsum;
//   void create(ll val){
//     prefixsum=suffixsum=bettersum=val;
//   }
//   void Merge(node& a,node &b){
//     prefixsum=max(a.prefixsum,a.totalsum+b.prefixsum);
//     suffixsum=max(b.suffixsum,a.suffixsum+b.sum);
//     totalsum=a.totalsum+b.totalsum;
    
//   }
// }
//ll dp[2][100];
vl compute(string s){
        vl has(s.length());
        ll i;

        for(i=0;i<s.length();i++){
            if(i==0){
                has[i]=((s[i]-'a'+1))%mod;
            }
            else
                has[i]=(has[i-1]*p + (s[i]-'a'+1))%mod;
        }
        return has;
}
vl g[N],dist(N+1,0);
vector<bool>vis(N,false);
void dfs(ll x){
  vis[x]=true;
  for(auto to:g[x]){
    if(!vis[to])
      dfs(to);
    dist[x]=max(dist[x],dist[to]+1);

  }
}
 ll dp[1002][1002];

int main(){
 ios_base::sync_with_stdio(0);
 ll i,j,n,m;
 cin >> n >> m;
 char c[n+1][m+1],ch;
 for(i=1;i<=n;i++){
   for(j=1;j<=m;j++){
     cin >> c[i][j];
   }
 }
 dp[n][m]=1;
 for(i=n;i>=1;i--){
   for(j=m;j>=1;j--){
     if(i==n && j==m)
      continue;
      if(c[i][j]=='#')
        dp[i][j]=0;
      else{
        // cout << i << " " << j << endl;
        dp[i][j]=dp[i+1][j]%mod+dp[i][j+1]%mod;
        dp[i][j]%=mod;
      }
   }
 }
 cout << dp[1][1];
    return 0;
}



Measured memory_bytes: 12160
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define maxn 110
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
char s[maxn];
int a[maxn];
int n,k;
int main()
{
	scanf("%s",s); n=strlen(s);
	k=read();
	int last=0,tot=0;
	for(int i=0;i<n;i++)
		if(s[i]!=s[i+1])a[++tot]=i-last+1,last=i+1;
	ll ans=0;
	if(tot==1)ans=(ll)n*k/2;
	else if(s[0]==s[n-1]){
		for(int i=2;i<tot;i++)
			ans+=(ll)k*(a[i]/2);
		ans+=(a[1]/2)+(ll)(k-1)*((a[1]+a[tot])/2)+(a[tot]/2);
	}
	else{
		for(int i=1;i<=tot;i++)
			ans+=(ll)k*(a[i]/2);
	}
	writeln(ans);
	return 0;
}

Measured memory_bytes: 128
import numpy as np
import itertools

H,W,K=map(int,input().split())
L=np.array([list(x for x in input()) for _ in range(H)])
H=np.arange(H)
W=np.arange(W)

white='.'
black='#'
ans=0

for i in range(len(H)):
  for j in itertools.combinations(H, i):
    temp=L.copy()
    for x in j:
      temp[x,:]=0
    for k in range(len(W)):
      for l in itertools.combinations(W, k):
        temp2=temp.copy()
        if len(l)==0:
          if np.count_nonzero(temp2=='#')==K:
            ans+=1
          continue
        for y in l:
          temp2[:,y]=0
        if np.count_nonzero(temp2=='#')==K:
          ans+=1

print(ans)

Measured memory_bytes: 27064
#include <bits/stdc++.h>
 
using namespace std; 
 
#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define fp(i,a,b,p) for(int i=a;i<b;i+=p)
#define SZ(x) (int)x.size()
#define INF 1e9
 
typedef  vector<string> vs;
typedef  vector<int> vi;
typedef  vector<long long> vl;	
 
 
int main(){
	
	int a,b;
	
	cin >> a >> b; 
	
	cout << max(a+b,max(a-b,a*b)) << endl;
 
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(input())
B = list(input())
C = list(input())

ans = 0
for a,b,c in zip(A, B, C):
    if a == b and b == c:
        continue
    elif a != b and b != c and a != c:
        ans += 2
    else:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<cmath>
#include<climits>

int main(){
	int n;
	std::vector<int> aList;

	std::cin>>n;
	aList.resize(n);

	for(int i=0; i<n; i++)
		std::cin>>aList[i];

	long long ans= 0;
	bool isZeroExist= false;
	int minAbs= INT_MAX;
	int minusCount= 0;

	for(int i=0; i<n; i++){
		if(aList[i]<0)
			minusCount++;

		if(aList[i]==0)
			isZeroExist=true;

		int varAbs= std::abs(aList[i]);
		minAbs= std::min(minAbs, varAbs);

		ans+= varAbs;
	}

	if(!isZeroExist && minusCount%2== 1)
		ans= ans- (2* minAbs);

	std::cout<< ans<<std::endl;

	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
using namespace std;
int N, d[50], sum;
int main() {
  scanf("%d", &N);
  for(int i = 0; i < N; ++i) {
    scanf("%d", &d[i]);
    for(int j = 0; j < i; ++j) sum += d[i]*d[j];
  }
  printf("%d\n", sum);
}

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


int main(){
    long k=100;
    int ans=0;
    l1 n =100;
    l1 x;
    cin>>x;
    while(n<x){
        ans++;
        l1 s = n/k;
        n+=s;
    } 
    cout<<ans;

    return 0;

}

Measured memory_bytes: 3620
import math


class LinearProbingIntSet:
    def __init__(self):
        self.count = 0
        self.size = 1
        self.keys = [None] * self.size

    def add(self, key):
        i = self._hash(key)
        for j in range(self.size):
            k = (i + j) % self.size
            if self.keys[k] is None:
                self.keys[k] = key
                self.count += 1
                break
            elif self.keys[k] == key:
                break
        else:
            raise RuntimeError('set is full')

        if self.count > self.size // 2:
            size = int(2 ** (math.log2(self.size+1)+1)) - 1
            self._resize(size)

    def delete(self, key):
        i = self._hash(key)
        while self.keys[i] is not None and self.keys[i] != key:
            i = (i + 1) % self.size

        if self.keys[i] != key:
            return
        self.keys[i] = None
        self.count -= 1

        i = (i + 1) % self.size
        while self.keys[i] is not None:
            key = self.keys[i]
            if i != self._hash(key):
                self.keys[i] = None
                self.count -= 1
                self.add(key)
            i = (i + 1) % self.size

        if self.count <= self.size // 4:
            size = max(1, int(2 ** (math.log2(self.size+1)-1)) - 1)
            self._resize(size)

    def __contains__(self, key):
        i = self._hash(key)
        for j in range(self.size):
            k = (i + j) % self.size
            if self.keys[k] is None:
                return False
            elif self.keys[k] == key:
                return True
        raise RuntimeError('set is full')

    def _hash(self, key):
        return (key * 13) % self.size

    def _resize(self, size):
        old_keys = self.keys
        self.count = 0
        self.size = size
        self.keys = [None] * self.size

        for key in old_keys:
            if key is None:
                continue
            self.add(key)


def run():
    q = int(input())
    s = LinearProbingIntSet()

    for _ in range(q):
        command, value = [int(x) for x in input().split()]
        if command == 0:
            s.add(value)
            print(s.count)
        elif command == 1:
            if value in s:
                print(1)
            else:
                print(0)
        elif command == 2:
            s.delete(value)
        else:
            raise ValueError('invalid command')


if __name__ == '__main__':
    run()



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

signed main() {
	ll n, l;
	string s[110];
	cin >> n >> l;
	rep(i, n) cin >> s[i];
	sort(s,s + n);
	rep(i, n) cout << s[i];
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(a<b && b<c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
}


Measured memory_bytes: 2060
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int N; cin >>N;
  vector< vector<char> > v(N, vector<char>(N, '-'));
  REP(i, N) REP(j, N) { char c; cin >>c; v[i][j] = c; }
  int cnt = 0, h[2];
  h[0] = 1;
  REP(i, N){
    int tmp = 0;
    REP(j, N){
      if(v[i][j] == 'o') tmp += 1;
      if(v[i][j] == 'x') tmp -= 1;
    }
    if(tmp > cnt){
      h[0] = i + 1;
      cnt = tmp;
    }
  }
  if(cnt == N - 1) h[1] = h[0];
  else{
    REP(i, N) if(v[i][h[0] - 1] == 'o') h[1] = i + 1;
  }
  REP(i, 1000){
    int judge_ai_hand;
    printf("%d\n", h[i % 2]); fflush(stdout);
    scanf("%d", &judge_ai_hand);
  }
  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;

const int max_n = 1e5 + 5;


int main () {
	make(n);
	vector<double> dp;
	dp.pb(1);
	FOR(i,0,n) {
		double p; scanf("%lf", &p);
		vector<double> dp2;
		FOR(j,0,i+2) dp2.pb(0);
		FOR(i,0,dp.size()) {
			dp2[i] += dp[i]*(1.-p);
			dp2[i+1] += dp[i] *1.* p;
		}
		dp = dp2;
	}
	double sum = 0.;
	FOR(i,0,n+1) {
		if (i+i>n) sum += dp[i];
	}
	printf("%.17lf\n", sum);


}	





Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

int main(){
  int n;
  string s,t;
  cin >> n >> s >> t;
  for(int i=0;i<n;i++){
    bool flag=true;
    for(int j=0;j<n-i;j++){
      if(s[i+j]!=t[j])flag=false;
    }
    if(flag){
      cout << (int)t.size()+i << endl;
      return 0;
    }
  }
  cout << (int)s.size()+(int)t.size() << endl;
return 0;}

Measured memory_bytes: 256
c11,c12,c13 = map(int,input().split())
c21,c22,c23 = map(int,input().split())
c31,c32,c33 = map(int,input().split())
def solve():
    if not (c11-c12 == c21-c22 == c31-c32):
        return False
    if not (c12-c13 == c22-c23 == c32-c33):
        return False
    if not (c11-c21 == c12-c22 == c13-c23):
        return False
    if not (c21-c31 == c22-c32 == c23-c33):
        return False
    return True

print('Yes' if solve() else 'No')

Measured memory_bytes: 3064
import java.lang.Math.sqrt
import java.lang.StringBuilder

fun main(args: Array<String>) {
    val n = readInt()
    val (s, t) = readStringList()

    val ans = StringBuilder()
    for (i in 0 until n) {
        ans.append(s[i]).append(t[i])
    }
    println(ans.toString())
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 37908
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
mod = 10**9+7
from collections import Counter

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        primes.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            primes.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        primes.append(n)
    return a
primes = []
for i in range(1, N+1):
    prime_factorize(i)
c = Counter(primes)
ans = 1
for n, cnt in c.most_common():
    ans *= (cnt+1)
    ans %= mod
print(ans)

Measured memory_bytes: 69564
def main():
    a, b, c = map(int, input().split())
    if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
        print(0)
    elif a == b and b == c:
        print(-1)
    else:
        ans = 0
        while True:
            if a % 4 == 2 or b % 4 == 2 or c % 4 == 2:
                print(ans + 1)
                exit()
            ans += 1
            ta, tb, tc = a, b, c
            a = (tb + tc) // 2 
            b = (ta + tc) // 2
            c = (ta + tb) // 2 


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0

for i in range(0, a + 1):
    for j in range(0, b + 1):
        for k in range(0, c + 1):
            if i*500 + j*100 + k*50 == x:
                count += 1

print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



signed main() {
	int a=0,b=0;
	string s;
	cin >> s;
	rep(i, s.size()) {
		if (s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G') {
			a++;
		}
		else {
			b = max(a, b);
			a = 0;
		}
	}
	b = max(a, b);
	cout << b << endl;
}



Measured memory_bytes: 256
use std::io;
use std::io::Read;

fn main(){
    let mut stdin = io::stdin();
    let mut lines_str = String::new();
    let _ = stdin.read_to_string(&mut lines_str);
    let lines_vec = lines_str.lines().collect::<Vec<&str>>();
    let n :i64 = lines_vec[0].trim().parse().unwrap();
    let mut result :i64 = -n;

    while result < 0 {
        result = result + 1000;
    }

    println!("{}", result);
}


Measured memory_bytes: 2076
// D - .. (Double Dots)
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

int main(){
	int N,M; cin>>N>>M;
	vector<vi> V(N);
	rp(i, 0, M){
		int a,b; cin>>a>>b; --a,--b;
		V[a].push_back(b);
		V[b].push_back(a);
	}
	vi ans(N, -1);
	queue<int> q;
	q.push(0);
	while(q.size()){
		int p = q.front(); q.pop();
		for(int c:V[p])
			if(c!=0 && ans[c]<0){ ans[c] = p; q.push(c); }
	}
	puts("Yes");
	rp(i, 1, N) cout<< ans[i]+1 <<endl;
}


Measured memory_bytes: 10236
#include <iostream>

using namespace std;

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

  if(K%2==0){
    cout << (K/2)*(K/2);
  }
  else{
    cout << ((K-1)/2)*((K-1)/2+1);
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

H, W = getNM()
maze = [input() for i in range(H)]

dp_row = [[-1] * W for i in range(H)]
dp_col = [[-1] * W for i in range(H)]

# 横
def dfs_row(y, x):
    if dp_row[y][x] >= 0:
        return dp_row[y][x]

    if maze[y][x] == '#':
        return 0

    res = 1
    nx = x + 1
    if 0 <= nx < W and maze[y][nx] == '.':
        res += dfs_row(y, nx)
    dp_row[y][x] = res
    return res

for i in range(H):
    for j in range(W):
        dfs_row(i, j)
    cnt = 0
    for j in range(1, W):
        if dp_row[i][j] >= 0 and dp_row[i][j - 1] >= 0:
            dp_row[i][j] = dp_row[i][j - 1]

# 縦
def dfs_col(y, x):
    if dp_col[y][x] >= 0:
        return dp_col[y][x]

    if maze[y][x] == '#':
        return 0

    res = 1
    ny = y + 1
    if 0 <= ny < H and maze[ny][x] == '.':
        res += dfs_col(ny, x)
    dp_col[y][x] = res
    return res

for i in range(H):
    for j in range(W):
        dfs_col(i, j)

for i in range(1, H):
    for j in range(W):
        if dp_col[i][j] >= 0 and dp_col[i - 1][j] >= 0:
            dp_col[i][j] = dp_col[i - 1][j]
# 集計
ans = 0
for i in range(H):
    for j in range(W):
        if maze[i][j] == '.':
            ans = max(ans, dp_row[i][j] + dp_col[i][j] - 1)
print(ans)


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

int main(){
  int ta,th,aa,ah;
  cin >> th >> ta >> ah >> aa;
  int c=0;
  while(th>0&&ah>0){
    if(c%2==0)
      ah-=ta;
    else
      th-=aa;
    c++;
  }
  cout << (th>0?"Yes":"No") << endl;
  return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if ((a + b) % 2 == 1) {
    cout << (a + b + 1)/2 << endl;
  }else{
    cout << (a + b)/2 << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int max = 0;
		int answer = 0;

		for (int i = 0; i < N; i++) {
			int H = scan.nextInt();
			if (H >= max) {
				answer++;
				max = H;
			}
		}

		System.out.println(answer);
 	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>


using namespace std;
const long long MM = 1e9+7;

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

  // F[i, j] number of permutation {0..i} which ends at {...j}, considering string s[0:i-2]
  // E.g., F[3, 2] counts {0 3 1 2}
  // sum_k F[N-1, k] is the output
  vector <vector <long long> > F(N, vector<long long>(N, 0) );

  F[0][0] = 1;

  for(auto i=1; i<N; i++) {
    char c = s.at(i-1);
    if (c == '<') { //  i-th > (i-1)-th
      // consider all possible ends j
      long long cum = F[i-1][0];
      for (auto j=1; j<=i; j++) {
        F[i][j] = cum;
        cum = (cum + F[i-1][j]) % MM;
      }
    } else { // ith- < (i-t)-th
    
      long long cum = 0;
      for(auto j=i; j>=0;j--) {
        cum = (cum + F[i-1][j]) % MM;
        F[i][j] = cum;
      }
    }
  }

  long long ans =0;
  for (auto i=0; i<N; i++) ans = (ans + F[N-1][i]) % MM;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 70656
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            String alpha = "abcdefghijklmnopqrstuvwxyz";
            String str = in.nextLine();

            char temp = ' ';
            for (int i = 0; i < alpha.length(); ++i) {
                char c = alpha.charAt(i);
                if (!str.contains("" + c)) {
                    temp = c;
                    break;
                }
            }

            if (temp == ' ') {
                out.println("None");
            } else {
                out.println(temp);
            }
        }

    }
}



Measured memory_bytes: 26700
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int m = sc.nextInt();
		char s[] = sc.next().toCharArray();
		char t[] = sc.next().toCharArray();
		HashMap<Long, Character> hm = new HashMap<>();
		long max = 0;
		long key;
		long lc = lcm(n, m);
		for (int i = 0; i < n; i++) {
			key = 1 + i * lc / n;
			hm.put(key, s[i]);
		}
		long ans = lc;
		for (int i = 0; i < m; i++) {
			key = 1 + i * lc / m;
			if (hm.containsKey(key)) {
				if (hm.get(key) == t[i]) {
					
				} else {
					ans = -1;
					break;
				}
			} else {
				hm.put(key, t[i]);
			}
		}
		System.out.println(ans);
	}

	private static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	private static long gcd(long m, long n) {
		if (m < n)
			return gcd(n, m);
		if (n == 0)
			return m;
		return gcd(n, m % n);
	}
}

Measured memory_bytes: 51152
until (a = $<.gets.split.map(&:to_i)) == [0, 0]
  h, w = a
  tiles = h.times.map {$<.gets.chomp}
  positions = [0]
  x, y = 0, 0
  
  result = loop do
    case tiles[y][x]
    when ">" then x += 1
    when "<" then x -= 1
    when "^" then y -= 1
    when "v" then y += 1
    when "." then break "#{x} #{y}"
    else raise "error"
    end
    po = y * w + x
    break "LOOP" if positions.include?(po)
    positions << po
  end
  puts result
end



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



int main(){
	
	int n;
	cin >> n;
	vector<long long> first(5,0);
	string s = "MARCH";
	for(int i = 0; i < n; i++)
	{
		string k;
		cin >> k;
		for(int j = 0; j < 5; j++)
		{
			if(k[0] == s[j]) first[j]++;
			
		}
	}

	long long ans = 0;
	for(int i = 0; i < 5; i++)
	{
		for(int j = i+1; j < 5; j++)
		{
			for(int k = j+1; k < 5; k++)
			{
				ans += first[i] * first[j] * first[k];
			}
			
		}
		
		
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int main(void) {
    int i, n;
    cin >> n;
    int ans = pow(3,n);
    int x = 1;
    REP (i,n) {
        int a;
        cin >> a;
        if (a % 2 == 0) {
            x *= 2;
        }
    }
    cout << ans - x << endl;
    return 0;
}

Measured memory_bytes: 640
x, y = map(int, input().split())

ans = []
if y - x >= 0:
    ans += [y - x]
if -y - x >= 0:
    ans += [-y - x + 1]
if y + x >= 0:
    ans += [y + x + 1]
if -y + x >= 0:
    ans += [-y + x + 2]
print(min(ans))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pi acos(-1)
#define mod 1000000007
using namespace std;

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

    int n, W;
    cin >> n >> W;
    int w[n], v[n];
    for(int i = 0; i < n; i++){
        cin >> w[i] >> v[i];
    }
    ll dp[W + 1];
    memset(dp, 0, sizeof dp);
    for(int i = 0; i < n; i++){
        for(int j = W - w[i]; j >= 0; j--){
            dp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i]);
        }
    }
    ll ans = 0;
    for(int i = 0; i <= W; i++){
        ans = max(ans, dp[i]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<map>
#include<queue>
using namespace std;
int main() {
	long long n;
	cin >> n;
	long long c = n;
	c %= 11;
	if (c == 0)cout << n / 11 * 2 << endl;
	else if (c > 6) {
		cout << n / 11 * 2 + 2 << endl;
	}
	else cout << n / 11 * 2 + 1 << endl;
	return 0;
}

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

    vector<int> V;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
    int q;
    cin>>q;
    if(q==2){
        V.pop_back();
    }else {
        int x;
        cin>>x;
        if(q==0){
            V.push_back(x);
        }else{
            cout<<V[x]<<endl;
        }
    }
    }
return 0;
}


Measured memory_bytes: 3912
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()){
        	String str = scan.nextLine();
        	str = str.replace(',', '.');
        	str = str.replace('.',' ');
        	String[] nstr = str.split(" ");
        	str = "";
        	for(int i = 0;i < nstr.length;i++){
        		int l = nstr[i].length();
        		if(l > 2 && l < 7){
        			str += ((str.equals("")?"":" ") + nstr[i]);
        		}
        	}
        	System.out.println(str);
        }
    }
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define sz(x) (int)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const int N = 5e5+10;

int main(){
fast;
int a,b;
cin>>a>>b;
cout<<a*b<<endl;
return 0;
}

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

int main()
{
    int N; cin>>N;
    vector<int> a(N),b(N),c(N-1);
    for(int i=0;i<N;i++) cin>>a[i],a[i]--;
    for(int i=0;i<N;i++) cin>>b[i];
    for(int i=0;i<N-1;i++) cin>>c[i];

    int ans=0;
    for(int i=0;i<N;i++){
        ans+=b[a[i]];
        if(i>0 and a[i-1]+1==a[i]){
            ans+=c[a[i-1]];
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
N, a, b = map(int, input().split())
mod = 10**9+7

def cmb(n, k):
  ne = 1
  ke = 1
  for i in range(k):
    ne = ne * (n - i) % mod
    ke = ke * (i + 1) % mod
  
  res = ne * pow(ke, (mod - 2), mod) % mod
  return res

result = (pow(2, N, mod) - 1 - cmb(N, a) - cmb(N, b)) % mod
print(result)


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

#define INF (INT32_MAX/2)
#define MOD (1000000000+7)
#define MAX 8

int N, A, B, C;
int l[MAX];

int dfs( int cur, int a, int b, int c )
{
	if( cur == N ) {
		if( min( a, min( b, c ) ) > 0 ) {
			return abs( a - A ) + abs( b - B ) + abs( c - C ) - 30;
		}
		else {
			return INF;
		}
	}
	int ret0 = dfs( cur + 1, a, b, c );
	int ret1 = dfs( cur + 1, a + l[cur], b, c ) + 10;
	int ret2 = dfs( cur + 1, a, b + l[cur], c ) + 10;
	int ret3 = dfs( cur + 1, a, b, c + l[cur] ) + 10;
	return min( ret0, min( ret1, min( ret2, ret3 ) ) );
}

int main() {
	cin >> N >> A >> B >> C;
	for( int i = 0; i < N; i++ ) {
		cin >> l[i];
	}

	int ans = dfs( 0, 0, 0, 0 );

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

[L,R] = inpl()
rL, rR = L%2019, R%2019
temp = INF
ans = INF
if R-L>= 2018 or rL > rR : ans = 0
else:
    for i in range(rL, rR):
        for j in range(i+1, rR+1):
            temp = ( i*j ) %2019
            if temp < ans: ans = temp
        
print(ans)

Measured memory_bytes: 12484
#include "bits/stdc++.h"

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int>H(N);
	int ans = 1e9;


	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	sort(H.begin(), H.end());

	for (int i = 0; i + K <= N; i++) {
		ans = min(ans, H[i + K - 1] - H[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<lli> prime(N + 1, 0);
    REP(i, 2, N + 1) {
        int t = i;
        REP(j, 2, i + 1) {
            while (t % j == 0) {
                prime[j]++;
                t /= j;
            }
        }
    }
    auto dp = make_v(N + 2, 101, 0LL);
    dp[0][1] = 1;

    REP(i, 0, N + 1) {
        REP(j, 1, 101) {
            dp[i + 1][j] += dp[i][j];
            REP(k, 1, 101) {
                if (k <= prime[i] && j * (k + 1) < 101) {
                    dp[i + 1][j * (k + 1)] += dp[i][j];
                }
            }
        }
    }

    cout << dp[N + 1][75] << endl;

    return 0;
}


Measured memory_bytes: 384