akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

ll MOD = 1e9 + 7;
ll fact[300003];
bool fact_init = false;

ll pow(ll a, ll b){
	if(b == 0) return 1;
	if(b % 2 == 1) return a * pow(a, b - 1) % MOD;
	
	ll d = pow(a, b / 2) % MOD;
	return d * d % MOD; 
}

ll comb(ll n, ll k){
	if(!fact_init){
		fact[0] = 1;
		fact[1] = 1;

		for(ll i = 2;i<=n;i++){
			fact[i] = fact[i-1] * i;
			fact[i] %= MOD;
		}

		fact_init = true;
	}

	ll ret = fact[n];
	ret *= pow(fact[k],MOD-2);
	ret %= MOD;
	ret *= pow(fact[n-k],MOD-2);
	ret %= MOD;
	return ret;

	// X^(-1) = X^(p-2) (mod p) (Fermat's little theorem)
}

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

	ll h, w, a, b;
	cin >> h >> w >> a >> b;

	ll ans = comb(h+w-2, h-1);

	rep(i, a){
		ans += MOD;
		ans -= comb(h-i-1+b-1, h-i-1) * comb(i+w-b-1, i) % MOD;
		ans %= MOD;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main()
{
  while(1)
    {
      int count=0,sum=0,i,k=0;
      char box[1001];
      scanf("%s",box);
      for(i=0;box[i]!='\0';++i)
	count++;
      for(i=0;i<count;i++)
	{
	  sum+=box[i]-'0';
	  if(box[0]-'0'==0)k=1;
	}
      if(k==1)break;
      printf("%d\n",sum);
    }
  return 0;
}

Measured memory_bytes: 536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

void solve(long long W, long long H, long long x, long long y){
    double ans=(double)W*H/2;
    ll ans1=x*2==W&&y*2==H?1:0;
    printf("%.7f %d\n",ans,ans1);
}

int main(){
    long long W;
    scanf("%lld",&W);
    long long H;
    scanf("%lld",&H);
    long long x;
    scanf("%lld",&x);
    long long y;
    scanf("%lld",&y);
    solve(W, H, x, y);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define ull unsigned long long
#define ULL ull
#define mp make_pair
#define pii pair<int,int>
#define piii pair<int, pii >
#define pll pair <ll,ll>
#define pb push_back
#define big 20160116
#define INF 2147483647
#define pq priority_queue
using namespace std;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
namespace Mymath{
	LL qp(LL x,LL p,LL mod){
		LL ans=1;
		while (p){
			if (p&1) ans=ans*x%mod;
			x=x*x%mod;
			p>>=1;
		}
		return ans;
	}
	LL inv(LL x,LL mod){
		return qp(x,mod-2,mod);
	}
	LL C(LL N,LL K,LL fact[],LL mod){
		return fact[N]*inv(fact[K],mod)%mod*inv(fact[N-K],mod)%mod;
	}
	template <typename Tp> Tp gcd(Tp A,Tp B){
		if (B==0) return A;
		return gcd(B,A%B);
	}
	template <typename Tp> Tp lcm(Tp A,Tp B){
		return A*B/gcd(A,B);
	}
};
namespace fwt{
	using namespace Mymath;
	void FWT(int a[],int n,LL mod)
	{
	    for(int d=1;d<n;d<<=1)
	        for(int m=d<<1,i=0;i<n;i+=m)
	            for(int j=0;j<d;j++)
	            {
	                int x=a[i+j],y=a[i+j+d];
	                a[i+j]=(x+y)%mod,a[i+j+d]=(x-y+mod)%mod;
	                //xor:a[i+j]=x+y,a[i+j+d]=x-y;
	                //and:a[i+j]=x+y;
	                //or:a[i+j+d]=x+y;
	            }
	}

	void UFWT(int a[],int n,LL mod)
	{
		LL rev=inv(2,mod);
	    for(int d=1;d<n;d<<=1)
	        for(int m=d<<1,i=0;i<n;i+=m)
	            for(int j=0;j<d;j++)
	            {
	                int x=a[i+j],y=a[i+j+d];
	                a[i+j]=1LL*(x+y)*rev%mod,a[i+j+d]=(1LL*(x-y)*rev%mod+mod)%mod;
	                //xor:a[i+j]=(x+y)/2,a[i+j+d]=(x-y)/2;
	                //and:a[i+j]=x-y;
	                //or:a[i+j+d]=y-x;
	            }
	}
	void solve(int a[],int b[],int n,LL mod)
	{
	    FWT(a,n,mod);
	    FWT(b,n,mod);
	    for(int i=0;i<n;i++) a[i]=1LL*a[i]*b[i]%mod;
	    UFWT(a,n,mod);
	}
};
const int Maxn=105;
int n,a[Maxn];
int main(){
	cin>>n;
	for (int i=1;i<=n;i++) cin>>a[i];
	int cnt=1;
	int ans=0;
	for (int i=2;i<=n;i++){
		if (a[i]==a[i-1]) cnt++;
		else{
			ans+=cnt/2;
			cnt=1;
		}
	}
	ans+=cnt/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define dd double
#define f0(i, n) for(int i = 0; i < n; i++)
#define fab(i,a,b) for(int i=a;i<b;i++)
#define f1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second





int main() {


	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif


//ios_base& scientific (ios_base& str);
	int n;
	cin >> n;

	int dp[n + 1] = {0};

	int h[n + 1];

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

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

	for (int i = 3; i <= n; i++) {

		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}

	cout << dp[n] << endl;






	return 0;
}

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

 using namespace std;
 int main() {
   string S;
   cin >> S;
   if (S == "SUN") cout << 7 << endl;
   else if (S == "MON") cout << 6 << endl;
   else if (S == "TUE") cout << 5 << endl;
   else if (S == "WED") cout << 4 << endl;
   else if (S == "THU") cout << 3 << endl;
   else if (S == "FRI") cout << 2 << endl;
   else if (S == "SAT") cout << 1 << endl;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF (9e18)
#define EPS (1e-6)
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<endl;}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
void INIT(){
	ios::sync_with_stdio(false); cin.tie(0);
}

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

ll dp[110][110];

int32_t main() {
	INIT();
	//code...
	ll n,m; cin>>n>>m;
	vector<string> v(n);
	for(auto &i:v) cin>>i;
	if(v[0][0]=='#') dp[0][0]=1;
	else dp[0][0]=0;
	For(j,1,m-1) dp[0][j]=(v[0][j]=='#' && v[0][j-1]=='.')?dp[0][j-1]+1:dp[0][j-1];
	For(i,1,n-1) dp[i][0]=(v[i][0]=='#' && v[i-1][0]=='.')?dp[i-1][0]+1:dp[i-1][0];
	For(i,1,n-1) For(j,1,m-1){
		ll a=dp[i-1][j];
		if(v[i][j]=='#' && v[i-1][j]=='.') a++;
		ll b=dp[i][j-1];
		if(v[i][j]=='#' && v[i][j-1]=='.') b++;
		dp[i][j]=min(a,b);
	}
	cout<<dp[n-1][m-1]<<"\n";
	return 0;
}






















Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
   long long n,a,sum=0,max=-1000001,min=1000001;
   cin >> n;
   for(int i=0;i<n;++i){
        cin >> a;
        sum+=a;
        if(a>max) max=a;
        if(a<min) min=a;
   }
   cout << min <<" "<< max <<" "<< sum << endl;
   return 0;
}

Measured memory_bytes: 3108
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {

    int n, p, item, maxv;
    for (; ;) {
        scanf("%d", &n);
        if (n == 0) break;
        p = 0;
        maxv = 0;
        for (int i = 0; i < n; i++) {
            scanf("%d", &item);
            if (item == 0) continue;
            maxv = max(maxv, item);
            p++;
        }
        if (maxv < 2) printf("NA\n");
        else printf("%d\n", p+1);
    }

    return 0;
}



Measured memory_bytes: 2680
#include <bits/stdc++.h>
using  namespace std;
int main(){
    long long n, t, check = 100;
    string s, ans="";
    cin >> n;
    long long S[n][26];
    for(int i=0;i<n;i++){
      for(int j=0;j<26;j++){
        S[i][j] = 0;
      }
    }
    for(int i=0;i<n;i++){
        cin >> s;
        for(int j=0;j<s.length();j++){
            S[i][int(s[j])-97]++;
        }
    }
    for(int i=0;i<26;i++){
        check = 100;
        for(int j=0;j<n;j++){
            check = min(check, S[j][i]);
        }
      	for(int k=0;k<check;k++){
           ans += char(i+97);
        }    
    }
    
    cout << ans << endl;
    return 0;
 
}


Measured memory_bytes: 256
import heapq
def dijkstra(n, edges, s):
    min_dist = [float('inf')] * n
    min_dist[s] = 0
    next_v = []
    heapq.heappush(next_v, (0, s))
    path = [-1] * n
    
    while True:
        if len(next_v) == 0: break
        d, v = heapq.heappop(next_v)
        
        for u, d in edges[v]:
            if min_dist[u] > min_dist[v] + d:
                min_dist[u] = min_dist[v] + d
                heapq.heappush(next_v, (min_dist[u], u))
                path[u] = v
                
    return min_dist, path

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

for _ in range(n-1):
    a, b, c = map(int, input().split())
    edges[a-1].append((b-1, c))
    edges[b-1].append((a-1, c))


q, k = map(int, input().split())
dist, _ = dijkstra(n, edges, k-1)

for _ in range(q):
    x, y = map(int, input().split())
    print(dist[x-1] + dist[y-1])

Measured memory_bytes: 47884
import heapq

x,y,a,b,c = map(int,input().split())

p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

#価値が小さいように並べる
p.sort()
q.sort()

#価値が大きいように並べる
r.sort(reverse = True)

#結局赤色上位x個,緑色上位y個だけ残せばよい
p = p[a-x:]
q = q[b-y:]

# heapqの形にする
heapq.heapify(p)
heapq.heapify(q)

#交換できる限り交換を行う
for i in r:
    if p[0] <= q[0]:
        if i > p[0]:
            heapq.heappop(p)
            heapq.heappush(p,i)
    else:
        if i > q[0]:
            heapq.heappop(q)
            heapq.heappush(q,i)

print(sum(p)+sum(q))

Measured memory_bytes: 23456
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
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()))
MOD = 10**9 + 7

