akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

typedef long long LL;

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

LL mul_mod(LL a, LL b, LL mod){
    if(b == 0) return 0;
    LL res = mul_mod((a + a) % mod, b / 2, mod);
    if(b & 1) res = (res + a) % mod;
    return res;
}

LL pow_mod(LL a, LL b, LL mod){
    if(b == 0) return 1;
    LL res = pow_mod(mul_mod(a, a, mod), b / 2, mod);
    if(b & 1) res = mul_mod(res, a, mod);
    return res;
}

LL inv_mod(LL a, LL mod){
    LL x, y;
    extgcd(a, mod, x, y);
    return (x % mod + mod) % mod;
}

vector<LL> inverse_list(int n, int p){
    vector<LL> inv(n + 1);
    inv[1] = 1;
    for (int i = 2; i <= n; ++i){
        inv[i] = inv[p % i] * (p - p / i) % p;
    }
    return inv;
}

pair<LL, LL> linear_congruence(const vector<LL>& A, const vector<LL>& B, const vector<LL>& M) {
    LL x = 0, m = 1;

    for(int i = 0; i < A.size(); i++) {
        LL a = A[i] * m, b = B[i] - A[i] * x, d = __gcd(M[i], a);
        if(b % d != 0) return make_pair(0, -1); // no solution
        LL t = b / d * inv_mod(a / d , M[i] / d) % (M[i] / d);
        x = x + m * t;
        m *= M[i] / d;
    }
    return make_pair(x % m, m);
}

int main(){
    LL N, M, D;
    while(cin >> N >> M >> D) {

        LL A[10];
        REP(i, M) cin >> A[i];

        for(int t = 0; t < D; t++) {
            vector<LL> a, b, m;
            REP(i, M) {
                LL y;
                cin >> y;
                if(y == -1) continue;
                a.push_back(1);
                b.push_back(y);
                m.push_back(A[i]);
            }

            pair<LL, LL> p = linear_congruence(a, b, m);

            if(N == -1 || p.first > N || p.second == -1) {
                N = -1;
            } else {
                LL k = (N - p.first) / p.second;
                assert(p.first + p.second * k <= N);
                assert(p.first + p.second * (k + 1) > N);
                N = p.first + p.second * k;
            }
            // cout << N << endl;
            
        }

        cout << N << endl;
    }
    return 0;

}

Measured memory_bytes: 1216
import math

a, b, x = map(int,input().split())
v = a*a*b

if x > v/2:
    y = 2*(b-(x/(a*a)))
    naname = math.sqrt((y*y) + (a*a))
    cosine = a/naname
    print(math.degrees(math.acos(cosine)))
elif x < v/2:
    y = 2*x/(b*a)
    naname = math.sqrt((y*y)+(b*b))
    cosine = b / naname
    print(90-math.degrees(math.acos(cosine)))
else:
    naname = math.sqrt((a*a)+(b*b))
    cosine = a/naname
    print(math.degrees(math.acos(cosine)))


Measured memory_bytes: 9328
using System;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力(N角形)
		int N = int.Parse(Console.ReadLine());
		// スペース区切りの整数の入力(N個の数)
		string[] input = Console.ReadLine().Split(' ');
		
		// 文字列の入力
		//string s = Console.ReadLine();

    // N個のinputから、最大の数を見つける
    int max = 0;
    int ii = 0; // 何番目が最大だったか？
    for(int i=0 ; i<input.Length; i++){
      if(max < int.Parse(input[i])){
        max = int.Parse(input[i]);
        ii = i;
      }
    }

    // ii 番目の maxが最大なので、それ以外の合計を計算する
    int sum = 0;
    for(int i=0; i<input.Length; i++){
      if(i==ii) continue;

      sum += int.Parse(input[i]);
    }

    // 多角形が作れるかの判定
    string ret;
    if(max < sum) ret = "Yes";
    else ret = "No";

		//出力
		Console.WriteLine(ret + "");
	}
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int

using namespace __gnu_pbds;

typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;


#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\



This functio helps to accesss map<pair<ll,ll>,ll ,hash_pair>myMap

struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};


power of 2 less than or equal to N

ll largest_power(ll N)
{
    //changing all right side bits to 1.
    N = N (N>>1);
    N = N| (N>>2);
    N = N| (N>>4);
    N = N| (N>>8);


//as now the number is 2 * x-1, where x is required answer, so adding 1 and dividing it by
 2.
            return (N+1)>>1;

}


     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;


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

ll n,k;
cin>>n>>k;
if(n==0)
{
    cout<<n<<endl;
}
else
{
    cout<<min(n%k,k-n%k)<<endl;
}
return 0;
}



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

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

  vector<string> blue(N);
  set<string> blue_set;
  for (size_t i = 0; i < N; i++) {
    string tmp;
    cin >> tmp;
    blue.at(i) = tmp;
    blue_set.insert(tmp);
  }

  int M;
  cin >> M;

  vector<string> red(M);
  for (size_t i = 0; i < M; i++) {
    string tmp;
    cin >> tmp;
    red.at(i) = tmp;
  }

  int ans = 0;
  for (auto itr_blue : blue_set) {
    int count_blue, count_red, delta;
    count_blue = count(blue.begin(), blue.end(), itr_blue);
    count_red = count(red.begin(), red.end(), itr_blue);
    delta = count_blue - count_red;
    
    if (delta > ans) ans = delta;
  }

  cout << ans << endl;
}


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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

