akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define sz(a)       (ll)(a.size())
#define cr(P)       cout<<P<<"\n";return;
#define mem(a,val)  memset(a, val, sizeof(a))
#define fr(i,x,n)   for(ll i=x; i<n; i++)
#define frr(i,x,n)  for(ll i=n-1; i>=x; i--)
using namespace std;


const ll N   =  500005;
const ll mod = 1e9 + 7;



void solve(){

 ll x=0, y=0, c = 0, ans = 1000;
 ll n, m, k;

 cin >> n;
 ll a[n+1];
 stack<ll>s;
 for (ll i = 1; i <= n; ++i){
 	cin >> a[i];
 	
 }

 vector<ll> dp(n+1,1000);

 for (ll i = 1; i <= n; ++i){
 	for (ll j = 1; j < i; ++j){
 		dp[i] = max((dp[j]/a[j]) * a[i] + dp[j] % a[j], dp[i]);
 		dp[i] = max(dp[i],dp[j]);
 	}
 // /	cout << dp[i] <<" ";
 	ans = max(ans , dp[i]);
 }
    
 cout << ans << '\n';

 
}

signed main(){
     
 ios_base::sync_with_stdio(false);   
 cin.tie(NULL);
 //int T;cin >> T;while (T--)
 solve();
 return 0;
}



Measured memory_bytes: 3648
#include <algorithm>
#include <cstdlib>
#include <iostream>

using namespace std;

int N;

int guess(int val) {
    if (val == N)
        val = 0;
    cout << val << endl;

    string s;
    cin >> s;
    if (s[0] == 'M')
        return 0;
    if (s[0] == 'F')
        return 1;
    exit(0);
}

int main() {
    cin >> N;

    int l = 0, r = N / 2;
    int gl = guess(l);
    int gr = guess(r);
    if (((r - l) % 2 == 0) == (gr == gl)) {
        swap(gl, gr);
        l = r;
        r = N;
    }

    for (int iter = 0; iter < 20; iter++) {
        if (r - l < 3) {
            for (int i = l; i <= r; i++)
                guess(i);
        }

        int mid = (l + r) / 2;
        int gm = guess(mid);
        if (((mid - l) % 2 == 0) == (gm == gl)) {
            l = mid;
            gl = gm;
        }
        else {
            r = mid;
            gr = gm;
        }
    }
}


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

int main() {
  string s,t;
  cin>>s>>t;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
}


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