s = input()
n = len(s)//2

res = 0
for i in range(n):
    if s[i] != s[-1*(i+1)]:
        res += 1

print(res)

Measured memory_bytes: 66156
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
cnt=0
if sum(a)==x:
    print(n)
    exit()
else:
    for i in range(n-1):
        if a[i]<=x:
            x-=a[i]
            cnt+=1
print(cnt)

Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+10;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n; cin >> n;
  vector<ll> a(n+2,0),b(n+2,0);
  for(int i=1; i<=n; i++){ cin >> a[i]; b[1] += a[i];}
  for(int i=2; i<=n; i+=2){ b[1] -= 2*a[i]; }  

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


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int H,W;
int a[26];

int halt(){
	cout << "No" << endl;
	return 0;
}

int main(){
	cin >> H >> W;
	repp(i,0,H){
		repp(j,0,W){
			char c;
			cin >> c;
			++a[c-'a'];
		}
	}
	if(H%2==1 && W%2==1){
		int x = H/2 + W/2;
		int y = 0 , z = 0;
		repp(i,0,26){
			if(a[i]%2==1) ++y;
			if(a[i]%4>1) ++z;
		}
		if(y != 1 || z > x || (z+x)%2 == 1) return halt(); 
	} else if(H%2==0 && W%2==0){
		repp(i,0,26){
			if(a[i]%4!=0){
				return halt();
			}
		}
	} else {
		if(H%2==1) swap(H,W);
		int x = H/2;
		int z = 0;
		repp(i,0,26){
			if(a[i]%4==2){
				++z;
			} else if(a[i]%2==1){
				return halt();
			}
		}
		if(z > x || (z+x)%2 == 1) return halt();
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int,input().split()))

