akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main() {
    const double PI=3.14159265358979323846;
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double XA, YA, XB, YB;

    XA = (double) A*cos(2*PI*(H*60+M)/720);
    YA = (double) A*sin(2*PI*(H*60+M)/720);
    XB = (double) B*cos(2*PI*M/60);
    YB = (double) B*sin(2*PI*M/60);

    double result;
    result = sqrt(pow(XA-XB, 2.0)+pow(YA-YB, 2.0));
    //cout << result << endl; 

    printf("%.10f\n", result);




    return 0;

    
}


Measured memory_bytes: 4104
from collections import deque

ans=deque([])

for _ in range(int(input())):
    
    a=list(map(int,input().split()))
    
    if len(a)==3:
        if a[1]==0: ans.appendleft(a[2])
        
        else: ans.append(a[2])
        
    if len(a)==2:
        
        if a[0]==1 : print(ans[a[1]])
        
        else: 
            
            if a[1]==0: ans.popleft()
            
            else: ans.pop()
    


Measured memory_bytes: 21936
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
route=[a,b,c,d,e]
min_route=a
for i in route:
    if i < min_route:
        min_route=i
if n%min_route == 0:
    time=n//min_route+4
else:
    time=n//min_route+5
print(time)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
    int a,b,c,i,k=0;
    scanf("%d %d %d",&a,&b,&c);
    for(i=a;i<=b;i++){
       if(c%i==0){
           k+=1;
       } 
    }
    printf("%d\n",k);
    return 0;
}


Measured memory_bytes: 2760
a = list(input())
a.reverse()
b = list(input())
b.reverse()
c = list(input())
c.reverse()

f = 'a'
ans = 'A'

while 1:
  if f == 'a':
    if len(a) == 0:
      ans = 'A'
      break
    f = a.pop()
  elif f == 'b':
    if len(b) == 0:
      ans = 'B'
      break
    f = b.pop()
  elif f == 'c':
    if len(c) == 0:
      ans = 'C'
      break
    f = c.pop()
  else:
    ans = '?'
    break

print(ans)


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

typedef long long ll;

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);

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

  if (a[0] != 0) {
    cout << -1 << endl;
    return 0;
  }

  for (int i = 0; i + 1 < n; ++i) {
    if (a[i] + 1 < a[i + 1]) {
      cout << -1 << endl;
      return 0;
    }
  }

  ll result = 0;

  int r = n - 1;
  int v = a[n - 1];
  result = a[n - 1];
  for (int i = n - 1; i >= 0; --i) {
    assert(a[i] - i >= v - r);    
    if (a[i] - i > v - r) {
      r = i;
      v = a[i];
      result += a[i];
    }
  }
  cout << result << endl;

  return 0;
}


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

int main()
{
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s[1] == s[2])
        cout << "No" << endl;
    else if (s[0] == s[1] && s[2] == s[3])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

/*****************************************************START******************************************************************/


int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	int T = 1;
	 //cin >> T;
	// cin.ignore(); must be there when using getline(cin, s)
	while (T--)
	{
		string s,t; 
		cin >> s >> t; 
		int ans = 0; 
		for(int i=0; i<int(s.length()); i++){
			if(s[i] != t[i]){
				ans++;
			}
		}
		cout << ans << endl;
		
				
	}
	return 0;
}


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

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

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();

            String[] map = new String[n];
            long[][] point = new long[n][11];

            for (int i = 0; i < n; i++) {
                String str = "";
                for (int j = 0; j < 10; j++) {
                    str += in.next();
                }
                map[i] = str;
            }

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < 11; j++) {
                    point[i][j] = in.nextLong();
                }
            }
            long ans = Long.MIN_VALUE;
            for (int i = 1; i < 1024; i++) {
                long p = 0;
                for (int j = 0; j < n; j++) {
                    String str = map[j];
                    int dec = Integer.parseInt(str, 2);
                    int cnt = Integer.bitCount(dec & i);
                    p += point[j][cnt];
                }
                ans = Math.max(ans, p);
            }

            out.print(ans);


        }

    }
}



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

long k;
string s;
long ans;
int main()
{
    // scanf("%d", &x);
    cin >> k;
    cin >> s;
    if (s.size() > k)
    {
        cout << s.substr(0, k) << "..." << endl;
    }
    else
    {
        cout << s << endl;
    }
    // printf("%d\n", x * x * x);
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
using namespace std;

long long modAdd(long long a, long long b, long long mod) {
	return ((a % mod) + (b % mod)) % mod;
}

long long modSub(long long a, long long b, long long mod) {
	long long c = ((a % mod) - (b % mod)) % mod;
	return ((c < 0) ? c + mod : c);
}
long long modMul(long long a, long long b, long long mod) {
	return ((a % mod) * (b % mod)) % mod;
}

long long modPow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0)
	{
		if (n & 1) {
			res = modMul(res, a, mod);
		}
		a = modMul(a, a, mod);
		n >>= 1;
	}
	return res;
}

