akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;

using ll=long long;

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
typedef long long ll;
const int MOD = 1000000007;

int D;
vector<int> cs(26);
vector<vector<int>> ss;

int calc_score(vector<int>& out) {
    int sat = 0;
    vector<int> lasts(26, 0);
    rep(d, D) {
        int j = out[d] - 1;
        lasts[j] = d + 1;
        rep(i, 26) sat -= (d+1-lasts[i])*cs[i];
        sat += ss[d][j];
    }
    return sat; 
}

pair<int, int> calc_prepro(int x, int d, vector<int>& outs) {
    int pre = 0, pro = D+1;
    rep(i, D) {
        if (outs[i] == x) {
            if (i < d - 1) pre = max(i+1, pre);
            if (i > d - 1) pro = min(i+1, pro);
        }
    }
    return {pre, pro};
}

int tosum(int n) {
    return n*(n+1)/2;
}

int calc_partial_score(int x, vector<int> outs) {
    int s = 0, last = 0;
    rep(d, D) {
        if (outs[d] == x) {
            s += tosum(d-last)*cs[x-1];
            last = d + 1;
        }
        // s += (d+1-last)*cs[x-1];
    }
    s += tosum(D-last)*cs[x-1];
    return s;
}

int chage_outs(int d, int to, vector<int>& outs, int score) {
    int from = outs[d-1];
    score -= -calc_partial_score(from, outs); 
    score -= -calc_partial_score(to, outs); 
    score -= ss[d-1][from-1];
    outs[d-1] = to;
    score += -calc_partial_score(from, outs); 
    score += -calc_partial_score(to, outs); 
    score += ss[d-1][to-1];
    outs[d-1] = from;
    return score; 
}


int main() {
    cin >> D;
    rep(i, 26) cin >> cs[i];
    ss.resize(D, vector<int>(26)); 
    vector<int> outs(D);
    rep(i, D) {
        int max_score = 0;
        rep(j, 26) {
            cin >> ss[i][j]; 
            if (ss[i][j] > max_score) {
                max_score = ss[i][j];
                outs[i] = j + 1; 
            }
        }  
    }
    const int STEP = 1e5;
    //random_device seed_gen;
    //mt19937 engine(seed_gen());
    mt19937 engine(100);
    uniform_int_distribution<> distD(1, D), distT(1, 26);
    uniform_real_distribution<> distE(0.0, 1.0);

    int score = calc_score(outs);
    int bestscore = score;
    vector<int> bestouts;
    rep(step, STEP) {
        int d = distD(engine);
        int to = distT(engine); 
        double e = distE(engine); 
        int new_score = chage_outs(d, to, outs, score);
        double th = 0.0;
        if (step*3 < STEP)  th = 0.05;
        else if (step*2 < STEP) th = 0.01;
        else if (step * 1.5) th = 0.001;
        // th = 0.0 ;
        if (e < th || new_score > score) {
            // cout << "CHANGE: step: " << step << ", score: " << new_score << endl;
            score = new_score;
            outs[d-1] = to;
            if (score > bestscore) {
                bestscore = score;
                bestouts = outs;
            }
        } 
    }
    for(int o : outs) cout << o << endl;
    // cout << score << endl;
    return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1LL<<60;

ll w[110], W;
int v[110], N;
ll dp[110][100010];

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; i++)cin >> w[i] >> v[i];

    for (int i = 0; i < 110; i++)for (int sum_v = 0; sum_v < 100010; sum_v++)dp[i][sum_v] = INF;
    dp[0][0] = 0;

    for (int i = 0; i < N; i++)
    {
        for (int sum_v = 0; sum_v <= 100000; sum_v++)
        {
            if (sum_v >= v[i]) dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v-v[i]] + w[i]);
            else dp[i+1][sum_v] = min(dp[i+1][sum_v], w[i]);
            dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }
    int ans = 0;

    for (int sum_v = 0; sum_v < 100010; sum_v++)if (dp[N][sum_v] <= W) ans = sum_v;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 89552
#pragma GCC target("avx")
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define PA pair<LL,LL>
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue
#define PQS priority_queue<LL,vector<LL>,greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define EB emplace_back
#define TS to_string
#define TU to_ullong
#define BPL __builtin_popcountll
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORR(i,a,n) for(i=n-1;i>=a;i--)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
//#define ERR 0.00000000000001
#define NUM 200010
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL LBn(VL &v,LL a){LL mx=v.size(),mn=-1,md;while(mx-mn>1){md=(mx+mn)/2;if(v[md]<a)mn=md;else mx=md;}return mx;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a%m<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}
template<typename T>bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  FAST;
  LL i,ans=0,A,B,C,D;
  cin>>A>>B>>C>>D;
  Yn((C+B-1)/B<=(A+D-1)/D);
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];

    int cnt = 0;

    rep(i, n) {
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}



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