ctr = Counter(A)
if N%2 and ctr[0] != 1:
    print(0)
    exit()

if N%2:
    for i in range(2,N,2):
        if ctr[i] != 2:
            print(0)
            exit()
else:
    for i in range(1,N,2):
        if ctr[i] != 2:
            print(0)
            exit()

MOD = 10**9+7
ans = 2**(N//2) % MOD
print(ans)

Measured memory_bytes: 14820
#include <iostream>
#include <set>
#include <algorithm>

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
//    sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート


using namespace std;
using ll = long long;

int
main(void){
  int n, a;
  cin >> n >> a;

  cout << n*n - a << endl;
  return 0;
}


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

using namespace std;

int main()
{
	char a[60];
	char b[60];
	char ans[105] = "";
	cin >> a;
	cin >> b;
	int asize = sizeof(a);
	int bsize = sizeof(b);
	for (int i = 0; i < 55; i++) {
		if (asize > i) {
			ans[2 * i] = a[i];
		}
		if (bsize > i) {
			ans[2 * i + 1] = b[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<int> a;
vector<bool> dp(100100, false);

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

    for(int i = 1; i <= k; ++i) {
        for(int j = 0; j < n; ++j) {
            if(i-a.at(j) >= 0 && dp[i-a.at(j)] == false) {
                dp[i] = true;
            }
        }
    }

    if(dp[k]) cout << "First" << endl;
    else cout << "Second" << endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

struct uf_tree
{
    vector<int> par, rank;
    uf_tree(int n) : par(n), rank(n)
    {
        for (int i = 0; i < n; i++)
        {
            par[i] = i;
            rank[i] = 1;
        }
    }

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

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

        if (x == y)
            return;

        if (rank[x] < rank[y])
            swap(x, y);
        par[y] = x;
        rank[x] += rank[y];
    }

    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
    int size(int x)
    {
        return rank[find(x)];
    }
};

int main()
{
    int n, m;
    cin >> n >> m;

    int a[m], b[m];

    rep(i, m)
    {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
    }

    int cnt = 0;

    rep(i, m)
    {
        uf_tree uf(n);
        rep(j, m)
        {
            if (j == i)
                continue;
            uf.unite(a[j], b[j]);
        }
        if (uf.size(0) != n)
            cnt++;
    }

    OP(cnt);

    return 0;
}

/*

bool g[50][50];
int n, m;
bool visited[50];
int ans = 0;

void dfs(int u)
{
    visited[u] = 1;
    rep(i, n)
    {
        if (g[u][i] == 1 && !visited[i])
            dfs(i);
    }
}

int main()
{
    rep(i, 50) rep(j, 50) g[i][j] = 0;

    cin >> n >> m;
    vector<pii> edge;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a][b] = 1;
        g[b][a] = 1;
        edge.push_back(pii(a, b));
    }

    rep(i, m)
    {
        pii e = edge[i];
        int cnt = 0;
        g[e.first][e.second] = g[e.second][e.first] = 0;
        rep(i, 50) visited[i] = 0;
        rep(i, n)
        {

            if (!visited[i])
            {
                dfs(i);
                cnt++;
            }
        }
        if (cnt >= 2)
            ans++;
        g[e.first][e.second] = g[e.second][e.first] = 1;
    }

    OP(ans);

    return 0;
}
*/

Measured memory_bytes: 256
import math
INF=float('inf')

n=int(input())
A=list(map(int,input().split()))

class SegmentTree:
    def __init__(self,n,ele=0): #!
        self.ide_ele=ele
        self.num=2**(n-1).bit_length()
        self.seg=[self.ide_ele]*2*self.num
        
    def segfunc(self,x,y): #!
        return math.gcd(x,y)
    
    def init(self,init_val):#初期化
        #set_val
        for i in range(n):
            self.seg[i+self.num-1]=init_val[i]
        #built
        for i in range(self.num-2,-1,-1):
            self.seg[i]=self.segfunc(self.seg[2*i+1],self.seg[2*i+2])
            
    def upgrade(self,k,x):#A[k]をxに変更
        k+=self.num-1
        self.seg[k]=x
        while k:
            k=(k-1)//2
            self.seg[k]=self.segfunc(self.seg[k*2+1],self.seg[k*2+2])
        
    def query(self,p,q):#[p,q)での解答
        if q<=p:
            return self.ide_ele
        p+=self.num-1
        q+=self.num-2
        res=self.ide_ele
        while q-p>1:
            if p&1==0:
                res=self.segfunc(res,self.seg[p])
            if q&1==1:
                res=self.segfunc(res,self.seg[q])
                q-=1
            p=p//2
            q=(q-1)//2
        if p==q:
            res=self.segfunc(res,self.seg[p])
        else:
            res=self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q])
        return res

st=SegmentTree(n,0)
st.init(A)
ans=0
for i in range(n):
  ans=max(ans,math.gcd(st.query(0,i),st.query(i+1,n)))
print(ans)

Measured memory_bytes: 88492
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
struct Point{
    double x,y;
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);  
    ll n;
    cin >> n;
    if(n%2==1){
        cout << 0 << endl;
        return 0;
    }
    ll cnt= 0;
    ll p=5;
    n-=n%10;
    
    
    while(n>=p){
        p*=5;
        cnt++;
    }
    ll c= 0;
    FOR(i,1,cnt+1){
        ll t= n/powl(5,i)/2;
        
        c+= t;
    }
    
        

        
    cout << c << endl;
    

}


Measured memory_bytes: 640
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    odd = 0
    for a in A:
        odd += 1 if a % 2 != 0 else 0

    print("YES") if odd % 2 == 0 else print("NO")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 14104
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		Console.WriteLine( det(X-Y) <= 1 ? "Brown" : "Alice");
		
		
	}
	
	long det (long x) { return x < 0 ? -x : x;}
	
	long X,Y;
	public Sol(){
		var d = rla();
		X = d[0]; Y = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(int i=(ll)(b);i>=(ll)(a);i--)

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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll m,d;cin>>m>>d;
  ll res=0;
  repi(i,1,m+1){
    repi(j,1,d+1){
      ll da=j%10,db=j/10;
      if(da<2||db<2)continue;
      if(i==da*db){res++;}
    }
  }
  cout<<res<<endl;

  return 0;

}


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