long long modDiv(long long a, long long b, long long mod) {
	return modMul(a, modPow(b, mod - 2, mod), mod);
}

long long modCombination(long long n, long long r, long long mod) {
	if (r > n / 2)
		return modCombination(n, n - r, mod);
	long long res = 1;
	for (long long i = 1; i <= r; i++) {
		res = modMul(res, n - i + 1, mod);
		res = modDiv(res, i, mod);
	}
	return res;
}

int main()
{
	long long k;
	cin >> k;
	vector<long long> m;
	int n = 0;
	m.push_back(7);
	if (k % 2 == 0) {
		cout << -1 << endl;
	}
	else {
		while (true) {
			if (m[n] % k == 0)
				break;
			m.push_back(modAdd(m[n], modMul(7, modPow(10, n + 1, k), k), k));
			n++;
			if (n >= 1000000)
				n = -2;
		}
		cout << n + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 11596
a,b = map(int,input().split())

if (a>0) & (b>0):
    print('Positive')
elif (a<0) & (b>0):
    print('Zero')
elif (a==0) or(b==0):
    print('Zero')
else:
    if (b-a)%2==1:
        print('Positive')
    else:
        print('Negative')

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

#define pb push_back
typedef long long int ll;
const ll MAX = 1e5+5;
const ll INF = 1e9+10;
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
vector<ll>graph[MAX];
ll n,m;
vector<ll>topo;
ll visited[MAX];

void dfs(ll st)
{
    visited[st]=1;
    for(auto child : graph[st])
    {
        if(!visited[child])
            dfs(child);
    }
    topo.push_back(st);
}

int main()
{
    faster;
    cin>>n>>m;
    
    while(m--)
    {
        ll a,b;
        cin>>a>>b;
        graph[a].pb(b);
    }
    for(int i=1;i<=n;i++)
    {
        if(!visited[i])
            dfs(i);
    }        
    ll dp[n+1];
    memset(dp,0,sizeof(dp));
    
    //reverse(topo.begin(),topo.end());
    
    for(auto i : topo)
    {
        for(auto child : graph[i])
        {
            dp[i]=max(dp[i],1+dp[child]);
        }
    }
    ll max_val=-INF;
    for(auto i:topo)
    {
     
        max_val=max(max_val,dp[i]);
    }
    cout<<max_val<<endl;
}


Measured memory_bytes: 9720
#include <cstdio>
#include <cctype>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
#define repe(i,x) for (edge *i=fst[x]; i; i=i->nxt)
using namespace std;

typedef long long LL;
int n,a[100100];
LL cnt[100100];
struct edge
{
    int v;
    edge *nxt;
} pool[200100],*tp=pool,*fst[100100];

int getint()
{
    char ch;
    while (!isdigit(ch=getchar()));
    int x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

bool dfs(int x,int fa)
{
    if (x!=1 && !fst[x]->nxt)
    {
        cnt[x]=a[x];
        return 1;
    }
    LL sum=0,maxw=0;
    repe(i,x)
        if (i->v!=fa)
        {
            if (!dfs(i->v,x))
                return 0;
            sum+=cnt[i->v],maxw=max(maxw,cnt[i->v]);
        }
    LL k=sum-a[x];
    if (k<0 || k*2>sum || k>sum-maxw)
        return 0;
    cnt[x]=sum-k*2;
    return 1;
}

int main()
{
    n=getint();
    repu(i,1,n)
        a[i]=getint();
    repu(i,1,n-1)
    {
        int u=getint(),v=getint();
        *tp=(edge){v,fst[u]},fst[u]=tp++;
        *tp=(edge){u,fst[v]},fst[v]=tp++;
    }
    puts(!dfs(1,0) || cnt[1] && fst[1]->nxt?"NO\n":"YES\n");
    return 0;
}

Measured memory_bytes: 9216
#include <stdio.h>
#include <string.h>
int main(void)
{
  int w[50],a,b,d,i,j=0,k,n,p,x,y=0,z=0;
  char s[500],c[500];

  scanf("%d",&n);

  for (size_t i = 0; i < n; i++)
  {
    scanf("%d",&w[i]);
  }
  for (size_t i = 1; i < n-1; i++)
  {
    if((w[i-1]<w[i])&&(w[i]<w[i+1])) z++;
    else if((w[i+1]<w[i])&&(w[i]<w[i-1])) z++;
  }
  
  printf("%d\n",z);
  return 0;
}

Measured memory_bytes: 1704
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int m = s.nextInt();
    int[][] mat = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        mat[i][j] = s.nextInt();
      }
    }
    int[] vec = new int[m];
    for (int i = 0; i < m; i++) {
      vec[i] = s.nextInt();
    }
    s.close();
    for (int i = 0; i < n; i++) {
      int sum = 0;
      for (int j = 0; j < m; j++) {
        sum += mat[i][j] * vec[j];
      }
      System.out.println(sum);
    }
  }
}



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