int_fast64_t mpow(int_fast64_t x,int_fast64_t n){
  using i64=int_fast64_t;
  if(n==0)return 1;
  if(n%2)return ((x%MOD)*(mpow(x,n-1)%MOD))%MOD;
  else {
    i64 half=mpow(x,n/2)%MOD;
    return (half*half)%MOD;
  }
}

map<int_fast64_t,int>prime_factor(int_fast64_t x){
  map<int_fast64_t,int>res;
  for(int_fast64_t i=2;i*i<=x;i++){
    while(x%i==0){
      res[i]++;
      x/=i;
    }
  }
  if(x!=1)res[x]=1;
  return res;
}

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

  int N,K;
  cin>>N>>K;
  ll ans=0;
  ll c=0;
  vector<int>C(K+1);
  for(int i=K;i>=2;i--){
    ll res=0;
    for(int j=i+i;j<=K;j+=i){
      res=(res+((mpow(K/j,N)-C[j]))%MOD)%MOD;
    }
    C[i]=res;
    ans=(ans+(i*(mpow(K/i,N)-res))%MOD)%MOD;
    c+=((mpow(K/i,N)-res)%MOD+MOD)%MOD;
  }
  cout<<(((ans+mpow(K,N))%MOD-c)%MOD+MOD)%MOD<<endl;
  return 0;
}


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

#define MEM(a, b) memset(a, b, sizeof a);
#define REP(i, k) for(int i = (0); i < (k); i++ )
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)

#define ALL(cont) cont.begin(), cont.end()
#define RALL(cont) cont.begin(), cont.end()
#define FOREACH(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define INF (int)INT_MAX
#define EPS (int)1e-9
#define PI acos(-1)
#define MOD 1000000007

#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long L;
typedef unsigned long UL;
typedef long long LL;
typedef unsigned long long ULL;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

vector<int> memo(4000, -1);
int r, g, b;
int f(int x) {
    if (x == 0) return 1;
    else if (x < 0) return -INF;
    else if (memo[x] != -1) return memo[x];
    else {
        memo[x] = 0;
        if (f(x - r) != -INF) memo[x] += f(x - r);
        if (f(x - g) != -INF) memo[x] += f(x - g);
        if (f(x - b) != -INF) memo[x] += f(x - b);
        return memo[x];
    }
}

void solve(__attribute__((unused)) int tc = 0) {
    int a;
    cin >> r >> g >> b >> a;

    int m[4000];
    MEM(m, 0);
    m[0] = 1;

    int s[3]= {r, g, b};
    REP(i, 3) {
        FOR(j, s[i], a) {
            m[j] += m[j - s[i]];
        }
    }

    cout << m[a] << endl;
    
    /*cout << f(a) << endl;
    FOR(i, 1, a) debug(i, memo[i]);*/
    return;
}