const int MAXX = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    vector<int> h(n), dp(n, MAXX);
    rep(i,n) cin >> h[i];
    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);

    for(int i = 0; i < n-2; ++i)
    {
        dp[i+2] = min(dp[i+1] + abs(h[i+2]-h[i+1]),
                       dp[i]  + abs(h[i+2] - h[i]));
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct Edge{
  int t, w;
  Edge(){}
  Edge(int t, int w): t(t), w(w) {}
};

using Graph = vector<vector<Edge> >;

int n;
int dist[100100];

int bfs(const Graph &G, int x){
  dist[x] = 0;
  queue<int> que;
  que.push(x);

  while(!que.empty()){
    int v = que.front(); que.pop();
    for(Edge e : G[v]){
      if(dist[e.t] != -1) continue;
      dist[e.t] = dist[v] + e.w;
      que.push(e.t);
    }
  }

  int ma = 0;
  int mv = -1;
  rep(i, n) if(chmax(ma, dist[i])) mv = i;

  return mv;
}

int main(){
  cin >> n;
  Graph G(n);
  rep(i, n-1){
    int s, t, w;
    cin >> s >> t >> w;
    G[s].push_back(Edge(t, w));
    G[t].push_back(Edge(s, w));
  }
  
  rep(i, n) dist[i] = -1;
  int x = bfs(G, 0);

  rep(i, n) dist[i] = -1;
  int y = bfs(G, x);
  cout << dist[y] << endl;

  return 0;
}




Measured memory_bytes: 9716
n = int(input())
A = list(map(int,input().split(" ")))

def bubbleSort(n,A):
    c = 0
    flag = True
    while flag:
        flag = False
        for j in reversed(range(1,n)):
            if A[j] < A[j-1]:
                c+=1
                tmp = A[j]
                A[j] = A[j-1]
                A[j-1] = tmp
                flag = True
    return (A,c,)


R,C = bubbleSort(n,A)
print(" ".join(["{0["+ str(i) + "]}" for i in range(n)]).format(R))
print(C)


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin>>N>>K;
    int A[50];
    int sum=0;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    sort(A,A+N,greater<int>());
    for(int k=0;k<K;k++){
        sum=sum+A[k];
    }
    cout<<sum<<endl;
    return 0;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int M, D, ans=0;
	cin>>M>>D;
	for(int i=1;i<=M;i++) for(int j=22;j<=D;j++) {
		if(j%10<2 || j/10<2) continue;
		ans+=(j%10)*(j/10)==i;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N;
  cin>>N;
  vector<tuple<string,int,int>> vec(N);
  rep(i,N){
    string s; int a,b;
    cin>>s>>a;
    b=-1*a;
    vec.at(i) = make_tuple(s,b,i+1);
  }
  sort(vec.begin(),vec.end());
  rep(i,N){
    string q; int w,e;
    tie(q,w,e) = vec.at(i);
    cout<<e<<endl;
  }
}

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

int main() {
  int n;
  cin >> n;
  if(n%2==0) cout << n/2 << endl;
  else cout << (n+1)/2 << endl;
}


Measured memory_bytes: 256
S = input()

S = S + '2'
D = []
p = S[0]
l = 0
for i in range(len(S)):
  if S[i] == p:
    l += 1
  else:
    D.append((p,l))
    l = 1
    p = S[i]
#print(D)

if len(D) == 1:
  print(len(S)-1)
else:
  csum =[D[0][1]]
  for i in range(1,len(D)):
    csum.append(csum[-1]+D[i][1])
  ans = float('inf')
  for i in range(len(D)-1):
    ans = min(max(csum[i],csum[len(D)-1]-csum[i]),ans)
  print(ans)


Measured memory_bytes: 48112
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    string t;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != 'x') t.push_back(s[i]);
    }
    // string r_t = t;
    // reverse(r_t.begin(), r_t.end());
    // if (t != r_t) {
    //     cout << -1 << endl;
    //     return 0;
    // }
    for (int i = 0; i < t.size(); i++) {
        if (t[i] != t[t.size() - 1 - i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    /*
    ababa
    axxxxbxxaxxxxxxxbxaxxxx
    // [0, 4, 2, 7, 1, 4]
    // abs(0 - 4) + abs(4 - 1) + abs(2 - 7)
    -> 4 + 3 + 5 == 12
    */
    vector<int> cnt;
    int crt = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != 'x') {
            cnt.push_back(crt);
            crt = 0;
        } else {
            crt++;
        }
    }
    cnt.push_back(crt);
    // for (int a : cnt) {
    //     cout << a << ' ';
    // }
    int ans = 0;
    for (int i = 0; i < cnt.size(); i++) {
        ans += abs(cnt[i] - cnt[cnt.size() - 1 - i]);
    }
    ans /= 2;
    cout << ans << endl;
}

