akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000.0
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
int N,M;
int K[205];
int S[205][22];
int H[205][22];
int V[205];
int Vsum[205];
double add[205][8010];
double dp[205][205];
double rec(int x,int y){
	if(Vsum[x]<y)return -INF;
	if(dp[x][y]!=-1.0)return dp[x][y];
	if(x==0)return dp[x][y]=add[x][y];
	double res = 0.0;
	for(int i=0;i<=y;i++)res = max(res,rec(x-1,y-i)+add[x][i]);
	return dp[x][y]=res;
}
int main(){
	scanf("%d %d",&N,&M);
	for(int i=0;i<N;i++){
		scanf("%d",&K[i]);
		for(int j=0;j<K[i];j++){
			scanf("%d %d",&S[i][j],&H[i][j]);
			for(int k=1;k<=S[i][j]*H[i][j];k++){
				add[i][V[i]+k]=add[i][V[i]]+(double)k/(double)S[i][j];
			}
			V[i]+=S[i][j]*H[i][j];
		}
	}
	Vsum[0] = V[0];
	for(int i=1;i<N;i++)Vsum[i]=Vsum[i-1]+V[i];
	M=min(M,Vsum[N-1]);
	for(int i=0;i<N;i++)for(int j=0;j<=M;j++)dp[i][j]=-1.0;
	printf("%.12f\n",rec(N-1,M));
	return 0;
}

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

