akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 1000000
#define MOD 1000000007
#define INF 100000000000000

vector<vector<pair<int,int>>> parent;

pair<int,int> find(pair<int,int> x){
  pair<int,int> y=parent.at(x.first).at(x.second);
  if(y!=x){
    y=find(y);
  }
  return parent.at(x.first).at(x.second)=y;
}

void unite(pair<int,int> x, pair<int,int> y){
  pair<int,int> a=find(x);
  pair<int,int> b=find(y);
  if(a!=b){
    parent.at(a.first).at(a.second)=b;
  }
}

int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char>> c(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>c.at(i).at(j);
    }
  }
  parent.resize(H,vector<pair<int,int>>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      parent.at(i).at(j)=make_pair(i,j);
    }
  }
  int dx[4]={1,0,-1,0};
  int dy[4]={0,1,0,-1};
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      for(int k=0;k<4;k++){
        int ni=i+dx[k];
        int nj=j+dy[k];
        if(ni<0||nj<0||ni>=H||nj>=W){
          continue;
        }
        if(c.at(i).at(j)!=c.at(ni).at(nj)){
          unite(make_pair(i,j),make_pair(ni,nj));
        }
      }
    }
  }
  vector<vector<ll>> number1(H,vector<ll>(W,0)),number2(H,vector<ll>(W,0));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      pair<int,int> p=find(make_pair(i,j));
      if(c.at(i).at(j)=='.'){
        number1.at(p.first).at(p.second)++;
      }else{
        number2.at(p.first).at(p.second)++;
      }
    }
  }
  ll ans=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      ans+=number1.at(i).at(j)*number2.at(i).at(j);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4224
n = int(input())

arr = [int(input()) for _ in range(n)]

max_arr = max(arr)
next_max = 0

cnt = 0
for i, a in enumerate(arr):
    if a == max_arr:
        cnt += 1
        idx = i
    else:
        next_max = max(next_max, a)

if cnt >= 2:
    ans = [max_arr] * n
else:
    ans = [max_arr] * idx + [next_max] + [max_arr] * (n - idx - 1)

print(*ans, sep="\n")


Measured memory_bytes: 17644
def Base_n_to_10(X,n):
    out = 0
    for i in range(1,len(str(X))+1):
        out += int(X[-i])*(n**(i-1))
    return out#int outn=int(input())
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
n=int(input())
x=input()
ans=[]
pc=x.count("1")
la=[float("inf")]*pc
for i in range(1,pc+1):
    i10=str(Base_10_to_n(i, 2)).count("1")
    if i%i10==0:
      la[i-1]=1
    else:
      la[i-1]=la[(i%i10)-1]+1
if pc!=1:
  x10=Base_n_to_10(x,2)
  a=x10%(pc+1)
  b=x10%(pc-1)
  for i in range(1,n+1):
    if x[i-1]=="0":
      ans.append((a+pow(2,n-i,pc+1))%(pc+1))
    else:
      ans.append((b-pow(2,n-i,pc-1))%(pc-1))
  for a in ans:
    if a==0:
      print(1)
    else:
      print(1+la[a-1])
else:
  x10=Base_n_to_10(x,2)
  for i in range(1,n+1):
    if x[i-1]=="0":
      ans.append((x10+pow(2,n-i,pc+1))%(pc+1))
    else:
      ans.append("n")
  for a in ans:
    if a==0:
      print(1)
    elif a=="n":
      print(0)
    else:
      print(1+la[a-1])


Measured memory_bytes: 104760
program main
 implicit none
 
 integer :: i,c(50),v(50),k,s = 0,n
 
 read(*,*)n
 read(*,*)(v(i),i=1,n)
 read(*,*)(c(i),i=1,n)
 
 do i = 1, n
   k = v(i) - c(i)
   if  (k > 0) then
     s = s + k
   end if
 end do
 
 write(*,*)s
end program main
 

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

int K, R[8], C[8], Order[8], Now[8][8];

bool Check(int i, int j){
  return 0 <= i && i < 8 && 0 <= j && j < 8; 
}

int Solve(int i, int j){
  for (int k = 1; k < 8; k++){
    if (Check(i + k, j + k)) Now[i + k][j + k]++;
    if (Check(i - k, j + k)) Now[i - k][j + k]++;
    if (Check(i - k, j - k)) Now[i - k][j - k]++;
    if (Check(i + k, j - k)) Now[i + k][j - k]++;
  }
  return 0;
}