Measured memory_bytes: 1228
#include <stdio.h>

int main(void){

    int arr[101];
    int key;
    int i, j, k, n;

    scanf("%d", &n);

    for(i=0; i<n; i++){
        scanf("%d", &arr[i]);
    }



    // sore start
    for (i = 1; i<=n; i++) {
        key = arr[i];
        j = i - 1;

        // print
        for(k=0; k<n; k++){
            if(k == n - 1) printf("%d", arr[k]);
            else printf("%d ", arr[k]);
        }
        printf("\n");

        while ((j>=0) && (arr[j] > key)) {
            arr[j+1] = arr[j];
            j--;
        }

        arr[j+1] = key;


    }


    return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int n,m;
    cin>>n>>m;
    int a[m],b[n];
    for(int i=0;i<m;i++)
        a[i]=n;
    for(int i=0;i<n;i++)
        b[i]=m;
        if(a[0]>b[0])
            {
                for(int i=0;i<n;i++)
                    cout<<b[i];
            }
        else{
                for(int i=0;i<m;i++)


            cout<<a[i];}

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

ll n;

void solve(){
    cin >> n;
    cout << n*(n-1)/2 << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}



Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
  int N = nextInt();
  ArrayList<Integer> list = nextIntArray();
  int output = 0;
  for(int i = 0; i < N - 1; i++){
    for(int j = i + 1; j < N; j++){
      output += list.get(i) * list.get(j);
    }
  }
  myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 32872
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	char c;
  	cin >> c;
  	if(c=='a' || c=='i' || c=='u' || c== 'e' || c== 'o'){
      cout << "vowel" << endl;
    }else{
      cout << "consonant" << endl; 
    }

 
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int A,B,C,D,R,L;
  cin>>A>>B>>C>>D;
  L=A+B;
  R=C+D;
  if(L>R){
    cout<<"Left"<<endl;
  } 
  else if(L==R){
    cout<<"Balanced"<<endl;
  }
  else{
    cout<<"Right"<<endl;
  }
}