using ll=long long;
#define int ll

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

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	while(true){
		int e=read();
		int ans=100000;
		int m;
		if(e==0) break;
		int z,y,x;
		for(z=1;z*z*z<e;z++){
		}
		for(y=1;y*y<e;y++){
		}
		for(int i=0;i<=z;i++){
			for(int j=0;j<=y;j++){
				if(e-i*i*i-j*j >= 0){
					x = e-i*i*i-j*j;
					ans = min(ans,x+j+i);
				}
			}	
		}
		
		cout << ans << endl;
		
	}
	
}

Measured memory_bytes: 3032
def main(input = STDIN)
  n, q = input.gets.split(" ").map(&:to_i)
  queue = Array.new(n)
  i = -1
  n.times do
    queue[i += 1] = Pro.new(*input.gets.split(" "))
  end
  i = 0
  last = 0
  now_time = 0
  size = n
  while size > 0
    now_time += q
    temp = queue[i].execute(q)
    if temp <= 0
      now_time += temp
      puts queue[i].name + " " + now_time.to_s
      size -= 1
      i = (i + 1) % n
    else
      queue[last] = queue[i]
      i, last = (i + 1) % n, (last + 1) % n
    end
  end
end
class Pro
  attr_reader :name
  def initialize(name, time)
    @name, @time = name.to_s, time.to_i
  end
  def execute(quantum)
    return @time -= quantum
  end
end
main

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

