akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;
using ULL = int64_t;
using P = pair<LL, LL>;
#define rep(i, n) for (LL i = 0; i < (n); ++i)
#define all(v) (v).begin(), (v).end()
#define DEBUG

int main() {
  LL n, h;
  cin >> n >> h;

  vector<P> c;
  rep (i, n) {
    LL a, b;
    cin >> a >> b;
    c.push_back(make_pair(a, (LL)0)); // Swing
    c.push_back(make_pair(b, (LL)1)); // Throw
  }
  sort(all(c), greater<P>());

  LL i = 0;
  while (h > 0) {
    if (c.at(i).second == 0) {
      // Swing
      const auto a = c.at(i).first;
      i += h / a + (h % a == 0 ? 0 : 1);
      break;
    } else {
      // Throw
      h -= c.at(i).first;
      i++;
    }
  }
  cout << i << endl;

  #ifdef DEBUG
  // cout << 123 << endl;
  #endif
}



Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define ll long long int 
#define endl '\n'
#define INF 1000000000
#define MOD 1000000007
#define MAX 100000000 
#define mp make_pair
#define pb push_back
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int ans=0,n=s.length();
    for(int i=0;i<n/2;i++)
    {
    	if(s[i]!=s[n-i-1])
    	{
    		ans++;
    	}
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
import math
while True:
  n = int(input())
  if n == 0:
    break
  name = ("lunch", "dinner", "midnight")
  dic = {}
  clear = {}
  for s in name:
    dic[s] = 0
    clear[s] = 0
  for _ in range(n):
    start, time = input().split()
    flag = (int(time) - int(start[3:])) % 60 <= 8
    if "11:00" <= start <= "14:59":
      dic["lunch"] += 1
      if flag:
        clear["lunch"] += 1
    elif "18:00" <= start <= "20:59":
      dic["dinner"] += 1
      if flag:
        clear["dinner"] += 1
    elif "21:00" <= start <= "23:59" or "00:00" <= start <= "01:59":
      dic["midnight"] += 1
      if flag:
        clear["midnight"] += 1
  for key in ("lunch", "dinner", "midnight"):
    if dic[key]:
      print(key, math.floor(100 * clear[key] / dic[key]))
    else:
      print(key, "no guest")
  


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

int main()
{
  int n;
  cin >> n;
  
  int max_a = 2020202;
  vector<int> s(max_a*2, 0);
  
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  rep(i,n) s[a[i]] = 1;
  rep(i,n-1) if(a[i] == a[i+1]) s[a[i]] = 2;
  
  
  for(int i = 1; i <= max_a; i++)
  {
    if(s[i] == 0) continue;
    for(int j = i+i; j <= max_a; j += i)
    {
      if(s[j] == 1) s[j] = 2;
    }
  }
  
  int ans = 0;
  for(int i = 0; i <= max_a; i++)
  {
    if(s[i] == 1) ans++;
  }
  
  cout << ans << endl;
  
  
  
  
  return 0;
}

Measured memory_bytes: 19888
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=22,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x=(x+y)%mod;}
template<class T>inline void read(T &x){
	x=0;char ch=getchar(),rev=0;
	while(ch>'9'||ch<'0') rev=(ch=='-'),ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	x=rev?-x:x;
}
template<class T>inline void print(T x,const char c){
	if(!x){putchar('0');putchar(c);return;}
	if(x<0) putchar('-'),x=-x;
	int m=0,a[10];
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');
	putchar(c);
}
inline int exp(int x,int y){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,m,sum,f[N][N],g[1<<15],dp[1<<15][N],mx[1<<15][N];

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			f[i][j]=-inf;
	for(int i=1;i<=m;i++){
		int x,y,z;scanf("%d%d%d",&x,&y,&z);
		x--;y--;f[x][y]=f[y][x]=z;
		sum+=z;
	}
	for(int i=1;i<(1<<n);i++){
		int d;
		for(int j=0;j<n;j++)
			if(i&(1<<j)){d=j;break;}
		g[i]=g[i^(1<<d)];
		for(int j=d+1;j<n;j++)
			if((i&(1<<j))&&f[d][j]>0) g[i]+=f[d][j];
	}
//	debug(g[7]);
	int ans=0;
	for(int i=1;i<(1<<n);i+=2){
		dp[i][0]=g[i];
		for(int j=1;j<n;j++){
			dp[i][j]=-inf;
			if(!(i&(1<<j))) continue;
			int u=i^1^(1<<j);
//			if(i==3&&j==1) debug(u);
			for(int s=u;s;s=(s-1)&u)
				gmax(dp[i][j],mx[i^s^(1<<j)][j]+g[s^(1<<j)]);
			gmax(dp[i][j],mx[u^1][j]);
		}
		for(int j=1;j<n;j++){
			if(i&(1<<j)) continue;
			mx[i][j]=-inf;
			for(int k=0;k<n;k++)
				if(i&(1<<k)) gmax(mx[i][j],dp[i][k]+f[j][k]);
		}
		gmax(ans,dp[i][n-1]);
	}
	printf("%d\n",sum-ans);
	return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



i64 n, a[101010], b[101010];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	for(int i = 0; i <= n; i++){
		if(i == 0) b[i] = 0;
		else b[i] = (a[i-1]-b[i-1]/2)*2;
	}
	for(int i = 0; i < n; i++){
		if(i == 0) b[i] = b[n]/2;
		else b[i] = (a[i-1]-b[i-1]/2)*2;
		cout << b[i] << " ";
	}
	cout << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 2944
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll K,N;
ll ans;
string S;
ll a;
ll A[100001];
ll H,M,HH,MM;
ll now;
 
int main(){
    cin >> K >> N;
    cout << K*N << endl;
}


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

int main( void )
{
    string line;
    long long a, b, n;
    while ( getline( cin, line ) ) {
        istringstream is( line );
        is >> a >> b >> n;
        a %= b;
        
        long long sum = 0;
        for ( long long i = 0; i < n; i++ ) {
            sum += ( 10 * a ) / b;
            a = ( 10 * a ) % b;
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 3010, LOG=20;

int n, T, k, u, v, x, y, t, a, b, ans;
pii A[MAXN];
int dp[MAXN][MAXN];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>T;
	for (int i=1; i<=n; i++) cin>>A[i].first>>A[i].second;
	sort(A+1, A+n+1);
	//for (int i=1; i<=n; i++) debugp(A[i])
	for (int i=1; i<=n; i++) for (int j=0; j<=T; j++){
		if (j) dp[i][j]=max(dp[i][j-1], dp[i-1][j]);
		if (j<T) ans=max(ans, dp[i-1][j] + A[i].second);
		if (j>=A[i].first) dp[i][j]=max(dp[i][j], dp[i-1][j-A[i].first] + A[i].second);
	}
	ans=max(ans, dp[n][T-1]);
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3010;
const int mod = 1e9+7;
bool vis[maxn][maxn][2];
int memo[maxn][maxn][2];
int n, m;

int add(int a, int b) {return (a+b)%mod;}
int mul(long long a, long long b) {return a*b%mod;}

int dp(int pos, int r, int b, bool k) {
	if (pos == m) return k;
	if (vis[pos][r][k]) return memo[pos][r][k];
	int &ans = memo[pos][r][k] = 0;
	if (r > 0) {
		ans = add(ans, dp(pos+1, r-1, b+1, k|(r==1)));
		ans = add(ans, dp(pos+1, r, b, k|(r==1)));
	}
	if (b > 0) {
		ans = add(ans, dp(pos+1, r+1, b-1, k|(r==0)));
		ans = add(ans, dp(pos+1, r, b, k|(r==0)));
	}
	vis[pos][r][k] = 1;
	return ans;
}

int main() {
	cin >> n >> m;
	int ans = 0;
	for (int i = 0; i <= n; ++i) {
		ans = add(ans, dp(0, i, n-i, 0));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 88960
def solve():
    sum_A = [0 for _ in range(N + 1)]
    sum_B = [0 for _ in range(M + 1)]

    for i in range(1, N + 1):
        sum_A[i] = sum_A[i-1] + A[i-1]

    for i in range(1, M + 1):
        sum_B[i] = sum_B[i-1] + B[i-1]

    ans = 0
    j = M
    for i in range(N + 1):
        if sum_A[i] > K:
            break

        while sum_B[j] > K - sum_A[i]:
            j -= 1

        ans = max(ans, i + j)

    print(ans)

if __name__ == "__main__":
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    solve()

Measured memory_bytes: 48480
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;


#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9+7;
vector<pair<int, int> > vp;
 
struct Less {
    bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
        return x.first > y.first;
    }
};

ll GCD(ll a, ll b){
    if(b==0) return a;
    return GCD(b, a%b);
}


//グラフの隣接リスト
VI g[200010];
//頂点の入次数を管理
int h[100010];
string s;
ll a[100010], b[100010];
vector<string> field;
int main(void) {
    ll N, K; cin >> N >> K;
    ll idx=INF;
    int temp=0;
    REP(i, N) {
        int n; cin >> n;
        if(temp<0&&n>0) idx=i;
        temp=n;
        if(n<=0){
            a[i] = -n*2;
            b[i] = -n;
        }else{
            a[i] = n;
            b[i] = n*2;
        }
    }
    
    ll ans = INF;
    if(idx==INF){
        bool ok=true;
        if(b[0]!=0&&a[0]%b[0]!=0) ok = false;    //負
        if(!ok){
            for(int i=0; i<N-K+1; ++i){
        ans = min(ans, a[i+K-1]);
        }
        }else{
        ans = b[N-K]; 
        }
    }else{
        for(int i=0; i<N-K+1; ++i){
          ans = min(ans, a[i]+a[i+K-1]);
    }
        for(int i=0; i<N-K+1; ++i){
         ans = min(ans, b[i]+b[i+K-1]);
    }
    }
    cout << ans << endl;
    
    
    
	return 0;
}

Measured memory_bytes: 6528
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  s = int(input())
  remain   = - s % (10**9) % (10**9)
  quotient = (s + remain) // (10**9)
  print(0, 0, 1, 10**9, quotient, remain)
  
if __name__=='__main__':
  main()



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

int main() {
	int n, k, num;
	double prob = 1;
	double p = 0;
	cin >> k >> n;
	for(int i = 1; i <= k; i++) {
		prob = 1;
		num = i;
		while(num < n) {
			num *= 2;
			prob /= 2;
		} p += prob;
	} cout.precision(17);
	cout << fixed << p/k << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define digit(N) cout << fixed << setprecision((N))
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")

int main()
{
	int a[] = {1,
			   1,
			   1,
			   2,
			   1,
			   2,
			   1,
			   5,
			   2,
			   2,
			   1,
			   5,
			   1,
			   2,
			   1,
			   14,
			   1,
			   5,
			   1,
			   5,
			   2,
			   2,
			   1,
			   15,
			   2,
			   2,
			   5,
			   4,
			   1,
			   4,
			   1,
			   51};

	int K;
	cin >> K;
	cout << a[K - 1] << "\n";
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = int.Parse(Console.ReadLine());
            var b = 1 * Math.PI;
            var ans = r * r * Math.PI;
            Console.WriteLine(ans / b);
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include <typeinfo>
#include <stdlib.h>
#define ll long long
const int MOD = 1000000007;
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (c >= a && c <= b) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

ll inf=1ll<<60;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n,a[100000],i,s=0,ans1=0,ans2=0;
	bool f;
	cin>>n;
	for (i=0;i<n;i++){
		cin>>a[i];
	}
	f=true;
	for (i=0;i<n;i++){
		s+=a[i];
		if (f==true){
			if (s>=0){
				ans1+=s+1;
				s=-1;
			}
			f=false;
		}
		else {
			if (s<=0){
				ans1+=1-s;
				s=1;
			}
			f=true;
		}
	}
	f=true;
	s=0;
	for (i=0;i<n;i++){
		s+=a[i];
		if (f==true){
			if (s<=0){
				ans2+=1-s;
				s=1;
			}
			f=false;
		}
		else {
			if (s>=0){
				ans2+=s+1;
				s=-1;
			}
			f=true;
		}
	}
	cout<<min(ans1,ans2);
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
long long IN(void)
{
  long long x=0;short f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
signed main(void)
{
  char S[1000000];
  int a=0x7f7f7f7f,cusum[1000001]={0},len,max=0,min,temp,RT=2,rv[1000001]={0};
  if(scanf("%s",S)!=0)len=strlen(S);
  for(int i=0;i<len;i++)
  {
    temp=cusum[i]+((S[i]=='1')?1:-1);
    cusum[i+1]=rv[i+1]=temp;
    max=(cusum[i+1]<max)?max:cusum[i+1];
  }
  for(int i=len-1;i>=0;i--){rv[i]=(rv[i]<rv[i+1])?rv[i+1]:rv[i];}
  while(RT--)
  {
    temp=0,min=0;
    for(int i=0;i<len;i++)
    {
      if(S[i]=='?'){if(temp+rv[i+1]-cusum[i]+2<=max){temp++;}else temp--;}
      else if(S[i]=='0'){temp--;}
      else{temp++;}
      min=(min<temp)?min:temp;
    }
    a=(a<max-min)?a:max-min;
    max++;
  }
  return printf("%d\n",a),0;
}

Measured memory_bytes: 10492
def resolve():
    import sys
    import string
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    # n = int(input().rstrip())
    s = input().rstrip()
    alphabets = set()
    for c in string.ascii_lowercase:
        alphabets.add(c)

    for c in s:
        if c in alphabets:
            alphabets.remove(c)
            if len(alphabets) == 0:
                print("None")
                return

    print(sorted(alphabets)[0])

if __name__ == "__main__":
    resolve()


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rep3(i, m, n) for(ll i=m;i<=(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1000000000000000000

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const ll mod = MOD;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

ll dp[100005];

void solve_abc_d() {
	ll n;
	ll wm;

	cin >> n >> wm;
	V w(n), v(n);
	rep(i, n) {
		cin >> w[i] >> v[i];
	}

	rep(i, 100005) dp[i] = LLINF;
	dp[0] = 0;
	rep(i, n) {
		rrep(j, 100001 - v[i], 0) {
			chmin(dp[j + v[i]], dp[j] + w[i]);
		}
	}

	ll l_ans = 0;
	rep(i, 100005) {
		if (dp[i] <= wm) {
			chmax(l_ans, i);
		}
	}

	cout << l_ans << "\n";

	return;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(15);

	solve_abc_d();

	return 0;
}


Measured memory_bytes: 4444
#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>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
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)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 5100000;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };



int v, e;
int h[100005];
VI vec[100005];
VI ans;

int main() {

	cin >> v >> e;

	rep(i, e) {
		int a, b;
		cin >> a >> b;
		vec[a].pb(b);
		h[b]++;
	}

	queue <int> q;

	rep(i, v) {
		if (h[i] == 0) q.push(i);
	}

	while (!q.empty()) {
		int tmp = q.front(); 
		q.pop();

		ans.push_back(tmp);

		rep(i, vec[tmp].size()) {
			h[vec[tmp][i]]--;
			if (h[vec[tmp][i]] == 0)q.push(vec[tmp][i]);
		}
	}

	rep(i, ans.size())cout << ans[i] << endl;

	return 0;
}



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

string s;
int abcd[4];
string ans;

void dfs(string tmp, int sum, int depth) {
  if (depth == 4) {
    if (sum == 7) ans = (tmp + "=7\n");
    return;
  }

  dfs(tmp + '+' + s[depth], sum + abcd[depth], depth + 1);
  dfs(tmp + '-' + s[depth], sum - abcd[depth], depth + 1);
  return;
}

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

  cin >> s;
  for (int i = 0; i < 4; i++) abcd[i] = s[i] - '0';

  dfs(s.substr(0, 1), abcd[0], 1);

  cout << ans;
  return 0;
}




Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string S,T;cin>>S>>T;
    if(S==T)
    {
        cout<<"Yes";
        return 0;
    }
    int SIZE=S.length()-1;

    for(int i=0;i<S.length();i++)
    {
        char temp=S[SIZE];
        for(int j=SIZE;j>0;j--)
        {
            S[j]=S[j-1];
        }
        S[0]=temp;
if(S==T)
{
    cout<<"Yes";
    return 0;
}
    }
    cout<<"No";
   return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
/*#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
                      
using namespace std;
                      
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
                      
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define ghost signed
#define left left228
#define right right228
#define prev prev228
#define list list228

const int N = 100 * 1000 + 228;

int n, ptr = 1;
bool is[N];
vector< pair<int, int> > e;

int build(int pos) {
	int sz = pos;
	int root = ptr++;
	--pos;
	while (pos && !is[pos]) --pos;
	if (pos) {
		e.push_back(make_pair(root, build(pos)));
		sz -= (pos + 1);
		for (int i = 0; i < sz; ++i) e.push_back(make_pair(root, ptr++));
	}
	return root;
}


ghost main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	n = (int)s.size();
	for (int i = 1; i <= n; ++i) {
		char c = s[i - 1];
		if (c == '0') is[i] = 0;
		else is[i] = 1;
	}
	if (is[n]) {
		cout << -1 << '\n';
		return 0;
	}
	if (!is[1]) {
		cout << -1 << '\n';
		return 0;
	}
	for (int i = 1; i < n; ++i) {
		if (is[i] != is[n - i]) {
			cout << -1 << endl;
			return 0;
		}
	}
	build(n);
	for (auto p : e) cout << p.first << " " << p.second << endl;
	return 0;
} // kek ;





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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
const int INF = 1e9;
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");
#define FOR(i, l, r) for (int i = int(l); i < int(r); ++i)
#define print(a)       for(auto x : a) cout << x << " "; cout << "\n"
#define print1(a)      for(auto x : a) cout << x.ff << " " << x.ss << "\n"
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << "\n"


ll fast_exp(ll base, ll exp) {ll res=1;while(exp>0) {if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return res%MOD;}
int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
int val(char c){if (c >= '0' && c <= '9')return (int)c - '0';else return (int)c - 'A' + 10;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll divisibles(ll a, ll b, ll m){if(a%m==0)return (b/m)-(a/m)+1;else return (b/m)-(a/m);}// in [a,b]
string bitstring(int n, int size){string s;while(n){s+=(n%2)+'0';n/=2;}while(s.size()<size){s+='0';}reverse(all(s));return s;}
// dsu start

vi root(200001,0);
vi size(200001,1);
int find(int x){while(x!=root[x])x = root[x];return x;}
bool same(int a,int b){return find(a)==find(b);}
void unite(int a, int b){a = find(a);b = find(b);if(size[a]<size[b])swap(a,b);size[a] += size[b];root[b] = a;}

// dsu end
vi vis(200001,0);
vi adj[200001];

int main()
{	
    std::ios::sync_with_stdio(false);
    //string bitstring = std::bitset< 3 >( 7 ).to_string(); <bits> (num)
    //srand(time(0));
    //cin.tie(NULL);
    //cout.tie(NULL);
    int w,a,b;
    cin>>w>>a>>b;
    int ax = a+w;
    int bx = b+w;

    if(ax>=b && a<b)
    	cout<<0<<"\n";
    else if(ax<b)
    {
    	cout<<b-ax<<"\n";
    }
    else if(bx>=a)
    	cout<<0<<"\n";
    else if(bx<a)
    	cout<<a-bx<<"\n";
 	   
}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n), b(n), ab;
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  ll ans = 0, s = 0;
  rep(i, n) {
    if (a[i] < b[i]) {
      ans++;
      s += b[i] - a[i];
    } else {
      ab.push_back(a[i] - b[i]);
    }
  }
  sort(ab.rbegin(), ab.rend());

  rep(i, ab.size()) {
    if (s <= 0) break;
    s -= ab[i];
    ans++;
  }

  if (s > 0) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}


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

int main(){
	int a,b,c,n;
	
	cin >> n;
	
	for(int i=0;i<n;i++){
		cin >> a >> b >> c;
		
		if(a>b)
			swap(a,b);
		if(b>c)
			swap(b,c);
		
		if(a*a+b*b==c*c)
			cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)

int g(char*s){
	ll ans=0;
	ll n=strlen(s);
	ll num=1;
	rep(i,0,n){
		if(s[i]<=57)num=s[i]-48;
		else{
			ll base;
			if(s[i]=='m')base=1000;
			if(s[i]=='c')base=100;
			if(s[i]=='x')base=10;
			if(s[i]=='i')base=1;
			ans+=num*base;
			num=1;
		}
	}
	return ans;
}

void f(int x){
	if(x>=1000){
		if(x/1000>1)printf("%d",x/1000);
		printf("m");
		x%=1000;
	}
	if(x>=100){
		if(x/100>1)printf("%d",x/100);
		printf("c");
		x%=100;
	}
	if(x>=10){
		if(x/10>1)printf("%d",x/10);
		printf("x");
		x%=10;
	}
	if(x>=1){
		if(x>1)printf("%d",x);
		printf("i");
	}
	puts("");
}

int main(){
	ll cnt;
	scanf("%lld",&cnt);
	while(cnt--){
		char s[10];
		char t[10];
		scanf(" %s %s",s,t);
		f(g(s)+g(t));
	}
}


Measured memory_bytes: 2104
/*input
10 4 8
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,x,y;
    cin >> n >> x >> y;
    vector<int>ans(n);
    for(int i = 1;i<=n;i++){
        for(int j = i+1;j<=n;j++){
            int dis = j-i;
            dis = min(dis,abs(j-y)+abs(i-x)+1);
            ans[dis]++;
        }
    }
    for(int i = 1;i<n;i++) cout << ans[i] <<endl;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#define local
#ifdef local
    #include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
    #include <boost/multiprecision/cpp_int.hpp>
#endif
#define p std::pair
#define ll long long
#define ld long double
#define ull unsigned long long
#define pi std::pair<int, int>
#define stdabs std::abs
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
#define oreq |=
#define npm next_permutation
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
ll extgcd(ll a, ll b, ll& x, ll& y);
ll nCr(ll n, ll r);
void stat();
template <typename T> T fact(T num);
constexpr ll mod = 1000000000 + 7;

int main()
{
    stat();
    int n;cin>>n;
//    vec<int> v(n);
    ll sum=0, a;
    rep(i,n){
//cin>>v[i];
cin>>a;
sum+=a;
    }
cout<<sum-n<<endl;

    return 0;
}
ll extgcd(ll a, ll b, ll& x, ll& y)
{
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) {
        is_prime[i] = true;
    }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++) {
        if (is_prime[i]) {
            for (unsigned ll j = 2 * i; j <= N; j += i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}

void stat(){
#ifdef local
    rep(i, 2){std::cout << "local enable" << std::endl;
}
#endif
#ifdef hacks
rep(i, 2) { std::cout << "boost enable" << std::endl; }
#endif
}

ll nCr(ll n, ll r)
{
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

template <typename T> T fact(T num)
{
    if (num == 1) { return 1; }
    return num * fact(num - 1);
}


Measured memory_bytes: 3488
n = gets.to_i
a = gets.split.map(&:to_i).sort
b = gets.split.map(&:to_i).sort
c = gets.split.map(&:to_i).sort
bc = Array.new(n, 0)
j = 0
for i in 0...n do
  while j < n && b[i] >= c[j] do
    j += 1
  end
  bc[i] = n - j
end
bc_sum = Array.new(n, 0)
prev = 0
(n - 1).downto(0) do |i|
  bc_sum[i] = bc[i] + prev
  prev = bc_sum[i]
end
count = 0
j = 0
for i in 0...n do
  while j < n && a[i] >= b[j] do
    j += 1
  end
  if j < n
    count += bc_sum[j]
  end
end
puts count


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

int main(){
  string s;
  cin >> s;
  int c = 0;
  
  for(int i = 0; i<4;++i){
	if(s[i] == '+') ++c;
	else --c;
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=5e5;
int N;
ll D;
int d[MAX_N];
ll A[MAX_N+1],B[MAX_N+1];
int main(){
	cin>>N>>D;
	REP(i,N){
		cin>>d[i];
	}
	A[0]=D;
	REP(i,N){
		if (A[i]>=d[i]){
			A[i+1]=A[i]-d[i];
		}else{
			A[i+1]=min(A[i],d[i]-A[i]);
		}
	}
	B[N]=1;
	for(int i=N-1;i>=0;i--){
		if (B[i+1]*2<=d[i]){
			B[i]=B[i+1];
		}else{
			B[i]=B[i+1]+d[i];
		}
	}
	int Q;
	cin>>Q;
	REP(i,Q){
		int q;
		cin>>q;
		cout<<(A[q-1]>=B[q] ? "YES" : "NO")<<endl;
	}
	return 0;
}

Measured memory_bytes: 11648
import sys
import math
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [A, B, K] = string_to_int(inputs[0])
    results = []
    small = A if A > B else B
    for i in reversed(range(1, small+1)):
        if A % i == 0 and B % i == 0:
            results.append(i)
    return results[K-1]


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 3316
#include<stdio.h>
int main(void){
  int A,B,ok=0;
  scanf("%d %d",&A,&B);

  if(A%3==0){
    ok=1;
  }else if(B%3==0){
    ok=1;
  }else if((A+B)%3==0){
    ok=1;
  }


if(ok==1){
  printf("Possible");
}else{
  printf("Impossible");
}
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
using namespace std;
int main() {
	int n, k,sum=0; cin >> n >> k;
	string s; cin >> s;
	for (int i = 0; i < n - 1; ++i)
		if (s[i] == s[i + 1]) sum += 1;
	sum += 2 * k;
	cout << min(sum, n - 1) << endl;
	return 0;
}

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

int main(){
    int s,w;
    cin >> s >> w;
    if(s<=w) cout << "unsafe" << endl;
    else cout <<"safe"<< endl;
    
}

Measured memory_bytes: 3636
N, K = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(N)]


xy.sort()
ans = 2000000000 * (xy[-1][0] - xy[0][0])
for i in range(K-1, N):
  for j in range(N-i):
    xnow = xy[j+i][0] - xy[j][0]
    ylst = [xy[k][1] for k in range(j, j+i+1)]
    ylst.sort()
    ynow = min([ylst[k+K-1]-ylst[k] for k in range(i+2-K)])
    ans = min(ans, xnow*ynow)
    
print(ans)


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



int main()
{
        ll n;
        cin >> n;

        string x;
        cin >> x;
        multiset<char> res(all(x));
        rep(i, 0, n-1) {
                cin >> x;
                multiset<char> tmp(all(res));
                multiset<char> ne(all(x));
                res.clear();
                set_intersection(all(ne), all(tmp), inserter(res, res.begin()));
        }
        for (auto el : res) {
                cout << el;
        }
        cout << endl;
}

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

typedef long long ll;

int a, b, w, ans;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> w >> a >> b;
    if (a > b)
        swap(a, b);
    if (b <= a + w)
        ans = 0;
    else
        ans = b - a - w;
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3644
import java.util.Scanner;
 

public class Main {
 
	
	public static int get(int a[],int index,int sum,int b[],int dp[][]) {
		
		if(index==a.length) {
			return Integer.MAX_VALUE/4;
		}
		if(sum<=0) {
			return 0;
		}
		if(dp[index][sum]!=-1) {
			return dp[index][sum];
		}
		dp[index][sum] = Math.min(get(a,index+1,sum,b,dp),get(a,index,sum-a[index],b,dp)+b[index]);
		return dp[index][sum];
	}
	
	public static void main(String[] args) {
		
		Scanner s = new Scanner(System.in);
		
		int h = s.nextInt();
		int n = s.nextInt();
		
		int a[] = new int[n];
		int b[] = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = s.nextInt();
			b[i] = s.nextInt();
		}
		
		int dp[][] = new int[n][h+1];
		for(int i=0;i<n;i++) {
			for(int j=0;j<=h;j++) {
				dp[i][j] = -1;
			}
		}
		System.out.println(get(a,0,h,b,dp));
		
	}
}

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

int main(void){
int n,d,x;
cin >> n >> d >> x;
vector<int>a(n);
for(int i = 0;i < n;i++){
  cin >> a[i];
}

int count = 0;
for(int i = 0;i < n;i++){
  int j = 0;
 while(j*a[i]+1 <= d){
count++;
j++;
 }
}


cout << count + x <<endl;


}

Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::{Chars};
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        h: usize,
        w: usize,
        a: [Chars;h],
    }

    let mut del_h: Vec<usize> = Vec::new();
    let mut del_w: Vec<usize> = Vec::new();

    let mut ok = true;
    for i in 0..h {
        ok = true;
        for j in 0..w {
            if ok==true && a[i][j]=='.' {
                continue;
            } else {
                ok = false;
                break;
            }
        }
        if ok==true {
            del_h.push(i);
        }
    }

    for j in 0..w {
        ok = true;
        for i in 0..h {
            if ok==true && a[i][j]=='.' {
                continue;
            } else {
                ok = false;
                break;
            }
        }
        if ok==true {
            del_w.push(j);
        }
    }

    let mut ph = 0;
    let mut pw = 0;
    
    del_h.push(h+5);
    del_w.push(w+5);

    debug!(del_h);
    debug!(del_w);
    debug!(a.len());

    for i in 0..h {
        if i==del_h[ph] {
            ph += 1;
            continue;
        } else {
            for j in 0..w {
                if j==del_w[pw] {
                    pw += 1;
                    continue;
                } else {
                    print!("{}", a[i][j]);
                }
            }
            print!("\n");
            pw = 0;
        }
    }
}


Measured memory_bytes: 2268
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>

using namespace std;
int main()
{
	int N;
	int a[101];

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

	int Ans = 0;
	int count = 1;

	for (int j = 0; j < N+1; j++) {
		if (a[j] == a[j + 1]) {
			count++;
		}
		else { 
			Ans += count / 2;
			count = 1;
		}
	}

	cout << Ans;

	return 0;
}

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

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

    int cnt = 0;
    while (1) {
        if (cnt % 2 == 0) {
            c -= b;
            if (c <= 0) {
                cout << "Yes" << endl;
                return 0;
            }
        } else {
            a -= d;
            if (a <= 0) {
                cout << "No" << endl;
                return 0;
            }
        }
        ++cnt;
    }

    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

int main(void) {
    string str;
    cin>>str;

    int num = 0;
    for(int i = 0;i < str.size();i++) {
        if(str[i] == 'o')
            num++;
    }

    if(((15-str.size()) + num) >= 8) {
        cout<<"YES"<<endl;
    } else {
        cout<<"NO"<<endl;
    }

    return 0;
}




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

// #pragma comment(linker, "/STACK:16777216")

using namespace std;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
#define F first
#define S second
//#define int ll
#define pii pair<int, int>
const int SZ = 3e5 + 4;
const double EPS = 1e-7;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

struct custom_hash {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return x + FIXED_RANDOM;
    }
};

int a, b;

void read() {
    cin >> a >> b;
}

void solve() {
    set<int> x = {1, 2, 3};
    x.erase(a);
    x.erase(b);
    cout << *x.begin();
}

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

    read();
    solve();

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, rt, a[100005], up[100005];

vector<ll> adj[100005];

void solve (ll cur, ll prv) {
	if(adj[cur].size() == 1) {
		up[cur] = a[cur];
		return;
	}
	ll sum = 0, mx = 0;
	for(auto &nxt : adj[cur]) {
		if(nxt == prv) continue;
		solve(nxt, cur);
		sum += up[nxt];
		mx = max(up[nxt], mx);
	}
	if(a[cur] > sum || sum - (mx * 2 > sum ? sum - mx : sum / 2) > a[cur]) {
		puts("NO"); exit(0);
	}
	up[cur] = sum - 2*(sum - a[cur]);
}

int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<n;i++) {
		ll A, B;
		scanf("%lld%lld",&A,&B);
		adj[A].push_back(B);
		adj[B].push_back(A);
	}
	if(n == 2) {
		puts(a[1] == a[2] ? "YES" : "NO");
		return 0;
	}
	for(int i=1;i<=n;i++) {
		if(adj[i].size() > 1) {
			rt = i; break;
		}
	}
	solve(rt, 0);
	puts(up[rt] ? "NO" : "YES");
}


Measured memory_bytes: 12672
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);

// ===

fn main() {
    let s: String = read();
    let s: Vec<char> = s.chars().collect();
    let (x, y): (i32, i32) = read();
    let mut x = x;

    let n = s.len();
    let mut seq = vec![vec![]; 2];
    let mut dir = 0;
    let mut go = 0;
    let mut first = 1;
    for i in 0..n+1 {
        if i < n && s[i] == 'F' {
            go += 1;
        } else {
            if go >= 1 {
                if first == 1 {
                    x -= go;
                } else {
                    seq[dir].push(go);
                }
            }
            go = 0;
            dir ^= 1;
            first = 0;
        }
    }

    if can_make(&seq[0], x) && can_make(&seq[1], y) {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn can_make(x: &Vec<i32>, t: i32) -> bool {
    let mut m = 0;
    for xi in x {
        m += (*xi) * 2;
    }
    m = max(m, t.abs() * 2) + 10;
    let GETA = m / 2;
    let m: usize = m as usize;
    let mut dp = vec![vec![false; m]; 2];
    let n = x.len();

    dp[0][GETA as usize] = true;
    for i in 0..n {
        let fr = i % 2;
        let to = 1 - fr;
        for j in 0..m {
            dp[to][j] = false;
        }
        let go = x[i] as usize;
        for j in 0..m {
            if dp[fr][j] {
                dp[to][j+go] = true;
                dp[to][j-go] = true;
            }
        }
    }
    dp[n%2][(GETA+t) as usize]
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(void){
      int a,b,k;
      char op;
      while(1){
            cin >> a >> op >> b;
            if(op=='?')break;
            else if(op=='+')k=a+b;
            else if(op=='-')k=a-b;
            else if(op=='*')k=a*b;
            else if(op=='/')k=a/b;
            cout<<k<<endl;
            }
      return 0;
}


Measured memory_bytes: 3100
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


H, A = list(map(int, sys.stdin.buffer.readline().split()))

ans = math.ceil(H / A)
print(ans)


Measured memory_bytes: 24320
//abc104_d.cpp
//Wed Aug 22 21:42:45 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll dp[s.length()+1][4];
	dp[0][0] = 1;
	dp[0][1] = 0;
	dp[0][2] = 0;
	dp[0][3] = 0;
	
	for (int i=1;i<=s.length();i++){
		int a,b,c,z;
		if (s[i-1] == '?'){
			z = 3;a = 1;b = 1;c = 1;
		}else if (s[i-1] == 'A'){
			z = 1;a = 1;b = 0;c = 0;
		}else if (s[i-1] == 'B'){
			z = 1;a = 0;b = 1;c = 0;
		}else if (s[i-1] == 'C'){
			z = 1;a = 0;b = 0;c = 1;
		}

		dp[i][0] = (dp[i-1][0]*z)%1000000007;
		dp[i][1] = (dp[i-1][1]*z+dp[i-1][0]*a)%1000000007;
		dp[i][2] = (dp[i-1][2]*z+dp[i-1][1]*b)%1000000007;
		dp[i][3] = (dp[i-1][3]*z+dp[i-1][2]*c)%1000000007;
	}



	cout << dp[s.length()][3] << endl;
//	printf("%.4f\n",ans);
}

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

using namespace std;

//#define FILE_IO

typedef long long LL;

int I, O, T, J, L, S, Z;

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &I);
    scanf("%d", &O);
    scanf("%d", &T);
    scanf("%d", &J);
    scanf("%d", &L);
    scanf("%d", &S);
    scanf("%d", &Z);

    LL ans = 2LL * O;
    if(I && J && L)
        ans += max(4LL * (I / 2) + 4LL * (J / 2) + 4LL * (L / 2),
                   6LL + 4LL * ((I - 1) / 2) + 4LL * ((J - 1) / 2) + 4LL * ((L - 1) / 2));
    else
        ans += 4LL * (I / 2) + 4LL * (J / 2) + 4LL * (L / 2);

    ans /= 2;

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256