char S[100005];
int cnt[26];

int main(){

	scanf("%s",S);

	int i;

	int len=strlen(S);

	for(i=0;i<len;i++){
	cnt[S[i]-'a']++;
	}

	for(i=0;i<26;i++){
		if(cnt[i]==0){
			printf("%c\n",i+'a');
			return 0;
		}
	}

	printf("None\n");

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.12f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 1010101;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[8] = { 1,-1,0,0,1,1,-1,-1 };
ll dy[8] = { 0,0,1,-1,1,-1,1,-1 };
ll d[110][2];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<ll>res(n);
	rep(i, n - 1) {
		res[i + 1] = res[i];
		if (s[i] == 'A' && s[i + 1] == 'C')res[i + 1]++;
	}
	rep(i, q) {
		ll l, r;
		cin >> l >> r;
		l--, r--;
		cout << res[r] - res[l] << endl;
	}
	return 0;
}


Measured memory_bytes: 4280
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl;
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2

int n, k;
vector<int>a;
int dp[5050][5050];
int check(int ex) {
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	rep(i, 0, n - 1)rep(x,0,k+1) {
		int ind = (i < ex) ? i : i + 1;
		dp[i + 1][x] = max(dp[i][x],dp[i+1][x]);
		if (x + a[ind] < 5050) {
			dp[i + 1][x + a[ind]] = max(dp[i + 1][x + a[ind]], dp[i][x]);
		}
	}
	for (int i = max(0, k - a[ex]); i < k;i++) {
		if (dp[n-1][i])return 1;
	}
	return 0;
}

int main() {
	cin >> n >> k;
	a.resize(n);
	rep(i, 0, n)cin >> a[i];
	sort(all(a));

	if (check(0)) {
		puts(0);
	}
	else if (!check(n-1)) {
		puts(n);
	}
	else {
		int noneed = 0, need = n - 1;
		while (need - noneed > 1) {
			int mid = (need + noneed) / 2;
			if (check(mid))need = mid;
			else noneed = mid;
		}
		puts(noneed + 1);
	}

	return 0;
}


Measured memory_bytes: 99840
from collections import Counter
n = int(input())
Slist = [Counter(list(input())) for _ in range(n)]
ans = []
for i in range(ord("a"), ord("a") + 26):
    searching_alpha = chr(i)
    min_num = 10**9
    for S in Slist:
        min_num = min(min_num, S[searching_alpha])
    ans.append(searching_alpha * min_num)
print("".join(ans))


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;