int main(){
  for (int i = 0; i < 8; i++) Order[i] = i;
  cin >> K;
  for (int i = 0; i < K; i++) cin >> R[i] >> C[i];

  do{
    bool flag = true;
    for (int i = 0; i < K; i++){
      if (Order[R[i]] != C[i]) flag = false;
    }
    if (!flag) continue;

    fill((int*)Now, (int*)(Now + 8), 0);
    for (int i = 0; i < 8; i++){
      int I = i, J = Order[i];
      Solve(I, J);
    }

    for (int i = 0; i < 8; i++){
      if (Now[i][Order[i]] > 0) flag = false;
    }
    
    if (flag){
      for (int i = 0; i < 8; i++){
        for (int j = 0; j < 8; j++){
          if (j == Order[i]) cout << 'Q';
          else cout << '.';
        }
        cout << endl;
      }
      return 0;
    }
  }while (next_permutation(Order, Order + 8));
  
  return 0;
}



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

#define ll long long int
#define lld long double
#define fl float
#define fst first
#define scd second
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);
#define INF (ll)10000000000000000
#define MOD (ll)1000000007
#define pb push_back


ll pwr(ll a, ll b){
 ll res=1;
 while(b>0){
  if(b&1)
   res=res*a;
  a*=a;
  b>>=1;
 }
 return res;
}

int main(){

 //START OF PROGRAM LOGIC
 ll n;
 cin>>n;
 map<ll,ll> mp;
 ll N=n;
 for(ll x=2;x*x<=N;x++){
  while(n%x==0 && n>1){
   n/=x;
   mp[x]++;
  }
 }
 if(n>=2)
  mp[n]++;
 ll ans=0;
 for(auto &x:mp){
  ll i=1;
  while(pwr(x.fst,x.scd)>=pwr(x.fst,i) && pwr(x.fst,i)>=0){
   //cout<<pwr(x.fst,i)<<" ";
   x.scd-=i;
   i++;
   ans++;
  }
 }
 if(mp.empty() && N!=1)
  ans=1;
 cout<<ans<<"\n";
 //END OF PROGRAM LOGIC

 return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  string s;
  while(getline(cin,s), s!=".") {
    stack<char> stk;
    bool f = 1;
    REP(i,s.size()) {
      if (s[i]=='[' || s[i]=='(')
        stk.push(s[i]);
      if (s[i]==']') {
        if (stk.empty() || stk.top() != '[') {
          f = 0;
          break;
        } else
          stk.pop();
      } else if (s[i]==')') {
        if (stk.empty() || stk.top() != '(') {
          f = 0;
          break;
        } else
          stk.pop();
      }
    }
    if (f && stk.empty())
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
}

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

ll modinv(ll a,ll m){
   ll b=m,u=1,v=0;
   while(b){
      ll t=a/b;
      a-=t*b; 
      swap(a,b);
      u-=t*v; 
      swap(u,v);
   }
   u%=m;
   if(u<0) u+=m;
   return u;
}

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



int main(){
   int n;
   cin>>n;
   string s;
   cin>>s;
   int ans=0;
   for(int i=1;i<n-1;i++){
      string x,y;
      for(int j=0;j<i;j++){
         x+=s[j];
      }
      for(int j=i;j<n;j++){
         y+=s[j];
      }
      int count=0;

      string xx,yy;
      rep(j,x.size()){
         bool flag=true;
         rep(k,j){
            if(x[j]==x[k]){
               flag=false;
            }
         }
         if(flag==1) xx+=x[j];
      }

      rep(j,y.size()){
         bool flag=true;
         rep(k,j){
            if(y[j]==y[k]){
               flag=false;
            }
         }
         if(flag==1)yy+=y[j];
      }

      rep(j,xx.size()){
         rep(k,yy.size()){
            if(xx[j]==yy[k]){
               count++;
               break;
            }
         }
      }

      ans=max(ans,count);
   }
   cout<<ans;
   return 0;
}



Measured memory_bytes: 256
// using no_way as a way
// using no_limitation as a limitation

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = (1e-9);
typedef long long ll;
typedef unsigned long long ull;
#define flush fflush(stdout), cout.flush()
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,line) memset(v,line,sizeof(v))
#define rep(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define RT(x) return cout<<x, 0;
//#define lcm(a,b) (a*(b/__gcd(a,b)))
#define P 1000000007
#define endl '\n'
// const int dx[] = {1,-1,0,0,1,-1,1,-1};
// const int dy[] = {0,0,1,-1,1,-1,-1,1};
// const int dxhorse[] = {-2,-2,-1,-1,1,1,2,2};
// const int dyhorse[] = {1,-1,2,-2,2,-2,1,-1};
 
