akhauriyash/Code-Regression huggingface dataset:
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    deque<char> cq;
    string s;
    cin >> s;
    REP(i, s.length()) cq.push_back(s[i]);
    int q = nxt();
    bool reverse = false;
    REP(i, q){
        int a = nxt();
        if(a == 1){
            reverse = !reverse;
        }
        else{
            int f;
            char c;
            cin >> f >> c;
            if(reverse) f = 3 - f;
            if(f==1) cq.push_front(c);
            else cq.push_back(c);
        }
    }
    if(!reverse){
while(!cq.empty()){
        cout << cq.front();
        cq.pop_front();
    }
    }
    else{
while(!cq.empty()){
        cout << cq.back();
        cq.pop_back();
    }
    }
    
    return 0;
}



Measured memory_bytes: 896
#!/usr/bin/ruby
while l=gets.chomp do
	if l=='' then next end
	if l[0..0]=='-' then break end
	a=l.to_f*16;
	if a==0 then raise 'zero' end
	puts a!=(a=a.to_i)||a>4095?'NA':sprintf('%08b.%04b',a/16,a%16)
end

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

int main() {
    vector<int> n(3);
    for (int i = 0; i < 3; i++) {
        cin >> n[i];
    }
    sort(n.begin(),n.end());
    cout << n[0] << " " << n[1] << " " << n[2] << endl;
}



Measured memory_bytes: 3152
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const ll INF = LLONG_MAX;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];
  ll ans = INF;

  rep(sx, n)rep(sy, n)rep(i, n) rep(j, n) {
    ll cnt = 0;
    ll startx = x[sx], starty = y[sy];
    ll endx = x[i], endy = y[j];
    rep(k, n) {
      ll nx = x[k], ny = y[k];
      if(startx <= nx && nx <= endx && starty <= ny && ny <= endy) cnt++;
    }
    if (cnt >= k) chmin(ans, (endx - startx) * (endy - starty));

  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
const ll longINF = 3e18;
const double eps = 1e-8;
const double dinf = 190.0;
const double pi = acos(-1);
const int INF = 2e9 +  1;

int n, h, w, c[105][105],a [10005];

pair <int,int> next(int x, int y) {
        if (y & 1) {
                if (x - 1 >= 0)
                        return {x - 1, y};
                else
                        return {x, y + 1};
        }
        else {
                if (x + 1 < h)
                        return {x + 1, y};
                else
                        return {x, y + 1};
        }
}           
        
int main() 
{        
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);                     
        //freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
        cin >> h >> w >> n;
        int x = 0, y = 0;
        for (int i = 1; i <= n; i++) {
                cin >> a[i];
                for (int j = 0; j < a[i]; j++) {
                        c[x][y]  = i;
                        auto p = next(x, y);
                        x = p.first;
                        y = p.second;
                }
        }
        for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                        cout << c[i][j] << " ";
                }
                cout << '\n';
        }
        return 0;

}

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

int n,w,wei[109],v[109],dp[100004][104];
signed main(){
    cin>>n>>w;
    for (int i=0; i<n; i++) {
        cin>>wei[i]>>v[i];
    }
    
    for (int i=0;i<=w; i++) {
        for (int j=0; j<n; j++) {
            if (wei[j]<=i) {
                
                dp[i][j+1]=max(dp[i][j+1],dp[i-wei[j]][j]+v[j]);

            }
           dp[i][j+1]=max(dp[i][j],dp[i][j+1]);
        }
    }
    cout<<dp[w][n]<<endl;
}

Measured memory_bytes: 81536
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n,h[100005],dp[100005]={};
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>h[i];
  }
  dp[1]=0;
  for(int i=2;i<=n;i++){
    if(i!=2)
    dp[i]=min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1]);
    else
      dp[i]=abs(h[i]-h[i-1])+dp[i-1];
  }
  cout<<dp[n]<<'\n';
  return(0);
}


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

int main() {
  int N,M;
  cin >> N >> M;
  
  int sum = 0;
  vector<int> A(M);
  for (int i=0; i<M; i++) {
    cin >> A.at(i);
    sum += A.at(i);
  }
  
  if (sum <= N) {
    cout << N-sum << endl;
  }
  else {
    cout << "-1" << endl;
  }
  
}

Measured memory_bytes: 3668
# -*- coding: utf-8 -*-
import sys

def assignColor():
    for i in range(n):
        if C[i] == -1:
            DFS(i)

#@profile
def DFS(start):
    S = [start]
    C[start] = start
    while len(S) != 0:
        u = S.pop(0)
        for i in adj_list[u]:
            if C[i] == -1:
                C[i] = start
                S.append(i)

if __name__ == "__main__":
    _input = sys.stdin.readlines()
    n, m = list(map(int, _input[0].split()))
    adj_list = [[] for i in range(n)]
    C = [-1] * n
    
    for i in range(m):
        s, t = list(map(int, _input[i+1].split()))
        adj_list[s].append(t)
        adj_list[t].append(s)
    assignColor()
    q = int(_input[m+1])
    for i in range(q):
        s, t = list(map(int, _input[m+i+2].split()))
        if C[s] == C[t]:
            print("yes")
        else:
            print("no")
            