int main(){
  long long int n, s;
  cin >> n >> s;
  if(s > n){
    cout << -1 << endl;
    return 0;
  }else if(s == n){
    cout << n+1 << endl;
    return 0;
  }
  long long int d = n - s, ans = -1, m = sqrt(d);
  for(long long int i = 1; i <= m; ++i){
    if(d%i) continue;
    long long int b = i + 1, n_ = n, t = n;
    while(n_ > 0){
      n_ /= b;
      t -= n_*(b-1);
      if(t < s) break;
    }
    if(t == s){
      cout << b << endl;
      return 0;
    }
    b = d/i + 1;
    n_ = n;
    t = n;
    while(n_ > 0){
      n_ /= b;
      t -= n_*(b-1);
      if(t < s) break;
    }
    if(t == s){
      ans = b;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdint>
#include<algorithm>

int64_t const MOD = 1e9+7;
int const MAXN = 1e4;

int N, np;
int64_t A[MAXN];

bool b[1000];
int64_t primes[180];
int64_t ix[180], tmp[180];
int64_t xl[MAXN];

int64_t factor(int64_t a) {
  for(int i = 0; i < np; ++i) {
    int64_t p = primes[i];
    tmp[i] = 0;
    while(a%p == 0) { a/=p; ++tmp[i]; }
  }
  return a;
}

void init() {
  std::fill_n(b, 1000, true);
   np = 0;
  for(int i = 2; i < 1000; ++i) if(b[i]) {
    primes[np++] = i;
    for(int j = i*2; j < 1000; j+=i) b[j] = false;
  }
}

int64_t mod_pow(int64_t x, int p) {
  int64_t res = 1;
  while(p > 0) {
    if(p&1) (res *= x) %= MOD;
    (x *= x) %= MOD;
    p >>= 1;
  }
  return res;
}
int64_t inv(int64_t x) { return mod_pow(x, MOD-2); }

int main() {
  std::cin >> N;
  std::fill_n(ix, np, 0);
  init();
  for(int i = 0; i < N; ++i) {
    std::cin >> A[i];
    xl[i] = factor(A[i]);
    for(int i = 0; i < np; ++i) ix[i] = std::max(ix[i], tmp[i]);
  }
  std::sort(xl, xl+N);
  int E = std::unique(xl, xl+N) - xl;
  int64_t x = xl[0];
  for(int i = 1; i < E; ++i) (x *= xl[i]) %= MOD;
  for(int i = 0; i < np; ++i) (x *= mod_pow(primes[i], ix[i])) %= MOD;
  int64_t ans = 0;
  for(int i = 0; i < N; ++i) ans += inv(A[i]);
  ans = ans%MOD*x%MOD;
  std::cout << ans << std::endl;
  return 0;
}


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

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> v;
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        v.push_back(a);
    }

    int ans = INT_MAX;
    for(int i=0;i<n;++i){
        vector<vector<int>> substrings;
        vector<int> substring;
        for(int j=0;j<n;++j){
            if(v[j] >= v[i])substring.push_back(v[j]);
            else if(substring.size() > 0){
                substrings.push_back(substring);
                substring.clear();
            }
        }
        if(substring.size() > 0)
            substrings.push_back(substring);

        vector<int> candidates;
        for(auto &substr : substrings){
            sort(substr.begin(), substr.end());
            for(int j=0;j<(int)substr.size()-(k-1);++j)
                candidates.push_back(substr[j]);
        }
        if(candidates.size() < q)continue;
        sort(candidates.begin(), candidates.end());
        ans = min(ans, candidates[q-1] - v[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int N;
    string S;
    const string pat1 = "OX";
    const string pat2 = "XO";
    int cnt = 0;
    
    cin >> N;
    cin >> S;
    
    int i = S.length();
    
    while (i > 0) {
        string search_pat = S.substr(i - 1, 2);
        
        if (search_pat == pat1 || search_pat == pat2) {
            cnt++;
            i--;
        }
        i--;
    }
    cout << cnt << endl;
}



Measured memory_bytes: 3336
#include <stdio.h>

int main(void)
{
	double v, y, t;
	int n;
	
	while(scanf("%lf", &v) != EOF){
		t = v / 9.8;
		y = 4.9 * t * t;
		n = (int)((y + 5) / 5);
		n += 1;
		
		printf("%d\n", n);
	}
	
	return 0;
}
		

Measured memory_bytes: 628
#include<stdio.h>
#include<math.h>
#define E 0.00000001

int iszr(double x){
  if(fabs(x)<E){
    return 1;
  }
  else{
    return 0;
  }
}

double a(double x1,double x2,double y1,double y2){
  return (y1-y2)/(x1-x2);
}

double b(double x1,double x2,double y1,double y2){
  return (x1*y2-x2*y1)/(x1-x2);
}

double c(double p,double x,double y){
  return y+x/p;
}

double xa(double p,double q,double r){
  return (r-q)/(p+1/p);
}

double ya(double p,double q,double r){
  return r+(q-r)/(p*p+1);
}

void doit(double x1,double y1,double x2,double y2,double xq,double yq){
  double x,y;
  if(iszr(x1-x2)==1){
    x=2.00000000*x1-xq;
    y=yq;
  }
  else if(iszr(y1-y2)==1){
    x=xq;
    y=2.00000000*y1-yq;
  }
  else{
    double p=a(x1,x2,y1,y2);
    double q=b(x1,x2,y1,y2);
    double r=c(p,xq,yq);
    double xp=xa(p,q,r);
    double yp=ya(p,q,r);
    x=2.00000000*xp-xq;
    y=2.00000000*yp-yq;
  }
  printf("%f %f\n",x,y);
}

int main(){
  double x1,y1,x2,y2,xq,yq;
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&xq,&yq)!=EOF){
    doit(x1,y1,x2,y2,xq,yq);
  }
  return 0;
}

Measured memory_bytes: 648
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
b = gets.chomp.split.map(&:to_i)

count = 0
n.times do |i|
  if b[i] > a[i]
    count += a[i]
    b[i] -= a[i]
    if b[i] > a[i+1]
      count += a[i+1]
      a[i+1] = 0
    else
      count += b[i]
      a[i+1] -= b[i]
    end
  else
    count += b[i]
  end
end

puts(count)

Measured memory_bytes: 19224
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int n,m,c;
    cin>>n>>m>>c;
    vector<int> b(m);
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    ll ans=0,sum=0;
    for(int i=0;i<n;i++){
        sum=0;
        for(int j=0;j<m;j++){
            int tmp;
            cin>>tmp;
            sum+=tmp*b[j];
        }
        sum+=c;
        if(sum>0) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

# https://qiita.com/e869120/items/eb50fdaece12be418faa
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_A&lang=ja


def main():
    n, w_limit = map(int, input().split())
    v, w = [0], [0]
    for _ in range(n):
        vi, wi = map(int, input().split())
        v.append(vi)
        w.append(wi)

    print(napzac(v, w, w_limit))


def napzac(v, w, w_limit):
    n = len(v)
    dp = [[0] * (w_limit + 1) for _ in range(n + 1)]  # dp の i だけ 1 origin..

    for i in range(n):
        for j in range(w_limit + 1):

            if j < w[i]:
                dp[i + 1][j] = dp[i][j]
            else:
                dp[i + 1][j] = max(
                    dp[i][j],
                    dp[i][j - w[i]] + v[i]
                )
    return dp[n][w_limit]


if __name__ == '__main__':
    main()



Measured memory_bytes: 25604
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        String s = stdIn.next();

        int y = 700;

        for(int i = 0; i < 3; i++)
            if(s.charAt(i) == 'o')
                y += 100;
        
        System.out.println(y);
    }
}

Measured memory_bytes: 21716
import math


n, m, x = list(map(int, input().split()))
c = []
a = []
for _ in range(n):
    inp = list(map(int, input().split()))
    c.append(inp[0])
    a.append(inp[1:])

ans = math.inf
for i in range(2 ** n):
    rikai = [0 for _ in range(m)]
    p = 0
    for j in range(n):
        if ((i >> j) & 1):
            p += c[j]
            for k, _ in enumerate(rikai):
                rikai[k] += a[j][k]
    if min(rikai) >= x:
        ans = min(ans, p)
if math.isinf(ans):
    print(-1)
else:
    print(ans)


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long

ll minx;
int n;
vector<ll> a;

int main()
{
    IOS;
    int k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        a.push_back(x);
    }
    bool dp[k+1];
    minx=a[0];
    for(int i=0;i<n;i++){
        minx=min(a[i],minx);
    }
    for(int i=0;i<=k;i++){
        dp[i]=false;
    }
    for(int i=0;i<n;i++){
        dp[a[i]]=true;
    }
    for(int i=0;i<minx;i++){
        dp[i]=false;
    }
    for(int i=0;i<=k;i++){
        for(int j=0;j<n;j++){
            if(i-a[j]>=0 && dp[i-a[j]]==false){
                dp[i]=true;
            }
        }
    }
    if(dp[k]==false)
        cout<<"Second";
    else
        cout<<"First";
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
int read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	int k=1,kk=0;if (c=='-')c=getchar(),k=-1;
	while (c>='0'&&c<='9')kk=kk*10+c-'0',c=getchar();return k*kk;
}using namespace std;
char s[1000000];
int f[10],l;
int main(){
	scanf("%s",s);l=strlen(s);for (int i=0;i<l;i++)f[s[i]-'a']++;
	if (max(f[0],max(f[1],f[2]))<=1+min(f[0],min(f[1],f[2])))puts("YES");else puts("NO");
}


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

using namespace std;