void file() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
}


int main(int argc, char const *argv[])
{
    // file();
    fast();
    
    int k; cin>>k;
    ll ans = 0;
    for (int a = 1; a <= k; ++a)
    {
        for (int b = 1; b <= k; ++b)
        {
            
            for (int c = 1; c <= k; ++c)
            {
                int add = __gcd(a, b);
                add = __gcd(add, c);
                ans+=add;

            }
        }
    }
    cout<<ans;
}

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

int main(){
	while (true){
		int n;
		cin >> n;

		if (n == 0)
			break;

		unsigned sum = 0;
		for (int i = 0; i < n; i++){
			int p;
			cin >> p;

			sum += (unsigned)p;
		}

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

		sort(j, j + (n - 1));

		unsigned sal_max = (unsigned)n*sum;

		for (int i = n - 1; i >= 1; i--){
			sum += (unsigned)j[i - 1];

			sal_max = max(sal_max, (unsigned)i*sum);
		}

		cout << sal_max << endl;
	}
	return 0;
}

Measured memory_bytes: 1424
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 3e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;
//#define endl "\n" //インタラクティブでは消す
//ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
ut N, M, K, L, Q, D, H, W,R;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
LL maps[SIZE2][SIZE2];
pr A[SIZE];
LL solve() {
	cin >> N;
	REP(i, N) {
		LL x, y;
		cin >> x >> y;
		A[i] = pr(x + y,x);
	}
	LL ans = 0;
	sort(A, A + N, greater<pr>());
	REP(i, N) {
		if (i % 2)
			ans -= A[i].first-A[i].second;
		else
			ans += A[i].second;
	}

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




//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	string s;
	solve();
		
	
	//cin >> N;
	return 0;

}


Measured memory_bytes: 10624
import collections
S = input()
Q = int(input())

query_list = [input().split() for _ in range(Q)]

T_cnt_list = collections.deque([0])
left = ''
right = ''

for i, query in enumerate(query_list):
    if query[0] == '1':
        T_cnt_list.append(1+T_cnt_list[-1])

    else:
        T_cnt_list.append(T_cnt_list[-1])

        if query[1] == '1' and T_cnt_list[i+1]%2 == 0:
            left = query[2] + left

        elif query[1] == '1' and T_cnt_list[i+1]%2 == 1:
            right = right + query[2]

        elif query[1] == '2' and T_cnt_list[i+1]%2 == 0:
            right = right + query[2]

        elif query[1] == '2' and T_cnt_list[i+1]%2 == 1:
            left = query[2] + left

if T_cnt_list[-1]%2 == 0:
    print(left + S + right)
else:
    print(right[::-1] + S[::-1] + left[::-1])


Measured memory_bytes: 44456
n = int(input())
a = []
for i in range(n):
    s, p = input().split()
    a.append([s, int(p),i])
 
a.sort(key=lambda x:x[1], reverse=True)
a.sort(key=lambda x:x[0])
 
for x in a:
    print(x[2]+1)

Measured memory_bytes: 3060
n,m=map(int,input().split())
edg=[[] for i in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    edg[a].append(b)
    edg[b].append(a)
f=1
for i in range(2,n+1):
    if 1 in edg[i] and n in edg[i]:
        f=0
print("POSSIBLE" if f==0 else "IMPOSSIBLE")


Measured memory_bytes: 108924
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int count=0;
  int ans=0;
  
  
  if(n<105) cout << 0 << endl;
  else if(n==105) cout << 1 << endl;
  else{
    for(int i=105;i<=n;i+=2){
      count=0;
      for(int j=1;j<=i;j++){
        if(i%j==0) ++count;
      }
      if(count==8) ++ans;
    }
    cout << ans << endl;
  }
  return 0;
}
  


Measured memory_bytes: 256
def main():
    X, K, D = map(int, input().split())
    answer = solve(X, K, D)
    print(answer)