Measured memory_bytes: 41080
#include <bits/stdc++.h>
using namespace std;
using lint = long;
using ll = long long;
#define rep(i,n) for(lint (i) = 0;(i) < (lint)(n);(i)++)
#define repInRange(i,start,end) for(lint (i) = (start);(i) < (end);++(i))
using lpair = pair<lint,lint>;
using Vecint = vector<lint>;
using Llist = list<lint>;

ll pow(ll k,ll l) {
	ll ret = 1;
	rep(i,l) {
		ret *= k;
	}
	return ret;
}

template <typename T>
T sum(vector<T> vec) {
	ll ret = 0;
	rep(i,vec.size()) {
		ret += vec.at(i);
	}
	return ret;
}

void Main() {
	ll h,w,ans;
	cin >> h >> w;
	if (h == 1 || w == 1) {
		cout << 1 << '\n';
		return;
	}
	cout << (h*w)/2 + (h*w)%2 << '\n';
}

signed main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	Main();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
string S, T, U; cin >> S; int N=S.size(), i;
T=string(N, '0'); U=string(N, '0');
for(i=0; i<N; i++){ if(i%2){ T[i]='1'; }else{ U[i]='1'; } }
int a=0, b=0, ans;
for(i=0; i<N; i++){
  if(S[i]!=T[i]){ a++; }
  if(S[i]!=U[i]){ b++; }
} 
ans=min(a, b);
cout << ans << "\n";
}

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

#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i, n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i, a, b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000005
using namespace std;
vector<int> list_factor(MAXX + 1);

void solve() {
    list_factor[1] = 1;
    for (int i = 2; i <= MAXX; i++) {
        if (!list_factor[i]) {
            list_factor[i] = i;
            for (int j = 2 * i; j <= MAXX; j += i) if (list_factor[j] == 0) list_factor[j] = i;
        }
    }
}