int main() {
#ifdef FILE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin.tie(0);
    ios_base::sync_with_stdio(false);

    /*int TC;
      cin >> TC;
      REP(tc, TC) {
      solve(tc);
      }*/
    solve();
#ifdef TIME
    cout << "Execution time(second) : " << int(clock() * 1000.0 / CLOCKS_PER_SEC) << " ms" << endl;
#endif
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v
#define NUM(x,v) (POSU(x,v)-POSL(x,v))
const ll INF=1e9+7;
const ll N = 100001;
ll n,a[N*3],ans=0;

int main(){
	cin>>n;
	FOR(i,0,n*3){
		cin>>a[i];
	}
	sort(a,a+3*n);
	ll i=n;
	while(1){
		ans+=a[i];
		i+=2;
		if(i>=3*n)break;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<list>

using namespace std;

list<int> li;
auto now=li.begin();

void f0()
{
    int a;
    cin>>a;

    now=li.insert(now,a);
}

void f1()
{
    int step;
    cin>>step;

    if(step>0)
    {
        while(step--) now++;
    }else
    {
        while(step++) now--;
    }
}

void f2()
{
    now=li.erase(now);
}

void print()
{
    for(auto i=li.begin();i!=li.end();i++)
    {
        cout<<*i<<endl;
    }
}

int main()
{
    int n;

    cin>>n;

    while(n--)
    {
        int op;
        cin>>op;

        switch(op)
        {
            case 0:f0();break;
            case 1:f1();break;
            case 2:f2();break;
        }
    }

    print();

    return 0;
}



Measured memory_bytes: 18620
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define mp make_pair
const int mod=1e9+7;

void solve()
{
  int n;
  cin>>n;
  vector<int> V(n);
  unordered_map<int,pair<int,bool> > um;
  unordered_map<int,int> m;
  for(int i=0;i<n;i++)
  {
    cin>>V[i];
    um[V[i]]=mp(i,true);
    m[V[i]]++;
  }
  if(um[1].second==true)
  {
    if(m[1]==1)
    cout<<1;
    else if(m[1]>1)
    cout<<0;
    return;
  }
  int cnt=0;
  for(int i=0;i<n;i++)
  {
    int x=V[i];
    for(int j=1;j<=sqrt(x);j++)
    {
      if(x%j==0)
      {
        if(m[j]==1)
        {
          if(um[j].second==true && um[j].first!=i)
          {
            cnt++;
            break;
          }
        }
        else if(m[j]>1)
        {
          if(um[j].second==true)
          {
            cnt++;
            break;
          }
        }

        if(m[x/j]==1)
        {
          if(um[x/j].second==true && um[x/j].first!=i)
          {
            cnt++;
            break;
          }
        }
        else if(m[x/j]>1)
        {
          if(um[x/j].second==true)
          {
            cnt++;
            break;
          }
        }
      }
    }
  }
  cout<<n-cnt<<endl;
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 40656
#include<iostream>
using namespace std;
int main(){
	string s;
	   cin>>s;
	   long long  t;
	    while((t=s.find("eraser"))!=s.npos)
	   {
	       s=s.replace(t,6,"");
	   }
	   while((t=s.find("erase"))!=s.npos)
	   {
	       s=s.replace(t,5,"");
	   }
	    while((t=s.find("dreamer"))!=s.npos)
	   {
	       s=s.replace(t,7,"");
	   }
	   while((t=s.find("dream"))!=s.npos)
	   {
	       s=s.replace(t,5,"");
	   }
	   
	   if(s.length()==0)
	    cout<<"YES";
	   else
	    cout<<"NO";
	    return 0;
}

Measured memory_bytes: 640
class UnionFind():
    def __init__(self, n):
        self.size = n
        self.data = [-1 for _ in range(n)]
        self.sizes = [1 for _ in range(n)]

    def __len__(self):
        return self.size

    def root(self, i):
        """0 <= i < n"""
        if self.data[i] < 0:
            return i
        self.data[i] = self.root(self.data[i])
        return self.data[i]

    def connected(self, i, j):
        return self.root(i) == self.root(j)

    def groupsize(self, i):
        return self.sizes[self.root(i)]

    def roots(self):
        """O(n)"""
        return [i for i, v in enumerate(self.data) if v < 0]

    def unite(self, i, j):
        i = self.root(i)
        j = self.root(j)
        if i == j:
            return
        if (-self.data[i]) < (-self.data[j]):
            self.data[i] = j
            self.sizes[j] += self.sizes[i]
        elif (-self.data[i]) > (-self.data[j]):
            self.data[j] = i
            self.sizes[i] += self.sizes[j]
        else:
            self.data[i] += -1
            self.data[j] = i
            self.sizes[i] += self.sizes[j]


N = int(input())
XY = []
XI = []
YI = []
for i in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))
    XI.append((x, i))
    YI.append((y, i))
XI.sort()
YI.sort()
DIJ = []
for i in range(N - 1):
    DIJ.append((XI[i+1][0] - XI[i][0], XI[i][1], XI[i+1][1]))
    DIJ.append((YI[i+1][0] - YI[i][0], YI[i][1], YI[i+1][1]))
DIJ.sort(reverse=True)
uf = UnionFind(N)
ans = 0
while len(DIJ):
    d, i, j = DIJ.pop()
    if uf.connected(i, j):
        continue
    uf.unite(i, j)
    ans += d
    if uf.groupsize(i) == N:
        break
print(ans)


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

int main() {
  string s;
  cin>>s;
  int len = s.length();
  int idx = 0;
  long long ans = 0;
  int a_cnt = 0;
  while (idx < len) {
    if (s[idx] == 'A') {
      ++a_cnt;
      ++idx;
      continue;
    }
    if (s[idx] == 'C') {
      a_cnt = 0;
      ++idx;
      continue;
    }
    if (idx == len - 1) {
      break;
    }
    if (s[idx] == 'B' && s[idx+1] == 'C') {
      ans += a_cnt;
      idx += 2;
    } else {
      ++idx;
      a_cnt = 0;
    }
  }
  cout<<ans<<endl;
}

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



int main(){
    int n;
    cin>>n;
    vector<int> p(n);
    vector<int> q(n);
    vector<vector<int>> G;
    
    for(int i=0;i<n;++i){
        cin>>p[i];
        --p[i];
    }
    map<int,int> mp;//[val,pos]
    for(int i=0;i<n;++i)mp[p[i]]=i;

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

    vector<bool> used(n,false);
    for(int i=0;i<n;++i){
        if(used[i])continue;
        vector<int> t;
        t.push_back(i);
        used[i]=true;
        int nx=q[i];
        while(nx!=i){
            t.push_back(nx);
            used[nx]=true;
            nx=q[nx];
        }
        G.push_back(t);
    }

    vector<int> d;

    for(auto seq:G){
        int okn=-1;
        for(int i=0;i<seq.size();++i){
            bool ok=true;
            for(int j=0;j<seq.size();++j){
                int prev=seq[j],nxt=seq[(j+i)%seq.size()];
                if(mp[prev]!=nxt){
                    ok=false;
                    break;
                }
            }
            if(ok){
                okn=i;
                break;
            }
        }
        if(okn==-1){
            cout<<"-1"<<endl;
            return 0;
        }
        d.emplace_back(okn);
    }

    for(int i=0;i<G.size();++i){
        for (int j = 0; j < G.size(); j++){
            int g = __gcd(G[i].size(), G[j].size());
            if (d[i] % g != d[j] % g){
                cout << -1 << endl;
                return 0;
            }
        }
    }

    int64_t cur = d[0];
    int64_t lcm = G[0].size();

    while (true){
        int flag = true;
        //cout << cur << " " << lcm << endl;
        for (int i = 0; i < G.size(); i++){
            bool f = cur % G[i].size() == d[i];
            if (f){
                lcm = lcm * G[i].size() / __gcd(lcm, int64_t(G[i].size()));
            }
            flag &= f;
        }
        if (flag)
            break;
            
        cur += lcm;
    }

    cout << cur << endl;

    return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <string>
#include <list>

std::string getFizzBuzzString(int n)
{
    std::string fizzBuzzString;
    
    if(n % 15 == 0)
    {
        fizzBuzzString = "FizzBuzz";
    }
    else if(n % 5 == 0)
    {
        fizzBuzzString = "Buzz";
    }
    else if(n % 3 == 0)
    {
        fizzBuzzString = "Fizz";
    }
    else
    {
        fizzBuzzString = std::to_string(n);
    }
    
    return fizzBuzzString;
}

void fizzBuzzGame(int num_of_players, int num_of_remarks)
{
    std::list<int> player_list;

    /* ?????¬???????????????????????¨???????????¬?????????????????????push?????? */
    for(int i = 1; i <= num_of_players; i++ )
    {
        player_list.push_back(i);
    }

    /* fizz buzz ?????????????§? */
    for(int i = 1; i <= num_of_remarks; i++)
    {
        /* ??\??????????????? */
        std::string remarks;
        std::cin >> remarks;

        /* ?????¬??????????????????????????£?????????????£???°??? */
        if(player_list.size() <= 1)
        {
            continue;
        }

        /* ?????¬?????????????????? */
        int player = *(player_list.begin());
        player_list.pop_front();

        /* ?????????????????? */
        std::string expect_remarks = getFizzBuzzString(i);
        
        /* ??£??????????¨??????????????????°????????????push???????????? */
        /* ????????£????????????????????????push??????????????¨??§??¢??±???????????¨????????? */
        if(remarks == expect_remarks)
        {
            player_list.push_back(player);
        }
    }
    
    /* ???????????????????????£??????????????¬????????????????????????????????? */
    player_list.sort();
    for(auto p : player_list)
    {
        if(p != *(player_list.begin()))
        {
            std::cout << " ";
        }
        std::cout << p;
    }

	//    for(auto itr = player_list.begin(); itr != player_list.end(); ++itr)
//    {
//        if(itr != player_list.begin())
//        {
//            std::cout << " ";
//        }
//        std::cout << *itr;
//    }
    std::cout << std::endl;
    
    return;
}

void volume2_0221()
{
    int num_of_players;
    int num_of_remarks;
    
    for(;;)
    {
        /* ?????¬???????????°??¨????¨??????°??????????????? */
        std::cin >> num_of_players >> num_of_remarks;
        
        /* ?????¬???????????°???????¨??????°??±??? 0 ????????\????????? */
        if( num_of_players == 0 && num_of_remarks == 0 )
        {
            break;
        }
        
        /* FizzBuzzGame ?????? */
        fizzBuzzGame(num_of_players, num_of_remarks);
    }

    return;
}

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

Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int h, w;
vector<vector<char> > G;
vector<int> mx = {0, 0, 1, -1}, my = {1, -1, 0, 0};
void dfs(int x, int y){
    for (int i = 0; i < 4; i++){
        if (x+mx[i]<0 || x+mx[i]>=h || y+my[i]<0 || y+my[i]>=w) continue;
        if (G[x+mx[i]][y+my[i]] == '.') continue;
        G[x][y] = 'a';
        if (G[x+mx[i]][y+my[i]] == '#') dfs(x+mx[i], y+my[i]);
    }
}
int main(){
    sc(h) sc(w)
    G.resize(h);
    for (int i = 0; i < h; i++) G[i].resize(w);
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++) cin >> G[i][j];
    }
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            if (G[i][j] == '#') dfs(i, j);
        }
    }
    bool ans = true;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            if (G[i][j] == '#') ans = false;
        }
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define db long double
#define pii pair<ll,ll>
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define vii vector<vi>
#define lb lower_bound
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,b,a) for(int i=(b);i>=(a);--i)
#define rep0(i,a,b) for(int i=(a);i<(b);++i)
#define fore(i,a) for(int i=0;i<a.size();++i)
#define gc() getchar()
#define ls x<<1,l,m
#define rs x<<1|1,m+1,r
inline int rd()
{
	int x=0;char c=gc();while(!isdigit(c))c=gc();
	while(isdigit(c))x=x*10+c-48,c=gc();return x;
}
const int N=200005;
int n,m,a[N];
inline bool chk(int p)
{
	rep(i,2*p+1,2*n)if(a[i]+a[2*n+2*p+1-i]<m)return 0;
	return 1;
}
int main()
{
	n=rd();m=rd();rep(i,1,2*n)a[i]=rd();
	sort(a+1,a+2*n+1);int l=0,r=n,mid,p=0,mx=0;
	while(l<=r)if(chk(mid=l+r>>1))p=mid,r=mid-1;else l=mid+1;
	rep(i,1,p)mx=max(mx,a[i]+a[1+2*p-i]);
	rep(i,2*p+1,2*n)mx=max(mx,a[i]+a[2*n+2*p+1-i]-m);
	printf("%d\n",mx);return 0;
}