def solve(X, K, D):
    if abs(X) >= D * K:
        return abs(X) - (D * K)

    least_hops = abs(X) // D

    hops_left = K - least_hops
    dst = abs(X) - (D * (least_hops + hops_left % 2))

    return abs(dst)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9168
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
    int H, W;
    while(1){
        cin >> H >> W;
        if(H==0&W==0){
            break;
        }
        else{
            for(int i=0; i<H; i++){
                if(i==0 || i==H-1){
                    for(int j=0; j<W; j++){
                        cout << "#" << flush;
                    }
                }
                else{
                    for(int j=0; j<W; j++){
                        if(j==0 || j==W-1){
                            cout << "#" << flush;
                        }
                        else cout << "." << flush;
                    }
                }

                cout << endl;
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef deque<ll> di;
typedef pair<ll,ll> pi;
#define pb push_back
#define mp make_pair
#define mh make_heap
#define pf push_front
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF 1000000000
#define FOR(i,a,b) for(ll i=a;i<b;i++)


int main()
{
    //freopen("contest.txt","r",stdin);
    //freopen("contest.txt","w",stdout);
    IOS
    string s;
    cin>>s;
    ll t=s.size()-1;
    if(s[t]!='s')
    cout<<s<<"s"<<endl;
    else
        cout<<s<<"es"<<endl;

    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int a[n];
		char c[n];
		int b[4][13]={0};
		for(int i=0;i<n;i++){
			cin>>c[i]>>a[i];
			if(c[i]=='S'){
				b[0][a[i]-1]=1;
			}else if(c[i]=='H'){
				b[1][a[i]-1]=1;
			}else if(c[i]=='C'){
				b[2][a[i]-1]=1;
			}else if(c[i]=='D'){
				b[3][a[i]-1]=1;
			}
		}
		for(int i=0;i<4;i++){
			for(int j=0;j<13;j++){
				if(b[i][j]==0){
					if(i==0){
						cout<<"S"<<' '<<j+1<<endl;
					}else if(i==1){
						cout<<"H"<<' '<<j+1<<endl;
					}else if(i==2){
						cout<<"C"<<' '<<j+1<<endl;
					}else if(i==3){
						cout<<"D"<<' '<<j+1<<endl;
					}
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3096
a = list(map(int,input()))

sep = []
for i in range(2**3):
    sep.append([])
    tmp = a[0]
    for j in range(3):
        if i>>j&1:
            sep[i].append("+")
            tmp += a[j+1]
        else:
            sep[i].append("-")
            tmp -= a[j+1]
    if tmp == 7:
        ans = i
b = []
for i in range(3):
    b.append(str(a[i]))
    b.append(str(sep[ans][i]))
b.append(str(a[3]))
b.append("=7")        
print("".join(b))

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    int a,b,c;cin>>a>>b>>c;
    if(b/a>=c)cout<<c<<endl;
    else cout<<b/a<<endl;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <string.h>
 
int n;
char str[105][16];
 
int main()
{
    int i, j;
    char prev;
    int f = 1;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%s", str[i]);
    }
 
 
    prev = str[0][strlen(str[0]) - 1];
    i = 1;
    while (i < n && f) {
        for (j = 0; j < i; j++) {
            if (strcmp(str[i], str[j]) == 0) {
                f = 0;
            }
        }
 
        if (prev != str[i][0]) {
            f = 0;
        }
        
        prev = str[i][strlen(str[i]) - 1];
 
        i++;
    }
 
    if (i < n || !f) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
        
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i,k,n) for(int i = k; i < n; i++)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define argmax max_element
#define argmin min_element
#define push push_back
#define pop pop_back
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef string str;

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

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

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

    ll X=in();
    vector<int> beki;

    rep(b, 32) {
        REP(p, 2, 10) {
            beki.push(pow(b, p));
        }
    }
    sort(ALL(beki));

    int ans=0;
    rep(i, beki.size()) {
        if(beki[i] > X) {
            ans=i-1;
            break;
        }
    }

    cout << beki[ans] << endl;

    return 0;
}


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

bool solve(int n, int m, int i, int *A){
	if(m==0)
		return true;
	if(m<0 || i>=n)
		return false;
	return solve(n, m, i+1, A) || solve(n,m-A[i],i+1,A);
}


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

	int q; cin >> q;
	for(int i=0; i<q; i++){
		int m; cin >> m;
		if(solve(n,m,0,A))
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  // vector<ll> a(N); rep(i, N) cin >> a[i];
  
  ll ans = N*N-K;
  // bool ok = false;

  cout << ans << endl;
  // cout << (ok?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}









Measured memory_bytes: 3572
import java.io.*;

public class Main {
  public static void main(String[] args) {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    try {
      String s = reader.readLine();
      String p = reader.readLine();
      s = s + s;
      if (s.indexOf(p) == -1) {
        System.out.println("No");
      }
      else {
        System.out.println("Yes");
      }
    }
    catch (IOException e) {
      System.out.println(e);
    }
  }
}

Measured memory_bytes: 24484
import java.util.Scanner;

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 coin = 0;
		int day = 0;
		while (coin < C) {
			day++;
			coin += A;
			if (day % 7 == 0) {
				coin += B;
			}
			if (coin >= C) {
				break;
			}
		}
		System.out.println(day);
	}

}



Measured memory_bytes: 26344
N, M = (int(i) for i in input().split()) 

outs = [[] for i in range(N)]
ins = [0] * N


for _ in range(M):
    x, y = (int(i) for i in input().split())
    x -= 1
    y -= 1
    outs[x].append(y)
    ins[y] += 1

q = []
for i in range(N):
    if ins[i] == 0:
        q.append(i)

result = []
while q != []:
    qn = q.pop()
    result.append(qn)
    for v in outs[qn]:
        ins[v] -= 1
        if ins[v] == 0:
            q.append(v)


last = [0] * N
# last[i] = iが最後だったときに最長のパス
for sq in result:
    for v in outs[sq]:
        last[v] = max(last[v], last[sq] + 1)

print(max(last))


     



Measured memory_bytes: 67360
N, x = map(int,input().split())
a = [i for i in map(int, input().split())]

a.sort()
ans = 0

for i in range(N):
    if (x >= a[i] and i < N-1) or (x == a[i] and i == N-1) :
        x -= a[i]
        ans += 1
    else:
        break
print(ans)

Measured memory_bytes: 3188
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    i64 a, b, n;
    cin >> a >> b >> n;
    i64 ans = 0;
    for (i64 x : {n, n / b * b - 1})
    {
        ans = max(a * x / b - a * (x / b), ans);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int i=0;
        while(!(a.equals("-"))){
            int num = sc.nextInt();
            for(i=0;i<num;i++){
                int n = sc.nextInt();
                String l = a.substring(0,n);
                String r = a.substring(n);
                a = r + l;
            }
            System.out.println(a);
            a = sc.next();
        }
        sc.close();
    }
}


Measured memory_bytes: 26436
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

(N, M) = reads()

d = defaultdict(list)
V = set()

for i in range(N):
  V.add(("p", i+1))
for j in range(M):
  V.add(("l", j+1))

for i in range(1, N+1):
  Ls = reads()[1:]
  for j in Ls:
    d[("l", j)].append(("p", i))
    d[("p", i)].append(("l", j))

def walk(v):
  V.discard(v)
  for w in d[v]:
    if w in V:
      walk(w)

# for (k, v) in d.items():
#   print(k, v)

v = ("p", 1)
walk(v)

# print(V)

print("NO" if len([v for v in V if v[0] == "p"]) > 0 else "YES")


Measured memory_bytes: 76524
S = list(input())
for i in range(len(S)):
    S[i] = int(S[i])
A = 10*S[0] + S[1]
B = 10*S[2] + S[3]
if (A == 0 or A >= 13) and (B == 0 or B >= 13):
    print("NA")
elif A == 0 or A >= 13:
    print("YYMM")
elif B == 0 or B >= 13:
    print("MMYY")
else:
    print("AMBIGUOUS")



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

// 素数列挙
vector<int> prime_list(int n) {
    vector<bool> is_prime(n + 1, true);
    vector<int> res;
    int i = 2;
    while (pow(i, 2) <= n) {
        if (is_prime[i]) {
            int j = i + i;
            while (j <= n) {
                is_prime[j] = false;
                j += i;
            }
        }
        i++;
    }
    for (int i = 0; i <= n; ++i) {
        if (is_prime[i] && i >= 2) {
            res.push_back(i);
        }
    }
    return res;
}

void Main() {
    int X; cin >> X;
    vector<int> Y = prime_list(2 * X);
    cout << *lower_bound(Y.begin(), Y.end(), X) << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 512
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    S = input().rstrip()
    N = len(S)
    for i in range(N):
        if i % 2 == 0:
            if S[i] == 'L':
                print('No')
                return 0
        else:
            if S[i] == 'R':
                print('No')
                return 0
    print('Yes')


if __name__ == '__main__':
    main()


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

int main(){
	int n;
	scanf("%d", &n);
	std::set <int> set;
	for (int i = 0, x; i < n; ++ i){
		scanf("%d", &x);
		if (set.count(x)){
			set.erase(x);
		}
		else{
			set.insert(x);
		}
	}
	return printf("%d\n", (int) set.size()), 0l;
}

Measured memory_bytes: 4864
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;

int dp[100010];

    int main(){
      int n;
      cin >> n;
      rep(i,n+1){
       dp[i]=inf; 
      }
      dp[0]=0;
      rep(i,5){
       dp[i+1]=i+1; 
      }
      dp[6]=1;
      dp[9]=1;
      rep(i,n+1){
        rep(j,8){
          if(i-pow(6,j)>=0){
            int jj=pow(6,j);       
           dp[i]=min(dp[i],1+dp[i-jj]); 
          }
        }
        rep(k,7){
          if(i-pow(9,k)>=0){
            int kk=pow(9,k);
           dp[i]=min(dp[i],1+dp[i-kk]); 
          }
        }
        rep(l,5){
         if(i-l>=0){
          dp[i]=min(dp[i],dp[i-l-1]+l+1); 
         }
        }
      }
      cout << dp[n] << endl;
//      rep(i,n+1)cout << "dp[" << i << "]:" << dp[i] << endl;
      return 0;}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
int main(){
    int h,w;cin >>h >>w;
    
    char arr[h][w] = {};
    fo(i,h){
        fo(j,w){
            cin >> arr[i][j]; 
        }
    }
    int i=0,j=0;  
    while(i<h-1&&j<w-1){
        if(arr[i][j+1]=='#'&&arr[i+1][j]!='#'){
            for(int y = i+2; y<h;++y){
                if(arr[y][j]=='#'){
                    cout << "Impossible";return 0;
                }
            }
            ++j;
        }
        else if(arr[i+1][j]=='#'&&arr[i][j+1]!='#'){
            for(int z = j+2; z<w;++z){
                if(arr[i][z]=='#'){
                    cout << "Impossible";return 0;
                }
            }
            ++i;
        }
        else{
            cout << "Impossible";return 0;
        }
    }
    if(i==h-1){
        for(int k=j+1;k<w;++k){
            if(arr[h-2][k]=='#'){
                cout << "IMPOSSIBLE";return 0;
            }
        }
        cout << "Possible";return 0;
    }
    else{
        for(int p=i+1;p<h;++p){
            if(arr[p][w-2]=='#'){
                cout << "IMPOSSIBLE";return 0;
            }
        }
        cout << "Possible";return 0;
    } 
}


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

int main()
{
    string S, T;
    cin >> S >> T;

    // 答えansを仮置きする。
    // これが十分に大きくないと不正解となるので、
    // この値なら絶対に正しい答えが出る、という値を仮置きすること
    int ans = T.size();

    // Sの何文字目から調べるかを全探索する
    for(int start = 0; start <= S.size() - T.size(); start++)
    {
        int diff = 0;
        for(int i = 0; i < T.size(); i++)
        {
            // 差分をカウント
            if(T[i] != S[start + i])
            {
                diff++;
            }
        }
        // 差分の最小値を保持する
        ans = min(ans, diff);
    }
    cout << ans << endl;
    return 0;
}

/*************
cabacc
abc

1
**************
codeforces
atcoder

6
**************/

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

struct D{
  int x,y,r,c;
  D(int x=0,int y=0,int r=0,int c=-1):x(x),y(y),r(r),c(c){};
};

D d[25];
int n;
char s[1<<24]; // stateの状態の時、取り除ける最大の枚数
int ans;

int dis(int i,int j){
  int x=d[i].x-d[j].x, y=d[i].y-d[j].y;
  return x*x+y*y;
}

bool isTop(int state,int i){ // d[i] の上に円盤がないならtrue
  //    cout << " isTop (" << state <<","<<i << ")" << endl;
  for( int j=0;j<i;j++ ){
    //    cout << " j=" << j;
    if( !(state & 1<<j) ) continue;
    int dist = dis(i,j);
    int r = d[i].r + d[j].r;
    r=r*r;

    //    cout << " dist="<<dist << " r="<<r  << endl;
    if( dist < r ) return false;
  }

  return true;
}

int dfs( int state ){
  /*
  cout << "state(" << state << ")";
  for( int i=n-1;i>=0;i-- ){
    if( state & 1<<i ) cout << "1";
    else cout << "0";
  }
  cout << " " << (int)s[state] << endl;;
  */

  int a,b,rtn=0,c;
  if( s[state]>=0 ) return s[state];


  for( int i=0;i<n;i++ ){
    if( ! (a=state & 1<<i) ) continue;
    if( !isTop(state,i) ) continue;
    //    cout << "i = top"<<endl;

    for( int j=i+1;j<n;j++ ){
      if( ! (b=state & 1<<j) ) continue;
      if( d[i].c!=d[j].c ) continue;
      if( !isTop(state,j) ) continue;
      //      cout << "j=top" <<endl;

      c=dfs( state-a-b )+2;
      if( c>rtn ) rtn=c;
    }
  }
  return s[state]=rtn;
}

int main(){

  while( cin>>n && n){
    for( int i=0;i<n;i++ )
      cin >> d[i].x >> d[i].y >> d[i].r >> d[i].c;

    for(int i=0,len=1<<n;i<len;s[i++]=-1 );
    s[0]=0;

    int state=0;
    for( int i=0;i<n;i++ )    state = state | 1<<i;
    cout << dfs( state ) << endl;
  }

  return 0;
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    cin>>n;
    if(n<1000){
        if(n>=100) cout<<"ABC"<<endl;
        else if(n>9) cout<<"ABC"<<endl;
        else cout<<"ABC"<<endl;
    }
    else{
                if(n>=100) cout<<"ABD"<<endl;
        else if(n>9) cout<<"ABD"<<endl;
        else cout<<"ABD"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>a){sort(all(a));return a;}

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

const int inf = 1e9;
const ll linf = 3e18;

int a[5000], b[5000];

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

    int A, B; cin >> A >> B;

    rep(i, A) cin >> a[i];
    rep(i, B) cin >> b[i];

    int ma = 0;

    rep(i, B) {
        int idx = i;

        int cnt = 0;

        rep(j, A) {
            if (a[j] == b[idx]) {
                idx++;
                cnt++;
            }

            if (idx == B) break;
        }

        chmax(ma, cnt);
    }

    cout << ma << endl;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

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

  char a, b, c, d;
  cin >> a >> b >> c >> d;

  for(ll i = 0; i < 2; i++){
    for(ll j = 0; j < 2; j++){
      for(ll k = 0; k < 2; k++){
        ll sum = a - '0';
        if(i == 0) sum += b - '0';
        else sum -= b - '0';

        if(j == 0) sum += c - '0';
        else sum -= c - '0';

        if(k == 0) sum += d - '0';
        else sum -= d - '0';

        if(sum == 7){
          char op1 = (i==0?'+':'-');
          char op2 = (j==0?'+':'-');
          char op3 = (k==0?'+':'-');
          cout << a << op1 << b << op2 << c << op3 << d << "=7" << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
a=[]
for i in range(h):
    a.append(list(input()))
judge = True
for i in range(h):
    for j in range(w):
        if a[i][j]==".":
            continue
        if i>0 and a[i-1][j]=="#":
            continue
        if j>0 and a[i][j-1]=="#":
            continue
        if j<w-1 and a[i][j+1]=="#":
            continue
        if i<h-1 and a[i+1][j]=="#":
            continue
        judge =False
    if not judge :
        break
print("Yes" if judge else "No")


Measured memory_bytes: 3064
object Main extends App {
  import scala.io.StdIn._
  val tetoris = Array.fill(4){
    val Array(h, w) = readLine.trim.split(' ').map(_.toInt)
    new Tetoromino(h, w, Array.fill(h){readLine.trim})
  }
  for (_ ← 0 until readInt()) {
    val state = State(Array.fill(4){readLine.trim})
    println(
      if (canFill(state, 0)(tetoris)) "Yes" else "No"
    )
  }
  def canFill(state: State, used: Int = 0)(implicit rest: Array[Tetoromino]): Boolean = {
    if (used == 14 || used == 13 || used == 11 || used == 7) true
    else rest.indices.filter(i ⇒ (used & (1 << i)) == 0).exists(i ⇒ state.put(rest(i)).exists(s ⇒ canFill(s, used | (1 << i))))
  }
}

case class Coordinate(x: Int, y: Int) {
  def +(that: Coordinate): Coordinate = Coordinate(x + that.x, y + that.y)
  def -(that: Coordinate): Coordinate = Coordinate(x - that.x, y - that.y)
}
class Tetoromino(val h: Int, val w: Int, state: Array[String]) {
  val block = (0 until h).flatMap(y ⇒ (0 until w).map(x ⇒ Coordinate(x, y))).filter(c ⇒ state(c.y)(c.x) == '#').toList match {
    case h::t ⇒ Coordinate(0, 0)::t.map(_ - h)
    case Nil ⇒ ???
  }
}
object State {
  def apply(state: Array[String]): State = {
    val empties = state.indices.flatMap(y ⇒ state(y).indices.filter(x ⇒ state(y)(x) == '.').map(x ⇒ Coordinate(x, y))).toSet
    new State(empties)
  }
}
class State(private val empties: Set[Coordinate]) {
  private val topLeft = Some(empties).filter(_.nonEmpty).map(_.minBy(c ⇒ c.y * 100 + c.x))
  def put(that: Tetoromino): Option[State] = {
    topLeft.map(c ⇒ that.block.map(_ + c)).filter(coords ⇒ coords.forall(empties.contains)).map(coords ⇒ new State(empties -- coords))
  }
}


Measured memory_bytes: 453884
#include "bits/stdc++.h"
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;
typedef long long ll;

template<typename T>
T gcd(T a, T b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

template<typename T>
T lcm(T a,T b){
    return a*b/gcd(a,b);
}

enum mode{
    m,
    p,
    None,
};

int main(void){
    mode mode=None;
    int n,a_,ans=1;
    vector<int> a;
    cin>>n;
    rep(i,n){
        cin>>a_;
        a.push_back(a_);
    }
    rep(i,n-1){
        if(mode==None){
            if(a[i]>a[i+1])mode=m;
            if(a[i]<a[i+1])mode=p;
        }
        if(a[i]>a[i+1]&&mode==p){
            ++ans;
            mode=None;
        }
        else if(a[i]<a[i+1]&&mode==m){
            ++ans;
            mode=None;
        }
    }
    cout<<ans;
}
/*
*/


Measured memory_bytes: 892
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

X, Y = MAP()

c = (Y-2*X)/2

if c%1 == 0 and 0 <= c <= X:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 10116
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

int main(int argc,char **argv){
  int32_t n,m;
  std::cin>>n>>m;

  std::vector <int>a(m);
  for(int i=0;i<m;i++){
    std::cin>>a[i];
  }

  int t;
  {
    int r=0,id=0,ppt=0,pt=1;
    for(int i=1;i<=n;i++){
      if(r<m&&i==a[r]){
	t=0;
	r++;
      }else{
	t=ppt+pt;
	t%=1000000007;
      }
      ppt=pt; 
      pt=t;
    }
  }
  std::cout<<t<<std::endl;
  
  return 0;
}


Measured memory_bytes: 640
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
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;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
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(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    ll cnt = 0, ans = 0, mi = INF;
    rep(i, 0, n) {
        if(a[i] < 0) cnt++;
        ans += abs(a[i]);
        chmin(mi, abs(a[i]));
    }
    if(~cnt & 1) {
        cout << ans << "\n";
    } else {
        cout << ans - 2 * mi << "\n";
    }
}

Measured memory_bytes: 3972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

typedef long long tint;

int main(){
	int x; cin >> x;
	for(int i=x;i<200000;i++){
		bool e = 1;
		for(int j=2;j*j<=x;j++) {if(i %j == 0) e = 0;}
		if(e){
			cout << i<< endl;
			return 0;
		}
	}
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

template<class T> inline bool chMax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b){ if (a > b) { a = b; return true; } return false; }

int main(){
	ll A, B, T;
	cin >> A >> B >> T;

	cout << B * (T / A) << endl;
	return 0;
}


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

int main() {
    int N;
    cin >> N;
    int res = 1;
    for (int i = 0; i < N; i++) {
        if (res < N) res *= 2;
        else if (res > N) {
            res /= 2;
            break;
        }
        else if (res == N) break;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int J, Y;

void solve(int j, int y, string str){
    if(j==J&&y==Y){
        cout<< str<< endl;
        return;
    }
    if(j>=4&&y>=4){
        if(j<J) solve(j+1, y, str+"A");
        if(y<Y) solve(j, y+1, str+"B");
    }else{
        if(j==5||y==5) return;
        if(j<J) solve(j+1, y, str+"A");
        if(y<Y) solve(j, y+1, str+"B");
    }
}

int main(){

    cin>> J>> Y;

    solve(0, 0, "");

    return 0;
}

Measured memory_bytes: 3188
N = int(input())
s = input()

e = [0]
w = [0]

te, tw = 0, 0
for i in range(N):
    if s[i] == 'E':
        te += 1
    else:
        tw += 1
    e.append(te)
    w.append(tw)

ans = N
for leader_idx in range(N):
    t = 0
    t += (e[N] - e[leader_idx + 1])
    t += (w[leader_idx] - w[0])
    ans = min(ans, t)
print(ans)


Measured memory_bytes: 17644