ll from[66];
ll to[66];
ll mo=1000000007;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	
	from[0]=1;
	FORR(c,S) {
		ZERO(to);
		if(c=='?' || c=='0') {
			int nex[7]={1,2,1,4,5,4,6};
			FOR(j,7) (to[nex[j]]+=from[j])%=mo;
		}
		if(c=='?' || c=='1') {
			int nex[7]={3,0,1,6,3,4,6};
			FOR(j,7) (to[nex[j]]+=from[j])%=mo;
		}
		swap(from,to);
	}
	cout<<(from[3]+from[6])%mo<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 720
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[110];
int main()
{
    int i,j,k,n,s;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    s=0;
    for(i=0;i<n;i++)
    if(a[i]==a[i+1])
    {
        a[i+1]=10000;
        s++;
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
using namespace std;
const ll maxn = 1e5 + 7;
const ll mod = 1e9 + 7;
const ll mod1 = 123456789;
const int maxx = 1005;
ll q, t, n, m, T, k, ans, a[maxn], b[maxn], f[maxx][maxx];
priority_queue<ll> pr;
string s, str;
char ss[maxx][maxx];
map<ll, ll> mp;
void sol()
{
    cin >> n;
    ll mx = 1e16;
    for(int i = 0; i < n; i ++)
    {
        cin >> a[i];
    }
    for(int i = n - 1; i >= 0; i--)
    {
        for(int j = i; j >= 0; j --)
        {
            if(i == n - 1)f[i][j] = (j == 0 ? a[i] : 0);
            else
                f[i][j] = min(a[i] + f[i+1][a[i] > 100 ? j + 1 : j], j > 0 ? f[i+1][j-1] : mx);
        }
    }
    cout << f[0][0];
}
deque<char>st;
char ch;
void test()
{
    cin >> s >> T;
    for(int i = 0; i < s.length(); i ++)
        st.push_back(s[i]);
    k = 1;
    while(T -- > 0)
    {
        cin >> n;
        if(n == 1)
            k = (k == 1 ? 2 : 1);
        else
        {
            cin >> t >> ch;
            if(t == 1)
            {
                if(k == 1)
                {
                    st.push_front(ch);
                }
                else
                    st.push_back(ch);
            }
            else
            {
                if(k == 1)
                    st.push_back(ch);
                else
                    st.push_front(ch);
            }
        }
    }
    if(k == 1)
    {
        while(!st.empty())
        {
            cout << st.front();
            st.pop_front();
        }
    }
    else
    {
        while(!st.empty())
        {
            cout << st.back();
            st.pop_back();
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    test();
}


Measured memory_bytes: 976
/*  CREATED BY
    STREAM_CIPHER
    29-aug-2020
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define debug1(a) cout<<#a<<"="<<(a)<<"\n"
#define debug2(a,b) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<"\n"
#define debug3(a,b,c) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<","<<#c<<"="<<(c)<<"\n"
#define fix_precision(n) cout << fixed << setprecision(n)
#define all(a) a.begin(),a.end()
const double pi=acos(-1.0);
int inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int mx=5*1000000;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    #endif
        double d,t,s;
        cin>>d>>t>>s;
        if(d/s<=t)
            cout<<"Yes\n";
        else
            cout<<"No\n";
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    //入力
    ll N,W; cin >> N >> W;
    ll w[110];
    ll v[110];
    for (ll i = 0;i<N;i++) cin >> w[i] >> v[i];

    //dp,初期化
    ll dp[110][100100] = {0};  //dp[i][sum_w] = i番目未満の品物(iは含まない)を用い、sum_w以下で最大のvalue

    //index整理（0始まりとして）
    //dp[i] = i番目未満の品物（iは含まない）
    //w[i] = i番目の品物の重さ
    //v[i] = i番目の品物の価値


    //ループ
    //dp[i+1][sum_w]へは、
    //dp[i][sum_w - w[i]]から遷移する。(ただし、sum_w - w[i] >= 0)
    for (ll i = 0;i<N;i++) {   //i番目までの品物から選ぶ
        for (ll sum_w = 0;sum_w<=W;sum_w++) {    //sum_w以下で、選べるか
            if (sum_w - w[i] >= 0) {    //今回の品物の重さw[i]を足して、sum_wを超えないかチェック
                chmax(dp[i+1][sum_w],dp[i][sum_w - w[i]] + v[i]);  //超えないなら、品物 iの価値（v[i]）足してみる
            }
            chmax(dp[i+1][sum_w],dp[i][sum_w]);   //選ばない場合
        }
    }

    cout << dp[N][W] << endl;
}

Measured memory_bytes: 86272
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  enum Color : int64_t { kRed = 0, kGreen, kTrans };
  vector<pair<int64_t, Color>> apples;
  for (int64_t i = 0; i < A; ++i) {
    int64_t z;
    cin >> z;
    apples.emplace_back(z, kRed);
  }
  for (int64_t i = 0; i < B; ++i) {
    int64_t z;
    cin >> z;
    apples.emplace_back(z, kGreen);
  }
  for (int64_t i = 0; i < C; ++i) {
    int64_t z;
    cin >> z;
    apples.emplace_back(z, kTrans);
  }
  sort(apples.begin(), apples.end());
  reverse(apples.begin(), apples.end());

  int64_t result = 0;
  int64_t count_red = 0;
  int64_t count_green = 0;
  int64_t count_trans = 0;
  for (const auto &apple : apples) {
    const int64_t value = apple.first;
    const Color color = apple.second;
    if (color == kRed) {
      if (count_red < X) {
        result += value;
        ++count_red;
      }
    } else if (color == kGreen) {
      if (count_green < Y) {
        result += value;
        ++count_green;
      }
    } else {
      result += value;
      ++count_trans;
    }
    if (count_red + count_green + count_trans == X + Y) {
      break;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 11572
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int n;
    cin >> n;
    vi h(n);
    for(int i=0; i<n; i++){
        cin >> h.at(i);
    }
    string res = "Yes";
    for(int i=n-1; i>=1; i--){
        if(h.at(i-1) > h.at(i) + 1){
            res = "No";
        }
        if(h.at(i-1) == h.at(i) + 1){
            h.at(i-1)--;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define GET(a) cin >> (a)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;


int main()
{
	int n, h, w;
	cin >> n >> h >> w;
	
	int a = 0;
	int b = 0;
	
	cout << ((n - (h - 1)) > 0 ? n - (h - 1) : 0) * ((n - (w - 1)) > 0 ? n - (w - 1) : 0) << endl;
	
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int W = scan.nextInt();
		int H = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		int r = scan.nextInt();
		if(x+r <= W && x-r >= 0 && y+r <= H && y-r >= 0){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26356
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1

using namespace std;

const double g=10.0,eps=1e-7;
const int N=200000+10,maxn=60000+10,inf=0x3f3f3f;

int f[32];
int a[N],b[N];
int main()
{
    for(int i=0;i<31;i++)
        f[i]=(1<<i);
    int n,k;
    scanf("%d%d",&n,&k);
    ll res=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&a[i],&b[i]);
        if((a[i]&k)==a[i])res+=b[i];
    }
    for(int i=30;i>=0;i--)
    {
        if(k&f[i])
        {
            ll ans=0,te=(k^f[i])|(f[i]-1);
            for(int j=0;j<n;j++)
                if((te&a[j])==a[j])
                    ans+=b[j];
            res=max(res,ans);
        }
    }
    printf("%lld\n",res);
    return 0;
}
/********************

********************/

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include <vector>

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

using namespace std;

int main() {
	string S;
	int left = -1, right = -1;

	cin >> S;
	
	if (S.length() == 2&&S[0]==S[1]) {
		cout << 1 << " " << 2 << endl;
		return 0;
	}

	REP(i, S.length() - 2) {
		if (S[i] == S[i + 1] || S[i] == S[i + 2] || S[i + 1] == S[i + 2]) {
			left = i + 1;
			right = i + 3;
			break;
		}
	}

	cout << left << " " << right << endl;
	
	

	return 0;
}

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

// 構造体
struct work {
  int A;
  int B;
};

// 比較関数
bool cmp (const work &a, const work &b) {
  if (a.B < b.B) {
    return true;
  }
  if (a.B > b.B) {
    return false;
  }
  if (a.A < b.A) {
    return true;
  }
  if (a.A > b.A) {
    return false;
  }
  return false;
}

int main() {

  int N;
  cin >> N;

  // A と B の情報を構造体を入れた配列で管理
  vector<work> W;
  for (int i = 0; i < N; i++) {
    int A_, B_;
    cin >> A_ >> B_;
    work w_ = work {A_, B_};
    W.push_back(w_);
  }

  // 比較関数で並び替え
  sort(W.begin(), W.end(), cmp);

  string answer = "Yes";

  // current:処理した仕事の量
  int current = 0;
  // 空き時間
  int free = 0;

  for (int i = 0; i < N; i++) {

    // 処理した時間に A を加える
    current += W[i].A;
    
    // B より処理した時間が大きいと作業は終わらない
    if (W[i].B < current) {
      answer = "No";
      break;
    } else {
      /*
      // 空き時間が0より小さいと作業は終わらない
      free = W[i].B - current;
      if (free < 0) {
        answer = "No";
        break;
      }
      */
    }
  }

  cout << answer << endl;

  return 0;
}

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

int main(){
  int N;
  cin >>N;
  vector<int>A(N);
  rep(i,N){cin >>A[i];}
  map<int,int>mp;
  ll ans=0;
  rep(i,N){
  	int x=A[i],y,z;
  	y=A[i]+i+1;
  	z=i+1-A[i];
    ans+=mp[z];
    mp[y]++;
  }
  cout<<ans;
}


Measured memory_bytes: 20912
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

//解説
//5で割ってx余る素数を5つ集めれば必ず合成数になる
//また，そのような数をN個集めても55555以下になる．
int N;
//エラトステネスの篩で素数をNまで求める
bool isPrime[60000];
void eratosthenes(int n){
    rep(i,n+1)isPrime[i]=true;
    isPrime[1]=false;
    for(int i=2;i*i<=n;i++){
        if(isPrime[i]){
            for(int j=i*2;j<=n;j+=i){
                isPrime[j]=false;
            }
        }
    }
}
signed main(){
    scanf("%lld",&N);
    eratosthenes(55555);
    int cnt=0;
    for(int i=7;cnt<N;i+=5){
        if(isPrime[i]){
            printf("%lld",i);
            cnt++;
            if(cnt!=N)printf(" ");
            else printf("\n");
        }
    }
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = LLONG_MAX;
/* テンプレートここまで */

int main() {
  ll N, C; cin >> N >> C;
  vector<vector<ll>> D(C, vector<ll>(C));
  REP(i, C) REP(j, C){
    cin >> D[i][j];
  }
  vector<vector<ll>> c(N, vector<ll>(N));
  REP(i, N) REP(j, N){
    cin >> c[i][j];
    c[i][j]--;
  }

  vector<vector<ll>> a(3, vector<ll>(C,0));
  REP(i, N) REP(j, N){
    ll idx = (i+j)%3;
    a[idx][c[i][j]]++;
  }

 ll ans = INF;
  REP(i, C) REP(j, C) REP(k, C){
    if(i == j || j == k || k == i) continue;
    vector<ll> color = {i, j, k};
    ll cost = 0;
    REP(l, 3) REP(m, C){
      cost += a[l][m] * D[m][color[l]];
    }
    ans = min(cost, ans);
  } 
  cout << ans << endl;
}


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

using namespace std;

#define MAX_N 1000000

long long int par[MAX_N]; //親
long long int Rank[MAX_N]; //木の深さ
long long int Size[MAX_N];

void init(long long int n){
    for(int i=0;i<n;i++){
        par[i] = i;
        Rank[i] = 0;
        Size[i] = 1;
    }
}

long long int find(long long int x){
    if(par[x] == x){
        return x;
    }else{
        return par[x] = find(par[x]);
    }
}

void unite(long long int x, long long int y){
    x = find(x);
    y = find(y);

    if(x==y){
        return;
    }

    if(Rank[x] < Rank[y]){
        par[x] = y;
        Size[y] += Size[x];
    }else{
        par[y] = x;
        Size[x] += Size[y];
        if(Rank[x] == Rank[y]){
            Rank[x]++;
        }
    }
}

bool same(long long int x, long long int y){
    return find(x) == find(y);
}

long long int size(long long int x){
    return Size[find(x)];
}

int main(){
    long long int N,M,sub=0;
    cin >> N >> M;
    init(N);
    vector<pair<int,int>> edge(M);
    vector<long long int> ans(M);

    for(int i=0;i<M;i++){
        cin >> edge[M-1-i].first >> edge[M-1-i].second;
        edge[M-1-i].first--;
        edge[M-1-i].second--;
    }

    ans[M-1] = N*(N-1)/2;

    for(int i=0;i<M-1;i++){
        int A,B;
        A = edge[i].first;
        B = edge[i].second;
        
        if(!same(A,B)){
            sub += size(A)*size(B);
            unite(A,B);
        }

        ans[M-2-i] = N*(N-1)/2 - sub;
    }

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

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

using namespace std;


vector<int> g[2000];

int dfs(int start, int cur, int prev, int tot, int lim) {
    int ans = tot > lim;
    for (auto &&c: g[cur]) {
        if (prev != c) ans += dfs(start, c, cur, tot + 1, lim);
    }
    return ans;
}

void solve(long long N, long long K, vector<long long> A, vector<long long> B) {
    vector< pair<int,int> > es;
    for (int i = 0; i < A.size(); i++) {
        A[i]--;
        B[i]--;
        g[A[i]].push_back(B[i]);
        g[B[i]].push_back(A[i]);
        es.emplace_back(A[i], B[i]);
    }

    int ans = 1e9;
    if( K % 2 ){
        for (auto &e : es) {
            int sub = 0;
            for( int j : {e.first, e.second}){
                sub += dfs(j, j, e.first ^ e.second ^j , 0, (K-1)/2);
            }
            ans = min(ans, sub);
        }
    }else{
        for(int i = 0 ; i < N ; i++){
            ans = min(ans, dfs(i, i, -1, 0, K / 2));
        }
    }
    cout << ans << endl;

}

int main() {
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    vector<long long> A(N - 1);
    vector<long long> B(N - 1);
    for (int i = 0; i < N - 1; i++) {
        scanf("%lld", &A[i]);
        scanf("%lld", &B[i]);
    }
    solve(N, K, A, B);
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 305;
const int INF = (LL)1e9 + 5;
const LL MOD = 998244353;

int N, cnt[4];
double dp[MAXN][MAXN][MAXN];

int main() {
	// ios_base::sync_with_stdio(0); cin.tie(0);
	
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}
	
	for (int k = 0; k <= cnt[3]; k++) {
		for (int j = 0; j <= N - k; j++) {
			for (int i = 0; i <= N - j - k; i++) {
				if (i == 0 && j == 0 && k == 0) continue;
				double &res = dp[i][j][k];
					
				res = 1.0;
				if (i != 0) res += dp[i - 1][j][k] * i / N;
				if (j != 0) res += dp[i + 1][j - 1][k] * j / N;
				if (k != 0) res += dp[i][j + 1][k - 1] * k / N;
				if (i + j + k != N) res = res * N / (i + j + k);
			}
		}
	}
	
	printf("%.20f\n", dp[cnt[1]][cnt[2]][cnt[3]]);
}


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

int main() {
  int N;
  scanf("%d", &N);

  int x[110] = {0};
  int y[110] = {0};
  int h[110] = {0};
  int p = 0;
  for (int i = 0; i < N; i++) {
    scanf("%d%d%d", &x[i], &y[i], &h[i]);
    if (h[i] > 0) p = i;
  }

  int ans[3] = {0};
  for (int cx = 0; cx <= 100; cx++) {
    for (int cy = 0; cy <= 100; cy++) {
      bool is_center = true;
      int gh = abs(x[p] - cx) + abs(y[p] - cy) + h[p];
      for (int i = 0; i < N; i++) {
        if (max(gh - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]) {
          is_center = false;
          break;
        }
      }
      if (is_center) {
        ans[0] = cx;
        ans[1] = cy;
        ans[2] = gh;
      }
    }
  }

  printf("%d %d %d", ans[0], ans[1], ans[2]);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[3];
	int c,b;
	cin>>c>>b;
	a[0]=c+b;
	a[1]=c-b;
	a[2]=c*b;
	sort(a,a+3);
	cout<<a[2]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=55;
int n,m,a[N],b[N],fa[N],d[N],s[N];
long long ans;
vector<int>e[N];
void dfs(int u,int f)
{
	fa[u]=f,d[u]=d[f]+1;
	for(auto v:e[u])
		if(v!=f)
			dfs(v,u);
}
void cal(int x,int y)
{
	if(d[x]<d[y])
		swap(x,y);
	while(d[x]>d[y])
	{
		s[x]=0;
		x=fa[x];
	}
	while(x!=y)
	{
		s[x]=s[y]=0;
		x=fa[x],y=fa[y];
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		e[u].push_back(v);
		e[v].push_back(u);
	}
	dfs(1,0);
	scanf("%d",&m);
	for(int i=0;i<m;i++)
		scanf("%d%d",&a[i],&b[i]);
	for(int i=0;i<(1<<m);i++)
	{
		for(int j=2;j<=n;j++)
			s[j]=1;
		for(int j=0;j<m;j++)
			if(i&(1<<j))
				cal(a[j],b[j]);
		int t=0;
		for(int j=2;j<=n;j++)
			t+=s[j];
		ans+=(1ll<<t)*(__builtin_popcount(i)&1?-1:1);
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int N; cin >> N;
	set<int> a;
	REP(i, N) {
		int tmp;
		cin >> tmp;
		a.insert(tmp);
	}

	int n = a.size();
	if (n % 2) cout << n << '\n';
	else cout << n - 1 << '\n';
	return 0;
}


Measured memory_bytes: 8208
import numpy as np
# 前後1まで回収できる
N = int(input())

# n以下のものをかぞえる
A = np.bincount(np.array(input().split(), dtype=np.int32))

B = A.copy() # そのままとる
B[1:] += A[:-1] # 1増やして回収
B[:-1] += A[1:] # 1減らして回収

answer = B.max()
print(answer)



Measured memory_bytes: 21852
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

ll solve(string s,ll k)
{
	ll n=s.size();
	for(ll i=1;i<n;i++)
	{
		if(s[i]==s[i-1])
		{
			s[i]='1';
			k--;
		}
		if(k<0)
			return 0;
	}
	return 1;
}	

int main()
{
	ll k,ans1=0,ans2=0,cnt=0,cnt2=0;
	string str;
	cin>>str>>k;
	ll l=0,h=str.size(),mid;
	for(ll i=0;i<str.size();i++)
	{
		if(str[i]==str[0])
			cnt++;
		else
			break;
	}
	ll n=str.size();
	if(cnt==n)
	{
		cout<<(n*k)/2;
		return 0;
	}
	ll a=cnt/2;
	for(ll i=str.size()-1;i>=0;i--)
	{
		if(str[i]==str[0])
			cnt2++;
		else
			break;
	}
	ll b=cnt2/2;
	cnt+=cnt2;
	while(l<=h)
	{
		mid=(l+h)/2;
		if(solve(str,mid))
		{
			ans1=mid;
			h=mid-1;
		}
		else
			l=mid+1;
	}
	ll c=(ans1-a-b)*k+a+b+(cnt/2)*(k-1);
	cout<<c;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input_byline {
    ($($r:tt)* ) => {
        let stdin = std::io::stdin();
        let mut q = std::collections::VecDeque::new();
        let mut next = || {
            if q.is_empty() {
                let mut s = String::new();
                stdin.read_line(&mut s);
                for v in s.split_whitespace() {
                    q.push_back(v.to_string());
                }
            }
            q.pop_front().unwrap()
        };
        input_inner!{next, $($r)*}
    };

}

#[allow(unused_macros)]
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait Printable {
    fn p(&self);
}

impl<T: std::fmt::Display> Printable for T {
    fn p(&self) {
        println!("{}", self);
    }
}

impl<T: std::fmt::Display> Printable for [T] {
    fn p(&self) {
        for i in 0..self.len() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", self[i]);
        }
        println!("");
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1e9 as usize + 9;

fn main() {
    input! {
        n: usize,
    }

    if n & 1 == 1 {
        println!("{}", 0);
        return;
    }

    let n = n / 2;
    let mut m = 5;
    let mut a = 0;
    while m <= n {
        a += n / m;
        m *= 5;
    }
    println!("{}", a);
}


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

using namespace std;

const int MAXN = 100010;

int n, m;

bool marc[MAXN];

vector< int > path[2];
vector< int > adj[MAXN];

void DFS(int cur, int t)
{
	marc[ cur ] = true;
	path[ t ].push_back( cur );

	for(int i = 0 ; i < adj[cur].size() ; i++)
	{
		int viz = adj[cur][i];

		if( !marc[viz] )
		{
			DFS( viz , t );
			return;
		}
	}
}

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

	for(int i = 1 ; i <= m ; i++)
	{
		int U, V;
		scanf("%d %d",&U,&V);

		adj[ U ].push_back( V );
		adj[ V ].push_back( U );
	}

	DFS( 1 , 0 );
	DFS( 1 , 1 );

	reverse( path[1].begin() , path[1].end() );

	path[1].pop_back();

	int sz = path[0].size() + path[1].size();

	printf("%d\n",sz);

	for(int i = 0 ; i < path[1].size() ; i++)
		printf("%d ",path[1][i]);

	for(int i = 0 ; i < path[0].size() ; i++)
		printf("%d ",path[0][i]);
}

Measured memory_bytes: 9720
//ALDS1_9C
#include <cstdio>
#include <string>
#include <queue>
using namespace std;

int main(){
 char com[20];
 priority_queue<int> PQ;
 while(true){
  scanf("%s",com);
  if(com[0]=='i'){
   int key;
   scanf("%d",&key);
   PQ.push(key);
  }else if(com[1]=='x'){
   printf("%d\n",PQ.top());
   PQ.pop();
  }else if(com[0]=='e'){
   break;
  }
 }
 return 0;
}

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

using namespace std;

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<lli, lli> pi;


int main()
{

    {
        int n;
        cin >> n;
        bool fl = true;
        for(int i=0; i<n; i++){
            int x;
            cin >> x;
            if(x%2 == 0){
                if(x%3 != 0 && x%5 != 0) fl = false;
            }
        }
        if(fl) printf("APPROVED\n");
        else printf("DENIED\n");
    }

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N, K = map(int, input().split(' '))

array = [tuple(map(int, input().split(' '))) for i in range(N)]
array = sorted(array, key=lambda x: x[0])

count = 0
i = 0
while True:
    count = count + array[i][1]
    if count >= K:
        break
    i = i + 1

print(array[i][0])


Measured memory_bytes: 18972
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}

template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}

bool check_if_can_cut(vector<ll>& a, ll max_length, ll max_cut){
    ll count_cut = 0;
    for(int i = 0 ; i < (int) a.size() ; i++){
        if( a[i] <= max_length) continue;
        ll new_cut = a[i] / max_length; 
        if( new_cut > max_cut - count_cut) return false;
        count_cut += new_cut;
    }
    return true;
}

void solve(){
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    ll sum = 0;
    ll max_term = 1;
    REP(i,n){
        cin >> a[i];
        sum += a[i];
        if(a[i] > max_term){
            max_term = a[i];
        }
    }
    if(k == 0){
        cout << max_term << "\n";
        return;
    }
    ll lb = 1; 
    ll rb = max_term;
    while( lb + 1 < rb){
        ll mb = (lb + rb) / 2;
        if(check_if_can_cut(a, mb, k)){
            rb = mb;
        }else{
            lb = mb + 1;
        }
    }
    if(!check_if_can_cut(a, lb, k)){
        lb++;
    }
    cout << lb << endl;

} 

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    solve();

    return 0;
}


Measured memory_bytes: 4732
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>

using namespace std;

const int M = 1500001;
int n,m,k,a[M],c[M][26], d[M][26],cnt=1,e[M],f[M],b[30];
char s[M];

void ins()
{
	int now=1;
	int n=strlen(s+1);
	for(int i=n;i>=1;i--)
	{
		if(!c[now][s[i]-'a']) c[now][s[i]-'a']=++cnt, f[cnt]=now,a[cnt]=s[i]-'a';
		now=c[now][s[i]-'a'];
	}
	e[now]=1;
	memset(b,0,sizeof(b));
	n=1;
	while(now)
	{
		
		for(int i=0;i<26;i++) d[now][i]+=b[i];
		b[s[n++]-'a']=1;
		now=f[now];
	}
}


int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("\n%s",s+1);
		ins();
	}
	long long res=0;
	for(int i=1;i<=cnt;i++) if(e[i])
	{
		int fa=f[i];
		res+=d[fa][a[i]]-1;
	}
	printf("%lld",res);
}

Measured memory_bytes: 216568