int main()
{

    vector<int> x(5);
    for (int i = 0; i < 5; i++)
    {
        cin >> x[i];
    }
    for (int j = 0; j < 5; j++)
    {
        if (x[j] == 0)
            cout << j + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
A=input().split()
a=int(A[0])
b=int(A[1])
c=int(A[2])
d=int(A[3])
if abs(a-c) <= d:
  print("Yes")
elif (abs(a-b) <= d) & (abs(b-c) <= d):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
n,m =map(int,input().split())
visited = False
q = [[] for _ in range(n)]
flag = False
for j in range(m):
    a,b = map(int,input().split())
    q[a].append(b)

while q[1]:
    c = q[1].pop()
    if n in q[c]:
        flag = True
print('POSSIBLE' if flag==True else 'IMPOSSIBLE')

Measured memory_bytes: 67488
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n:usize,
        mut a:[i32;n]
    };
    let mut _result = 0;
    let v: &mut [i32] = &mut a;
    v.sort_by(|a, b| b.cmp(a));
    for i in 0..n {
        if i % 2 == 1 {
            let diff: i32 = v[i - 1] - v[i];
            _result += diff.abs();
        }
    }
    if n % 2 == 1 {
        _result += v[n - 1]
    };

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


Measured memory_bytes: 2152
#include <stdio.h>
#include <string.h>

#define N 100
#define C 26

int main() {
	static char s[N + 1], used1[C], used2[C];
	int n, i, j, k, c, cnt, max;

	scanf("%d%s", &n, s);
	max = 0;
	for (i = 1; i < n; i++) {
		memset(used1, 0, sizeof used1);
		memset(used2, 0, sizeof used2);
		cnt = 0;
		for (j = 0; j < i; j++)
			used1[s[j] - 'a'] = 1;
		for (k = i; k < n; k++)
			used2[s[k] - 'a'] = 1;
		for (c = 0; c < 26; c++)
			if (used1[c] && used2[c])
				cnt++;
		if (max < cnt)
			max = cnt;
	}
	printf("%d\n", max);
	return 0;
}


Measured memory_bytes: 128
import sys
read = sys.stdin.buffer.read#全部読み込むやつ
readline = sys.stdin.buffer.readline#1行読み込むやつ
readlines = sys.stdin.buffer.readlines#リストで読み込むらしい

S = read().rstrip()
length = len(S)
ans = "x" * length
print(ans)

Measured memory_bytes: 38384
require 'pp'
require 'prime'
n = gets.to_i
ans = n.to_s.size
1.upto(n ** (1/2.0)) do |i|
  next if n % i != 0
  ans = [ans,[(n/ i), i].map(&:to_s).map(&:size).max].min
end
p ans


Measured memory_bytes: 4348
from sys import exit
S = input()
T = input()
start = [-1] * 26
goal = [-1] * 26
for i in range(len(S)):
  a = ord(S[i]) - ord('a')
  b = ord(T[i]) - ord('a')

  if start[a] != -1 or goal[b] != -1:
    if start[a] != b or goal[b] != a:
      print('No')
      exit()
  else:
    start[a] = b
    goal[b] = a
print('Yes')


Measured memory_bytes: 3632
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

int main(){
    int n,m;
    cin >> n>> m;
    mat a(n,vec(m));
    rep(i,n) rep(j,m) cin >> a[i][j],--a[i][j];
    vector<bool> stop(m,false);
    vec id(n,0),memo(m,0);//id:iのid[i]ばんめの競技について・memo:競技の人数
    ll ans=n;
    rep(roop,m){
        rep(i,n){
            while(stop[a[i][id[i]]])++id[i];//次の競技はどうか考える
            ++memo[a[i][id[i]]];//競技参加者
        }
        auto ite = max_element(ALL(memo));//最大要素をさす最初のいてれーた
        ans = min(ans,*ite);
        stop[ite-memo.begin()]=true;//ite-memo.begin()の競技が排除
        rep(i,m)memo[i]=0;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4304
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,M;
	int s[101][101];
	int k[101];
	int p[101];
	scan(N>>M);
	rep(i,M){
		scan(k[i]);
		rep(j,k[i]){
			scan(s[i][j]);
			s[i][j]--;
		}
	}
	rep(i,M){
		scan(p[i]);
	}
	int Nth=(1<<N);
	int ans=0;
	rep(bit,Nth){
		int flag=1;
		bool on[101]={};
		rep(i,N){
			on[i]=((bit>>i)&1);
		}
		rep(i,M){
			int onnum=0;
			rep(j,k[i]){
				if(on[s[i][j]]) onnum++;
			}
			if(onnum%2==p[i]){

			}
			else flag=0;
		}
		if(flag) ans++;
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int A, B;
	cin >> A >> B;
	int cnt = 0;
	for (int i = A; i <= B; i++)if ((i / 10000 == i % 10) && ((i / 1000) % 10 == (i / 10) % 10))cnt++;
	cout << cnt;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> v(n);
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        v[i] = make_pair(a, b);
    }
    sort(v.begin(), v.end());
    ll ans = 0;
    ll cnt = 0;
    int idx = 0;
    while(1) {
        ans += v[idx].first * v[idx].second;
        cnt += v[idx].second;
        if (cnt >= m) {
            ans -= v[idx].first * (cnt - m);
            break;
        }
        ++idx;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
int n,k;
int arr[200001];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    set<int> lol;
    cin>>n>>k;
    for (int i=1;i<=n;i++){
        lol.insert(i);
    }
    for (int i=0;i<k;i++){
        int m,x;
        cin>>m;
        for (int j=0;j<m;j++){
            cin>>x;
            if (lol.find(x)!=lol.end()){
                lol.erase(x);
            }
        }
    }
    cout<<lol.size();
    /*
    cin>>n;
    for (int i=1;i<=n;i++){
        cin>>arr[i];
    }
    */
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
class book{
public:
	ll t,a,b,flag;
};
bool compare(pair<ll,ll> p1,pair<ll,ll> p2){
  if(p1.second==p2.second) return p1.first>p2.first;
	return p1.second>p2.second;
}
bool comp(char a, char b)
{
    return (a < b);
}
int mex(int *A,int n){
	int C[n];
	for(int i=0;i<n;i++) C[i]=A[i];
	sort(C,C+n);
	for(int i=0;i<=n;i++){
		if(!binary_search(C,C+n,i)) return i;
	}
}
bool check(int *A,int n){
	for(int i=0;i<n-1;i++){
		if(A[i]>A[i+1]) return false;
	}
	return true;
}
bool subsetSum(vector<ll> arr, int n, int s){
	int dp[2][s+1];

	for(int i=0;i<=s;i++){
		dp[0][i] = false;
	}
    dp[0][0] = true;

    int flag = 1;

	for(int i=1;i<=n;i++){
		for(int j =1;j<=s;j++){
			dp[flag][j] = dp[flag^1][j];
			if(j-arr[i-1]>=0){
				dp[flag][j] = dp[flag][j] || dp[flag^1][j-arr[i-1]];
			}
		}
        flag^=1;
	}

 	return dp[flag^1][s];
}
int main() {
	// your code goes here


	int T=1;
	//cin>>T;

	while(T--){
	    // ll n;
			 //cin>>n;
			 ll a;
			 cin>>a;
			 if(a<30) cout<<"No"<<endl;
			 else cout<<"Yes"<<endl;

}
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
//#define minn 999999999
//#define maxx 0
ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
ll modulo(ll a, ll b)
{
    ll r = a % b;
    return r < 0 ? r + b : r;
}
//ncr
ull ncr(ull n, ull r)
{
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    ull ans = 1;
    ull i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
///////////////////////////////////////////////////////
class abc
{
    public:
    ll x;
    ll y;
};
bool fun1(abc xx,abc yy)
{
    return (abs(xx.x) + abs(xx.y) ) < ( abs(yy.x) + abs(yy.y) ) ;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*ll tc;
    cin>>tc;
    while(tc--)
    {}*/
    string s;
    cin>>s;
    if( (s[2]==s[3]) && s[4]==s[5] )
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

void update(vec<int>& v){
    int N = v.size();
    vec<int> imos(N+1);
    for(int i=0;i<N;i++){
        int l = max(i-v[i],0),r = min(i+v[i]+1,N);
        imos[l]++,imos[r]--;
    }
    for(int i=0;i<N;i++) imos[i+1] += imos[i];
//    for(int i=0;i<N;i++) cerr << imos[i] << (i!=N-1? " ":"\n");
    imos.pop_back();
    v = imos;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    vec<int> A(N,0);
    vec<int> imos(N+1);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    int c = 0;
    for(int i=0;i<K;i++){
        c++;
        update(A);
        if(all_of(A.begin(),A.end(),[&](int x){return x==N;})){
            break;
        }
    }
    cerr << c << "\n";
    for(int i=0;i<N;i++) cout << A[i] << (i!=N-1? " ":"\n");
}

Measured memory_bytes: 5784
import heapq

n, m = map(int,input().split())
ab = [[0] * 2 for i in range(n)]
for i in range(n):
    a, b = map(int,input().split())
    ab[i][0], ab[i][1] = a, -1*b
heapq.heapify(ab)

b = [0]
heapq.heapify(b)
ans = 0
for i in range(1, m+1):
    while ab:
        tmp = heapq.heappop(ab)
        if tmp[0] <= i:
            heapq.heappush(b, tmp[1])    
        else:
            heapq.heappush(ab, tmp)
            break
    if b:
        ans -= heapq.heappop(b)
print(ans)

Measured memory_bytes: 24480
from itertools import combinations

h,w,k = map(int,input().split())
mat = [input() for i in range(h)]
r = [0 for i in range(h)]
c = [0 for i in range(w)]
black = 0
for i in range(h):
    for j in range(w):
        if mat[i][j]=="#":
            r[i] += 1
            c[j] += 1
            black += 1

ans = 0
for i in range(h):
    for combr in combinations(range(h),i):
        for j in range(w):
            for combc in combinations(range(w),j):
                temp = 0
                for x in combr:
                    temp += r[x]
                for y in combc:
                    temp += c[y]
                overlap = 0
                for x in combr:
                    for y in combc:
                        if mat[x][y]=="#":
                            overlap += 1
                if black+overlap-temp==k:
                    ans += 1

print(ans)

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

class Program
{
    static void Main(string[] args)
    {
        var jewelryNum = int.Parse(Console.ReadLine());
        List<int> jewelryWorthList = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        List<int> jewelryGetCost = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();

        List<Jewelry> Jewelrys = new List<Jewelry>();
        for (int i = 0; i < jewelryNum; i++)
        {
            Jewelrys.Add(new Jewelry
                { Worth = jewelryWorthList[i],
                  Cost = jewelryGetCost[i],
            });
        }

        Console.WriteLine(Jewelrys.Where( jewelry => jewelry.Profit > 0).Sum(jewelry => jewelry.Profit));
    }

    class Jewelry
    {
        /// <summary>価値</summary>
        public int Worth { get; set; }

        /// <summary>入手するためのコスト</summary>
        public int Cost { get; set; }

        /// <summary>得する値（価値-コスト）</summary>
        public int Profit { get { return Worth - Cost;}}
    }
}


Measured memory_bytes: 13396
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 1e18;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double dbl;
#define pb push_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define all(a) a.begin(),a.end()
bool debug = 0;
const int MAXN = 1e6 + 100;
const int LOG = 20;
const int mod = 1e9 + 7;
const int MX = 1e5 + 100;
typedef long long li;
const li MOD = 1000000000949747713ll;

ll dp[512][512];
int a[512], b[512];

ll pw[512][512];
ll sum_a[512][512];

void solve() {
    int n;
    cin >> n;
    int c;
    cin >> c;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i) {
        cin >> b[i];
    }
    for (int i = 1; i <= 500; ++i) {
        pw[i][0] = 1;
        for (int j = 1; j <= 500; ++j) {
            pw[i][j] = (pw[i][j - 1] * i) % mod;
        }
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= c; ++j) {
            for (int f = a[i]; f <= b[i]; ++f) {
                sum_a[i][j] += pw[f][j];
            }
            sum_a[i][j] %= mod;
        }
    }
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= c; ++j) {
            if (dp[i - 1][j] != 0) {
                for (int k = 0; k + j <= c; ++k) {
                    dp[i][j + k] += dp[i - 1][j] * sum_a[i][k];
                    dp[i][j + k] %= mod;
                }
            }
        }
    }
    cout << dp[n][c] << "\n";

}

signed main() {
#ifdef zxc
    debug = 0;
    freopen("../input.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#else

#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(20);

    int t = 1;
    while (t--)
        solve();
    dout << endl << "time : " << (1.0 * clock() / CLOCKS_PER_SEC) << endl;
}

Measured memory_bytes: 6016
#include <string>
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    string a,b;

    cin >> a >> b;

    string c;

    for (int i = a.length() - 1;i >= 0;i--) c.push_back(a[i]);

    if (b == c) printf("YES\n");
    else printf("NO\n");

    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate

N = int(input())
A = list(map(int,input().split()))
acc = list(accumulate(A))
mod = 10**9+7

ans = 0
for i in range(N-1):
    tmp = acc[-1] - acc[i]
    ans += (A[i]*tmp)%mod
    ans %= mod
print(ans)

Measured memory_bytes: 31200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int main(){
    int N;
    string s, t;
    cin >> N >> s >> t;
    int dup = 0;
    rng(i,1,N+1){
        if(s.substr(N-i,i) == t.substr(0,i)){
            dup = i;
        }
    }
    cout << 2 * N - dup << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

string str;
char res[8][5];

string conv[10] = {
  "* = ****",
  "* =* ***",
  "* =** **",
  "* =*** *",
  "* =**** ",
  " *= ****",
  " *=* ***",
  " *=** **",
  " *=*** *",
  " *=**** "
};

int main() {
  bool start = true;
  while (cin >> str) {
    if (!start) cout << endl;
    while (str.size() < 5) str = "0" + str;
    for (int i = 0; i < 5; ++i) {
      int j = str[i] - '0';
      for (int k = 0; k < conv[j].size(); ++k) {
	res[k][i] = conv[j][k];
      }
    }
    for (int i = 0; i < 8; ++i) {
      for (int j = 0; j < 5; ++j) {
	cout << res[i][j];
      }
      cout << endl;
    }
    start = false;
  }
}


Measured memory_bytes: 1188
A = int(input())
def getIJ(A):
  for i in reversed(range(1, int(A**0.5)+1)):
    if A % i == 0:
      return (i, A//i)
  return (0, 0)
def calc(A):
  i, j = getIJ(A)
  return i + j - 2
print(calc(A))

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

static const int MMAX = 20;
static const int NMAX = 50000;
static const int INFTY = (1 << 29);


int main()
{
    int n, m;
    int C[MMAX + 1];
    int T[NMAX + 1];

    std::scanf("%d %d", &n, &m);

    for (int i = 1; i <= m; i++) std::scanf("%d", &C[i]);

    for (int i = 0; i <= NMAX; i++) T[i] = INFTY;
    T[0] = 0;

    for (int i = 1; i <=m; i++) {
        for (int j = 0; j + C[i] <= n; j++) {
            T[j + C[i]] = std::min(T[j + C[i]], T[j] + 1);
        }
    }

    std::printf("%d\n", T[n]);

    return 0;
}



Measured memory_bytes: 3404
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  string s,t;
  cin >> s >> t;
  cout << t+s << endl;
}

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


Measured memory_bytes: 256
n = gets.to_i
as = gets.split.map &:to_i
MOD = 10 ** 9 + 7

lcm_sum = as[0]

as[1..-1].each{ |a|
	lcm_sum = lcm_sum.lcm(a)
}

output = 0

as.each{ |a|
	output += (lcm_sum / a) % MOD
}

puts output % MOD

Measured memory_bytes: 61060
object Main extends App {
  val amount = Array(500,100,50)
  val in = Iterator.continually(io.StdIn.readLine.toInt)
    .take(4).toArray

  val ans = {
      for {
        i <- 0 to in(0)
        if amount(0)*i <= in(3)
        j <- 0 to in(1)
        if amount(0)*i + amount(1)*j <= in(3)
        k <- 0 to in(2)
        if amount(0)*i + amount(1)*j + amount(2)*k == in(3)
      } yield  true
    }.size

  println(ans)
}

Measured memory_bytes: 26076
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>
#include <bitset>
#include <string.h>
// #include <limits.h>

#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long        ll;
typedef unsigned long long    ull;

#define INTMAX  99999999

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

#define MAX_N (100000)
#define MAX_A (1000*1000*1000)
#define MAX_T (1000*1000*1000)

int N;
int T;
int A[MAX_N];
// int diffcount[MAX_A];

typedef multimap<int,pair<int,int>, greater<int> > DiffPairMap;

DiffPairMap diffpair_map;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	int mina = MAX_A;
	vector<int> mini_vec;

	cin >> N >> T;
	FOR(n,N) {
		cin >> A[n];
		if (A[n]-mina>0) {
			// diffcount[A[n]-mina]++;
			vector<int>::iterator it = mini_vec.begin();
			for(;it!=mini_vec.end();it++) {
				diffpair_map.insert(MP(A[n]-mina, MP(*it,n)));
			}
		}
		else {
			if (mina>=A[n]) {
				mina = A[n];
				mini_vec.clear();
				mini_vec.push_back(n);
			}
			else {
				mini_vec.push_back(n);
			}
		}
	}

	DiffPairMap::iterator it = diffpair_map.begin();
	int maxkey = it->first;
	int maxcount = diffpair_map.count(maxkey);

	// DOUT << maxkey << endl;
	// DOUT << maxcount << endl;
	cout << maxcount << endl;

	return 0;
}
 


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

int main() {
  string s;
  while(getline(cin, s)) {
    if(s[0] == '0') break;
    vector<int> card;
    int one = 0;
    for(int i = 0; i < s.size(); i++) {
      if('0' <= s[i] && s[i] <= '9') {
        if(i+1 != s.size() && '0' <= s[i+1] && s[i+1] <= '3') {
          card.push_back((s[i]-'0')*10 + (s[i+1]-'0'));
          i++;
        } else {
          card.push_back(s[i]-'0');
        }
        if(i > 0 && s[i-1] == ' ' && s[i] == '1') one++;
        else if(i == 0 && s[i+1] == ' ' && s[i] == '1') one++;
      }
    }
    sort(card.begin(), card.end(), greater<int>());

    int ans = 0;
    for(int i = 0; i < card.size(); i++) {
      if(card[i] != 1) {
        if(card[i] > 10) ans += 10;
        else ans += card[i];
      } else {
        if(ans+10+one <= 21) ans += 11;
        else ans += 1;
        one--;
      }
    }
    if(ans > 21) ans = 0;
    cout << ans << endl;
  }
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
typedef long long ll;
#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 FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int> >
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int> >
#define VPII vector<pair<int,int> >

#define INT ll

using namespace std;
/*........................................Define functions.........................................*/


/*....................................Define global variables .....................................*/



/*.........................................kemkemG0................................................*/
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);


	int N, D;
	cin >> N >> D;
	VVI v(N, VI(D));
	REP(i, N)REP(j, D) {
		cin >>v[i][j];
	}
	int ans=0;
	FOR(i,0,N-2)FOR(j,i+1,N-1){
		int dd=0;
		REP(k,D){dd+= (v[i][k]-v[j][k])*(v[i][k]-v[j][k]); }

		int dint=sqrt(dd);
		if(dint==sqrt(dd))ans++;
	}
	cout<<ans<<endl;






	return 0;
}





Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;
const double pi=acos(-1.0);

signed main(){
    char A,B,C,D,E,F,G,H,I;cin>>A>>B>>C>>D>>E>>F>>G>>H>>I;
    cout<<A<<E<<I<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    string S;

    cin >> S;

    cout << S.substr(0,3) << endl; 

    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void) {
	int a[5];
	int i, j;
	int swap;
	scanf("%d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4]);
	for (i = 4; i > 0; i--)
		for (j = 0; j < i; j++)
			if( a[j] < a[j+1]) {
				swap = a[j];
				a[j] = a[j+1];
				a[j + 1] = swap;
			}
	printf("%d %d %d %d %d\n", a[0], a[1], a[2], a[3], a[4]);
	return 0;
}

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

int main() {
  string w;
  cin >> w;
  string nomal="abcdefghijklmnopqrstuvwxyz";
  for (int i=0 ;i<nomal.size();i++) {
    int ans=0;
    for (int j=0 ; j < w.size(); j++) {
      if (nomal.at(i)==w.at(j)){
        ans++;
      }
    }
    if (ans % 2 != 0) {
      cout << "No" << endl;
      break;
    }
    if (i==nomal.size()-1){
      cout << "Yes" << endl;
    }
  } 
}


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

int main() {
  int x;
  cin >> x;
  int s;
  
  if(x>=400 && x<600){
    s=8;
  }else if(x>=600 && x<800){
    s=7;
  }else if(x>=800 && x<1000){
    s=6;
  }else if(x>=1000 && x<1200){
    s=5;
  }else if(x>=1200 && x<1400){
    s=4;
  }else if(x>=1400 && x<1600){
    s=3;
  }else if(x>=1600 && x<1800){
    s=2;
  }else if(x>=1800 && x<2000){
    s=1;
  }
  
  cout << s << endl;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REP(i, n) for(ll i = 1; i < (ll)(n); i++)
typedef long long ll;
const ll mod = 1e9+7;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

//繰り返し自乗法によるmod累乗計算
//a = 底、　n = 指数
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//nCa 
ll comb(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}


int main(){
  int n;
  cin >> n;
  if(n == 25) cout << "Christmas" << endl;
  else if(n == 24) cout << "Christmas Eve" << endl;
  else if(n == 23) cout << "Christmas Eve Eve" << endl;
  else if(n == 22) cout << "Christmas Eve Eve Eve" << endl;
}






Measured memory_bytes: 256
import math

if __name__ == "__main__":
    D, G = map(int, input().split())
    p_c_l = [list(map(int, input().split())) for _ in range(D)]
    _min = sum([p_c[0] for p_c in p_c_l])
    for i in range(2 ** D):
        count = 0
        total = 0
        bins = '{:0={}b}'.format(i, D)
        incomplete_index = int(bins.rfind('0'))
        for index, _bin in enumerate(bins):
            if _bin == '0':
                continue
            total += 100 * (index + 1) * p_c_l[index][0] + p_c_l[index][1]
            count += p_c_l[index][0]
        if incomplete_index == -1:
            break
        remaining = G - total
        if remaining <= 0:
            if count < _min:
                _min = count
            continue
        incomplete_p = 100 * (incomplete_index + 1)
        incomplete_ans_num = math.ceil(remaining / incomplete_p)
        incomplete_p_num = p_c_l[incomplete_index][0]
        if incomplete_ans_num >= incomplete_p_num:
            continue
        count += incomplete_ans_num
        if count < _min:
            _min = count

    print(_min)


Measured memory_bytes: 74464
from collections import Counter, defaultdict as dd
N = int(input())
Es = dd(dict)
ct = Counter()
for i in range(2, N+1):
    a = int(input())
    ct[a] += 1
    Es[a][i] = 1

q = [1]
visited = [False] * (N+1)
anss = [None] * (N+1)
while q:
    node = q[-1]
    if not visited[node]:
        visited[node] = True
        if node not in Es:
            anss[node] = 0
            q.pop()
        else:
            for to in Es[node].keys():
                q.append(to)

    else:
        q.pop()
        maxDiff = 0
        for a, b in zip(range(ct[node]), sorted([anss[to] for to in Es[node].keys()])):
            diff = b - a
            maxDiff = maxDiff if maxDiff > diff else diff
        anss[node] = ct[node] + maxDiff

print(anss[1])


Measured memory_bytes: 54868
#include <bits/stdc++.h>
using namespace std;
#define MAX 100

int table[MAX][MAX];
int csum[MAX];

int main(){
	int r, c;
	
	cin >> r >> c;
	
	for(int i=0; i<r; i++){
		int sum = 0;
		for(int j=0; j<c; j++){
			int cell;
			cin >> cell;
			sum += cell;
			csum[j] += cell;
			cout << cell << " ";
		}
		cout << sum << "\n";
	}
	
	int sum = 0;
	for(int j=0; j<c; j++){
		cout << csum[j] << " ";
		sum += csum[j];
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3104
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	void run() {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int n = sc.nextInt();
			a = a%b;
			int ans = 0;
			for(int i=0;i<n;i++) {
				a *= 10;
				ans += a/b;
				a = a%b;
			}
			System.out.println(ans);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(void){
    int n, t, a;
    int h[1000];
    double g[1000];
    double min = 10000000;
    int idx;

    cin >> n;
    cin >> t >> a;

    for(int i = 0; i < n; i++){
        cin >> h[i];
    }

    for(int i = 0; i < n; i++){
        g[i] = (double)(t - h[i] * 0.006);
    }

    for(int i = 0; i < n; i++){
        if(fabs((double)a - g[i]) < min){
            idx = i;
            min = fabs((double)a - g[i]);
        }
    }

    cout << idx+1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n, w;
	cin >> n >> w;

	vector<pair<int, int>> all;

	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;

		all.push_back({ a,b });
	}

	//dp[i][j] stores weight

	vector<int> fill(1000001, 99999999999LL);
	vector<vector<int>> dp(n + 1, fill);

	fill.clear();
	for (int i = 0; i <= n; i++)
	{
		dp[i][0] = 0;
	}

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j < all[i - 1].second; j++)
		{
			dp[i][j] = dp[i - 1][j];
		}
		for (int j = all[i - 1].second; j < 1000001; j++)
		{
			if (dp[i - 1][j - all[i - 1].second] + all[i - 1].first > w)
			{
				dp[i][j] = dp[i - 1][j];
				continue;
			}
			else
			{
				dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - all[i - 1].second] + all[i - 1].first);
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < 1000001; i++)
	{
		if (dp[n][i] != 99999999999LL)
		{
			ans = i;
		}
	}
	cout << ans << "\n";

}


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


void solve(long long X, long long t){
    cout << max(0LL, X-t) << endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long t;
    scanf("%lld",&t);
    solve(X, t);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
tmp = ""
for letter in S:
    if tmp == "":
        tmp += letter
    elif letter == ")" and tmp[-1] == "(":
        tmp = tmp[:-1]
    else:
        tmp += letter

head = "(" * tmp.count(")")
tail = ")" * tmp.count("(")
print(head + S + tail)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<assert.h>

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=310;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

namespace io {
	const int L=(1<<21)+1;
	char ibuf[L],*iS,*iT,obuf[L],*oS=obuf,*oT=obuf+L-1,c,st[55];int f,tp;
#define gc() (iS==iT?(iT=(iS=ibuf)+fread(ibuf,1,L,stdin),(iS==iT?EOF:*iS++)):*iS++)
	inline void flush() {
		fwrite(obuf,1,oS-obuf,stdout);
		oS=obuf;
	}
	inline void putc(char x) { *oS++=x; if (oS==oT) flush(); }
	template<class I> inline void gi(I&x) {
		for (f=1,c=gc();c<'0'||c>'9';c=gc()) if (c=='-') f=-1;
		for (x=0;c<='9'&&c>='0';c=gc()) x=x*10+(c&15); x*=f;
	}
	template<class I> inline void print(I x) {
		if (!x) putc('0');
		if (x<0) putc('-'),x=-x;
		while (x) st[++tp]=x%10+'0',x/=10;
		while (tp) putc(st[tp--]);
	}
	inline void gs(char*s, int&l) {
		for (c=gc();c<'a'||c>'z';c=gc());
		for (l=0;c<='z'&&c>='a';c=gc()) s[l++]=c;
		s[l]=0;
	}
	inline void ps(const char*s) { for (int i=0,n=strlen(s);i<n;i++) putc(s[i]); }
	struct IOFLUSHER{ ~IOFLUSHER() { flush(); } } _ioflusher_;
};
using io::putc;
using io::gi;
using io::gs;
using io::ps;
using io::print;

int C[N][N];
int f[N][N],g[N][N];
int main()
{
	int n,m,mod,i,j,k;
	gi(n),gi(m),gi(mod);
	for (i=0;i<=n;i++)
		for (j=C[i][0]=1;j<=i;j++)
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;

	for (k=1;k<=m;k++)
		f[1][k]=g[1][k]=m-k+1;
	for (i=2;i<=n;i++) {
		for (k=m-1;k;k--)
			f[i][k]=(g[i-1][k+1]+f[i][k+1])%mod;
		for (k=1;k<=m;k++) {
			g[i][k]=f[i][k];
			for (j=1;j<i;j++)
				g[i][k]=(g[i][k]+1LL*f[j][k]*g[i-j][k]%mod*C[i-1][j-1])%mod;
		}
	}
	
	print(g[n][1]%mod);
	return 0;
}


Measured memory_bytes: 3456
N = int(input())
A = [int(i) for i in input().split()]
A.reverse()
L = [1] * N
q = []
i = 0
ans = []
def kousin(i):
  ans.append(A[i])
  if q:
    for u in q:
      if u < i:
        L[u] += 1
        if A[u] == L[u]:
          kousin(u)
while i < N:
  if A[i] != L[i]:
    q.append(i)
  else:
    kousin(i)
  i += 1
if len(ans) == N:
  for i in ans:
    print(i)
else:
  print(-1)
  

Measured memory_bytes: 40300
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
int main(){
	/*
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll sum=0;
	for(int i=n-1;i>=0;i--){
		if(i%2==0) sum+=a[i];
		else sum-=a[i];
	}
	cout<<sum<<" ";
	for(int i=0;i<n-1;i++){
		ll g=2*a[i]-sum;
		cout<<g<<" ";
		sum=g;
	}
}


Measured memory_bytes: 2176
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)
ll N;
string s;
ll I,IO,IOI,IOIO;

int main()
{
	cin>>N;
	cin>>s;
	rep(i,N){
		if(s[i]=='J'){
			I++;
		}
		else if(s[i]=='O'){
			if(I>0){
				I--;
				IO++;
			}
			else if(IOI>0){
				IOI--;
				IOIO++;
			}
		}
		else{
			if(IO>0){
				IO--;
				IOI++;
			}
			else if(IOIO>0){
				IOIO--;
				IOI++;
				IO++;
			}
			else I++;
		}
	}
	cout<<IOIO+IOI<<endl;
}

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

int main(){
  int r, g, b, i;
  
  cin >> r >> g >> b;
  
  i = r * 100 + g * 10 + b;
  
  if(i % 4 == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n,k = gets.chomp.split.map(&:to_i)
s = Set.new

n -= (n / k) * k
ans = n
until s.include? n
  s.add n
  n = (n-k).abs
  ans = n if ans > n
end

puts ans

Measured memory_bytes: 2172