Measured memory_bytes: 256
function Main(stdin){
stdin = stdin.trim().split("\n").reverse();
stdout = [];
function input(){return stdin.pop()};
function print(x){stdout.push(x)};


var s = input()
var n = s.length
var x = new Array(n)
var ans = 0

if (s[0]=="A" || s[0]=="T" || s[0]=="C"|| s[0]=="G"){
    x[0] = 1; ans = 1
}else{
    x[0] = 0; ans = 0
}
for (var i = 1; i < n; i++){
    if (s[i]=="A" || s[i]=="T" || s[i]=="C"|| s[i]=="G"){
        x[i] = x[i-1] + 1
    }else{
        x[i] = 0
    }
    ans = Math.max(ans, x[i])
}
print(ans)




stdout = stdout.join("\n");
console.log(stdout);
return stdout
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N;
int a[300010], b[300010];
ll L[300010], R[300010];

void func(int n, int *a, ll *b) {
  priority_queue<int, vector<int>, greater<int>> que;
  ll sum = 0;
  for (int i = 0; i < 3*n; i++) {
    sum += a[i];
    que.emplace(a[i]);
    if (que.size() > n) {
      sum -= que.top();
      que.pop();
    }
    b[i] = sum;
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < 3*N; i++) {
    cin >> a[i];
    b[3*N-i-1] = -a[i];
  }
  func(N, a, L);
  func(N, b, R);
  reverse(R, R+3*N);
  ll ans = -(1LL << 60);
  for (int i = N-1; i < 2*N; i++) {
    ans = max(ans, L[i] + R[i+1]);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 8184
n,x = map(int,input().split())
a = list(map(int, input().split()))
ans = 0
a.sort()
for i in range(0,n):
    x -= a[i]
    if x < 0:
        break
    if i == n-1:
        if x == 0:
            ans += 1
            break
        else:
            break
    ans += 1
print(ans)


Measured memory_bytes: 2940
import std.stdio;
import std.string;
import std.algorithm;
import std.range;
import std.conv;
import std.math;

void main() {
	int n;
	scanf("%d\n", &n);
	auto arr = readln.split.to!(int[]);
	int max = int.min;
	int min = int.max;
	foreach(x; arr) {
		max = x > max ? x : max;
		min = x < min ? x : min;
	}
	writeln(max-min);
}


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

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7



int main(void){
    int n;
    scanf("%d", &n);
    int mem[5];
    for(int i = 0;i < 5;i++){
        mem[i] = 0;
    }
    for(int i = 0;i < n;i++){
        char s[11];
        scanf("%s", &s);
        if(s[0]=='M')mem[0]++;
        if(s[0]=='A')mem[1]++;
        if(s[0]=='R')mem[2]++;
        if(s[0]=='C')mem[3]++;
        if(s[0]=='H')mem[4]++;
    }
    ll ans = 0;
    for(int i = 0;i < 3;i++){
        for(int j = i+1;j < 4;j++){
            for(int k = j+1;k < 5;k++){
                ans += (ll)mem[i]*mem[j]*mem[k];
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#define WHITE 0
#define GRAY  1
#define BLACK 2
#define MAX 100

void InitializeBoolMatrix(int nmbr_of_rows, int nmbr_of_columns, bool mtrx[][MAX]){
	for (int row = 0; row < nmbr_of_rows; ++row) {
		for (int column = 0; column < nmbr_of_columns; ++column)
			mtrx[row][column] = false;
	}
}

void ListToMatrix(int number_of_vertices, bool mtrx[][MAX]){
	int vertex_from, vertex_to, degree_out;	
	for (int vertex_i = 0; vertex_i < number_of_vertices; ++vertex_i) {
		scanf("%d %d", &vertex_from, &degree_out);
		vertex_from--; //0?????????????????????
		for (int vertex_out_i = 0; vertex_out_i < degree_out; ++vertex_out_i) {
			scanf("%d", &vertex_to);
			vertex_to--; //0?????????????????????
			mtrx[vertex_from][vertex_to] = true;
		}
	}
}

void BuildAdjacencyMatrix(int n, bool adjmtrx[][MAX]){
	InitializeBoolMatrix(n, n, adjmtrx);
	ListToMatrix(n, adjmtrx);
}

bool adjmtrx[MAX][MAX];
int color[MAX];
int time;
int discoveredtime[MAX];
int finishedtime[MAX];

void Dfs(int present_vertex, int n){
	int pv = present_vertex;
	color[pv] = GRAY;
	discoveredtime[pv] = ++time;
	for(int v = 0;v < n;v++){
		if(adjmtrx[pv][v] && color[v] == WHITE){
			Dfs(v, n);
		}
	}
	color[pv] = BLACK;
	finishedtime[pv] = ++time;
}

void DfsInit(int n){
	for (int i = 0; i < n; ++i)
		color[i] = WHITE;
	time = 0;
}

int main(){
	int number_of_vertices;
	scanf("%d", &number_of_vertices);
	int n = number_of_vertices;
	BuildAdjacencyMatrix(n, adjmtrx);
	DfsInit(n);
	for (int vertex_i = 0; vertex_i < n; ++vertex_i){
		if(color[vertex_i] == WHITE)
		Dfs(vertex_i, n);
	}
	for (int id = 0; id < n; ++id)
		printf("%d %d %d\n", id+1, discoveredtime[id], finishedtime[id]);
	return 0;
}

Measured memory_bytes: 2728
#include <iostream>

using namespace std;

int main(void){
  
  long numbers[210];
  int N;
  int count = 0;
  
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> numbers[i];
  }
  
  while(true){
    
    bool check = true;
    
    for(int i=0; i<N; i++){
      if(numbers[i]%2 == 0){
        numbers[i] /= 2;
      }else{
        check = false;
        break;
      }
    }
    
    if(check){
      count += 1;
    }else{
      break;
    }
  }
  
  cout << count << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int main(){
    ll n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    rep(i,n){
        ll l=-d*i+(n-i-1)*c;
        ll r=-c*i+(n-i-1)*d;
        if(b-a>=l&&r>=b-a){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LaL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
using namespace std;

int main(){
  ll A,B,N,ans=0;
  cin>>A>>B>>N;
  
  if(B==1){
    cout<<0<<endl;
    return 0;
  }
  
  if(N<B){
    ans+=A*N/B;
  }
  else{
    ans+=A*(B-1)/B;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;
long long gcd(long long a, long long b){
    if(b==0) return a;
    return gcd(b, a%b);
}
long long a, b;
string s; 
int main() {
    cin >> a >> b;
    cout << (a-1)*(b-1) << endl;
    
	return 0;
}

Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int euclid(int x, int y){
    if(min(x, y) ==  0) return max(x, y);
    else return euclid(max(x, y)% min(x, y) , min(x, y));
}

int main() {
    int ans = 0;
    int tmp, hoge;
    int mp[201][201];
    REP(i, 201) REP(j, 201) mp[i][j] = 0;
    int k;
    cin >> k;
    int mi, ma;
    REP1(a, k){
        REP1(b, k){
            REP1(c, k){
                if(mp[a][b]) tmp = mp[a][b];
                else {
                    tmp = euclid(a, b);
                    mp[a][b] = tmp;
                    mp[b][a] = tmp;
                }
                if(mp[tmp][c]) ans += mp[tmp][c];
                else {
                    hoge = euclid(tmp, c);
                    mp[tmp][c] = hoge;
                    mp[c][tmp] = hoge;
                    ans += hoge;
                }
                //cout << tmp << endl;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3792
using System;

public class Test
{
    public static void Main()
    {
    
        var i = 1;
        while (true)
        {
            int x;
            x = int.Parse(Console.ReadLine());
            if (x == 0)
            {
               break;
            }
            Console.WriteLine("Case {0}: {1}", +i, x);
            i = i + 1;
        }

    }
}


Measured memory_bytes: 15932
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int check(char x){
    if(x=='M')return 1000;
    else if(x=='D')return 500;
    else if(x=='C')return 100;
    else if(x=='L')return 50;
    else if(x=='X')return 10;
    else if(x=='V')return 5;
    else if(x=='I')return 1;
    else return 0;
}
int main(void){

	char str[100]={0};

	while(cin>>str){
    int ans=0;
        for(int i=0;sizeof(str);i++){
            if(check(str[i])<check(str[i+1]))ans+=(check(str[i+1])-check(str[i])),i++;
            else if(str[i]==0)break;
            else ans+=check(str[i]);

        }

        cout<<ans<<endl;

        for(int i=0;i<sizeof(str);i++){
            str[i]=0;
        }



	}


	return 0;
}

Measured memory_bytes: 1140
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	ll h;
	cin>>h;
	ll cnt[50],pw[50];
	cnt[0]=1;
	pw[0]=1;
	REP(i,1,50){
		cnt[i]=cnt[i-1]*2+1;
		pw[i]=pw[i-1]*2;
	}
	rep(i,50){
		if(h<pw[i]){
			cout<<cnt[i-1];
			break;
		}
	}
	re 0;
}

Measured memory_bytes: 256
#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,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int r,g,b;
    cin>>r>>g>>b;
    if((r*100+g*10+b)%4==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
s=[list(map(int,input().split())) for i in range(N)]
s=sorted(s,key=lambda x:x[0])

ans=0
cnt=0
for i in range(N):
    cnt+=s[i][1]
    if M >= cnt:
        ans+=s[i][0]*s[i][1]
    elif M < cnt:
        cnt-=s[i][1]
        ans+=(M-cnt)*s[i][0]
        break
print(ans)

         
        

Measured memory_bytes: 29792
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
static const double EPS = 1e-8;
typedef long long ll;

int main()
{
	string c;
	while (cin >> c, c != "#")
	{
		map<char, int> m;
		bool ok = false;
		for (int i = 0; i < c.size(); ++i)
		{
			if (c[i] == ')')
			{
				bool t = true;
				for (map<char, int>::iterator it = m.begin(); it != m.end(); ++it)
					if (it->second == 3)
						t = false;
				if (t)
				{
					ok = true;
					break;
				}
				m.clear();
			}
			else if (isalpha(c[i]))
				m[c[i]] |= c[i-1] == '~' ? 2 : 1;
		}
		puts(ok ? "yes" : "no");
	}

	return 0;
}

Measured memory_bytes: 892