int main() {
  int N; cin >> N;
  int x = 0, y = 0;
  int t = 0;

  bool f = true;
  for (int i = 0; i < N; i++) {
    int ti, xi, yi; cin >> ti >> xi >> yi;
    int d = abs(xi - x) + abs(yi - y);
    int a = (ti - t) - d;

    if(a < 0 || a % 2 == 1) {
      f = false;
    }
    else {
      t = ti;
      x = xi;
      y = yi;
    }
  }

  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==b)printf("%d\n",c);
	else if(a==c)printf("%d\n",b);
	else if(b==c)printf("%d\n",a);
	return 0;
}


Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    dp = [float('inf')] * (N + 5)
    dp[0] = 0
    for i in range(1,N):
        for k in range(1,K+1):
            if i - k >= 0:
                dp[i] = min(dp[i], dp[i-k] + abs(H[i] - H[i-k]))

    print(dp[N-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 85612
A,B,C,D,E,F=map(int,raw_input().split(' '))

w_m=0
w_t=0
s_m=0

a_max=F/(100*A)
b_max=F/(100*B)

def sugar(w):
    c_max=(F-w)/C
    d_max=(F-w)/D
    m=0
    for c in range(0,c_max+1):
        for d in range(0,d_max+1):
            if (C*c+D*d)>E*w/100. or (C*c+D*d)+w>F:
                continue
            elif (C*c+D*d)>m:
                m=(C*c+D*d)
    return m

m=0.
for a in range(0,a_max+1):
    for b in range(0,b_max+1):
        w=100*(A*a+B*b)
        if w>w_t and w<F:
            w_t=w
        if w>F:
            continue
        s=sugar(w)
        if (w+s)==0 or w+s>F:
            continue
        elif 100.*s/(w+s)>m:
            m=100.*s/(w+s)
            w_m=w
            s_m=s

if w_m==0 and s_m==0:
    print w_t,0
else:
    print int(w_m+s_m),s_m


Measured memory_bytes: 2696
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) cout << ", "; else first = false;
    cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  lli n, t; cin >> n >> t;
  lli ans = 1e9;
  for (int i=0; i<n; ++i) {
    lli c, u; cin >> c >> u;
    if (u <= t) ans = min(ans, c);
  }
  if (ans < 1e9) {
    cout << ans << '\n';
  } else {
    cout << "TLE\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int a[500];
int f(int a) {
    if (a<0) return -a;
    return a;
} 
int main(){
    int n,r,z=0;
    scanf("%d",&n);
    if (n==0) printf("0");
    r=2;
    int m=f(n);
    while (m) {
        a[++z]=m%r; 
        m/=r;
    }
    int x=0;
    if (n>=0) x=2;else x=1; 
    for (int i=x;i<=z;i+=2)
    if (a[i]>0)  {
        a[i+1]++;
        if (a[i+1]>=r) a[i+2]+=a[i+1]/r,a[i+1]%=r;
        if (a[z+1]) z++; 
        a[i]=-(r-a[i]);
    }
    for (int i=z;i>0;i--)
    if (f(a[i])<10) printf("%d",f(a[i]));else 
    printf("%c",(char)f(a[i])+'A'-10);
    return 0;
} 

Measured memory_bytes: 256
n,m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]
ans = 0
for i in range(m):
  graph = [list() for i in range(n+1)]
  visited = [True]+[False] * (n)
  for k,(a,b) in enumerate(ab):
    if k == i:
      continue
    graph[a].append(b)
    graph[b].append(a)
  NEXT = [1]
  while len(NEXT):
    now = NEXT.pop()
    for j in graph[now]:
      if not visited[j]:
        visited[j] = True
        NEXT.append(j)
  if not all([j for j in visited]):
    ans += 1
print(ans)

Measured memory_bytes: 3064
def getlist():
    return list(map(int, input().split()))

N = int(input())
H = getlist()

ans = 0
c = 0
v = 0
for i in range(N):
    if H[i] <= v:
        c += 1
        if c > ans:
            ans = c
    else:
        c = 0
    v = H[i]

print(ans)

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

using namespace std;

int main(int qtd, char* nome[])
{
    string p;
    cin >> p;

    char color = p[0];
    int ans = 0;
    for (int i = 1; i < p.size(); i++){
        if(color == p[i]){
            ans++;
            if (p[i] == '0')
                p[i] = '1';
            else
                p[i] = '0';
        }
        color = p[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
a,b,C=map(float,input().split())
import math
S=0.5*a*b*math.sin(math.radians(C))
print('{:.8f}'.format(S))
print('{:.8f}'.format(a+b+math.sqrt(pow(a,2)+pow(b,2)-2*a*b*math.cos(math.radians(C)))))
print('{:.8f}'.format(S*2/a))



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

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

typedef long long ll;

const ll MOD = 998244353;

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> add(n);
    add[0] = 1; add[1] = MOD - 1;
    vector<int> l(k), r(k);
    for (int i = 0; i < k; ++i) {
        cin >> l[i] >> r[i];
    }
    ll can = 0;
    for (int i = 0; i < n; ++i) {
        can += add[i];
        can %= MOD;
        for (int j = 0; j < k; ++j) {
            if (i + l[j] < n) {
                add[i + l[j]] += can;
                add[i + l[j]] %= MOD;
            }
            if (i + r[j] < n - 1) {
                add[i + r[j] + 1] += MOD - can;
                add[i + r[j] + 1] %= MOD;
            }
        }
    }
    cout << can << endl;
    return 0;
}

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

#define F first
#define S second
#define pb push_back 
#define mp make_pair

#define ll long long 
#define ld long double 

#define vi vector <int>
#define vb vector <bool>
#define vc vector <char>
#define vll vector <ll>
#define vs vector <string>

#define pll pair < ll , ll >
#define pld pair < ld , ld >
#define pii pair < int , int >

#define vpld vector < pld >
#define vpii vector < pii >
#define vpll vector < pll >

#define vvi vector < vector < int > >
#define vvll vector < vector < ll > >
#define vvld vector < vector < ld > >
#define vvb vector < vector < bool > >
#define vvpii vector < vector < pii > >

#define all(v) (v).begin() , (v).end()
#define allrev(v) (v).rbegin() , (v).rend()

#define dist(x1 , y1 , x2 , y2) sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1))

const int MOD = 1e9 + 7 ;

bool isprime (ll num) {
    for (ll i = 2 ; i * i <= num ; ++i) {
		if (num % i == 0) return false ;
	}
    return true;
}
 
ll gcd (ll a, ll b) {
    if (b == 0) return a ;
	else return gcd (b , a % b) ;
}
 
ll lcm (ll a, ll b) {
    return ((a / gcd(a , b)) * b) ;
}
 
ll cel (ll x1, ll y1) {
    if ((x1) <= 0) return (x1) / (y1) ;
    return (((x1) / (y1)) + (((x1) % (y1)) != 0)) ;
}

int power(int x, unsigned int y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y%2 == 0) 
        return power(x, y/2)*power(x, y/2); 
    else
        return x*power(x, y/2)*power(x, y/2); 
} 

void solve (int test_case) {
	ll int a,b,c,d;
	cin>>a>>b>>c>>d;
	/*if(a>0&&b>0&&c>0&&d>0) cout<<b*d;
	else if(a>0&&b>0&&c<0&&d<0) cout<<a*d;
	else if(a<0&&b<0&&c>0&&d>0) cout<<b*c;
	else if(a<0&&b<0&&c<0&&d<0) cout<<a*c;
	else if(a==0||c==0) cout<<b*d;
	else if(b==0||d==0) cout<<a*c;
	else cout<<b*d;*/
	 ll ans=max({a*c,a*d,b*c,b*d});
	cout<<ans;
}

int main() {
	ios_base :: sync_with_stdio (false) ;
	cin.tie(0) ;
	cout.tie(0) ;
	int tc = 1 ;
	//cin >> tc ;
	while (tc--) {
		solve (tc) ;
	}
	return 0 ;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>

using namespace std;

class UnionFind
{
public:
	vector<int> par;
	vector<int> rk;
	UnionFind(int n)
	{
		par.resize(n);
		rk.resize(n);
		for (int i = 0; i < n; ++i)
		{
			par[i] = i;
		}
	}
	int find(int x)
	{
		if (par[x] == x)
		{
			return(x);
		}
		return(par[x] = find(par[x]));
	}
	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);
		if (rk[x] < rk[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (rk[x] == rk[y])
			{
				++rk[x];
			}
		}
	}
	bool same(int x, int y)
	{
		return(find(x) == find(y));
	}
};


void solve()
{
	int n, m;
	cin >> n >> m;
	UnionFind uf(n);
	for (int i = 0; i < m; ++i)
	{
		int s, t;
		cin >> s >> t;
		uf.unite(s, t);
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; ++i)
	{
		int s, t;
		cin >> s >> t;
		if (uf.same(s, t))
		{
			cout << "yes" << endl;
		}
		else
		{
			cout << "no" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1796
import kotlin.math.pow

fun main() {
    val n = readLine()?.toLong() ?: return
    if (n == 0L) {
        println("0")
        return
    }

    val h = hashMapOf<Long, Long>()
    h[0] = 1
    h[1] = -2
    var s = 0L
    var b = 0L
    var c = 0
    if (n < 0) {
        s = 0L
        b = -2L
        c = 0
        while (s > n) {
            s += b
            h[c + 2L] = h[c.toLong()]!! - (b * 2)
            b *= 4
            c += 2
            h[c - 1L] = s
        }
        s = -(2.0.pow((c - 1).toDouble()).toLong())

    } else {
        s = 1L
        b = 4L
        c = 1
        h[2] = b
        while (s < n) {
            s += b
            h[c + 2L] = h[c.toLong()]!! - (b * 2)
            b *= 4
            c += 2
            h[c - 1L] = s
        }
        s = 2.0.pow((c - 1).toDouble()).toLong()
    }
    buildString {
        append("1")
        (c - 2).downTo(0).forEach {
            val v = 2.0.pow(it.toDouble()).toLong()
            if (s != n) {
                if (it % 2L == 0L) {
                    if (s + v + h.getOrDefault(it - 1L, 0) <= n) {
                        s += v
                        append("1")
                    } else {
                        append("0")
                    }
                } else {
                    if (s - v + h[it - 1L]!! >= n) {
                        s -= v
                        append("1")
                    } else {
                        append("0")
                    }
                }
            } else {
                append("0")
            }
        }
    }.let {
        println(it)
    }
}

Measured memory_bytes: 34956
N=parse(Int,readline())
A=map(x->parse(Int,x),split(readline()))
ans=Int[]
for _=1:N
	id=-1
	for j=N-_+1:-1:1
		if A[j]==j
			id=j
			break
		end
	end
	if id<0
		println(-1)
		exit()
	end
	push!(ans,id)
	for j=id+1:N
		A[j-1]=A[j]
	end
end
reverse!(ans)
println.(ans)


Measured memory_bytes: 116516
import sys
sys.setrecursionlimit(10**6)
def grun(A, K):
    if A < K:
        return 0
    a, b = divmod(A, K)
    if b == 0:
        return a
    a += 1
    r = A % a
    return grun((((a-1)*K-r)//a)*a+r, K)
def solve():
    N = int(input())
    X = 0
    for _ in range(N):
        A, K = map(int, input().split())
        X ^= grun(A, K)
    print('Takahashi' if X else 'Aoki')

if __name__ == '__main__':
    solve()

Measured memory_bytes: 37740
#include <bits/stdc++.h>
using namespace std;
using st = size_t;
#define reps( i, n ) for ( size_t i = 0; i < ( size_t )( n ); ++i )

int main() {
    int n;
    cin >> n;
    vector<int> v( n );
    reps( i, n ) { cin >> v.at( i ); }
    sort( v.begin(), v.end() );
    int64_t min = 1000000000000000000, c;
    if ( n == 1 )
        min = 0;
    for ( st i = v.at( 0 ); i < v.at( n - 1 ); ++i ) {
        c = 0;
        for ( st j = 0; j < v.size(); ++j ) {
            c += ( v.at( j ) - i ) * ( v.at( j ) - i );
        }
        min = ::min( min, c );
    }
    if(min==1000000000000000000)
        min = 0;
    cout << min << "\n"s;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//

int main(){
    int rmax=200001;
    int p[200001]={0};
    int divi=2;
    p[0]=1,p[1]=1;
    while(divi*divi<=rmax){
        int i=2;
        while(i*divi<=rmax){
            p[i*divi]=1;
            i++;
        }
        divi++;
        while(p[divi]==1){
            divi++;
        }
    }
    int q[200001]={0};
    FOR(i,0,rmax){
        q[i]=(p[i]==0)&&(p[(i+1)/2]==0);
    }
    FOR(i,0,rmax-1){
        q[i+1]+=q[i];
    }
    int Q; cin>>Q;
    FOR(i,0,Q){
        int l,r; cin>>l>>r;
        cout<<q[r]-q[l-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 2176
<?php
fscanf(STDIN, "%d %d", $N, $K);
fscanf(STDIN, "%s", $S);

$ans = 0;
for ($i = 0; $i < $N - 1; $i++) {
    if ($S[$i] === $S[$i + 1]) {
        $ans++;
    }
}
$ans = min($ans + $K * 2, $N - 1);
printf("%d", $ans);


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll num;
  cin>>num;
  vector<ll> v(num);
  for(ll i=0;i<num;i++) cin>>v[i];
  sort(v.begin(),v.end());
  cout<<abs(v[num-1]-v[0])<<endl;
}


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

typedef long long ll;
typedef set<pair<ll, ll> >::iterator ite;
const int MAXN = 200010;
const ll INF = 1LL<<60;
int n, f1, f2;
ll x[MAXN], y[MAXN], ans = INF;
ll Rmin = INF, Rmax, Bmin = INF, Bmax; 
bool f;
set<pair<ll, ll> > S;

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = x*10 + ch-'0';
	return x * f;
}

inline ll calc(int x, int y) {
	ll d1 = max(Rmax-Rmin,max(x-Rmax, Rmin-x));
	ll d2 = max(Bmax-Bmin,max(y-Bmax, Bmax-y));
	return d1*d2;
}

int main() {
	int i;
	n = read();
	for(i = 1; i <= n; i++) {
		x[i] = read(), y[i] = read();
		if(x[i] < y[i]) swap(x[i], y[i]);
		Rmax = max(Rmax, x[i]);
		Bmin = min(Bmin, y[i]);
		Rmin = min(Rmin, x[i]);
		Bmax = max(Bmax, y[i]);
	}
	ans = min(ans, (Rmax-Rmin)*(Bmax-Bmin));
	Rmin = Bmin;
	for(i = 1; i <= n; i++) {
		if(x[i] == Rmax) f1++;
		if(y[i] == Rmin) f2++;
		if(x[i] == Rmax && y[i] == Rmin) f = true;
	}
	if(f&&f1==1&&f2==1) return 0;
	for(i = 1; i <= n; i++) S.insert(make_pair(y[i], i));
	while(true) {
		ite it = S.end();
		it--;
		ans = min(ans, (Rmax-Rmin)*((*it).first-(*S.begin()).first));
		if((*S.begin()).second != -1) {
			int id = (*S.begin()).second;
			S.erase((*S.begin()));
			S.insert(make_pair(x[id], -1));
		}
		else break;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 15872
<?php
  	$num = trim(fgets(STDIN));
	$weights = explode(" ", trim(fgets(STDIN)));	
	$min = array_sum($weights);
	
	for ($i=0;$i<$num;$i++) {    
      	
      	$firstHalf = array_slice($weights, 0, $i);
        $latterHalf = array_slice($weights, $i, $num);
      	
      	$diffabs =  abs(array_sum($firstHalf) - array_sum($latterHalf));
      	
      	if ($diffabs < $min) {
          	$min = $diffabs;
        }
    }
	
	echo $min . "\n";

Measured memory_bytes: 3576
#include<stdio.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

void run (void) {
  i32 n, m, d;
  scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32, &n, &m, &d);
  double p = (double)(d == 0 ? n : 2 * (n - d)) / n / n;
  double ans = p * (m - 1);
  printf ("%.7f\n", ans);
}

int main (void) {
  run();
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <bitset>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

const ll base = 80*80+3;
constexpr size_t BITSET_SIZE = 80*80*80+10;

ll H, W;
ll A[90][90], B[90][90];
std::bitset<BITSET_SIZE> dp[90][90];

std::bitset<BITSET_SIZE> shift( const std::bitset<BITSET_SIZE> &x, ll s ) {
  if( s > 0 )
    return x << s;
  else
    return x >> (-s);
}

int main()
{
  std::cin >> H >> W;

  rep( i, H ) rep( j, W )
    std::cin >> A[i][j];

  rep( i, H ) rep( j, W )
    std::cin >> B[i][j];

  dp[0][0].set(base+A[0][0]-B[0][0]);
  dp[0][0].set(base-A[0][0]+B[0][0]);

  rep( i, H ) rep( j, W ) {
    if( i-1 >= 0 ) {
      dp[i][j] |= shift( dp[i-1][j], A[i][j]-B[i][j] );
      dp[i][j] |= shift( dp[i-1][j], -A[i][j]+B[i][j] );
    }
    if( j-1 >= 0 ) {
      dp[i][j] |= shift( dp[i][j-1], A[i][j]-B[i][j] );
      dp[i][j] |= shift( dp[i][j-1], -A[i][j]+B[i][j] );
    }
  }

  ll ans = INF;

  rep( i, BITSET_SIZE ) if( dp[H-1][W-1][i] )
    chmin( ans, llabs(i-base) );

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 404192
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static long LMS = 1900;
	public static long SMS = 100;
	public static void main(String[] args) {
		int i=0;
		int j=0;
		int k=0;
		Scanner sc = new Scanner(in);
		long n = parseLong(sc.next());
		long m = parseLong(sc.next());
		sc.close();
		long t = m*LMS+(n-m)*SMS;
		out.println(t*(long)pow(2,m));
	}
}


Measured memory_bytes: 22612
n,m = gets.split.map(&:to_i)
ac = Array.new(n).map{|i| i=0}
wa = Array.new(n).map{|i| i=0}
m.times {
    pi,si = gets.split.map(&:to_s) 
    if si == "AC" then
         ac[pi.to_i-1] += 1
    elsif si == "WA" && ac[pi.to_i-1] == 0 then
        wa[pi.to_i-1]+=1
    end
}

miss = 0;

n.times{ |i|
    if  ac[i] > 0 then miss += wa[i] end
}
print(ac.count{|i| i> 0}," ",miss,"\n")


Measured memory_bytes: 4860
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll (i) = (s); (i) < (x); (i) ++)
#define REP(i, x) PREP(i, 0, x)
#define MREP(i, s, x) for(ll (i) = (s); (i) >= (x); (i) --)
#define MOD7 (1000000007LL)
#define MOD9 998244353LL
#define INF (1LL<<60)
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;
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; }

using graph = vector<vector<ll>>;

graph g, rev_g;
vector<bool> seen;
vector<ll> numbering;
vector<ll> scc; // 頂点番号がgroupのグループに属するか返す
vector<vector<ll>> group; // グループごとに属する頂点番号を格納

void dfs(ll v){
    seen[v] = true;
    for(auto next_v : g[v]){
        if(seen[next_v]) continue;
        dfs(next_v);
    }
    numbering.push_back(v);
    return;
}

void rev_dfs(ll v, ll num){
    seen[v] = true;
    group[num].push_back(v);
    scc[v] = num;
    for(auto next_v : rev_g[v]){
        if(seen[next_v]) continue;
        rev_dfs(next_v, num);
    }
}

int main(){
    ll n, m;
    cin >> n >> m;
    g.resize(n);
    rev_g.resize(n);
    REP(i, m){
        ll a, b;
        cin >> a >> b;
        a --, b --;
        g[a].push_back(b);
        rev_g[b].push_back(a);
    }

    seen.resize(n);
    REP(i, n){
        // 未探索
        seen[i] = false;
    }

    REP(v, n){
        if(seen[v] == false) dfs(v);
    }

    reverse(numbering.begin(), numbering.end());

    REP(i, n){
        seen[i] = false;
    }

    scc.resize(n);

    ll num = 0;
    for(auto v : numbering){
        if(seen[v] == false){
            group.push_back(vector<ll>());
            rev_dfs(v, num);
            num ++;
        }
    }

    REP(i, num){
        sort(group[i].begin(), group[i].end());
    }

    REP(v, n){
        ll i = scc[v];
        for(auto ite = group[i].begin(); ite < group[i].end(); ite ++){
            cout << (*ite) + 1;
            if(ite != group[i].end() - 1) cout << " ";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 5672
'''     ##     ##  #######  # #  ######
        ##     ##  ##   ##  ###    ##
        ##     ##  ##    #  # #    ##
        #########  #######  # #    ##    '''

import sys
import math
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, input().strip().split())
def get_list(): return list(get_ints())

def printspx(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end=" \ ")

MODPRIME = int(1e9+7); BABYMODPR = 998244353;

ONLINE_JUDGE = 1
if not ONLINE_JUDGE:
    sys.stdin  = open("input.txt","r")
    sys.stdout = open("output.txt","w")
    sys.stderr = open("output.txt","w")

# for _testcases_ in range(int(input())):
s = input()
a = b = -1
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        a, b = i+1, i+2
        break
    elif i != len(s) - 2 and s[i] == s[i+2]:
        a, b = i+1, i+3
        break
print(a, b)




'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS BY ME @luctivud ( UDIT GUPTA )
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
DO NOT PLAGIARISE.
TESTCASES:
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

Measured memory_bytes: 39408
#include <stdio.h>
#include <queue>
#include <algorithm>
using namespace std;

int L[100005], R[100005];
priority_queue<pair<int, int>> pq[2];
int used[100005];

long long trial(int state){
    int cur = 0;
    long long res = 0;
    while(!pq[state].empty()){
        int x = pq[state].top().first;
        int ind = pq[state].top().second;
        if(state == 0) x = -x;
        pq[state].pop();
        if(used[ind]) continue;
        used[ind] = 1;
        if(state == 0 && x > cur) continue;
        else if(state == 1 && x < cur) continue;
        state = !state;
        res += abs(cur-x);
        cur = x;
    }
    res += abs(cur);
    return res;
}

int main(){
    int N;
    scanf("%d", &N);
    for(int i=0; i<N; i++){
        scanf("%d%d", &L[i], &R[i]);
        pq[0].push({-R[i], i});
        pq[1].push({L[i], i});
    }
    long long res = trial(0);
    for(int i=0; i<N; i++){
        used[i] = 0;
        pq[0].push({-R[i], i});
        pq[1].push({L[i], i});
    }
    res = max(res, trial(1));
    printf("%lld", res);
    return 0;
}


Measured memory_bytes: 4460
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[] arrived;
    static ArrayList<ArrayList<Integer>> li;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        Long[] a = new Long[n];
        long[] f = new long[n];
        long total = 0;
        for(int i = 0; i < n; i++){
            long t = sc.nextLong();
            a[i] = t;
            total += t;
        }
        Arrays.sort(a,Collections.reverseOrder());
        if(total <= k){
            System.out.println(0);
            return;
        }
        for(int i = 0; i < n; i++){
            long t = sc.nextLong();
            f[i] = t;
        }
        Arrays.sort(f);
        System.out.println(beamSearch(k,a,f));
    }
    
    public static long beamSearch(long k, Long[] a, long[] f){
        int n = a.length;
        long left = 0;
        long right = (long)Math.pow(10,12)+1;
        while(right - left > 1){
            long mid = (right + left)/2L;
            long tmp = 0;
            for(int i = 0; i < n; i++){
                tmp += Math.max(0,a[i]-(mid/f[i]));
            }
            if(tmp <= k){
                right = mid;
            }else{
                left = mid;
            }
        }
        return right;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
    
    public void close() throws Exception{
        this.reader.close();
        return;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 64000
# Author: cr4zjh0bp
# Created: Sat Mar 28 15:38:17 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import deque

n = ni()
abc = nan(n - 1)
q, k = na()
k -= 1
xy = nan(q)
tree = [[] for _ in range(n)]
for i in range(n - 1):
    a, b, c = abc[i]
    a -= 1
    b -= 1
    tree[a].append((b, c))
    tree[b].append((a, c))

def bfs():
    q = deque()
    q.append(k)
    dist = [-1] * n
    dist[k] = 0
    while len(q):
        p = q.popleft()
        for i, w in tree[p]:
            if dist[i] != -1:
                continue
            dist[i] = dist[p] + w
            q.append(i)
    return dist

dist = bfs()
for i in range(q):
    x, y = xy[i]
    x -= 1
    y -= 1
    print(dist[x] + dist[y])

Measured memory_bytes: 87852
import itertools
N , M ,Q= map(int,input().split())
seq = list(range(N+M-1))
pattern = list(itertools.combinations(seq,N))
prob_array = []
for i in range(Q):
    a ,b ,c , d = map(int,input().split())
    prob_array.append([a,b,c,d])
    
def convert_number(lst):
    num_ = 1
    lst = list(lst)
    lst.insert(0,-1)
    return_list = []
    for i in range(len(lst) - 1):
        num_ += lst[i+1] - lst[i] - 1
        return_list.append(num_)
    return return_list
    
opt_point = 0
for input_list in pattern:
    judge_list = convert_number(input_list)
    temp_point = 0
    for p_ in prob_array:
        if judge_list[p_[1] - 1] - judge_list[p_[0] - 1] == p_[2]:
            temp_point += p_[3]
    if temp_point >= opt_point:
        opt_point = temp_point
print(opt_point)            
            
    




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

int main(void)
{
    long long  N, D;
    cin >> N >> D;
    vector<long long> X(N);
    vector<long long> Y(N);
    for (long long i = 0; i < N; i++)
    {
        cin >> X[i] >> Y[i];
    }

    long long ans = 0;
    for (long long i = 0; i < N; i++)
    {
        if (pow((pow(X[i], 2) + pow(Y[i], 2)), 0.5) <= D)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6428
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int N, K, ans=0;
  cin >> N >> K;
  int p[N];
  for(int i=0; i<N; i++) cin >> p[i];
  sort(p, p+N);
  for(int i=0; i<K; i++) ans += p[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;

int main(){
    ll n; cin>>n;
    ll ans=0;
    rep(i,0,n){
        ll l,r;
        cin>>l>>r;
        ans+=r-l+1;
    }
    cout<<ans<<"\n";
}

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

int main() {
    LL n, current, answer;

    cin >> n;

    if (n%2 == 1) {
        cout << 0 << endl;
    } else {
        n /= 2;

        current = 5;
        answer = 0;

        while (n/current > 0) {
            answer += n/current;
            current *= 5;
        }

        cout << answer << endl;
    }
}


Measured memory_bytes: 256
//
//  main.cpp
//  temp
//
//  Created by ???????????? on 2017/11/06.
//  Copyright ?? 2017??´ ????????????. All rights reserved.
//

#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    int a,b;
    cin >> a >> b;
    cout << a * b << " " << a + b + a + b << endl;
    return 0;
}

Measured memory_bytes: 3044
import re


S = input()

if re.match('^keyence$', S):
    print('YES')
elif re.match('^(.+)keyence$', S):
    print('YES')
elif re.match('^k(.+)eyence$', S):
    print('YES')
elif re.match('^ke(.+)yence$', S):
    print('YES')
elif re.match('^key(.+)ence$', S):
    print('YES')
elif re.match('^keye(.+)nce$', S):
    print('YES')
elif re.match('^keyen(.+)ce$', S):
    print('YES')
elif re.match('^keyenc(.+)e$', S):
    print('YES')
elif re.match('^keyence(.+)$', S):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int a[32] = {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};

signed main() {
	int k;
	cin >> k;
	cout << a[k - 1] << endl;
	return 0;
}

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

int main(){
  int N,t=0,c=1;
  cin>>N;
 vector<pair<int,int>> P(N);
  for(int i=0;i<N;i++){
    cin>>P.at(i).second>>P.at(i).first;
  }
  sort(P.begin(),P.end());
  for(int i=0;i<N;i++){
    t+=P.at(i).second;
    if(P.at(i).first<t){
      c=0;
    }
  }
  if(c==0){
    cout<<"No";
  }
else{
  cout<<"Yes";
}
  
 // cout<<P.at(0).second;
       
}


Measured memory_bytes: 1792
/*
 * @Author: RBQRBQ
 * @Date: 2020-04-05 15:08:15
 * @LastEditors: RBQRBQ
 * @LastEditTime: 2020-04-05 19:16:50
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll,ll> pii;
namespace IO{
    template<typename T>inline void read(T &x){
        x=0;ll f=1;char ch=getchar();
        while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
        while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
        x=x*f;
    }
}
using namespace IO;
vector<pii> pp;
vector<pii> T;
ll mxL,minR,mxR,minL;


int main()
{
    int N;
    cin>>N;
    mxL=mxR=-1;
    minL=minR=10000000000ll;
    int P,Q;
    for(int i=1;i<=N;i++)
    {
        ll x,y;
        read(x),read(y);
        y++;
        pp.push_back(make_pair(x,y));
        if(x>mxL)
        {
            mxL=x;
            P=i;
        }
        if(minR>y)
        {
            minR=y;
            Q=i;
        }
    }
    ll ans1=0,ans2=0;
    minL=0;
    for(int i=1;i<=N;i++)
    {
            minL=max(minL,pp[i-1].second-pp[i-1].first);
    }

    ans1=max((minL),0ll)+max((minR-mxL),0ll);

    int ca=1;
    for(auto p:pp)
    {
        if(ca!=P&&ca!=Q)
        T.push_back(make_pair(max(p.second-mxL,0ll),max(minR-p.first,0ll)));
        ca++;
    }
    sort(T.begin(),T.end());
    ll P1=pp[P-1].second-pp[P-1].first;
    ll Q1=pp[Q-1].second-pp[Q-1].first;
    ll x1=0,x2=Q1;
    // for(auto p:T)
    // {
    //     cout<<p.first<<" "<<p.second<<endl;
    // }
    for(int i=0;i<T.size();i++)
    {
        
        x1=min(T[i].first,P1);
        ans2=max(ans2,x1+x2);
        x2=min(T[i].second,x2);
    }
    ans2=max(ans2,P1+x2);
    cout<<max(ans1,ans2);

}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

typedef long long LL;
  
#define ordered_set tree<LL, null_type,less_equal<LL>, rb_tree_tag,tree_order_statistics_node_update> 



const int N = 2e5 + 7;

LL a[N];

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	LL n, k, sum = 0, ans = 0; cin >> n >> k;
	ordered_set ost; ost.insert(0);
	for(int i = 1; i <= n; i++) {
		LL x; cin >> x; sum += x;
		LL z = sum - k * i;
		ans += ost.order_of_key(z + 1);
		ost.insert(z);
	}
	cout << ans << endl;
}

Measured memory_bytes: 16156
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;
typedef long long ll;

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> data(Q);
    for (int i = 0; i < Q; i++) {
        cin >> data.at(i);
    }
    vector<int> point(N + 1, 0);
    for (int i = 0; i < Q; i++) {
        point.at(data.at(i))++;
    }
    for (int i = 1; i <= N; i++) {
        if (point.at(i) > Q - K) {
            cout << "Yes" << endl;
            continue;
        }
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3996
import sys

sys.setrecursionlimit(10**7)
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
printn = lambda x: print('\n'.join(x))

a, b, n = nm()
if b-1 < n:
    c = (a-1)//b + 1
    print(a - c)
else:
    print(a*n//b - a*(n//b))


Measured memory_bytes: 9256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
struct edge{ int to, cost; };
const int INF = 1001001001;
const int MAX_N = 200005;
const int MAX_V = 200005;
vector<edge> G[MAX_V];
int d[MAX_V];
int bef[MAX_N];

void dijkstra(int s){
    // greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+MAX_V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        for(int i=0; i<G[v].size(); i++){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                bef[e.to] = v;
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    rep(i,m){
        int from,to,cost;
        cin >> from >> to;
        cost = 1;
        edge e1, e2;
        e1.to = to; e1.cost = cost;
        e2.to = from; e2.cost = cost;
        G[from].push_back(e1);
        G[to].push_back(e2);
    }

    dijkstra(1);

    cout << "Yes" << endl;
    srep(i,2,n+1){
        cout << bef[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 16240
#include<cstdio>

using namespace std;

int main(){
	int N, M, K;
	scanf("%d%d%d", &N, &M, &K);
	for(int i = 0; i <= N; ++i){
		for(int j = 0; j <= M; ++j){
			int tmp = i * j + (N - i) * (M - j);
			if(tmp == K){
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 128