int main() {
  int n;
  cin >> n;
  int k;
  cin >> k;
  int cnt = 0;
  rep(i, n) {
    int h;
    cin >> h;
    if(h >= k) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

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

int main()
{
  int N,K,Q;
  cin >> N >> K >> Q;
  int A;
  int p[N];
  int i,j;
  
  for(i=0;i<N;i++)
    p[i]=K-Q;
  for(i=0;i<Q;i++)
  {
    cin >> A;
    p[A-1]++;
  }
  
  for(i=0;i<N;i++)
    if(p[i] > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n, x;
    cin >> n >> x;
    vector <int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector <int> mn = a;
    ll ans = 2e18;
    for (int mx = 0; mx < n; ++mx) {
        for (int i = 0; i < n; ++i) mn[i] = min(mn[i], a[(i - mx + n) % n]);
        ll cur = (ll)mx * x;
        for (int i = 0; i < n; ++i) cur += mn[i];
        ans = min(ans, cur);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    set<int> st;
    map<int, bool> repeat, vis;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (st.count(x))
            repeat[x] = true;
        st.insert(x);
    }
    int ans = 0;
    for (auto i : st) {
        if (vis[i])
            continue;
        for (int j = i * 2; j <= 1e6; j += i)
            vis[j] = true;
        if (!vis[i] && !repeat[i])
            ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int dp[100005];

int Frog_Jump(int n, int arr[])
{
    if(n == 2)
        return arr[2] - arr[1];

    dp[1] = 0;
    dp[2] = abs(arr[2] - arr[1]);
    dp[3] = abs(arr[3] - arr[1]);

    for(int i = 4; i <= n; i++){
        int x = abs(arr[i] - arr[i - 2]);
        int a = dp[i - 2] + x;

        int y = abs(arr[i] - arr[i - 1]);
        int b = dp[i - 1] + y;

        dp[i] = min(a, b);
    }

    return dp[n];
}

int main ()
{
    int N;
    int h[100005];

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

    cout << Frog_Jump(N, h) << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>

int main(){
    ll A,B,C,K;
    cin>>A>>B>>C>>K;
    ll ans=0;
    ll na=0,nb=0,nc=0;
    if(K>=A){
        na=A;
        if(K>=(A+B)){
            nb=B;
            if(K<=(A+B+C)){
                nc=K-(na+nb);
            }else{nc=C;}
        }else{na=A;nb=(K-na);nc=0;}
    }
    else{na=K;nb=0;nc=0;}
    ans=na+nc*(-1);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>

using namespace std;
int main(){
    int a,b,c,x,y,max,next,flag_x = 0,money = 0;
    cin >> a >> b >> c >> x >> y;
    if(x > y){
        max = x;
        next = y;
        flag_x++;
    }else{
        max = y;
        next =x;
    }
    if(a+b > c*2){
        money += c*2*(next);
    }else{
        money += (a+b)*(next);
    }

    if(flag_x){
        if(a>=c*2){
            money += c*2*(max-next);
        }else{
            money += a*(max-next);
        }
    }else{
        if(b>=c*2){
            money += c*2*(max-next);
        }else{
            money += b*(max-next);
        }
    }
    cout << money <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cout<<fixed<<setprecision(12);
  cin.tie(0);	
  ios::sync_with_stdio(false);
  while(1){
    int n,m,k;
    cin>>n>>m>>k;
    if(n==0) break;
    int dp[(n*m)+1]={0},dp2[(n*m)+1]={0};
    dp[0]=1;
    rep(i,n){
      repn(j,((i+1)*m)+1){
	rep(k,m){
	  if(j-(k+1) >= 0){
	    dp2[j]+=dp[j-(k+1)];
	  }
	}
      }
      rep(j,(n*m)+1){
	dp[j]=dp2[j];
	dp2[j]=0;
      }
    }
    double under=0,over=0;
    rep(i,(n*m)+1){
      //cout<<dp[i]<<" "<<i<<endl;
      under+=dp[i];
      over+=dp[i]*max((int)1,(i-k));
    }
    cout<<over/under<<endl;
  }
    

  return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;

string substring(int L, string S, ull mask){
    string s="",r="";
    for(int i=0;i<L;i++){
        if((1<<i)&mask) s+=S[i];
        else r+=S[i];
    }
    return s+","+r;
}

int main(){
    int N;
    string S;
    cin >> N >> S;

    string A,B;
    A=S.substr(0,N);
    B="";
    for(int i=1;i<=N;i++){
        B=B+S[2*N-i];
    }

    map<string,ll> cA,cB;
    for(ull m=0;m<(1<<N);m++){
        cA[substring(N,A,m)]++;
        cB[substring(N,B,m)]++;
    }

    ll ans=0;
    for(auto x : cA){
        ans+=x.second*cB[x.first];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 83584
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int x,a,b;
    cin>>x>>a>>b;
    if(a>=b){
        cout<<"delicious"<<endl;
    }else if(-a+b<=x){
        cout<<"safe"<<endl;
    }else{
        cout<<"dangerous"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; 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(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int n;
	cin >> n;
	vector<int> s;
	long long int sum = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		s.push_back(a);
		sum = sum + a;
	}
	long long int now = 0;
	long long int now1 = 0;
	long long int judge = sum / 2;
	for (int i = 0; i < n - 1; i++) {
		now = now + s[i];
		if (now >= judge) {
			break;
		}
	}
	for (int i = n; i > 0; i--) {
		now1 = now1 + s[i];
		if (now1 >= judge) {
			break;
		}
	}
	cout << min(max(now, sum - now) - min(now, sum - now), max(now1, sum - now1) - min(now1, sum - now1));
}

Measured memory_bytes: 1400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            string szLine = Console.ReadLine();
            long n = long.Parse(szLine);
            szLine = Console.ReadLine();
            string[] szArr = szLine.Split(' ');

            long[] arr = new long[n];

            for (int i = 0; i < arr.Length; ++i)
            {
                arr[i] = long.Parse(szArr[i]);
            }


            // oddの数が2の倍数ならおｋ
            int oddTotal = 0;
            foreach(long val in arr)
            {
                if(val % 2 != 0)
                {
                    oddTotal++;
                }
            }

            string result = oddTotal % 2 == 0 ? "YES" : "NO";
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 20832
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define int long long
#define gcd __gcd
const int inf = 0x3f3f3f3f;
const int maxn = 201110;
const int M = 1e9+7;
int n,m,k,ok;

bool check(int x)
{
    int a = x*0.08;
    int b = x*0.1;
    if(a == n && b == m) return true;
    return false;
}

signed main()
{
    cin>>n>>m;
    int ans = 0;
    for(int i = 1; i <= 2000; i++) 
    {   
        if(check(i))
        {
            ans = i;
            break;
        }
    }
    if(ans) cout<<ans<<endl;
    else cout<<-1<<endl;
    return 0;
}

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

int main() {
    int N, M; cin >> N >> M;
    vector<int> X(M), Xdiff;
    for(int i = 0; i < M; i++) cin >> X[i];
    sort(X.begin(), X.end());
    for(int i = 1; i < M; i++) {
        Xdiff.push_back(X[i] - X[i-1]);
    }
    sort(Xdiff.begin(), Xdiff.end());
    reverse(Xdiff.begin(), Xdiff.end());
    int sum = 0;
    for(int i = N-1; i < M; i++) {
        sum += Xdiff[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
ll gcd(ll a, ll b) {
    return b != 0 ? gcd(b, a%b) : a;
}

map<ll, ll> prime_factorization(ll n){
    map<ll,ll> ret;
    for(ll i=2;i*i<=n+1;i ++){
        while(n%i==0){
            ret[i] ++;
            n /= i;
        }
    }
    if(n!=1) ret[n]=1;
    return ret;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);
    //start = chrono::system_clock::now();
        ll A, B;
        cin >> A >> B;
        ll div = gcd(A,B);
        auto divs = prime_factorization(div);
        cout << divs.size()+1 << endl;
    //end = chrono::system_clock::now();
    //cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
    return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    vector<int> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i];
    }
    
    if (n == 2) {
        if (data[0] == data[1] && data[0] == 1) {
            std::cout << "Possible" << std::endl;
        } else {
            std::cout << "Impossible" << std::endl;
        }
        return 0;
    }

    vector<int> funami(n, 0);
    rep(i, data.size()) {
        funami[data[i]]++;
    }

    int left, right;
    rep(i, funami.size()) {
        if (funami[i]) {
            left = i;
            break;
        }
    }
    for (int i = n-1; i >= 0; i--) {
        if (funami[i]) {
            right = i;
            break;
        }
    }

    if (funami[left] > 1) {
        if (funami[left] > 2) {
            std::cout << "Impossible" << std::endl;
            return 0;
        }
        if (right != left * 2 - 1) {
            std::cout << "Impossible" << std::endl;
            return 0;
        }
        for (int i = left; i < right; i++) {
            if (funami[i] < 2) {
                std::cout << "Impossible" << std::endl;
                return 0;
            }
        }
        std::cout << "Possible" << std::endl;
        return 0;
    }

    if (left * 2 != right) {
        std::cout << "Impossible" << std::endl;
        return 0;
    }

    for (int i = left; i < right+1; i++) {
        if (!funami[i]) {
            std::cout << "Impossible" << std::endl;
            return 0;
        }
    }

    if (funami[left] > 1) {
        std::cout << "Impossible" << std::endl;
        return 0;
    }

    for (int i = left+1; i < right+1; i++) {
        if (funami[i] <= 1) {
            std::cout << "Impossible" << std::endl;
            return 0;
        }
    }
    std::cout << "Possible" << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());

		int sum = 0;

		String[] s1 = new String[N];
		int A = 0;
		int B = 0;
		int BA = 0;

		for(int i=0;i<N;i++) {
            int t=0;
			String st = sc.next();
			if(st.substring(0,1).equals("B")) {
				t+=2;
			}
			int sl = st.length();
			if(st.substring(sl-1,sl).equals("A")){
				t++;
			}

			if(t==1) {
				A++;
			}else if(t==2){
				B++;
			}else if(t==3){
				BA++;
			}

			for(int j=0;j<sl-1;j++){

				String t1= st.substring(j,j+2);
				if(t1.equals("AB")) {
					sum++;
					j++;
				}
			}
		}
		if(BA==0) {
			if(B==A) {
				sum += A;
			}else {
				sum += Math.min(A,B);
			}
		}else {
			if(B==A){
				if(A==0) {
					sum += (BA-1);
				}else {
					sum = sum + BA + A;
				}
			}else{
				if(B==0||A==0) {
					sum += BA;
				}else {
					sum += BA + Math.min(A,B);
				}
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 33544
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int A = sc.nextInt();
    	int B = sc.nextInt();
    	int C = sc.nextInt();
    	int D = sc.nextInt();
    	if ((A+B) < (C+D)) {
    		System.out.println("Right");
    	} else if ((A+B) > (C+D)) {
    		System.out.println("Left");
    	} else {
    		System.out.println("Balanced");
    	}
    }
}

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

int n, m;
int sol[100001];

vector <pair <int, int> > v[100001];
unordered_map <int, int> used[100001];

queue <int> q;

void dfs(int nod, int cul, int val){
    if(nod == n){
        printf("%d", sol[n]);
        exit(0);
    }

    for(auto it : v[nod]){
        if(it.second == cul){
            if(sol[it.first] < val - 1) continue ;
            if(used[it.first].count(cul)) continue ;

            used[it.first][cul] = 1;

            if(sol[it.first] > val){
                sol[it.first] = val;
                q.push(it.first);
            }
            dfs(it.first, cul, val);
        }
    }
}

void dijkstra(){
    memset(sol, 0x3f, sizeof(sol));

    q.push(1);
    sol[1] = 0;

    int ind = 0;
    while(!q.empty()){
        int nod = q.front();
        q.pop();

        for(auto it : v[nod]){
            if(sol[it.first] < sol[nod]) continue ;
            if(used[it.first].count(it.second)) continue ;

            used[it.first][it.second] = 1;
            used[nod][it.second] = 1;
            if(sol[it.first] > sol[nod] + 1){
                sol[it.first] = sol[nod] + 1;
                q.push(it.first);
            }
            dfs(it.first, it.second, sol[nod] + 1);
        }
    }
}

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

    int x, y, c;
    for(int i = 1; i <= m ; ++i){
        scanf("%d%d%d", &x, &y, &c);
        v[x].push_back({y, c});
        v[y].push_back({x, c});
    }

    dijkstra();

    printf("-1");
    return 0;
}


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

import sys
from itertools import accumulate
from bisect import bisect_right

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def build_grid(H, W, intv, _type, space=True, padding=False):
    # 入力がスペース区切りかどうか
    if space:
        _input = lambda: input().split()
    else:
        _input = lambda: input()
    _list = lambda: list(map(_type, _input()))
    # 余白の有無
    if padding:
        offset = 1
    else:
        offset = 0
    grid = list2d(H+offset*2, W+offset*2, intv)
    for i in range(offset, H+offset):
        row = _list()
        for j in range(offset, W+offset):
            grid[i][j] = row[j-offset]
    return grid

def popcount(i):
    return bin(i).count('1')

H, W, K = MAP()
grid = build_grid(H, W, 0, int, space=0)

ans = INF
for S in range(1<<(H-1)):
    N = popcount(S) + 1
    A = list2d(N, W, 0)
    for w in range(W):
        A[0][w] = grid[0][w]
    h = 0
    for k in range(H-1):
        if S & 1<<k:
            h += 1
        for w in range(W):
            A[h][w] += grid[k+1][w]
    for i in range(N):
        A[i] = [0] + list(accumulate(A[i]))
    cnt = 0
    idx = 1
    while 1:
        nxt = INF
        for i in range(N):
            j = idx
            tgt = K + A[i][idx-1]
            while j < W+1 and A[i][j] <= tgt:
                j += 1
            nxt = min(nxt, j)
            # nxt = min(nxt, bisect_right(A[i], K+A[i][idx-1], lo=idx))
        if idx == nxt:
            cnt = INF
            break
        idx = nxt
        if idx == W+1:
            break
        cnt += 1
    ans = min(ans, N-1+cnt)
print(ans)


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(LL i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (LL)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;
const int MAX = 100005;
string t = "keyence";
int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //freopen("In.txt" , "r" , stdin);
	string s;
	cin >> s;
	if(s == t)
	{
		cout << "YES";
		return 0;
	}
	for(int i = 0; i < s.size(); i++)
	{
		for(int j = i; j < s.size(); j++)
		{
			string u;
			for(int k = 0; k < s.size(); k++)
				if(k < i || k > j)
					u += s[k];
			if(u == t)
			{
				cout << "YES";
				return 0;
			}
		}
	}
	cout << "NO";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;} 
int lcm(int a,int b){return a/gcd(a,b)*b;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    int maxv = -1 * INF;
    int cnt = 0;
    rep(i,n){
        maxv = max(cnt,maxv);
        if(s[i] == 'I') cnt++;
        else cnt--;
    }   
    cout << max(cnt,maxv) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {
	
	ll X;
	cin >> X;

	ll num = X / 100;

	if (X - num * 100 <= num * 5) cout << 1;
	else cout << 0;
}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005
  
typedef struct pp{
  char name[100];
  int t;
}P;
  
P Q[LEN+1];
int head, tail, n;
  
void enqueue(P x){
  Q[tail]=x;
  if(tail+1 == LEN+1)tail=0;
  else  tail++;
}
  
P dequeue(){
  P x;
  x=Q[head];
  if(head+1 == LEN+1)head=0;
  else head++;
  return x;
}
  
int isEmpty(){
  if(head == tail) 
     return 1;
  else
     return 0;
}
  
int main(){
  int elaps = 0;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  
  head = 1;
  tail = n + 1;
    
  while(1){
    if(head==tail)break;

    u = dequeue();

      
    if(u.t > q){
      elaps += q;
      u.t -= q;
      enqueue(u);
    }
      
    else {
      elaps += u.t;
      printf("%s %d\n",u.name,elaps);
    }
  
  }
  return 0;
}

Measured memory_bytes: 10756
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	vector<int>x;
	string s;
	while (cin >> s){
		if (s == "0")break;
		int sum = 0;
		for (int i = 0; i != s.size(); i++){
			sum += s[i] - '0';
		}
		x.push_back(sum);
	}
	for (int i = 0; i != x.size(); i++)
	{
		cout << x[i] << endl;
	}
}

Measured memory_bytes: 3168
#include<stdio.h>
int main()
{
	int n,num;
	int a[105],b[105];
	int min=1005,flag=0;
	scanf("%d%d",&n,&num);
	for(int i=0;i<n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		if(b[i]<=num)
		{
			flag=1;
			if(a[i]<min)
				min=a[i];
		}
	}
	if(flag==1)
		printf("%d\n",min);
	else
		printf("TLE\n");
	return 0;
}

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

#define DIV 1000000007

int main(void){
	long long n, m;
	long long a[200000] = { 0 };
	long long ans = 1;
	long long f[200000] = { 0 };
	int flag = 0;

	scanf("%lld %lld", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%lld", &a[i]);
		if (i && a[i] == a[i - 1] + 1) flag = 1;
	}
	if (flag)printf("0");
	else {
		f[0] = 1, f[1] = 1;
		for (int i = 2; i <= n; i++)
			f[i] = (f[i - 1] % DIV + f[i - 2] % DIV) % DIV;

		if (m == 0)printf("%lld", f[n]);
		else {
			for (int i = 0; i <= m; i++) {
				if (i == 0)ans = (ans * f[a[i] - 1]) % DIV;
				else if (i == m)ans = (ans * f[n - a[i - 1] - 1]) % DIV;
				else ans = (ans * f[a[i] - a[i - 1] - 2]) % DIV;
			}
			printf("%lld", ans);
		}
	}
	return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

long long k, q;
long long d[5000];
long long n[5000];
long long x[5000];
long long m[5000];
long long sum;
long long sum_all;
long long diff;
int main() {
	cin >> k >> q;
	for (int i = 0; i < k; i++) {
		cin >> d[i];
	}

	for (int i = 0; i < q; i++) {
		cin >> n[i] >> x[i] >> m[i];
	}
	for (int i = 0; i < q; i++) {
		sum = (x[i] % m[i]);
		sum_all = 0;
		diff = 0;
		for (int j = 0; j < k; j++) {
			sum_all += d[j] % m[i];
			if (d[j] % m[i] == 0) {
				diff += 1;
			}
		}
		sum += sum_all * ((n[i] - 1) / k);
		diff = diff * ((n[i] - 1) / k);
		for (int j = 0; j < (n[i] - 1) % k; j++) {
			sum += d[j] % m[i];
			if (d[j] % m[i] == 0) {
				diff += 1;
			}
		}
//		cout << sum << " ";
//		if (sum < 0) { n[i] += 1; }
		cout << n[i] - 1 - sum / m[i] - diff << "\n";
	}
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int  INF = (1 << 30);

struct roadwork {
	int x, s, t;
	roadwork() : x(0), s(0), t(0) {}
	void read() { cin >> s >> t >> x; }
};

int main() {
	int N, Q; cin >> N >> Q;
	vector<roadwork> rw(N);
	for (int i = 0; i < N; ++i)
		rw[i].read();
	// 出発時間系の座圧
	map<int, int> mp;
	mp[-INF] = 0;
	mp[INF] = 0;
	for (auto& r : rw) {
		mp[r.s - r.x] = 0;
		mp[r.t - r.x] = 0;
		// mp[r.s - r.x - 1] = 0;
	}
	int tmp = 0;
	vector<int> time;
	for (auto& e : mp) {
		e.second = tmp++;
		time.push_back(e.first);
	}

	int sz = mp.size();
	vector<int> res(sz, INF);
	vector<vector<pair<bool, int>>> imos(sz);
	for (auto& r : rw) {
		imos[mp[r.s - r.x]].emplace_back(true, r.x);
		imos[mp[r.t - r.x]].emplace_back(false, r.x);
	}
	map<int, int> cnt;
	for (int i = 0; i < sz; ++i) {
		for (auto& p : imos[i]) {
			if (p.first) {
				cnt[p.second]++;
			}
			else {
				if (cnt[p.second] > 1) --cnt[p.second];
				else cnt.erase(p.second);
			}
		}
		if (cnt.size())
			res[i] = (*(cnt.begin())).first;
	}

	/*
	for (auto i : time) cout << i << " ";
	cout << endl;
	for (auto i : res) cout << i << " ";
	cout << endl;
	*/

	while (Q--) {
		int d; cin >> d;
		auto iter = upper_bound(time.begin(), time.end(), d);
		int idx = iter - time.begin() - 1;
		//cout << "idx : " << idx << "  ";
		if (res[idx] != INF)
			cout << res[idx] << endl;
		else cout << -1 << endl;
	}
}


Measured memory_bytes: 56692
n = int(input())
an = [int(i) for i in input().split()]
ans_a = max(an)
ans_b = 0
for i in an:
  if min(ans_a - ans_b,ans_b) < min(ans_a - i,i):
    ans_b = i
print(str(ans_a) + ' ' + str(ans_b))

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

#define crap ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CN cout<<"NO\n"
#define CY cout<<"YES\n"

using namespace std;
using ll = long long;
void solve()
{
    ll n,k,x;
    cin>>n>>k>>x;
    ll y=ceil((n*1.0)/k); 
    cout<<y* x;
}
int main()
{
    crap;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin) ;
        freopen("output.txt","w", stdout) ;
        freopen("error.txt","w", stderr) ;
    #endif
    int t;t=1;
 //  cin>>t;
    while(t--)
        {solve();}
    return 0;
}

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

int main(){
    int n,count;
    cin>>n;
    count=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(x==2){
            count++;
        }
        else if(x%2!=0){
            if(x<9){
                count++;
            }
            else{
                for(int j=3;j<=sqrt(x);j++){
                    if(x%j==0){
                        break;
                    }
                    if(j==(int)sqrt(x)){
                        count++;
                    }
                }
            }
        }
    }
    cout<<count<<endl;
}



Measured memory_bytes: 3092
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
int main(void){
  string s;
  cin>>s;
  rep(i,s.size()){
    if(i%2==1){
      if(s[i]=='L'||s[i]=='U'||s[i]=='D'){
        continue;
      }else{
        cout<<"No"<<endl;
        return 0;
      }
    }else{
      if(s[i]=='R'||s[i]=='U'||s[i]=='D'){
        continue;
      }else{
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes";
  return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    vector<pair<ll,ll>> v(n);
    for(auto& i : v) cin >> i.first >> i.second;

    sort(all(v), [](auto a, auto b){return a.second < b.second;});

    ll time = 0;
    bool ok = true;

    REP(i, n){
        time += v[i].first;
        ok &= (time <= v[i].second);
    }

    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i,k,n) for(int i = k; i < n; i++)
//#define sum(start, end) accumulate(start, end, 0)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef string str;

using namespace std;
template <class T = ll> T in() { T _in; cin >> _in; return (_in); }


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

    ll a = in(), b = in();

    if((a % 2 == 0) || (b % 2 == 0))
        cout << "Even" << endl;
    else
        cout << "Odd" << endl;

    return 0;
}


Measured memory_bytes: 256
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn str_to_ints(s: String) -> std::vec::Vec<i64> {
    let mut ret = std::vec::Vec::new();
    let ws = s.split_whitespace();
    for w in ws {
        ret.push(w.parse().unwrap());
    }
    ret
}

fn read_ints() -> std::vec::Vec<i64> {
    str_to_ints(read_line())
}

fn main() {
    let d: i64 = read_ints()[0];
    if d == 25 {
        println!("Christmas");
    } else if d == 24 {
        println!("Christmas Eve");
    } else if d == 23 {
        println!("Christmas Eve Eve");
    } else if d == 22 {
        println!("Christmas Eve Eve Eve");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin>>s;
  int c=0;
  for(int i=0;i<3;i++){
    if(s.at(i)=='o'){
      c+=1;
    }else{
    }
  }
  cout<<700+100*c<<endl;
}

Measured memory_bytes: 256
# include "iostream"
# include "cstdio"

using namespace std;

int Dollar;

int main(){
	register int i; 
	scanf("%d",&Dollar); 
	for(i=0;i*7<=Dollar;i++){
		if((Dollar-i*7)%4==0){
			printf("Yes");
			return 0; 
		}
	}
	printf("No"); 
	return 0; 
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

// https://atcoder.jp/contests/abc074/tasks/arc083_a
bool dp[3001][3001];
int main() {
  int a,b,c,d,e,f; cin >> a >> b >> c >> d >> e >> f;

  auto check = [&] (int water, int sugar) {
    return water * e >= sugar * 100;
  };

  int ans_sugar = 0;
  int ans_water = 0;
  
  dp[0][0] = true;
  rep(i, f+1) rep(j, f+1) {
    if(!dp[i][j]) continue;
    if(i+100*a+j <=f) dp[i+100*a][j] = dp[i][j];
    if(i+100*b+j <=f) dp[i+100*b][j] = dp[i][j];
    if(i+j+c <=f && check(i, j+c)) dp[i][j+c] = dp[i][j];
    if(i+j+d <=f && check(i, j+d)) dp[i][j+d] = dp[i][j];
    
    // (100 * ans_sugar) / (ans_sugar + ans_water) < (100 * j) / (i+j)
    if((ans_sugar ==0) ||  (100 * ans_sugar) * (i+j) < (100 * j) * (ans_sugar + ans_water)) {
      ans_sugar = j;
      ans_water = i;
    }
  }
  cout << (ans_sugar+ans_water) << " " << ans_sugar <<endl;
}


Measured memory_bytes: 3656
import java.util.*;

public class Main {	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        ArrayList<Integer> mountain = new ArrayList<Integer>();
        
        for(int i=0;i<10;i++){
        mountain.add(Integer.parseInt(sc.nextLine()));
        }
        
        for(int i=0;i<3;i++){      	
        	int max = mountain.get(0);
        	int save=0;
        	for(int j=0;j<mountain.size();j++){
        		if(max<mountain.get(j)){
        			max=mountain.get(j);
        			save=j;
        		} 		
        	}
        	System.out.println(mountain.get(save));
        	mountain.remove(save);        	
        }
    }
}

Measured memory_bytes: 26124
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    // your code goes here
    char ch;
    cin >> ch;
    if (ch >= 'a' && ch <= 'z')
    {
        cout << "a" << endl;
    }
    else
    {
        cout << "A" << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
#include <cstring>
#include <iostream>
#define dbg(x) cout << #x"="<< (x) << endl

using namespace std;

int main(){
	long long a,b,x;
	long long ans = 0;
	cin >> a >> b >> x;
	if(a==0){
		ans = b/x + 1;
	}else{
		ans = b/x - (a-1)/x;
	}
	
	cout << ans << endl;
	return 0;
}

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

using namespace std;

vector<string> ans;
bool ap[30];
string s;
int sum;

void dfs(int n,char c,string now){
//cout<<"dfs(int "<<n<<",char "<<c<<",string "<<now<<")"<<endl;
	if(n==s.size()){
		sum++;
		ans.push_back(now);
		return ;
	}
	if(ap[c-'a']==true || c=='a'){
		bool bac=ap[c-'a'];
		ap[c-'a']=true;
		dfs(n+1,s[n+1],now+c);
		ap[c-'a']=bac;
	}
	if(ap[c-'a'+1]==false && c!='z'){
		bool bac=ap[c-'a'+1];
		ap[c-'a'+1]=true;
		dfs(n+1,s[n+1],now+(char)(c+1));
		ap[c-'a'+1]=bac;
	}
}

int main(){
	while(1){
		while(!ans.empty())ans.pop_back();
		sum=0;
		cin>>s;
		if(s=="#")break;
		dfs(0,s[0],"");
		cout<<sum<<endl;

		if(sum<=10){
			for(int i=0;i<sum;i++){
				cout<<ans[i]<<endl;
			}
		}
		else{
			for(int i=0;i<5;i++){
				cout<<ans[i]<<endl;
			}
			for(int i=ans.size()-5;i<ans.size();i++){
				cout<<ans[i]<<endl;
			}
		}
	}
	return 0;
}

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

#define all(x) (x).begin(),(x).end()

using namespace std;

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
 
/* Coding Space*/
vector<int> G[100001];
int main(){
  int n; cin >> n;
  rep(i,n-1){
    int a,b; cin >> a >> b;
    G[a].pb(b);
    G[b].pb(a);
  }
  
  ll f = 0,s = 0;
  vi t(n+1);
  queue<tii> q;
  q.push(tii{1,1});
  q.push(tii{n,2});
  while(!q.empty()){
    int ni,nc; tie(ni,nc) = q.front(); q.pop();
    if(t[ni] != 0) continue;
    t[ni] = nc;
    ((nc == 1)?f:s) += 1;
    rep(i,G[ni].size())
      q.push(tii{G[ni][i],nc});
  }
  if(s >= f)
    cout << "Snuke" << endl;
  else
    cout << "Fennec" << endl;
}

Measured memory_bytes: 6528
def make_divisors(n):
    """自然数nの約数を列挙したリストを出力する
    計算量: O(sqrt(N))
    入出力例: 12 -> [1, 2, 3, 4, 6, 12]
    """
    divisors = []
    for k in range(1, int(n**0.5) + 1):
        if n % k == 0:
            divisors.append(k)
            if k != n // k:
                divisors.append(n // k)
    divisors = sorted(divisors, reverse = True)
    return divisors

n, k = map(int, input().split())
a = list(map(int, input().split()))

sum_a = sum(a)
div = make_divisors(sum_a)

for num in div:
    cnt = 0
    li = [0] * n
    for i in range(n):
        li[i] = a[i] % num
    li = sorted(li)
    
    ruiseki = [0] * (n+1)
    for i in range(n):
        ruiseki[i+1] = ruiseki[i] + li[i]
    if ruiseki[-1] == 0:
        print(num)
        exit()
    for i in range(n)[::-1]:
        cnt += num - li[i]
        if ruiseki[i] == cnt:
            if cnt <= k:
                print(num)
                exit()

Measured memory_bytes: 42732
// https://atcoder.jp/contests/abc124/tasks/abc124_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    string S;
    cin >> S;
    int len = S.size();
    // 偶数番目を0、奇数番目を1にする回数
    int cnt1 = 0;
    REP(i, len) {
        if (i % 2 == 1) {
            if (S[i] == '0') {
                cnt1++;
            }
        } else {
            if (S[i] == '1') {
                cnt1++;
            }
        }
    }

    // 偶数番目を1、奇数番目を0にする回数
    int cnt2 = 0;
    REP(i, len) {
        if (i % 2 == 1) {
            if (S[i] == '1') {
                cnt2++;
            }
        } else {
            if (S[i] == '0') {
                cnt2++;
            }
        }
    }
    cout << min(cnt1, cnt2) << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


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

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


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>

#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
typedef long long int ll;

int main(){
  string s;
  cin >> s;
  bool flag=true,loopflag=false;
  while(!s.empty()) {
    if ((0 < s.size() && s.size() < 5) || loopflag){
      flag = false;
    break;
    }
    loopflag = true;
    if(s.size()>=7){
      if(s.substr(0, 7)=="dreamer" && s.substr(7,3)!="ase"){
        s=s.substr(7);
        loopflag = false;
        continue;
      }
    }
    if(s.size()>=6){
      if(s.substr(0, 6)=="eraser" && s.substr(6,3)!="ase") {
        s = s.substr(6);
        loopflag = false;
        continue;
      }
    }
    if(s.size()>=5){
      if(s.substr(0, 5)=="erase") {
        s = s.substr(5);
        loopflag = false;
        continue;
      }
      if(s.substr(0, 5)=="dream") {
        s = s.substr(5);
        loopflag = false;
        continue;
      }
    }
  }


  cout << (flag? "YES" : "NO") << endl;

  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdio.h>
using namespace std;
int a[10010]={0};
int b[10010]={0};
int ans=1001,w;
void kotani(int i,int j,int c,int n);
int main(){
	while(1){
	int n;
	scanf("%d",&n);
		w=n;
		ans=n;
		if(n==0)break;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++){
		for(int j=1;j<=3;j++){
			memcpy(b,a,sizeof(int) *n);
			if(b[i]!=j){
				b[i]=j;
				kotani(0,1,1,n);
			}
		}
	}
	printf("%d\n",ans);
	}
}
void kotani(int i,int j,int c,int n){
	if(b[i]==b[j]&&j<n){
		kotani(i,j+1,c+1,n);
	}
	else{
		if(c>=4){
			int u=0;
			for(int z=j;z<n;z++){
				b[i+u]=b[z];
				u++;
			}
			ans=min(ans,n-c);
			kotani(0,1,1,n-c);
		}
		else if(i+1<n){
			kotani(i+1,i+2,1,n);
		}
	}
}

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

int main() {
  int x, y;
  while (true) {
    cin >> x >> y;
    if (!x && !y) break;
    if (x > y) swap(x, y);
    cout << x << ' ' << y << endl;
  }
  return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];

  bool flag = false;
  rep(i, N) {
    if ((a[i] % 2) == 0 && a[i] > 2) {
      flag = true;
      break;
    }
  }

  if (!flag) {
    cout << 0 << endl;
    return 0;
  }

  int ans = 0;
  rep(i, N) {
    while ((a[i] % 2) == 0 && a[i] != 0) {
      ans++;
      a[i] /= 2;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)

void debug_out() {}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

int run(istream& in, ostream& out) {
    ll H, N;
    in >> H >> N;
    ll count = 0;
    REP(i, N) {
        ll A;
        in >> A;
        count += A;
    }
    ll ans = 0;
    out << (count >= H ? "Yes" : "No" ) << endl;
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k; cin >> n >> k;
	vector<int> p(n);
	for(int i=0; i<n; ++i) cin >> p[i];

	int sum=0, mx,l=0;
	for(int i=0; i<k; ++i) sum += p[i];
	mx=sum;
	for(int i=0; i+k<n; ++i){
		sum = sum-p[i]+p[i+k];
		if(mx<sum){
			mx=sum;
			l=i+1;
		}
	}
	
	double ans=0;
	for(int i=0; i<k; ++i){
		ans += p[l+i]+1;
	}
	cout << fixed << setprecision(12);
	cout << ans/2 << endl;
}

Measured memory_bytes: 1152