Measured memory_bytes: 1024
//k_tourist
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define mx 3005
#define non __builtin_popcount
#define ml map<ll, ll> 
#define uml unordered_map<ll, ll>
#define ms map<string , ll> 
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define pl pair<ll, ll>
#define vl vector<ll>
#define vll vector<pl>
#define tpl pair<ll, pl>
#define vlll vector<tpl>
#define vs vector<string>
#define pb push_back
#define mk make_pair
#define M_PI 3.14159265358979323846
#define endl '\n'
#define fst ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%I64d",&x)
#define inf ((ll)1e18 + 1)
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define pow powr
#define sp(a) setprecision(a)
#define rep(i,a,b)  for (i=(a);i<(b);i++)
#define nrep(i,a,b) for (i=(a);i>(b);i--)
using namespace std;
using namespace __gnu_pbds;  

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>  ordered_set;
 
ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void flag(ll fl){

	if(fl)
	cout<<"NO";
	else
	cout<<"YES";
}

ll a[mx], dp[mx][mx], n;

ll deq(ll x, ll  y){

	if(x <0 || y> n-1 || x> y)
	return 0;

	if(dp[x][y] != -1)
	return dp[x][y];

	return dp[x][y]= max(a[x] - deq(x+1, y), a[y] - deq(x, y-1));
}
void bta_de_yarr(){

	ll  i, j, fl=0, ans, m;

	cin>>n;

	rep(i, 0, n)
	cin>>a[i];

	rep(i, 0, n+1)
	rep(j, 0, n+1)
	dp[i][j]= -1;

	ans= deq(0 , n-1);
	
	cout<<ans;
	// flag(fl);
	cout<<endl;
}