int gcd(int a, int b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

void trozen() {
    solve();
    int n;
    cin >> n;
    vector<int> v1(MAXX + 1);
    vector<int> arr(n);
    bool flag = true;
    int temp;
    rep(i, n) {
        cin >> temp;
        arr[i] = temp;
        int div = list_factor[temp];
        while (temp > 1) {
            while (temp % div == 0) {
                temp = temp / div;
            }
            if (v1[div] > 0)flag = false;
            else v1[div]++;
            div = list_factor[temp];
        }
    }
    if (flag) {
        cout << "pairwise coprime" << endl;
        return;
    }
    int result = arr[0];
    for (int i = 1; i < n; i++) {
        result = gcd(arr[i], result);
        if (result == 1) {
            cout << "setwise coprime" << endl;
            return;
        }
    }
    cout << "not coprime" << endl;
}

int32_t main() {
    op1;
    op2;
    op3;
    trozen();
    return 0;
}

Measured memory_bytes: 26636
#include <cstdio>

typedef long long LL;

int N, A, B;

int main() {
	scanf("%d%d%d", &N, &A, &B);
	if (A > B) return puts("0"), 0;
	if (N == 1) return printf("%d\n", A == B), 0;
	printf("%lld\n", (LL)B * (N - 2) - (LL)A * (N - 2) + 1);
	return 0;
}

Measured memory_bytes: 1736
<?php
  $x = trim(fgets(STDIN));
  for($i=2; $i<=$x; $i++){
    if($x%$i == 0){
      if($i==$x){
        echo $x."\n";
        exit;
      }else{
        $x++;
        $i = 2;
        continue;
      }
    }
  }

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

int main(){
    int m,d;
    cin >> m >> d;
    int count = 0;
    for(int i = 1; i <= m; i++){
        for(int j = 10; j <= d; j++){
            if(j%10 < 2 || j/10 < 2 ){continue;}
            int d1 = j - (j/10)*10;
            int d10 = j/10;
            if(d1*d10 == i) count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.lang.Math;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		String S = reader.next()+"E";
		solver(S);
	}
	
	public static void solver(String S) {
		// write logic
		int len = S.length();
		int begin = 0;
		int end = 0;
		int[] ans = new int[len+1];
		for(int i=1; i<len; i++) {
		    if(S.charAt(i-1) == S.charAt(i)) continue;
		    else {
	            end = i-1;
		        if(S.charAt(i-1) == 'R') {
		            // R -> L
		            double seq = end - begin + 1;
		            ans[i-1] += (int)Math.ceil(seq/2.0);
		            ans[i] += (int)(seq - Math.ceil(seq/2.0));
		        } else {
		            // L -> R
		            double seq = end - begin + 1;
		            ans[begin-1] += (int)(seq - Math.ceil(seq/2.0));
		            ans[begin] += (int)Math.ceil(seq/2.0);
		        }
	            begin = i;
		    }
		}
		for(int i=0; i<len-1; i++) {
		    System.out.print(ans[i]);
		    if(i != len-2) System.out.print(" ");
		}
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 45128
#include <bits/stdc++.h>
using namespace std;
     
int main(){
 double A,B;
 cin >> A >> B;
 string ans="EQUAL";

 if(A>B){
 ans="GREATER";
 }else if(A<B){
 ans="LESS";
 }

 cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define NDEBUG

#ifdef NDEBUG
#define DEBUG_PRINT(fmt, ...) ((void)0)
#else
#define DEBUG_PRINT(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
#endif
#define ASSERT_RANGE(min,x,max) assert(((x)>=(min)) && ((x)<=(max)))


#define N_MIN 1
#define N_MAX 200000
#define A_MIN 1
#define A_MAX 1000000
#define K_MIN 0
#define K_MAX 1000000000000000000

int sort_int(int *a, int N) {// {{{
	int i;
	for (i = 0; i < N-1; i++) {
		int j;
		for (j = i + 1; j < N; j++) {
			if (a[i] > a[j]) {
				int tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
	return 0;
}// }}}
void merge_int(int *a, int *b, int lower, int sep, int upper) {// {{{
	int i_lower = lower;
	int i_upper = sep;
	int i_b = 0;
	while ((i_lower < sep) && (i_upper < upper)) {
		if (a[i_lower] < a[i_upper]) {
			b[i_b++] = a[i_lower++];
		} else {
			b[i_b++] = a[i_upper++];
		}
	}
	if (i_lower >= sep) {
		while (i_upper < upper) {
			b[i_b++] = a[i_upper++];
		}
	} else {
		while (i_lower < sep) {
			b[i_b++] = a[i_lower++];
		}
	}
	for (i_lower = 0; i_lower < i_b; i_lower++) {
		a[i_lower+lower] = b[i_lower];
	}
}// }}}
void merge_sort_int(int *a, int *b, int lower, int upper) {// {{{
	int sep;
	if ((lower == upper) || (lower + 1 == upper)) {
		return;
	}
	sep = (lower + upper) / 2;
	merge_sort_int(a,b,lower,sep);
	merge_sort_int(a,b,sep,upper);
	merge_int(a,b,lower,sep,upper);
}// }}}

int main(int argc, char **argv) {
	int N;
	long long K;
	int A[A_MAX];
	int F[A_MAX];
	long long maxAF = (long long)A_MAX*(long long)A_MAX;

	long long sumA = 0;
	int i;
	int x;

	fscanf(stdin,"%d%lld",&N,&K);
	for (i = 0; i < N; i++) {
		fscanf(stdin, "%d",&x);
		A[i] = x;
		sumA += x;
	}
	for (i = 0; i < N; i++) {
		fscanf(stdin, "%d",&x);
		F[i] = x;
	}

	sumA -= K;
	if (sumA <= 0) {
		fprintf(stdout,"0\n");
		return 0;
	}
	{
		int tmp[N];
		merge_sort_int(A,tmp,0,N);
		merge_sort_int(F,tmp,0,N);
	}

	{
		long long target_upper = maxAF;
		long long target_lower = 0;

		while (target_upper - target_lower > 1) {
			long long target = (target_upper + target_lower) / 2;
			long long cost = 0;
			for (i = 0; i < N; i++) {
				long long cur_target = target/(long long)F[N-1-i];
				if (A[i] > cur_target) {
					cost += (long long)A[i] - cur_target;
				}
				DEBUG_PRINT("%lld %d ",cur_target,A[i]);
				if (cost > K) {
					target_lower = target;
					break;
				}
			}
			DEBUG_PRINT("\n");
			if (cost > K) {
				target_lower = target;
			} else {
				target_upper = target;
			}
			DEBUG_PRINT("%lld,%lld,%lld\n",cost,target_lower,target_upper);
		}
		fprintf(stdout,"%lld\n",target_upper);
	}
	return 0;
}



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

int main(int argc, char const *argv[])
{
	int c[3][3];
	for (int i = 0; i < 3; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			cin>>c[i][j];
		}
	}
	int a[3],b[3];
	for (a[0] = 0; a[0] <= 100; ++a[0])
	{
		for (a[1] = 0; a[1] <= 100; ++a[1])
		{
			for (a[2] = 0; a[2] <= 100; ++a[2])
			{
				for (int i = 0; i < 3; ++i)
				{
					b[i]=c[0][i]-a[0];
				}
				if (b[0]<0||b[1]<0||b[2]<0)
				{
					continue;
				}
				int f=1;
				for (int i = 0; i < 3; ++i)
				{
					for (int j = 0; j < 3; ++j)
					{
						if (c[i][j]!=a[i]+b[j])
						{
							f=0;
						}
					}
				}
				if (f)
				{
					cout<<"Yes\n";
					return 0;
				}
			}
		}
	}
	cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var AB = ReadLine().Split().Select(int.Parse).ToArray();
        var A = AB[0];
        var B = AB[1];
        if (A >= 13) WriteLine(B);
        else if (A >= 6) WriteLine(B / 2);
        else WriteLine(0);
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
using namespace std;
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;




int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	ll i,n;
	ll m=LLINF;
	ll sum=0;
	cin>>n;
	vector<ll> v(n,0);
	int minus=0;
	rep(i,n){
		cin>>v[i];
		if(v[i]<0)minus++;
		if(m>abs(v[i]))m=abs(v[i]);
		sum+=abs(v[i]);
	}
	if(minus%2==0){
		cout<<sum<<endl;
	}
	else cout<<sum-2*m<<endl;
	
	
//	cout<<sum<<" "<<m<<endl;
	
	
//////////////////////////////////////////////////////
	return 0;
}








Measured memory_bytes: 1024
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define N 500005
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
using namespace std;
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,k,f[N][27],g[N][21],a[N],x,y;
char str[N];
void pre(){
	F(i,1,n+2){
		F(j,0,26) f[i][j]=n+2;
		F(j,0,20) g[i][j]=n+2;
	}
	D(i,n,1){
		f[i][a[i]]=i+1;
		F(j,a[i]+1,26) f[i][j]=f[f[i][j-1]][j-1];
		g[i][0]=f[i][26];
		F(j,1,20) g[i][j]=g[g[i][j-1]][j-1];
		F(j,0,25) if (f[i][j]==n+2) f[i][j]=f[g[i][0]][j];
	}
}
bool solve(int x,int y){
	D(i,20,0){
		if (g[x][i]==y+1) return 1;
		if (g[x][i]<y) x=g[x][i];
	}
	return 0;
}
signed main(){
// 	freopen("fusion.in","r",stdin);
// 	freopen("fusion.out","w",stdout);
	scanf("%s",str+1);
	n=strlen(str+1);
	F(i,1,n) a[i]=str[i]-'a';
	pre();
	m=read();
	F(i,1,m){
		x=read();y=read();
		if (solve(x,y)) puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 96768
def main():
    *S, = input()
    count = 0
    maximum = 0
    for i in S:
        if i == "A" or i == "C" or i == "G" or i == "T":
            count += 1
        else:
            if maximum < count:
                maximum = count
            count = 0
    print(max(count, maximum))
main()

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

typedef long long LL;
typedef vector<int> VI;

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> pairs(n);
  int a, b;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    pairs[i] = make_pair(a, b);
  }
  sort(pairs.begin(), pairs.end(), [](pair<int, int> &x, pair<int, int> &y) {
                                     if (x.second == y.second) {
                                       return x.first > y.first;
                                     }
                                     return y.second < x.second;
                           });
  vector<int> rest(m);
  int ans = 0;
  for (int i = 0; i < m; i++) {
    rest[i] = i;
  }
  for (int i = 0; i < n; i++) {
    auto p = pairs[i];
    if (p.first > m) {
      continue;
    }
    //cout << m-p.first << endl;
    if (binary_search(rest.begin(), rest.end(), m-p.first)) {
      auto it = lower_bound(rest.begin(), rest.end(), m-p.first);
      rest.erase(it);
    } else {
      if (rest.size() == 0)
        continue;
      auto it = lower_bound(rest.begin(), rest.end(), m-p.first);
      if (it == rest.begin())
        continue;
      if (*(it-1) >= 0)
        rest.erase((it-1));
    }
    ans += p.second;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
import sys
sys.setrecursionlimit(200002)

def try_dfs_fill_distance(graph, cur_node, cur_dist_from_origin, distance_cache):
    found_conflicts = False
    for neighbor_node_data in graph[cur_node]:
        neighbor_node, neighbor_distance_from_cur = neighbor_node_data
        neighbor_dist_from_origin = (cur_dist_from_origin + neighbor_distance_from_cur)
        #print("cur_node:{} neighbor_node:{} neighbor_dist:{} origin to {}:{}".format(cur_node, neighbor_node, neighbor_distance_from_cur, neighbor_node, neighbor_dist_from_origin))
        if distance_cache[neighbor_node] == None:
            distance_cache[neighbor_node] = neighbor_dist_from_origin
            found_conflicts = try_dfs_fill_distance(graph, neighbor_node, neighbor_dist_from_origin, distance_cache)
        else:
            if distance_cache[neighbor_node] != neighbor_dist_from_origin:
                #print("{} {} {}".format((distance_cache[neighbor_node] == None), distance_cache[neighbor_node], neighbor_dist_from_origin))
                found_conflicts = True

        if found_conflicts:
            break

    return found_conflicts

if __name__ == '__main__':
    n, m = list(map(int, input().split(" ")))
    graph = [[] for _ in range(n + 1)]
    for _ in range(m):
        l, r, d = list(map(int, input().split()))
        graph[l].append((r, d))
        graph[r].append((l, -d))

    distance_cache = [None for _ in range(n + 1)]
    has_conflict = False
    for i in range(1, len(distance_cache)):
        if distance_cache[i] == None:
            distance_cache[i] = 0
            has_conflict = try_dfs_fill_distance(graph, i, 0, distance_cache)
            if has_conflict:
                break

    print("No" if has_conflict else "Yes")


Measured memory_bytes: 134636
N,K = (int(T) for T in input().split())
Reminder = [0]*K
for NT in range(1,N+1):
    Reminder[NT%K] += 1
Count = 0
for RA in range(0,K):
    RB = (K-RA)%K
    RC = (K-RA)%K
    if (RB+RC)%K==0:
        Count += Reminder[RA]*Reminder[RB]*Reminder[RC]
print(Count)

Measured memory_bytes: 10292
#include "bits/stdc++.h"
using namespace std;
#define F first
#define S second
#define show(x) cout<<#x<<" "<<x<<" ";
#define f(i,j,k) for(int i = j;i<=k;i++)
#define fr(i,j,k) for(int i = j;i>=k;i--)
#define ll long long
#define all(A)  A.begin(),A.end()  
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);  
const int MSIZE = 1e2+5;
const int MOD = 1e9+7;

int wts[MSIZE];
int vals[MSIZE];

ll dp[MSIZE][(int)1e5+5];

const ll inf = 1e18+7;

ll ks(int n,int v) {
    if(v==0)    return 0;
    if(n==0)    return inf;
    if(dp[n][v]!=-1)    return dp[n][v];

    return dp[n][v] = min(v>=vals[n]?(wts[n]+ks(n-1,v-vals[n])):inf,
                ks(n-1,v));

}

int main(){
    FIO
    int N, W; cin>>N>>W;


    f(i,1,N)  cin>>wts[i]>>vals[i];

    int vmax = N*1e3;
    //Top Down
    memset(dp,-1,sizeof(dp));
    int ans = 0;
    f(i,1,vmax) 
        if(ks(N,i)<=W) ans = i;
    
    cout<<ans<<endl;

    return 0;

}
    


Measured memory_bytes: 82304
import sys
input = lambda: sys.stdin.readline().rstrip()
from heapq import heapify, heappush as hpush, heappop as hpop
H, W, K = map(int, input().split())
x1, y1, x2, y2 = map(int, input().split())
X = [1] * (W + 2)
for _ in range(H):
    X += [1] + [1 if a == "@" else 0 for a in input()] + [1]
X += [1] * (W + 2)
X += X[:]
H, W = H+2, W+2
HW = H * W
s, t = x1 * W + y1, x2 * W + y2
ss, tt = s + HW, t + HW
def dijkstra():
    n = 2 * H * W
    h = [s, ss]
    D = [-1] * n
    done = [0] * n
    D[s] = 0
    D[ss] = 0
    kk = 21
    m = (1 << kk) - 1
    while h:
        x = hpop(h)
        d, i = x >> kk, x & m
        done[i] = 1
        if i < HW:
            for j in (i+1, i-1):
                nd = d + 1
                if X[j]: continue
                if D[j] < 0 or D[j] > nd:
                    if done[j] == 0:
                        hpush(h, (nd << kk) + j)
                        D[j] = nd
        else:
            for j in (i+W, i-W):
                nd = d + 1
                if X[j]: continue
                if D[j] < 0 or D[j] > nd:
                    if done[j] == 0:
                        hpush(h, (nd << kk) + j)
                        D[j] = nd
            
        j = i + HW if i < HW else i - HW
        nd = (d + K - 1) // K * K
        if X[j]: continue
        if D[j] < 0 or D[j] > nd:
            if done[j] == 0:
                hpush(h, (nd << kk) + j)
                D[j] = nd
    return [-(-a//K) for a in (D[t], D[tt]) if a >= 0]

di = dijkstra()
print(min(di) if di else -1)

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

int main(){
  int n;
  cin >> n;
  int a[n+1]={};
  a[0]=-1;
  rep(i,n)cin >> a[i+1];
  int b[n+1]={};
  for(int i=n;i>=1;i--){
    int sum=0;
    for(int j=i+i;j<=n;j+=i){
      sum+=b[j];
    }
    b[i]=sum+a[i];
    b[i]%=2;
  }
  int cnt=0;
  rep(i,n){
    if(b[i+1]>0)cnt++;
  }
  cout << cnt << endl;
  rep(i,n){
    if(b[i+1]>0)cout << i+1 << ' ' ;
  }
  cout << endl;
return 0;}

Measured memory_bytes: 2432
/*
Author: Xjrjyy
LANG: C++
PROG: abc177_d.cpp
Mail: admin@xjrjyy.com
Blog: https://blog.xjrjyy.cn/
*/

#include <cstdio>
#include <cctype>
#include <vector>
#include <iostream>

#define MAXN (200005)

int n, m;
int ans = -1;
int fa[MAXN], si[MAXN];
int fd(const int &x)
{
	return fa[x] == x ? x : fa[x] = fd(fa[x]);
}
void unionset(int x, int y)
{
	x = fd(x); y = fd(y);
	if (x == y) return;
	if (si[x] < si[y]) std::swap(x, y);
	fa[y] = x; si[x] += si[y];
	
}

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i)
    {
    	fa[i] = i;
    	si[i] = 1;
    }
    int a, b;
    while (m--)
    {
    	scanf("%d%d", &a, &b);
    	unionset(a, b);
    }
    for (int i = 1; i <= n; ++i)
    {
    	if (ans < si[i])
    		ans = si[i];
    }
    printf("%d", ans);
    return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll T[100005];
bool isPrime[100005];

void solve()
{
    REP(i, 100005)
    {
        isPrime[i] = true;
        T[i] = 0;
    }
    isPrime[0] = isPrime[1] = false;
    FOR(i, 100005, 2)
    {
        T[i] = T[i - 1];
        if (!isPrime[i])
            continue;
        if (isPrime[(i + 1) / 2])
            T[i]++;
        for (int j = i * 2; j < 100005; j += i)
            isPrime[j] = false;
    }
}

int main()
{
    solve();
    int Q;
    cin >> Q;
    REP(i, Q)
    {
        int l, r;
        cin >> l >> r;
        cout << T[r] - T[l - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

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

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

signed main(){
    int N;
    string W[100];
    cin >> N;
    REP(i, N) cin >> W[i];
    map<string, bool> mp;
    mp[W[0]] = true;
    char c = W[0].back();
    FOR(i, 1, N){
        if(mp[W[i]] == true || W[i].front() != c){
            PRINT("No");
            return 0;
        }
        mp[W[i]] = true;
        c = W[i].back();
    } 
    PRINT("Yes");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){
    ll a,b,c;
    cin >> a>>b>>c;
    if(a+b+c > 21){
        cout <<"bust" << endl;
    }
    else{
        cout << "win" << endl;
    }
}


Measured memory_bytes: 256
//610????°??±??????±?£???????????±±
#include<stdio.h>
int main(void)
{
	int h,w,i,j,flg,b[101][101],x;
	char a[101][101];
	scanf("%d %d",&h,&w);
	for(i=0;i<h;i++){
		scanf("%s",a[i]);
	}
	for(i=0;i<h;i++){
		flg=0;
		x=0;
		for(j=0;j<w;j++){
			if(a[i][j]=='c'){
				b[i][j]=0;
				flg=1;
			}	
			if(flg==1&&j+1<=w){
				if(a[i][j+1]=='.'){
					x++;
					b[i][j+1]=x;
				}
				else if(a[i][j+1]=='c'){
					b[i][j+1]=0;
					x=0;
				}
			}
			if(flg==0){
				b[i][j]=-1;
			}	
		}
	}
		
	for(i=0;i<h;i++){
		printf("%d",b[i][0]);
		for(j=1;j<w;j++){
			printf(" %d",b[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2792
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using LD = long double;
constexpr int P = 200003;
constexpr int maxn = 1 << 19;
const double PI = acos(-1.);
int Log[P], Exp[P];
struct comp{
	double a, b;
	comp(double a = 0, double b = 0) : a(a), b(b){};
	comp operator + (const comp& x)const{return comp(a + x.a, b + x.b);}
	comp operator - (const comp& x)const{return comp(a - x.a, b - x.b);}
	comp operator * (const comp& x)const{return comp(a * x.a - b * x.b, a * x.b + b * x.a);}
	comp operator / (const int& x)const{return comp(a / x, b / x);}
	comp conj()const{return comp(a, -b);}
};
void FFT(comp* a, int n, bool inv = false){
	static int on = 0, rev[maxn];
	static comp w[maxn];
	if(on != n){
		for(int i = 0; i < n; i += 1){
			rev[i] = i ? rev[i >> 1] >> 1 | (i & 1 ? n >> 1 : 0) : 0;
			w[i] = comp(cos(PI / n * i), sin(PI / n * i));
		}
		on = n;
	}
	for(int i = 0; i < n; i += 1) if(i < rev[i]) swap(a[i], a[rev[i]]);
	for(int m = 1; m <= n >> 1; m <<= 1)
		for(int j = 0; j < n; j += m << 1)
			for(int k = 0, p = 0; k < m; k += 1, p += n / m){
				comp tmp = (inv ? w[p].conj() : w[p]) * a[j + k + m];
				a[j + k + m] = a[j + k] - tmp;
				a[j + k] = a[j + k] + tmp;
			}
	if(inv) for(int i = 0; i < n; i += 1) a[i] = a[i] / n;
}
comp A[maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int N;
    cin >> N;
    for(int i = 0; i + 1 < P; i += 1){
        Exp[i] = i ? Exp[i - 1] * 2 % P : 1;
        Log[Exp[i]] = i;
    }
    LL ans = 0;
    for(int i = 1, x; i <= N; i += 1){
        cin >> x;
        if(x) A[Log[x]].a += 1;
        ans -= (LL)x * x % P;
    }
    FFT(A, maxn);
    for(int i = 0; i < maxn; i += 1) A[i] = A[i] * A[i];
    FFT(A, maxn, true);
    for(int i = 0; i < maxn; i += 1)
        ans += (LL)(A[i].a + .5) * Exp[i % (P - 1)];
    cout << ans / 2;
    return 0;
}

Measured memory_bytes: 24012
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int ans=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)!=t.at(i))ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3912
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n;
  string s;
  cin >> n;
  s=to_string(n);
  int dsum=0;
  rep(i,s.size()){
    dsum+=stoi(s.substr(i,1));
  }
  if (n%dsum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


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

    int n;
    cin >> n;
    string s;
    cin >> s;
    bool flag=1;
    rep(i,n/2) {
        if (s[i]!=s[n/2+i]) flag=0;
    }
    if (flag && n%2==0) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 3660
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; ++i)
#define RANGE(i, x, n) for(ll i = x; i < n; ++i)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;

void accelerate()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

const int MAXN = 2e5+10;
int n;
string s;

int main()
{
    accelerate();
    cin >> n;
    cin >> s;
    vector<int> cnt0(n+1);
    vector<int> cnt1(n+1);
    REP(i, n) {
        if(s[i] == '#') {
            cnt1[i+1] += cnt1[i] + 1;
            cnt0[i+1] += cnt0[i];
        }else {
            cnt1[i+1] += cnt1[i];
            cnt0[i+1] += cnt0[i] + 1;
        }
    }
    int ans = cnt0[n];
    RANGE(i, 1, n+1) {
        ans = min(ans, cnt1[i] + cnt0[n] - cnt0[i]);
    }
    cout << ans << endl;
}


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

int main() {
    string S;
    cin >> S;
    const int N = S.size();
    int ans = N;
    for (int j = 0; j < N-1; ++j) {
        if (S[j] != S[j+1]) {
            ans = min(ans, max(j+1, N-1-j));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long

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

  int n,k; cin >> n >> k;
  string s; cin >> s;

  function< int(string) > rec =
  [&](string s){
    int ans = 0,l = 0,r = 0;
    int cnt = 0;
    queue<int> q;
    for(int i = 0; i < n; i++){
      if(s[i] == '0'){
        while(r < n && s[r] == '0'){
          r++;
        }
        q.push(r);
        cnt++;
        if(cnt > k){
          l = q.front(); q.pop();
          cnt--;
        }
        i = r-1;
      }
      else {
        r++;
      }
      ans = max(ans,r - l);
    }
    return ans;
  };
  int res = 0;
  res = max(res,rec(s));
  //cout << rec(s) << " ";
  reverse(s.begin(),s.end());
  res = max(res,rec(s));
  //cout << rec(s) << endl;
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 720
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();

void solution();
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

void solution(){
    string s;
    cin >> s;
    if(s.size() < 2 || s.size()%2){
        cout << "No" << endl;
        return;
    }

    for(int i = 0; i < s.size(); i += 2){
        if(s[i] == 'h' && s[i+1] == 'i') continue;
        else{
            cout << "No" << endl;
            return;
        }
    }

    cout << "Yes" << endl;
    return;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int d,g; cin >> d >> g;
    vector<int> p(d),c(d);
    rep(i,d){
        cin >> p[i] >> c[i];
    }

    int ans = INF;
    for(int mask=0;mask<(1<<d);mask++){
        //cout << static_cast<bitset<10>>(mask) << endl;
        int point = 0;
        int cnt = 0;
        for(int i=0;i<d;i++){
            if(mask & (1<<i)){
                point += c[i];
                point += 100 * (i+1) * p[i];
                cnt += p[i];
            }
        }

        //cout << "mid " << point << " " << cnt << endl;

        for(int i=d-1;i>=0;i--){
            if(mask & (1<<i)) continue;
            if(g <= point) break;
            int num = min(p[i],(g-point+100*(i+1)-1)/(100*(i+1)));
            point += num * 100 * (i+1);
            cnt += num;
        }

        //cout << point << " " << cnt << endl;
        ans = min(ans,cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*

const val mod = 1000000007

fun countPath(matrix: Array<CharArray>, h: Int, w: Int): Int {
    val dp = Array(h) { IntArray(w) }
    
	dp[0][0] = 1
    for (i in 0 until h) {
        for (j in 0 until w) {
            if (matrix[i][j] == '#') continue
            if (i >= 1) dp[i][j] = (dp[i - 1][j] + dp[i][j]) % mod
            if (j >= 1) dp[i][j] = (dp[i][j - 1] + dp[i][j]) % mod

        }
    }
    return dp[h - 1][w - 1]
}

fun main(args: Array<String>) {
    val result = with(Scanner(System.`in`)) {
        val (h, w) = nextLine().split(' ').map { it.toInt() }

        val list = mutableListOf<CharArray>()

        for (i in 0 until h) {
            val row = nextLine()
                    .toCharArray()

            list.add(row)
        }

        countPath(list.toTypedArray(), h, w)
    }

    println(result)
}


Measured memory_bytes: 45564
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
const int maxn = 100000 + 5;
typedef long long ll;

int par[maxn], n, q;
bool marked[maxn];

int ancestor(int x)
{
	while(par[x] != x && !marked[x])	x = par[x];
	return x;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	while(~scanf("%d%d", &n, &q))
	{
		if(n == 0 && q == 0)	break;
		memset(marked, 0, sizeof(marked));
		for(int i = 1; i <= n; i++)	par[i] = i;

		int p;	marked[1] = true;
		for(int i = 2; i <= n; i++)
		{
			scanf("%d", &p);
			par[i] = p;
		}

		char op;	int x;
		ll ans = 0;
		while(q--)
		{
			scanf("\n%c%d", &op, &x);
			if(op == 'M')	marked[x] = true;
			else			ans += ancestor(x);
		}
		printf("%lld\n", ans);
	}
}

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

int main(){
    long long n,m;
    scanf("%lld%lld",&n,&m);
    if(n == 1 && m == 1){
        printf("1\n");
    }else if(n == 1){
        printf("%lld\n", m-2);
    }else if(m == 1){
        printf("%lld\n", n-2);
    }else{
        printf("%lld\n", (n-2)*(m-2));
    }
}


Measured memory_bytes: 256
import numpy as np
H, W = map(int, input().split())

S = []
for h in range(H):
    S.append(input())


ans = np.zeros((H+2,W+2),dtype = int)

dx = [-1,0,1]
dy = [-1,0,1]

for h in range(H):
    for w,s in enumerate(S[h]):
        if s == '#':
            x = w + 1
            y = h + 1
            for del_x in dx:
                for del_y in dy:
                    if not (del_x == 0 and del_y == 0):
                        ans[y+del_y][x+del_x] += 1
for h in range(H):
    ans2 = ''
    for w in range(W):
        if S[h][w] == '#':
            ans2 += '#'
        else:
            ans2 += str(ans[h+1][w+1])

    print(ans2)


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

using namespace std;

using ll = long long;

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

    int res = d[N/2] - d[N/2-1];
    cout << res << endl;

}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n; cin >>n;
  ll key=0;
  vector<vector<int>> a(2,vector<int>(n));//a(2,vector<int>(n));
  rep(i,n) cin >> a[0][i];
  rep(i,n) cin >> a[1][i];
  rep(i,n) key += a[0][i];
  rep(i,n){
    ll ans =0;
    rep(j,i+1){
      ans+=a[0][j];
     }
    rep2(j,i,n){
      ans+=a[1][j];
     }
    key=max(key,ans);
   }
  cout <<key<<endl;
}

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

int color[100010] = {};
int old[100010];
vector<int> graph[100010];
int v[100010], d[100010], c[100010];


int main(){
    int n, m, q;
    cin >> n >> m;

    memset(old, -1, sizeof(old));

    int a, b;
    for(int i = 0;i < m;i++){
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }


    cin >> q;
    for(int i = 0;i < q;i++){
        cin >> v[i] >> d[i] >> c[i];
        v[i]--;
    }

    queue<pair<int, pair<int, int> > > que;
    for(int p = q-1;p >= 0;p--){
        if(old[v[p]] < d[p]){
            que.push(make_pair(v[p], make_pair(d[p], c[p])));
            while(!que.empty()){
                int idx = que.front().first;
                int vi = que.front().second.first;
                int co = que.front().second.second;
                que.pop();
                old[idx] = vi;
                if(color[idx] == 0) color[idx] = co;

                if(vi == 0) continue;
                vi--;
                for(int i = 0;i < graph[idx].size();i++){
                    int next = graph[idx][i];
                    if(old[next] < vi){
                        que.push(make_pair(next, make_pair(vi, co)));
                    }
                }
            }
        }
    }

    for(int i = 0;i < n;i++){
        cout << color[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 9720
import java.util.Scanner;
class Main {
	int W,H,x,y,r;
	public void suzuki(){
		Scanner sc = new Scanner(System.in);
		W = sc.nextInt();
		H = sc.nextInt();
		x = sc.nextInt();
		y = sc.nextInt();
		r = sc.nextInt();
		if(x < W && y < H){
			if(r <= x && r <= y){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}else{
			System.out.println("No");
		}
	}
	public static void main(String[] args){
		new Main().suzuki();
	}

}

Measured memory_bytes: 17348
#include <bits/stdc++.h>
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
#define srep(i, l, r) for (register int i = l; i < r; i++)
#define sper(i, r, l) for (register int i = r; i > l; i--)
#define ll long long int 
#define pair<int, int>
#define fi first
#define se second
#define maxn 
using namespace std;

int main(){
	int n;
	scanf("%d", &n);
	printf("%d", (n - 1) >> 1);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
	int k,x;
	cin>>k>>x;
	if(k==1) cout<<x;
	else
	{
		for(int i=k-1;i>=0;i--)
			cout<<x-i<<' ';
		for(int i=1;i<k-1;i++)
			cout<<x+i<<' ';
		cout<<x+k-1;
	}	
	return 0;
}

Measured memory_bytes: 256