akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    int N;
    string A, B, C;
    cin >> N >> A >> B >> C;
    int ans = 0;
    for(int i = 0; i < N; ++i){
        if(A[i] != B[i] && B[i] != C[i] && C[i] != A[i]){
            ans += 2;
        }else if(A[i] == B[i] && B[i] == C[i]){
            ans += 0;
        }else{
            ans += 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main () {
    
    int N,n,k,x;
    
    cin >> N;
    
    int A[105][105] = {};
    
    for (int i = 1; i <= N; i ++) {
        
        cin >> n >> k;
        
        for (int j = 0; j < k; j ++) {
            
            cin >> x;
            
            A[i][x] = 1;
            
        }
        
    }
    
    for (int i = 1; i <= N; i ++) {
        
        for (int j = 1; j < N; j ++) {
            
            cout << A[i][j] << " ";
            
        }
        
        cout << A[i][N] << endl;
        
    }
    
    return 0;
    
}


Measured memory_bytes: 3136
#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;

int main(){
  int W,a,b;
  cin >> W >> a >> b;
  if(a>b)swap(a,b);

  cout << max(0,b-W-a) << endl;

}



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

int main() {
	int N, i, s; 
	cin >> N;
	int A[N];
	
	for (i=0; i<N; i++)
		cin >> A[i];

	for (s=0; s<N-1; s++)
		cout<<A[s]<<" ";
	cout<<A[N-1]<<'\n';

	for (i=1; i<=N-1; i++) {
		int j, v;
		v=A[i];
		j=i-1;
		while (j>=0 && A[j]>v){
			A[j+1]=A[j];
			j--;
		}
		A[j+1]=v;
		
		for (s=0; s<N-1; s++)
		cout<<A[s]<<" ";
		
		cout<<A[N-1]<<'\n';
	}
	
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 3084
#include<iostream>
#include<math.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
  ll n;
  cin >> n;
  ll ans = 0;

  for (int i = 1; i <= n; i++)
  {
    if((i%3==0)||(i%5==0)){
      ans=ans;
    }
    else{
      ans+=i;
    }
  }
  cout << ans;
  
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
signed main(){
	int q;
	cin >> q;
	while(q--){
		long long a,b;
		cin >> a >> b;
		long long mult = a*b;
		long long t = sqrt(mult);
		if(t*(t+1)<mult){
			cout << t*2-1 << endl;
		}
		else if(t*t==mult){
			if(a!=b){
				cout << (t-1)*2-1<<endl;
			}
			else{
				cout << (t-1)*2<<endl;
			}
		}
		else{
			cout << (t-1)*2<<endl;
		}
	}
}

Measured memory_bytes: 256
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()

    var ans = 0.0
    for(i in 0 until n){
        val (a, b) = readLine()!!.split(" ")
        val num = a.toDouble()

        if(b == "JPY"){
            ans += num
        }
        else {
            ans += num * 380000
        }
    }

    println(ans)

}

Measured memory_bytes: 37780
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC, task a, 2020/04/19
//ms, ac
/*
*/

int main(void){
  int R;
  double pi = 3.141592;

  cin >>R;
  cout <<2*pi*R <<endl;

  return 0;
}
/*
*/


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

x=list(map(int,input().split()))
A=max(x)
x.insert(0,-1)
dp=[[[0]*(n+1) for _ in range(n*A+1)] for i in range(n+1)]
dp[1][x[1]][1]=1
dp[1][0][0]=1
for i in range(1,n):
    q=x[i+1]
    for s in range(n*A+1):
        for k in range(i+1):
            if s+q<=n*A:
                dp[i+1][s+q][k+1]+=dp[i][s][k]
            dp[i+1][s][k]+=dp[i][s][k]

ans=0
i=1

while i<=n and a*i<=n*A:
    ans+=dp[n][a*(i)][i]
    i+=1
print(ans)




Measured memory_bytes: 135868
MAX = 2**31-1

def rmq(a, b, k, l, r, node)
  return MAX if r <= a || b <= l
  return node[k] if a <= l && r <= b
  m = (l+r)/2
  vl = rmq(a, b, 2*k+1, l, m, node)
  vr = rmq(a, b, 2*k+2, m, r, node)
  return vl < vr ? vl : vr
end

n, q = gets.split.map(&:to_i)

m = 1
while m < n
  m *= 2
end
node = Array.new(2*m-1){MAX}

q.times{
  com, x, y = gets.split.map(&:to_i)
  case com
  when 0
    k = x + m - 1
    node[k] = y
    while k > 0
      k = (k-1)/2
      node[k] = node[2*k+1] < node[2*k+2] ? node[2*k+1] : node[2*k+2]
    end
  when 1
    p rmq(x, y+1, 0, 0, m, node)
  end
}

Measured memory_bytes: 10920
console.log((args=>{
  let X = args.trim()|0;
  P: while(1) {
    for ( let i = 2; i*i <= X; i++ ) {
      if ( X % i === 0 ) {
        X++;
        continue P;
      }
    }
    return `${X}`;
  }
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 29632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,string> tp;
//typedef vector<tp> vt;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m;
	cin>>n>>m;
	vp in(m);
	rep(i,m)cin>>in[i].first>>in[i].second;
	sort(all(in));
	vp out(n);
	rep(i,n)out[i]={i,i+1};
	rep(i,m){
		int t=in[i].second;
		out[t]=out[t-1]={min(out[t].first,out[t-1].first),max(out[t].second,out[t-1].second)};
	}
	rep(i,n-1)cout<<out[i].second-out[i].first<<" ";
	cout<<out[n-1].second-out[n-1].first<<endl;
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    ans=[]
    for i in range(100):
        temp=(N-1)%26+ord("a")
        s=chr(temp)
        ans.append(s)
        N=(N-1)//26
        if N==0:
            break
        
    print(''.join(map(str, ans[::-1])))

main()


Measured memory_bytes: 61904
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)


//verified
const ll mod=1e9+7;

vector<ll> fact,ifact;
ll power(ll a,ll b,ll mod){
	ll ret=1;
	if(b>0){
		ret = power(a,b/2,mod);
		if(b%2==0)ret = (ret*ret)%mod;
		else ret = (((ret*ret)%mod)*a)%mod;
	}
	return ret;
}

void initF(int n) { //n is upper (nCr)
	fact.resize(n,1);
	ifact.resize(n,1);
	for (int i = 1; i < n; i++) fact[i] = i * fact[i - 1] % mod;
	
	ifact[n-1]= power(fact[n-1],mod-2,mod);
	
	for(int i=n-2;i>=0;i--) ifact[i] = ifact[i+1]*(i+1)%mod;
}
ll C(int n,int r){
	if(n<0||r<0||r>n)return 0;
	if(r>n/2)r=n-r;
	return fact[n]*ifact[n-r]%mod*ifact[r]%mod;
}

const ll MOD = 1e9+7;

int main(){
	    initF(1e6);
	int h,w,a,b;
	cin>>h>>w>>a>>b;
	
	ll ans = 0;
	
	rep(i,h-a-1){
//		cout<<i<<endl;
		ans = ( ans + C(b+i,i)%MOD * C(w+h-b-3-i,w-b-2)%MOD )%MOD;
	}
	ans = ( ans + C(b+h-a-1,h-a-1)%MOD * C(w+h-b-2-(h-a-1),w-b-1)%MOD )%MOD;
	
	
	cout<<ans<<endl;
}

Measured memory_bytes: 15872
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数
vector<long long> fact, fact_inv, inv;

//二項係数前処理計算量O(SIZE)
void init_nCk(int SIZE) {
    fact.resize(SIZE + 5);
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
}
    
//nCk　計算量(1)
ll nCk(int n, int k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;
}

ll fsum(ll r,ll c){
    ll res=0;
    REP2(i,1,r+1){
        res+=(nCk(i+c+1,c)-1)%MOD;
        res%=MOD;
    }
    while(res<0) res+=MOD;
    return res;
}
int main(){
    ll r1,r2,c1,c2;
    cin>>r1>>c1>>r2>>c2;
    r1--;
    c1--;
    ll r1c1,r1c2,r2c1,r2c2;
    init_nCk(10000000);
    r1c1=fsum(r1,c1);
    r1c2=fsum(r1,c2);
    r2c1=fsum(r2,c1);
    r2c2=fsum(r2,c2);

    ll ans=(r2c2+r1c1)%MOD;
    ans-=r1c2;
    ans%=MOD;
    while(ans<0) ans+=MOD;

    ans-=r2c1;
    ans%=MOD;

    while(ans<0) ans+=MOD;

    cout<<ans<<endl;
    

    
}

Measured memory_bytes: 237616
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
 
 
//typedef tuple <int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<ll> vll;
 
#define siz(x) (int)(x).size()
#define Y second
#define X first
#define IN insert
#define PB push_back
#define P pop_back
#define PU push
#define PO pop
//#define F find
#define ED end()
#define MP( a, b) make_pair( a, b )
 
//#define MOD 1000000007ll
#define INF 1000000000
#define endl "\n"
#define rep(a,i,b) for (ll i = (a); i < (b); ++i)
#define reps(a,i,b) for (ll i = (a); i <= (b); ++i)
#define repd( num, i, ed ) for(ll (i)= (num)-1; (i) >= ed; --(i))
#define repkt( bg, i, num, kt ) for(ll (i)= (bg); (i) < (num) && (kt); ++(i))
#define repchar( i ) for(char (i)= 48; (i) <= 122; (i)++)   
#define in(n) scanf("%lld", &n)
#define out(n) printf("%lld\n", n)
#define outS(s) printf("%s\n", s)
#define setA(a,n) for(ll i= 0, j= sizeof(a)/sizeof(a[0]); i < j; ++i) a[i]= n;
#define repe(num,i,ed) for(ll (i)= (num); (i) >= ed; --(i))
// const int INF=0x3f3f3f3f;
const ll mod=1e9+7;
const ll N=1e5+5,K=105;
const int si=(1<<20);
const ll M=50+5;
const ll oo=1e18+5;
const double INFdb=1e10;

int n;
int a[N],b[N],c[N];
int dp[N][3];

int main(){
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
    #ifndef ONLINE_JUDGE
        // freopen("input.txt", "r", stdin);
    #endif
    cin>>n;
    for(int i=1;i<=n;++i){
		cin>>a[i]>>b[i]>>c[i];
	}
	dp[1][0]=a[1];
	dp[1][1]=b[1];
	dp[1][2]=c[1];
	for(int i=2;i<=n;++i){
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
	}
	cout<<max({dp[n][0],dp[n][1],dp[n][2]});
    cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms\n";                                                                          
    return 0;
}



Measured memory_bytes: 2688
import collections
import math

A, B = map(int, input().split())

# 最大公約数を求める
smaller = min(A, B)
larger = max(A, B)

max_cd = 1
for i in range(1, int(math.sqrt(smaller))+1):
    if smaller % i == 0:
        if larger % i == 0:
            max_cd = i
        if larger % (smaller // i) == 0:
            max_cd = smaller // i
            break

#print(max_cd)

# 最大公約数を素因数分解する
c = collections.Counter()
i = 2
while i*i <= max_cd:
    if max_cd % i == 0:
        max_cd = max_cd // i
        c[i] += 1
    else:
        i += 1

if max_cd != 1:
    c[max_cd] += 1


ans = len(c.keys()) + 1
print(ans)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;

int b,k;
char peeta[1005][1005];
int dp[1005][1005];
int main(){
	scanf("%d%d",&b,&k);
	for (int i= 0;i<b;i++) scanf("%s",&peeta[i]);
	for(int i = 0 ;i<b;i++){
		for (int j = 0;j<k;j++){
			if(peeta[i][j]=='#') continue;
			if(i==0 && j ==0){
				dp[i][j] = 1;	
			} else if(i==0){
				dp[i][j] = (dp[i][j-1])%MOD;
			} else if(j == 0){
				dp[i][j] = (dp[i-1][j])%MOD;
			} else {
				dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
			}
		}
	}
	printf("%d\n",dp[b-1][k-1]);
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int m,k;cin>>m>>k;
  int t = 0;
  rep(i, pow(2, m))if(i!=k)t^=i;
  if(t==k){
    rep(i, pow(2, m))if(i!=k)cout<<i<<' ';
    cout<<k<<' ';
    rrep(i, pow(2, m))if(i!=k)cout<<i<<' ';
    cout<<k;
    cout<<endl;
    return 0;
  }

  if(k>=pow(2, m)-1){ cout<<-1<<endl; return 0; }

  if(k==0){
    rep(i, pow(2,m))cout<<i<<' '<<i<<' ';
    return 0;
  }

  int mx = pow(2, m)-1;
  int mxb = mx^k;
  rep(i, pow(2, m))if(i!=mx && i!=mxb)cout<<i<<' ';
  cout<<mx<<' '<<mxb<<' ';
  rrep(i, pow(2, m))if(i!=mx && i!=mxb)cout<<i<<' ';
  cout<<mxb<<' '<<mx;
  cout<<endl;

//cout<<mx<<'*'<<mxb<<endl;
//  int t = 0;rep1(i, 120){t^=i; cout<<i<<' '<<t<<endl;}

  return 0;
}


Measured memory_bytes: 4088
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, K;
  cin >> N >> K;
  vector<int> data;
  int count = 0;
  char a, b;
  cin >> a;
  for(int i = 0; i < N - 1; i++){
    cin >> b;
    if(a != b)count++;
    a = b;
  }
  cout << min(N - 1, N - 1 - count + 2 * K) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using Pc = pair<double, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

void dfs(int from) {
	int c = 1;
	for (auto t : tree[from]) {
		c = c != color[from] ? c : c + 1;
		color[t] = c;
		colorMap[make_pair(from, t)] = c;
		m = max(c, m);
		dfs(t);
		c++;
	}
}

int main() {
	int N;
	cin >> N;
	int ans = (N + 1) / 2;
	cout << ans << endl;
}



Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,A[53],b,c[54];
  int ans=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(int i=0;i<n;i++){
    scanf("%d",&b);
    ans+=b;
  }
  for(int i=2;i<n+1;i++){
    scanf("%d",&c[i]);
  }
  for(int i=1;i<n;i++){
    if(A[i-1]+1==A[i]){
      ans+=c[A[i]];
    }
  }
  
  printf("%d\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
 
int main()
{
    int N;
    cin >> N;
    vector<int> A(N, 0);
    for (int i = 0; i < N - 1; i++)
    {
        int idx;
        cin >> idx;
        A[idx - 1]++;
    }
    for (int i = 0; i < N; i++)
    {
        cout << A[i] << endl;
    }
 
    return 0;
}

Measured memory_bytes: 4048
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int main(void)
{
    for(;;){
        int x,  y, s;
        scanf(" %d %d %d", &x, &y, &s);
        if(x == 0 && y == 0 && s == 0)
            break;

        // ??????????????§?????????
        int ma = 0;
        for(int i = 1; i < 1000; i++){
            for(int j = 1; j < 1000; j++){
                int pbi = i * (100+x) / 100;
                int pbj = j * (100+x) / 100;
                if(pbi + pbj == s){
                    int pai = i * (100+y) / 100;
                    int paj = j * (100+y) / 100;
                    ma = max(ma, pai + paj);
                }
            }
        }
        printf("%d\n", ma);
    }

    return 0;
}

Measured memory_bytes: 1188
a = int(input())
b = int(input())
c = int(input())
x = int(input())

# for k in range(0, min((x - 500 * i - 100 * j) // 50 + 1, c + 1)):
ans = 0
for i in range(0, min(x // 500 + 1, a + 1)):
    # print('9', i)
    for j in range(0, min((x - 500 * i) // 100 + 1, b + 1)):
        # print('11', j)
        if (x - 500 * i - 100 * j) <= 50 * c:
            ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <vector>

void swap(int& a, int& b)
{
    int tmp;
    tmp = a;
    a = b;
    b = tmp;
}

int partition(std::vector<int>& A, int p, int r)
{
    int x = A[r];
    int i = p - 1;
    for(int j = p; j < r; j++){
	if(A[j] <= x){
	    i = i + 1;
	    swap(A[i], A[j]);
	}
    }
    swap(A[i+1], A[r]);
    return i + 1;
}

int main(int argc, char **argv)
{
    int n;
    std::cin >> n;

    std::vector<int> A(n);
    for(int i = 0; i < n; i++){
	std::cin >> A[i];
    }
    int q = partition(A, 0, n-1);

    std::stringstream ss;
    std::string sep = "";
    int i = 0;
    for(; i < q; i++){
	ss << sep << A[i];
	sep = " ";
    }
    ss << sep << "[" << A[i] << "]";
    i++;
    for(; i < n; i++){
	ss << sep << A[i];
	sep = " ";
    }
    std::cout << ss.str() << std::endl;
}



Measured memory_bytes: 4288
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define rsort_v(v) std::sort(v.rbegin(), v.rend())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))
 
 // ^^^ Template ^^^ //

int main() {
	in(ll, N);
	in_v(ll, a, N);
	bool odd = false;
	for(ll i : a){
		if(i % 2){
			odd = true;
			break;
		}
	}
	if(odd)
		out("first");
	else
		out("second");
}



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

using namespace std;

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

typedef long long int ll;


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

	int n;
	int arr[1000];
	cin >> n;

	rep(i , n)
		cin >> arr[i];
	
	float ans = 0;
	rep(i , n)
		ans += (1.0 / arr[i]);
	
	cout << (1.0/ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define ll long long
#define maxn 400040
using namespace std;
const int mo=1000000007;

int n,a[maxn],b[maxn],c[maxn];
ll f[4040][4040],ans,p[maxn];

inline int ksm(int x,int y)
{
	int ans=1;
	while(y)
	{
		if(y&1) ans=(ll)ans*x%mo;
		x=(ll)x*x%mo;
		y>>=1;
	}
	return ans;
}

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

	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		m=max(m,max(a[i],b[i]));
	}
	for(int i=1;i<=n;i++)f[m+a[i]][m+b[i]]++;

	c[0]=p[0]=1;
	for(int i=1;i<=m*4;i++) c[i]=(ll)c[i-1]*i%mo,p[i]=ksm(c[i],mo-2)%mo;

	for(int i=m*2;i>=0;i--)
		for(int j=m*2;j>=0;j--)
			f[i][j]=(f[i][j]+f[i+1][j]+f[i][j+1])%mo;

	for(int i=1;i<=n;i++) ans=(ans+f[m-a[i]][m-b[i]])%mo;
	for(int i=1;i<=n;i++) ans=(ans-(ll)c[a[i]*2+b[i]*2]*p[a[i]*2]%mo*p[b[i]*2]%mo)%mo;

	ans=(ans*ksm(2,mo-2))%mo;

	printf("%lld\n",(ans+mo)%mo);
}

Measured memory_bytes: 133376
#include<bits/stdc++.h>
using namespace std;
long long x[100010],y[100010],z[100010];
int main(){

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

  long long a,b,c,cnt=0,ans=0,n;
  string s,v;
  
  cin>>a>>b;
  if(b%a==0){
    cout<<a+b<<'\n';
  }else{
    cout<<b-a<<'\n';
  }
}


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

int main(){
  string s, t;
  cin >> s >> t;
  string ss = s+s;
  vector<vector<int>> nex(s.length(),vector<int>(26,-1));
  vector<int> idx(26,-1);
  for(size_t i = ss.length()-1; i >= s.length(); --i){
    idx[ss[i]-'a'] = i;
  }
  for(size_t i = s.length()-1; i < s.length(); --i){
    nex[i] = idx;
    idx[s[i]-'a'] = i;
  }
  long long ans = 0;
  size_t i = idx[t[0]-'a'];
  if(idx[t[0]-'a'] < 0){
    cout << -1 << endl;
    return 0;
  }
  ans += i+1;
  for(size_t j = 1; j < t.length(); ++j){
    int c = t[j] - 'a';
    if(nex[i][c] < 0){
      cout << -1 << endl;
      return 0;
    }
    ans += (nex[i][c]-i);
    i = nex[i][c]%s.length();
  }
  cout << ans << endl;
}


Measured memory_bytes: 13952
#include <iostream>

using namespace std;

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

    if ((s[0] != s[1]) && (s[0] != s[2]) && (s[1] != s[2]))
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=a;i<=n;++i)
#define lpd(i,a,n) for(int i=a;i>=n;--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-8
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 100002;
int n,m,x[N],y[N],s[N],l[N],ms[N];
vector<pii> g[N];
bool v[N];
ll val[N];

void bfs(int x){
    mem(v, 0);
    queue<int> q;
    v[1] = true;
    q.push(1);
    val[1] = x;
    while(sz(q)){
        int i = q.front(); q.pop();
        for(pii j : g[i]) if(!v[j.f]){
            v[j.f] = true;
            l[j.f] = l[i] + 1;
            val[j.f] = j.s - val[i];
            q.push(j.f);
        }
    }
}

int main(){
    read2i(n,m);
    lp(i,1,n) ms[i] = infi;
    lp(i,1,m){
        read3i(x[i],y[i],s[i]);
        g[x[i]].pb({y[i], s[i]});
        g[y[i]].pb({x[i], s[i]});
        ms[x[i]] = min(ms[x[i]], s[i]);
        ms[y[i]] = min(ms[y[i]], s[i]);
    }

    bfs(1);
    lp(i,1,n) l[i] &= 1;

    si need;
    lp(i,1,m){
        if(l[x[i]] == l[y[i]]){
            ll d = s[i] - (val[x[i]] + val[y[i]]);
            if(d & 1) return cout <<0, 0;
            else need.insert((l[x[i]] ? -d : d) / 2);
        }
        else if(val[x[i]] + val[y[i]] != s[i]) return cout <<0, 0;
    }
    if(sz(need) > 1) return cout <<0, 0;
    if(sz(need) == 1){
        bfs(1 + *need.begin());
        lp(i,1,m) if(val[x[i]] <= 0 or val[y[i]] <= 0 or val[x[i]] + val[y[i]] != s[i])
            return cout <<0, 0;
        return cout <<1, 0;
    }

    ll mxSt = -infll, mnEnd = infll;
    lp(i,1,n){
        ll f,s;
        if(l[i]) f = val[i] - 1, s = val[i] - ms[i] + 1;
        else f = 1 - val[i], s = ms[i] - 1 - val[i];
        if(f > s) swap(f, s);
        mxSt = max(mxSt, f);
        mnEnd = min(mnEnd, s);
    }
    cout <<max(0ll, mnEnd - mxSt + 1);
    return 0; 
}


Measured memory_bytes: 9728
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
#include <map>
using ll = long long int;
using namespace std;

int main()
{
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(N, (K - Q));
    for (int i = 0; i < Q; i++)
    {
        int tmp;
        cin >> tmp;
        A[tmp - 1]++;
    }
    for (int i = 0; i < N; i++)
    {
        if (A[i] > 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int n, y;
  cin >> n >> y;
  for (int a = 0; a <= n; a++){
    for (int b = 0; b <= n; b++){
      if(a+b > n){continue;}
      if (a*10000 + b*5000 + (n - (a+b))*1000 == y){
        cout << a << " " << b << " " << n - (a+b) << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int N;
    scanf("%d",&N);
    if(N%10 == 3){
        printf("bon\n");
    }else if(N%10 == 0 || N%10 == 1 || N%10 == 6 || N%10 == 8){
        printf("pon\n");
    }else{
        printf("hon\n");
    }
    return 0;
}


Measured memory_bytes: 1648
N, M = map(int, input().split())
C = list(map(int, input().split()))
C.sort()

dp = [[10**18]*(N+10) for _ in range(M+10)]
dp[0][0] = 0

for i in range(M):
    for j in range(N+1):
        if j - C[i] >= 0:
            dp[i+1][j] = min(dp[i][j - C[i]] + 1, dp[i][j], dp[i+1][j - C[i]] + 1)
        else:
            dp[i+1][j] = dp[i][j]



print(dp[M][N])


Measured memory_bytes: 47304
#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);

    ll N,K; cin >> N >> K;
    ll tmp = K;
    ll cnt=1;

    while(tmp <= N){
        tmp *= K;
        cnt++;
    }

    cout << cnt << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

int main() {
    long x,t;
    cin >> x >> t;
    if(x <= t){
        cout << 0 << endl;
    }else{
        cout << x-t << endl;
    }
}



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

int K,a=0,b=0;
string A[100],B[100];

int solve(){
  for(int i=0;i<K;i++){    
    if(A[i]=="kougekida"&&B[i]=="kougekida"){      
      if(a>b)return 1;
      else if(a<b)return 2;
      else a=b=0;
    }else if(A[i]=="kougekida"){
      if(a==0)return 2;
      else if(a==5)return 1;
      else if(B[i]=="tameru")return 1;
      else a=0;
    }else if(B[i]=="kougekida"){
      if(b==0)return 1;
      else if(b==5)return 2;
      else if(A[i]=="tameru")return 2;
      else b=0;
    }else{
      if(A[i]=="tameru")a=min(5,a+1);
      if(B[i]=="tameru")b=min(5,b+1);
    }
  }
  return 0;
}

int main(){
  cin>>K;
  for(int i=0;i<K;i++)cin>>A[i];
  for(int i=0;i<K;i++)cin>>B[i];
  int ans=solve();
  if(ans==1){
    cout<<"Isono-kun"<<endl;
  }else if(ans==2){
    cout<<"Nakajima-kun"<<endl;
  }else{
    cout<<"Hikiwake-kun"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007

using namespace std;
using ll = long long int;
using ull = unsigned long long;

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) {
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

int main() {
	int k;
	int a, b;
	cin >> k;
	cin >> a >> b;
	int ans = k;
	for (int i = 2; ans <= b; i++) {
		if (a <= ans) {
			cout << "OK" << endl;
			return 0;
		}
		ans = k * i;
	}
	cout << "NG" << endl;
	return 0;
}

Measured memory_bytes: 3604
N = int(input())
List = list(map(int,input().split()))

ListK = [i+1+List[i] for i in range(N)]
ListL = [i+1-List[i] for i in range(N)]

from collections import Counter 
ans = 0

NewlistK = Counter(ListK)
NewlistL = Counter(ListL)

for i in range(N):
  ans += (NewlistK[i])*(NewlistL[i])

print(ans)  
  

Measured memory_bytes: 63348
#include<iostream>
using namespace std;
int kaku_keta_wa(int f);

int main(void) {
	int N, A, B; cin >> N >> A >> B;
	int i, sum = 0;
	for (i = 1; i <= N; i++) {
		if (A <= kaku_keta_wa(i) && kaku_keta_wa(i) <= B) {
			sum += i;
		}
	}
	cout << sum << endl;

	return 0;
}

int kaku_keta_wa(int f) {
	int M, sum = 0;
	while (f) {
		M = f % 10;
		sum = sum + M;
		f = f / 10;
	}
	return sum;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

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

	if (N == M) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int T;
  cin>>T;
  while(T--){
    int n, k, l, r;
    cin>>n;
    vector<pii> a, b;
    ll ans=0;
    REP(i, n){
      cin>>k>>l>>r;
      ans+=min(l, r);
      if(l>r){
        a.push_back(pii(k, l-r));
      }
      if(l<r){
        b.push_back(pii(n-k, r-l));
      }
    }
    sort(ALL(a));
    sort(ALL(b));
    priority_queue<int, vi, greater<int>> pq;
    for(auto xy : a){
      int x=xy.first, y=xy.second;
      ans+=y;
      pq.push(y);
      if(pq.size()>x){
        ans-=pq.top();
        pq.pop();
      }
    }
    priority_queue<int, vi, greater<int>> pq2;
    for(auto xy : b){
      int x=xy.first, y=xy.second;
      ans+=y;
      pq2.push(y);
      if(pq2.size()>x){
        ans-=pq2.top();
        pq2.pop();
      }
    }
    cout<<ans<<'\n';
  }
  return 0;
}


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

int main() {
	string ss;
	cin >> ss ;
	rep(i,(int)(ss.length())) printf("x");
	return 0;
}

Measured memory_bytes: 256
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
ls = [list(map(int,input().split())) for _ in range(n)]
ans = 0

for l in ls:
    total = c
    for i in range(m):
        total += l[i] * b[i]
    if total > 0:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 
map<ll, int> primes;

void primeFactors(ll n) {
	while(n % 2 == 0) {
		primes[2]++;
		n /= 2;
	}

	for(int i = 3; i <= sqrt(n); i += 2) {
		while(n % i == 0) {
			primes[i]++;
			n /= i;
		}
	}

	if(n > 2)
		primes[n]++;
}

int main() {
	ll n;
	cin >> n;
	primeFactors(n);
	int cnt = 0;
	for(auto i : primes) {
		cnt += (-1 + sqrt(1+8*i.se))/2;
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 3676
#!/usr/bin/env ruby

(a, b, k) = gets.chomp.split(/ /).map(&:to_i)


def eat(f, s)
  if (f % 2 != 0)
    f = f - 1
  end
  f /= 2
  s += f
  [s, f]
end

f = a
s = b
k.times do

  (f, s) = eat(f, s)
end

if (k % 2 != 0)
  res = "#{s} #{f}"
else
  res =  "#{f} #{s}"
end
puts res

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N;
bool a[21][21];
ll DP[1 << 21];

int main() {
	cin >> N;
	for (int i = 0; i != N; ++i)
		for (int j = 0; j != N; ++j)
			cin >> a[i][j];
	DP[0] = 1;
	for (int i = 0; i != 1 << N; ++i) {
		int c = 0;
		for (int j = 0; j != N; ++j)
			if (i&(1 << j))
				++c;
		for (int j = 0; j != N; ++j) {
			if (a[c][j] && (i | 1 << j) != i)
				DP[i + (1 << j)] = (DP[i + (1 << j)] + DP[i]) % mod;
		}
	}
	cout << DP[(1 << N) - 1] << endl;
	return 0;
}

Measured memory_bytes: 16640
S=input()
dp=[[0 for i in range(len(S))] for j in range(2)]
if len(S)==1:
    print(S)
    exit()
dp[0][0]=int(S[0])
dp[1][0]=int(S[0])-1
for i in range(len(S)-1):
    dp[0][i+1] = dp[0][i]+int(S[i+1])
    dp[1][i+1] = max(dp[0][i]+int(S[i+1])-1,dp[1][i]+9)
print(max(dp[1][len(S)-1],dp[0][len(S)-1]))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int r = sc.nextInt();
		if(n >= 10) {
			System.out.println(r);
		} else {
			r += 100 * (10 - n);
			System.out.println(r);
		}
	}

}


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

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

using ll = long long;
using pii = pair<int, int>;

void solve() {
    ll a, b, k;
    cin >> a >> b >> k;
    ll m = min(a, k);
    a -= m, k -= m;
    cout << a << ' ' << max(0ll, b - k);
}

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
#define inf             1e18
#define mod             1000000007
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r;








void sol()
{   
    cin>>x>>y;
    if(y&1){cout<<"No\n";return;}
    if(2*x>=y/2 && x<=y/2){cout<<"Yes\n";return;}
    // if((x==y/4 &&y%4==0) || x==y/2){cout<<"Yes\n";return;}
    
    
    cout<< "No" <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

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

int main() {
    int N,a,cnt=0;
    cin >> N;
    //vector<int> a(N);
    for(int i=1;i<=N;i++){
        cin >> a;
        if(i%2==1&&a%2==1){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#define rep(i, n) for (int i = 0; (i) < (int)(n); i++)
using namespace std;
int main() {
    long long X;
    cin >> X;
    long long c500, c5, h = 0;
    c500 = X / 500;
    h += c500 * 1000;
    X -= c500 * 500;
    c5 = X / 5;
    h += c5 * 5;
    X -= c5 * 5;
    cout << h << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll,P> LP;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

struct UnionFind{
  vector<int> v;
  UnionFind(int n) : v(n, -1) {}
  void init(){ for(int i = 0;i < v.size();i++)v[i]=-1; }
  int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (-v[x] < -v[y]) swap(x, y);
    v[x] += v[y]; v[y] = x;
    return true;
  }
  bool root(int x) { return v[x] < 0; }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -v[find(x)]; }
};

ll n,m;
ll x;
vector<LP> es;

ll mod_pow(ll x,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*x%mod;
    x=x*x%mod;
    n>>=1;
  }
  return res;
}

int main(){
  cin>>n>>m;
  cin>>x;
  rep(i,m){
    ll a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    es.push_back(LP(c,P(a,b)));
  }
  sort(all(es));
  ll res=0;
  ll e=0,g=0;
  rep(i,m){
    UnionFind uf(n);
    uf.unite(es[i].se.fi,es[i].se.se);
    ll sum=es[i].fi;
    rep(j,m){
      if(i==j)continue;
      if(uf.same(es[j].se.fi,es[j].se.se)){
        continue;
      }
      sum+=es[j].fi;
      uf.unite(es[j].se.fi,es[j].se.se);
    }
    if(sum==x)e++;
    else if(sum>x)g++;
  }

  if(e==0){
    cout<<0<<endl;
  }else if(e+g!=m){
    cout<<(mod_pow(2,e)-1+mod)%mod*mod_pow(2,g)*2%mod<<endl;
  }else{
    cout<<(mod_pow(2,e)-2+mod)%mod*mod_pow(2,g)%mod<<endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000000+7
#define MEM_SIZE = 1e5+5;

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;
template< typename T >

void warshall_floyd(Matrix< T > &g, T INF_A) {
  for(int k = 0; k < g.size(); k++) {
    for(int i = 0; i < g.size(); i++) {
      for(int j = 0; j < g.size(); j++) {
        if(g[i][k] == INF_A || g[k][j] == INF_A) continue;
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
}

void solve(void)
{

  int H,W;
  cin>>H>>W;
  vector<vector<char> > data(H,vector<char>(W));
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cin>>data[i][j];
    }
  }
  int N = H*W;


  Matrix<int> mat(N,vector<int>(N,INF));


  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if(data[i][j] =='.')
      {
        if(i != 0)
        {
          if(data[i-1][j] == '.')
          {
            mat[i*W+j][(i-1)*W+j] = 1;
            mat[(i-1)*W+j][i*W+j] = 1;
          }
        }

        if(i != H-1)
        {
          if(data[i+1][j] == '.')
          {
            mat[i*W+j][(i+1)*(W)+j] = 1;
            mat[(i+1)*(W)+j][i*W+j] = 1;
          }
        }

        if(j != 0)
        {
          if(data[i][j-1] == '.')
          {
            mat[i*W+j][i*W+j-1] = 1;
            mat[i*W+j-1][i*W+j] = 1;
          }
        }

        if(j != W-1)
        {
          if(data[i][j+1] == '.')
          {
            mat[i*W+j][i*W+j+1] = 1;
            mat[i*W+j+1][i*W+j] = 1;
          }
        }
      } 
    }
  }

  for (int i = 0; i < N; i++)
  {
    mat[i][i] = 0;
  }
  
  warshall_floyd(mat,(int)INF);
  int ANS = 0;
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      if(mat[i][j] != INF) ANS = max(ANS,mat[i][j]);

      // cout<<mat[i][j]<<endl;
    }
  }

  cout<<ANS<<endl;
  
  
  

  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // std::cout << std::fixed;
  // std::cout << std::setprecision(8);

  solve();

 
  return 0;
}

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

int main(){
  int N,A,B,j=0;
  cin>>N>>A>>B;
  for(int i=1;i<=N;i++){
    int l=0;
    for(int k=i;k>0;k/=10)
      l+=k%10;
    if(A<=l && l<=B)
      j+=i;
  }
  cout<<j<<endl;
}

Measured memory_bytes: 380
import copy
n = int(input())
a = [int(input()) for _ in range(n)]
 
b = copy.deepcopy(a)
b.sort()
max1 = b[-1]
max2 = b[-2]
 
for i in a:
    if i == max1:
        print(max2)
    else:
        print(max1)

Measured memory_bytes: 14568