int main(){
    fst

	// freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
	ll t;
    t= 1;
	//cin>>t;
    while(t--){
        bta_de_yarr();
    }
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pk(x) cout<<(x)<<" ";
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a[100001],b[100001],c[100001],d,n,m,x,y,z,h,w,k,sum,mi=inf,ma=-inf,ans,s,t,l,r,res,tmp,itr,p,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<ll, ll> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<ll,ll> > VP;
P pa;

ll fi[25][25];
ll fic[25][25];

bool condition(ll x, ll y){
    if(x<0 || x>=w || y<0 || y>=h)return 0;
    else if(fic[x][y]>0)return 0;
    else if(fi[x][y]==1)return 0;
    else return 1;
}


void bfs(ll i,ll j){
    queue<P >sta;
    rep(k,w)rep(l,h)fic[k][l]=0;
    fic[i][j]=1;
    sta.push({i,j});
    ll nx,ny;
    while(!sta.empty()){
        pa=sta.front();
        sta.pop();
        x=pa.first;
        y=pa.second;
        rep(ind,4){
            nx=x+dx[ind];
            ny=y+dy[ind];
            if(condition(nx,ny)){
                sta.push({nx,ny});
                fic[nx][ny]=fic[x][y]+1;
            }
        }
    }
    rep(k,w){rep(l,h){
        ma=max(ma,fic[k][l]);
    }}
}



int main(void){
    cin>>w>>h;
    rep(i,w){
        cin>>st;
        rep(j,h){
            if(st[j]=='#')fi[i][j]=1;
        }
    }
    rep(i,w)rep(j,h){
        if(!fi[i][j])bfs(i,j);
    }
    p(ma-1);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
ans = []
d = 0
while n:
    select = n & 1
    ans.append(select)
    if d & 1:
        n += select
    else:
        n -= select
    d += 1
    n >>= 1
if not ans:
    ans.append(0)
print(''.join(map(str, reversed(ans))))


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

using namespace std;
const int N = 1e5 + 5;

int main() {
    //freopen("in.txt", "rt", stdin);
    int n, m;
    scanf("%d %d", &n, &m);
    int s = 0, e = n + 1;
    int a, b;
    while (m--) {
        scanf("%d %d", &a, &b);
        s = max(s, a);
        e = min(e, b);
    }
    printf("%d", max(0, e - s + 1));
}

Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;


int main(void) {

    int n; cin>>n;

    int seki=1, GCD=0;
    int lcm=1;
    for (int i = 0; i < n; ++i) {
        int a; cin>>a;
        lcm = lcm * a / __gcd(lcm,a);
    }

    cout<<lcm<<endl;

    return 0;
}


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  string S;
  cin >> S;
  if (S == "ABC")
    cout << "ARC" << endl;
  else
    cout << "ABC" << endl;
}


Measured memory_bytes: 3640
//============================================================================
// Name        : ITP_1_5_C.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int H,W;
	do {
		cin >> H >> W;
		if(H==0 && W==0) break;
		for(int j=0;j<H;++j) {
			for(int i=0;i<W;++i){
				if((i+j)%2==0) {
					printf("#");
				} else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	} while(1);
	return 0;
}

Measured memory_bytes: 3040
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <string>

using namespace std;

#define N 3
#define N2 9

struct Puzzle {
	int f[N2];
	int space;
	string path;
	bool operator <(const Puzzle &p) const {
		for (int i = 0; i < N2; ++i) {
			if (f[i] == p.f[i])
				continue;
			return f[i] > p.f[i];
		}
		return false;
	}
};

bool isResolved(Puzzle p) {
	for (int i = 0; i < N2; ++i) {
		if (p.f[i] != i + 1)
			return false;
	}
	return true;
}

const int dx[4] { -1, 0, 1, 0 };
const int dy[4] { 0, -1, 0, 1 };
const char dir[4] { 'u', 'l', 'd', 'r' };

string bfs(Puzzle p) {
	queue<Puzzle> Q;
	p.path = "";
	Q.push(p);
	map<Puzzle, bool> M;
	M[p] = true;
	Puzzle u, v;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		if (isResolved(u))
			return u.path;
		int sx = u.space / N;
		int sy = u.space % N;
		for (int r = 0; r < 4; ++r) {
			int tx = sx + dx[r];
			int ty = sy + dy[r];
			if (tx < 0 || ty < 0 || tx >= N || ty >= N)
				continue;
			v = u;
			swap(v.f[u.space], v.f[tx * N + ty]);
			v.space = tx * N + ty;
			if (!M[v]) {
				M[v] = true;
				v.path += dir[r];
				Q.push(v);
			}
		}
	}
	return "unresolved";
}

int main() {
	Puzzle p;
	for (int i = 0; i < N2; ++i) {
		scanf("%d", &p.f[i]);
		if (p.f[i] == 0) {
			p.f[i] = N2;
			p.space = i;
		}
	}
	string ans = bfs(p);
	cout << ans.size() << endl;

	return 0;
}

Measured memory_bytes: 30664
A, B, C, D = map(int, input().split())
if A < C and B < D:
    print(max(0, B - C))
elif C <= A and B < D:
    print(max(0, B - A))
elif A < C and D <= B:
    print(max(0, D - C))
else:
    print(max(0, D - A))

Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
#include<math.h>
#include<stdlib.h>
#include<cstring>
#include<cstdio>
#include<utility>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;
const int Max = 1e5+5;
const int mod = 1e9+7;
const int Hash = 10000;
const int INF = 1<<30;
const ll llINF = 1e18;

int a,b,x;
int main( )
{
    while(~scanf("%d%d%d", &x,&a,&b))
    {
        if(b > x+a)
            cout<<"dangerous"<<endl;
        else if(b <= a)
            cout<<"delicious"<<endl;
        else
            cout<<"safe"<<endl;
    }
    return 0;
}


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

#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (int i = 0; i <  (int)(n); i++)

namespace graph {
  static const int V_MAX = 1010;
  static const int INF = 1<<28;
  struct edge {
    int from, to, dist;
  };

  int V_SIZE = 0;
  std::vector<edge> G[V_MAX];

  int wf_dp[V_MAX][V_MAX];
  bool wf_initialized = false;
  void wf_init() {
    if(wf_initialized) return;
    assert(V_SIZE > 0);
    for(int i = 0; i < V_SIZE; i++)
    for(int j = 0; j < V_SIZE; j++) {
      if(i == j) wf_dp[i][j] = 0;
      else {
        auto itr = find_if(G[i].begin(), G[i].end(), [j](edge e) { return e.to == j; });
        if(itr != G[i].end()) wf_dp[i][j] = itr->dist;
        else wf_dp[i][j] = INF;
      }
    }
    for(int k = 0; k < V_SIZE; k++)
    for(int i = 0; i < V_SIZE; i++)
    for(int j = 0; j < V_SIZE; j++) {
      wf_dp[i][j] = std::min(wf_dp[i][j], wf_dp[i][k] + wf_dp[k][j]);
    }
    wf_initialized = true;
  }
}

namespace solver {
  using namespace std;
  using namespace graph;
  typedef long long ll;

  ll H, W, A[40040];

  void init() {
    scanf("%lld %lld", &H, &W);
    int c;
    V_SIZE = 10*10;
    rep(i, 10) rep(j, 10) {
      scanf("%d", &c);
      G[i].push_back({i, j, c});
    }
    rep(i, H*W) scanf("%lld", A+i);
  }

  void solve() {
    ll ans = 0;
    wf_init();
    rep(i, H*W) if(A[i] != -1) {
      ans += wf_dp[A[i]][1];
    }
    cout << ans << endl;
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
    int n,x,l[100],i,d[100]={0},s=1;
    scanf("%d%d",&n,&x);
    for(i=0;i<n;i++)
        scanf("%d",&l[i]);
    i=1;
    while((i<=n)&&(d[i-1]<=x)){
        d[i]=d[i-1]+l[i-1];
        if(d[i]<=x)
            s++;
        i++;
    }
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
k = [list(map(int,input().split())) for i in range(n)]
for i in k:
  i.pop(0)
cnt = [[] for i in range(m)]
for i in range(n):
  for j in range(m):
     cnt[j].append(k[i].count(j+1))
ans = 0
for i in cnt:
  if sum(i) == n:
    ans += 1
print(ans)

Measured memory_bytes: 3064
A, B, K = [int(e) for e in input().split(" ")]

d = min(A, B)
buf = []
for i in range(d):
    c = d - i
    if A % c == 0 and B % c == 0:
        buf.append(c)
    if len(buf) >= K:
        break
print(buf[-1])




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

using namespace std;
typedef long long ll;

#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
const ll N = 123456;
vector < int > a[N];

int fe[N];
int snu[N];

void dfs(int s, bool flag) {
    for(int i : a[s]) {
        if(flag == true && fe[i] != 0) continue;
        if(flag == false && snu[i] != 0) continue;
        if(flag == true) {
            fe[i] = fe[s] + 1;
        }
        else {
            snu[i] = snu[s] + 1;
        }
        dfs(i , flag);
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    rep(i , 1 , n - 1) {
        int x , y;
        cin >> x >> y;

        a[x].push_back(y);
        a[y].push_back(x);
    }

    fe[1] = 1;
    snu[n] = 1;

    dfs(1 , true);
    dfs(n , false);

    int f = 0;
    int s = 0;

    rep(i , 1 , n) {
        if(fe[i] <= snu[i]) {
            f++;
        }
        else s++;
    }

    if(f > s) {
        cout << "Fennec" << endl;
    }
    else cout << "Snuke" << endl;
    return 0;
}


Measured memory_bytes: 11776
iipt=lambda:int(input())
miipt=lambda: list(map(int, input().split()))
while True:
    w,h,n=miipt()
    if w==h==n==0: break
    s=[miipt() for i in range(2*n)]
    right=[0,h]
    for i, (x1,y1) in enumerate(s):
        if x1<w:
            t=y1*w/(w-x1)
            if 0<=t<=h:
                right.append(t)
            t = h-(h-y1)*w/(w-x1)
            if 0<=t<=h:
                right.append(t)
        for x2,y2 in s[:i]:
            if x1!=x2:
                t = y2-(y2-y1)/(x2-x1)*x2
                if 0<=t<=h:
                    right.append(t)


    right.sort()
    ans=0
    INF=1e16
    EPS=1e-11
    #print(right)
    for y1,y2 in zip(right, right[1:]):
        if abs(y2-y1)<1e-11:
            continue
        y=(y1+y2)/2
        a,b = sorted([max(0,min(h,y+(y_-y)/(x_+EPS)*w))  for x_, y_ in s])[n-1:n+1]
        #print(y1,y2,[(y_-y)/x_ if x_ else INF if y_>y else -INF for x_, y_ in s])
        #A=max(0,min(h,y+a*w))
        #B=max(0,min(h,y+b*w))
        ans+=(y2-y1)*(b-a)
        #print((y2-y1),(B-A),(a,A),(b,B))

    print("{:0.11f}".format(ans/h/h))



Measured memory_bytes: 6328
import java.io.*;

public class Main{
	public static void main(String[] argv) throws NumberFormatException, IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		int lineNum = Integer.parseInt(br.readLine());
		for(int i=0; i<lineNum; i++){
			line = br.readLine();
			String[] sCoord = line.split(" ");
			float[] fCoord = new float[6];
			for(int j=0; j<6; j++){
				fCoord[j] = Float.parseFloat(sCoord[j]);
			}
			/*
			 * 違う
			 * float cenX = (fCoord[0] + fCoord[2] + fCoord[4])/3.0f;
			 * float cenY = (fCoord[1] + fCoord[3] + fCoord[5])/3.0f;
			 */
			
			float div = (fCoord[0]-fCoord[2])*(fCoord[3]-fCoord[5])-(fCoord[2]-fCoord[4])*(fCoord[1]-fCoord[3]);
			float n = fCoord[0]*fCoord[0] - fCoord[2]*fCoord[2] + fCoord[1]*fCoord[1] - fCoord[3]*fCoord[3];
			float m = fCoord[2]*fCoord[2] - fCoord[4]*fCoord[4] + fCoord[3]*fCoord[3] - fCoord[5]*fCoord[5];
			float a = fCoord[3]-fCoord[5];
			float b = fCoord[3]-fCoord[1];
			float c = fCoord[4]-fCoord[2];
			float d = fCoord[0]-fCoord[2];
			float cenX = (a*n + b*m)/div/2;
			float cenY = (c*n + d*m)/div/2;
			if(cenX == 0.0)cenX=0.0f;
			if(cenY == 0.0)cenY=0.0f;
			float dis = (float)Math.sqrt(Math.pow((double)cenX-fCoord[0], 2.0) + Math.pow((double)cenY-fCoord[1], 2.0));
			System.out.printf("%.3f %.3f %.3f\n", cenX, cenY, dis);
		}
	}
}

Measured memory_bytes: 16972
N = int(input())

#約数列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
         if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    #divisors.sort()
    return divisors

ans_list = list()
divisors = make_divisors(N)

for p in divisors:
    if p!= N:
        m = N//p - 1
        if N//m == N%m:
            ans_list.append(m)
    
print(sum(ans_list))

Measured memory_bytes: 9440
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++);
#define end return 0;
 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll ans=INF;
ll a,b,c,d,e;
ll x[100005],y[100005],z[100005];
ll dp[100005];
bool endo=false;
char s[100005];

void dfs(ll a,ll b){
	if(b>k)return;
	if(x[a]>=0)return;
	x[a]=b;
	num++;
	for(int ii=0;ii<G[a].size();ii++){
		dfs(G[a][ii],b+1);
	}
}
int main(){
    cin>>n>>k;
	for(i=0;i<n-1;i++){
		cin>>a>>b;
		G[a].push_back(b);
		G[b].push_back(a);
		y[i]=a;
		z[i]=b;
	}
	if(k%2==0){
		k=k/2;
		for(i=1;i<=n;i++){
			for(j=1;j<=n;j++){
				x[j]=-1;
			}
			num=0;
			dfs(i,0);
			ans = min(ans,n-num);
		}
	}else{
		k=k/2;
		for(i=0;i<n-1;i++){
			for(j=1;j<=n;j++){
				x[j]=-1;
			}
			num=0;
			x[z[i]]=0;
			dfs(y[i],0);
			x[z[i]]=-1;
			dfs(z[i],0);
			ans = min(ans,n-num);
		}
	}
	p(max(ans,0ll));
	end;
}

Measured memory_bytes: 6272
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	public static void main(String[] args) {
		FastReader fr = new FastReader();
		
		int N = fr.nextInt();
		int W = fr.nextInt();
		
		int[] w = new int[N];
		int[] v = new int[N];
		
		for (int i = 0; i < N; i++) {
			w[i] = fr.nextInt();
			v[i] = fr.nextInt();
		}
		
		long[] dp = new long[1000000]; 
		
		for (int i = 0; i < N; i++) {
			for (int j = W; j >= 0; j--) {
				if (j+w[i] <= W) {
					dp[j + w[i]] = Math.max(dp[j + w[i]], dp[j] + v[i]);
				}
			}
		}
		
		long res = 0;
		for (int i = 0; i <= W; i++) {
			res = Math.max(dp[i], res);
		}
		
		System.out.println(res);
	}

}


Measured memory_bytes: 40736
S = input()
KEYENCE = "keyence"


isKeyence = False
for i in range(len(S)):
    for j in range(i, len(S)):
        s = S[:i] + S[j:]
        if s == KEYENCE:
            isKeyence = True
if isKeyence:
    print("YES")
else:
    print("NO")



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

ll pn[51],bn[51];

ll solve(ll n,ll x){
	if(n==0)return 1;
	else if(x<=1)return 0;
	else if(x<=1+bn[n-1])return solve(n-1,x-1);
	else if(x==bn[n-1]+2)return pn[n-1]+1;
	else if(x<=bn[n]-1)return pn[n-1]+1+solve(n-1,x-2-bn[n-1]);
	else return pn[n];
}

int main(){
	ll n,x;
	cin>>n>>x;
	pn[0]=1;bn[0]=1;
	for(int i=0;i<50;i++){
		pn[i+1]=1+2*pn[i];
		bn[i+1]=3+2*bn[i];
	}

	cout<<solve(n,x)<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace abc141_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();
      var k = CIn.ReadInt();
      var q = CIn.ReadInt();
      var a = CIn.ReadIntArray(q);

      var p = new int[n];

      for (var i = 0; i < q; i++)
      {
        p[a[i] - 1]++;
      }

      for (var i = 0; i < n; i++)
      {
        Console.WriteLine(k - q + p[i] > 0 ? "Yes" : "No");
      }
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}


Measured memory_bytes: 18008
import java.util.Scanner;

public class Main { //クラス名はMain
    public static void main(String[] args) {
        //コード
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        if((a == b || b == c || a==c) &&(a != b || b != c || a!=c) ){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21972
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){

  int n, a[1000], ans=-1;

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

  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      string ns=to_string(a[i]*a[j]);

      bool f=true;
      for(int k=1;k<ns.size();k++){
	if(ns[k-1]+1!=ns[k]){
	  f=false;
	  break;
	}
      }
      if(f) ans=max(ans, a[i]*a[j]);
    }
  }

  cout<<ans<<endl;
  
  return 0;
}



Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=100009;
 
// Happy Coding!


void solve(){
    
    int a,b;
    cin>>a>>b;
    
    string num=to_string(a)+to_string(b);
    int n=stoi(num);
    
    
    int s=sqrt(n);
    if(n==s*s){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

 
int main() {
    faster;
    int t=1;
    // cin>>t;
    
    while(t-->0){
        solve();
    }
	return 0;
}

Measured memory_bytes: 3688
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

const int N = 105;

int n, x;
int arr[N];

int main()
{
  cin >> x >> n;
  set<int> s;
  for(int i = 0; i < n; i++) {
    cin >> arr[i];
    s.insert(arr[i]);
  }
  int d = 1e9, ans;
  for(int i = 0; i < 300; i++) {
    if(s.find(i) == s.end()) {
      if(abs(i - x) < d) {
        d = abs(i - x);
        ans = i;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n) FOR(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

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

typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1ll<<29;
const bool debug = 0;

int main() {
	int w;
	cin >> w;
	cout << w * 32 << endl;
	return 0;
}

Measured memory_bytes: 3092
class BIT:
    def __init__(self, n):
        self.N = n
        self.n = 1<<n.bit_length()
        self.data = [0] * (self.n + 1)
        
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.n:
            self.data[i] += x
            i += i & -i
N = int(input())
A = list(map(int, input().split()))
N0 = N*(N+1)//2
def C(x):
    B = BIT(N*2+1)
    s = [0]*(N+1)
    for i in range(N):
        a = A[i]
        s[i] = 1 if x<a else -1
        s[i]+=s[i-1]
    res = 0
    for i in range(-1, N):
        res+=B.sum(s[i]+N+1)
        B.add(s[i]+N+1, 1)
    return res<N0//2
ok = max(A)
ng = min(A)-1
while abs(ok-ng)>1:
    mid = (ok+ng)//2
    if C(mid):#midが条件を満たすか
        ok = mid
    else:
        ng = mid
print(ok)

    

    

Measured memory_bytes: 118688
#include<stdio.h>
int main()
{
	int n,x;
	while(~scanf("%d%d",&n,&x))
	{
		int a[200]={0};
		int total=0,t=0;
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&a[i]);
		}
		for(int i=1;i<=n+1;i++)
		{
			t=t+a[i-1];
			if(t<=x)
			total++;
		}
		printf("%d\n",total);
	}
}

Measured memory_bytes: 128