akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
int main() 
{
cin>>a>>b>>c;
if(a%2==0||b%2==0||c%2==0) 
{
cout<<0<<endl;
return 0;
}
cout<<min(min(a*b,a*c),b*c)<<endl;
}

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

int N, K;
vector<int> A;

int rec(int n, int cnt) {
	if (n <= K)
		return cnt + 1;
	return rec(n - K + 1, cnt + 1);
}

int main(void) {
	cin >> N >> K;
	A.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> A[i];

	int ans = rec(N, 0);

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
	T f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 200003, M = N << 1;

int n, k;

int main()
{
	//File("");
	n = gi <int> (), k = gi <int> ();
	if (k > (n + 1) / 2) puts("NO");
	else puts("YES");
	return 0;
}


Measured memory_bytes: 3584
#include <iostream>

using namespace std;

int main()
{
   int a, c;
   char b;
   while(true){
    cin >> a >> b >> c;
       if(b == '?'){
           break;
       }
       if(b == '+'){
           cout << (a+c) << endl;
       }
       if(b == '-'){
           cout << (a-c) << endl;
       }
       if(b == '*'){
           cout << (a*c) << endl;
       }
       if(b == '/'){
           cout << (a/c) << endl;
       }
       
   }
   
   return 0;
}


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

const int MAXN = 1e5 + 10;

int n, a[MAXN], f[MAXN], k;

int main() {
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    for (int i = 1; i <= n; ++i) f[i] = 0x3f3f3f3f;
    f[0] = 0, f[1] = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= k; ++j) {
            f[i + j] = min(f[i + j], f[i] + abs(a[i] - a[i + j]));
        }
    }
    printf("%d\n", f[n]);
    return 0;
}

Measured memory_bytes: 1024
import sys
from math import ceil
inputs = sys.stdin.readlines()

d, g = map(int, inputs[0].split())
P = list(map(int, map(lambda x: x.split()[0], inputs[1:])))
C = list(map(int, map(lambda x: x.split()[1], inputs[1:])))

ans = float('inf')
for bit in range(1 << d):
    count, total, rest = 0, 0, set(range(1, d+1))
    for i in range(d):
        if bit & (1 << i):
            total += P[i] * (i + 1) * 100 + C[i]
            count += P[i]
            rest.discard(i + 1)

    if total < g:
        use = max(rest)
        n = ceil((g - total) / (use * 100))
        if P[use-1]-1 < n:
            continue
        count += n
        total += n * use * 100
        
    if total >= g:
        ans = min(ans, count)
print(ans) 


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

"""解説
http://drken1215.hatenablog.com/entry/2019/05/12/004500

N//m = N%m = k （kは約数。かつ余り）とすると、

N = mk + k
N = k(m+1)

k は MOD m の余りなので、m > k である。
よって、

N = k*(m+1) > k*k

よって、

N > k**2
√N > k

これに気づけばOK。あとはkについて全探索。O(√N)


(例)
・N=8, m=3のとき
3*2 + 2 = 8
m*k + k = N

・N=8, m=7のとき
7*1 + 1 = 8
m*k + k = N

"""
import math

def solve():
    N = int(input())

    ans = 0
    for k in range(1, math.floor(math.sqrt(N))+1):
        if N%k != 0: continue # kはNの約数より
        # N = k(m+1)
        # m = (N/k) - 1
        m = (N/k) - 1
        if m <= 0: continue
        if N//m == N%m:
            ans += m
    print(int(ans))


if __name__ == "__main__":
    solve()


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

int main() {
  int n;
  cin >> n;
  double total = 0.0;
  for(int i = 0; i < n; i++) {
    double x;
    cin >> x;
    total += 1.0 / x;
  }
  total = 1.0 / total;
  cout << setprecision(16) << total << endl;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
int N,cnt=0,ans=0;
string S;
int main(){
  cin >> N >> S;
  for(int j=0;j<N;j++){
    string l=S;
    l.resize(j);
    string r=S.substr(j);
    cnt=0;
    for(int i=97;i<=122;i++){
      if(l.find(i)!=string::npos && r.find(i)!=string::npos) cnt++;
    }
    ans=max(ans,cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define __STDC_FORMAT_MACROS
#define p64 PRId64

#include <bits/stdc++.h>

using namespace std;
using ll = int64_t;

ll A, B;

bool check(ll mid)
{
    const string asc = "asc";
    const string dsc = "dsc";

    const string bg = "bg";
    const string eq = "eq";
    const string sl = "sl";

    const ll mn = -1;
    const ll zr = 0;
    const ll ps = 1;
    const ll ps2 = 2;

    const pair<string, string> asb = make_pair(asc, bg);
    const pair<string, string> ase = make_pair(asc, eq);
    const pair<string, string> asl = make_pair(asc, sl);

    const pair<string, string> dsb = make_pair(dsc, bg);
    const pair<string, string> dse = make_pair(dsc, eq);
    const pair<string, string> dsl = make_pair(dsc, sl);

    // A や B を除いて要素を mid 並べる
    // A 昇順 asc small < big
    // B 降順 dsc big > small
    map<pair<string, string>, ll> CenterOdd
    {
        {asb, zr},
        {ase, ps},
        {asl, ps},
        {dsb, zr},
        {dse, ps},
        {dsl, ps},
    };

    // A や B を除いて要素を mid 並べる
    map<pair<string, string>, pair<ll, ll> > CenterEven
    {
        {asb, make_pair(CenterOdd[asb], ps)},
        {ase, make_pair(CenterOdd[ase], ps2)},
        {asl, make_pair(CenterOdd[asl], ps2)},
        {dsb, make_pair(ps, CenterOdd[dsb])},
        {dse, make_pair(ps2, CenterOdd[dse])},
        {dsl, make_pair(ps2, CenterOdd[dsl])},
    };

    ll mx = -1000000001;
    ll mHalf = mid / 2;

    // mid が奇数ならば
    // A や B を除く前の中央は 1 点に定まる
    if (mid % 2 != 0) mHalf++;

    pair<string, string> symbla;

    if (mHalf < A) symbla = asb;
    else if (mHalf == A) symbla = ase;
    else symbla = asl;

    pair<string, string> symblb;

    if (mHalf < B) symblb = dsb;
    else if (mHalf == B) symblb = dse;
    else symblb = dsl;

    if (mid % 2 == 0)
    {
        // 中央 左
        // 中央 右
        ll al = mHalf + CenterEven[symbla].first;
        ll au = mHalf + CenterEven[symbla].second;

        if (au == A) au++;

        ll bl = mHalf + CenterEven[symblb].first;

        if (bl == B) bl++;

        ll bu = mHalf + CenterEven[symblb].second;

        mx = max(mx, al * bl);
        mx = max(mx, au * bu);
        mx = max(mx, (ll)0);
    }
    else
    {
        ll a = mHalf + CenterOdd[symbla];
        ll b = mHalf + CenterOdd[symblb];

        mx = max(mx, a * b);
        mx = max(mx, (ll)0);
    }

    return mx < A * B;
}

// Bisection Method
// [left, right]
// to narrow the range
ll BisectionMethod(ll left, ll right)
{
    bool flg = false;

    int times = 0;

    // A * B より小さいという条件を満たさない間は
    // 探索を継続する
    while (1 < abs(right - left) || !flg)
    {
        if (100 < times) break;

        ll mid = (left + right) / 2;

        flg = check(mid);

        if (flg) left = mid;
        else right = mid;

        times++;
    }

    return (left + right) / 2;
}

int main()
{
    ll Q;
    cin >> Q;

    while (Q--)
    {
        cin >> A >> B;
        if (B < A) swap(A, B);
        cout << BisectionMethod(0, 2 * B) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
//#############################################################################
#include "bits/stdc++.h"
//#############################################################################
//Macros 
#define MOD 1000000007
#define eb emplace_back
#define mp make_pair
#define fr first
#define sc second
#define vec vector
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a, n) a, a + n
//Type Defs
typedef long long ll;
typedef unsigned long long ull;
//#############################################################################
using namespace std;
//#############################################################################
//Helpers
void io_handler()
{
#ifdef LOCAL_TESTING
    freopen("inputf.in", "r", stdin);
    freopen("outputf.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
void print_matrix(vector<vector<ll>> mat){
    for(auto row: mat){
        for(auto e : row){cout << e << " ";}
        cout << endl;
    }
}
void print_vector(vector<ll> v){
    for(auto e : v){cout<< e <<" ";}
    cout<<endl;
}
map<int,int> get_count(vector<ll> v){
    map<int,int> count;
    for(auto e: v){
        if(count.find(e)!=count.end()){count[e]++;}
        else{count[e] = 1;}}
    return count;
}
//#############################################################################
//Solution
void solve(){
    ll n,m; 
    cin>>n>>m;
    vec<vec<ll>> graph(n,vec<ll>());
    vec<bool> visited(n,false);
    vec<ll> dp(n,0LL);
    vec<ll> in(n,0LL);
    for(ll i = 0LL; i<m; i++){
        ll u,v; cin>>u>>v;
        graph[u-1].eb(v-1);
        ++in[v-1];
    }
    ll ans = 0LL;
    queue<ll> q;
    for(ll i = 0; i<n; i++){
        if(in[i]==0){
            q.push(i);
            visited[i] = true;
        }
    }
    while(!q.empty()){
        ll node = q.front(); q.pop();
        for(auto nbr : graph[node]){
            --in[nbr];
            dp[nbr]=max(dp[nbr],dp[node]+1);
            if(in[nbr]==0){ 
                if(!visited[nbr]){
                    q.push(nbr); 
                    visited[nbr] = true;
                }
            }
        }
    }

    cout<<*max_element(all(dp))<<endl;
}
//#############################################################################
//Driver
int main()
{
    io_handler();
    int t = 1;
    //cin>>t;
    for (int i = 0; i < t; i++){
        solve();
    }
#ifdef LOCAL_TESTING
    cout << "⏰ Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}
//#############################################################################


Measured memory_bytes: 7296
import sys
N,M = map(int,input().split())
if N > 1 and M == 0:
  print(10**(N-1))
  sys.exit()
  
num = [0]*N
flag = 0
for i in range(M):
  si,ci = map(int,input().split())
  if N > 1 and si == 1 and ci == 0:
    print(-1)
    sys.exit()
  if num[si-1] != 0 and ci != num[si-1]:
    print('-1')
    sys.exit()
  num[si-1] = ci
if num[0] == 0 and N > 1:
  num[0] = 1
n = int(''.join(map(str,num)))
print(n)
          

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

ll modular_expo(ll base, ll index, ll mod)
{
    ll ret = 1;
    while(index > 0)
    {
        if(index & 1) ret = (ret * base) % mod;
        base = (base * base) % mod;
        index >>= 1;
    }
    return ret;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    ll ans = 0;
    for(int i = 0; i < 60; i++)
    {
        ll zc = 0;
        ll oc = 0;
        for(int j = 0; j < n; j++)
        {
            if(a[j] & 1) oc++;
            else zc++;
            a[j] /= 2;
        }
        ans = (ans + (((zc * oc) % MOD) * modular_expo(2, i, MOD)) % MOD) % MOD;
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a)  (a).begin(),(a).end()

int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}

signed main(){
  int n,m;
  cin>>n>>m;
  V<P<int,int>> a(m);
  fo(i,m){
    cin>>a[i].fi>>a[i].se;
  }

  Sort(a);

  if(n==1&&m==0){
    cout<<0<<endl;
    return 0;
  }
  if(n==2&&m==0){
      cout<<10<<endl;
      return 0;
  }
  if(n==3&&m==0){
      cout<<100<<endl;
      return 0;
  }
  if(n==1){
    int d=1;
    fo(i,m){
      if(a[i].fi==1&&a[i].se==0)
        d=d;
      else
        d=0;
    }
    if(d){
      cout<<0<<endl;
      return 0;
    }

  }
  for(int i=1; i<=999; i++){
    if(keta(i)!=n)
      continue;
    string f=to_string(i);
    int c=1;
    fo(k,m){
      if(f[a[k].fi-1]-'0'!=a[k].se){
        c=0;
      }

    }
    if(c){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}

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

using namespace std;

#define ALL(T) T.begin(),T.end()

set<string> list;

int main(){
	string tgt = "AIDUNYAN";
	string ans = "AIZUNYAN";
	list.insert(tgt);
	next_permutation(ALL(tgt));
	while (tgt != "AIDUNYAN") {
		next_permutation(ALL(tgt));
		list.insert(tgt);
	}
//	for (set<string>::iterator it = list.begin(); it != list.end(); it++) {
//		cout << *it << endl;
//	}

	string D; cin >> D;
	for (int i = 0; i < (int)D.size()-7; i++) {
		string tmp = D.substr(i, 8);
		if (list.find(tmp) != list.end()) {
			for (int j = i; j < i+8; j++) {
				D[i] = '*';
			}
		}
	}

	for (int i = 0; i < (int)D.size()-7; i++) {
		if (D[i] == '*') {
			for (int j = i; j < i+8; j++) {
				D[j] = ans[j-i];
			}
		}
	}
	cout << D << endl;


	return 0;
}

Measured memory_bytes: 2140
#include<cstdio>
int main(){
	int deg[5]={},cnt[2]={};
	for(int i=1,a,b;i<=3;i++)
		scanf("%d%d",&a,&b),deg[a]++,deg[b]++;
	for(int i=1;i<=4;i++)cnt[deg[i]&1]++;
	if(cnt[1]==0||cnt[1]==2)puts("YES");
	else puts("NO");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define rep(i,a,b) for(int i = a;i < b; ++i)
using namespace std;

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

const int N = 1e5 + 5;

int main(){
	cin.tie(0);	
	cout.tie(0);	
	ios_base::sync_with_stdio(0);
	int val[3];
	int n,k;
	cin >> n >> k;
	rep(i,0,3)cin >> val[i];
	string s;
	cin >> s;
	vector<int> v(n);
	vector<bool> win(n);
	rep(i,0,n){
		int to = 2; 
		if(s[i] == 's')to = 0;
		if(s[i] == 'p')to = 1;
		v[i] = to;
	}
	int ans = 0;
	rep(i,0,n){
		if(i - k >= 0 && win[i-k] && v[i-k] == v[i]){
			win[i] = 0;	
		}
		else{
			win[i] = 1;
			ans += val[v[i]];
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 848
#include<iostream>

using namespace std;

int main(){
    int sum;
    int x,y,z;
    int k,s;
    
    cin >> k >> s;
    sum = 0;
    for(x=0;x<=k;x++){
        for(y=0;y<=k;y++){
            if( x + y > s ){
                break;
            }
            if( s - (x + y ) <= k){
                sum++;
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

/*---------------------------------------------------*/

int n,w,l,d;
string name[15];
pair<int,pair<int,string> > data[15];

int main(){
  bool ok=false;
  while(cin>>n){
    if(n==0)break;
    if(ok)cout<<endl;
    else ok=true;
    
    rep(i,n){
      cin>>name[i]>>w>>l>>d;
      data[i].first=w*3+d;
      data[i].second.first=n-i;
      data[i].second.second=name[i];
    }

    sort(data,data+n);reverse(data,data+n);
    
    rep(i,n){
      cout<<data[i].second.second<<","<<data[i].first<<endl;
    }
  }
}

Measured memory_bytes: 3000
#include<stdio.h>
#include<utility>


int main(){
   int h,w;
   char evenc,oddc;
   while(scanf("%d %d",&h,&w) && (h != 0 || w != 0)){
       evenc = '.',oddc = '#';
       for(int i=1;i <= h;i++){
           for(int j=1;j <= w;j++){
               if(j % 2 == 0){
                   printf("%c",evenc);
               } else{
                   printf("%c",oddc);
               }
           }
           printf("\n");
           std::swap(evenc,oddc);
       }
       printf("\n");
   }
   return 0;
}


Measured memory_bytes: 2680
import java.util.*;
public class Main{

    public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if(n>=30)
    System.out.println("Yes");
    else 
    System.out.println("No");
    }
      //  System.out.println("Hello World");
}


Measured memory_bytes: 35816
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int n,m;cin>>n>>m;
    vector<int> p(n,0);
    rep(i,m){
        int a,b;cin>>a>>b;a--;b--;
        p[a]++;p[b]++;
    }
    rep(i,n){
        if(p[i]%2!=0){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 3764
#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>;
const long long INF = 1ll << 60;



int main() {
  ll N, A, B; cin >> N >> A >> B;
  ll SUM = A + B;
  ll ans = (N / SUM) * A;
  ll amari = N%SUM;
  ans += min(amari,A);
  cout << ans << endl;  


	return 0;
}



Measured memory_bytes: 3668
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<utility>
#include<functional>
#include<cassert>
#include<cmath>
#include<math.h>
#include<unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<vint> vvint;
#define PI 3.1415926535
#define MOD 1000000007
#define rep(i, n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define MAX ((ll)1<<(ll)31)-1
ll f(ll x, ll y) {
	if (x%y == 0) { return y; }

	return f(y, x%y);
}

int main(void) {
	ll a, b; cin >> a >> b;
	ll x=f(a, b);
	cout << a * b / x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1e9+5;
const int N=2e5+5;
const int mod=1e9+7;


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	ll a1,a2;
	cin>>a1>>a2;
	ll sum_xor=0;
	for(int i=2;i<n;++i){
		ll x;
		cin>>x;
		sum_xor^=x;
	}
	ll bit=0;
	ll mask=1;
	ll ans=0;
	while(sum_xor^a1^a2){
		if((sum_xor&mask)==((a1^a2)&mask)){}
		else{
			bit=mask>>1;
			if(!bit||a1<=bit||((a1&bit)!=(a2&bit))){
				return cout<<-1,0;
			}
			a1-=bit;
			a2+=bit;
			ans+=bit;
		}
		mask<<=1;
	}
	//~ redundant
	for(mask=bit;mask>0;mask>>=1){
		if(!(a1&mask)&&(a2&mask)) ans-=mask;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3648
while True:
    n=input()
    if n==0:
        break
    graph=[[1<<30]*n for i in xrange(n)]
    for i in xrange(input()):
        a,b,c=map(int,raw_input().strip().split(","))
        graph[a][b]=graph[b][a]=c
    visited=[False]*n
    visited[0],ans=True,0
    while not all(visited):
        t=min( [(i,j,graph[i][j])for j in xrange(n) if not visited[j] for i in xrange(n) if visited[i]],key= lambda x:x[2])
        ans+=t[2]/100-1
        visited[t[1]]=True
    print ans

Measured memory_bytes: 4492
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{

    

    class Program
    {
        
        
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int H = int.Parse(input[0]);
            int W = int.Parse(input[1]);

            char[,] canvas = new char[H, W];

            for(int i = 0; i < H; i++)
            {
                string ch = Console.ReadLine();

                for(int j = 0; j < W; j++)
                {
                    canvas[i, j] = ch[j];
                }

            }

            bool can_paint = true;

            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    can_paint = true;
                    if (canvas[i, j] == '#')
                    {
                        if(i - 1 >= 0 && canvas[i - 1, j] == '#')
                        { 
                            can_paint = true;
                        }
                        else if (i + 1 < H && canvas[i + 1, j] == '#')
                        {
                            can_paint = true;
                        }
                        else if (j - 1 >= 0 && canvas[i, j - 1] == '#')
                        {
                            can_paint = true;
                        }
                        else if (j + 1 < W && canvas[i, j + 1] == '#')
                        {
                            can_paint = true;
                        }
                        else
                        {
                            can_paint = false;
                        }
                    }
                    if (!can_paint)
                    {
                        break;
                    }
                }

                if (!can_paint)
                {
                    break;
                }
                
            }


            if (can_paint)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }


        }
    }
}

Measured memory_bytes: 11092
#include <cstdio>
#define F(i,x,y) for(int i=x;i<=y;++i)
using namespace std;
int n,a;
bool flag=true;
int main(){
	scanf("%d",&n);
	F(i,1,n){
		scanf("%d",&a);
		if(a%2==0){
			if(a%3==0 or a%5==0);
			else flag=false;
		}
	}
	if(flag) printf("APPROVED\n");
	else printf("DENIED\n");
	return 0;
}


Measured memory_bytes: 128
N,M=map(int,input().split())
if N%2==1:
    for i in range(1,M+1):
        a,b=i,N-i+1
        print(a,b)
else:
    t=0
    for i in range(1,M+1):
        a,b=i,N-i
        if (a-1)+(N+1-b)>=b-a:
            t=1
        a+=t
        print(a,b)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
ll n,a=0;
ll f(ll n){
  if(n < 2)return 1;
  return n*f(n-2);
}
int main(){
  cin >> n;
  for (ll i = 1; i < LLONG_MAX; i++) {
    ll x = pow(5,i)*10;
    if(n/x >= 1)a += n/x;
    else break;
  }
  cout << (n%2 == 0? a+(n/10) : 0) << endl;
}


Measured memory_bytes: 640
#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)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int X;
    cin >> X;
    vector<bool> dp(X + 1);
    dp[0] = 1;
    rep(i, X + 1) {
        if (dp[i]) FOR(j, 100, 106) {
            if (i + j <= X) dp[i + j] = 1;
        }
    }
    cout << dp[X] << endl;
    return 0;
}

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

int main() {
	long m, n;
	cin >> m >> n;
	if (m == 1 && n == 1) {
		cout << 1 << endl;
		return 0;
	}
	else if (m == 1 || n == 1) {
		cout << max(m,n) - 2 << endl;
		return 0;
	}
	else {
		cout << m * n - 2 * (m + n - 2) << endl;
		return 0;
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const long long MOD = 1000000007;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int h, n;
    cin >> h >> n;
    int tot = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        tot += a;
    }
    if (tot >= h)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[100000];
int main()
{
	int n;
	long long ba=1,bz=1;
	cin>>n;
	for(int t=0;t<n;t++)
	{
		cin>>a[t];
		if(a[t]==0)
		{
			cout<<0;
			return 0;
		}
	}
	for(int t=0;t<n;t++)
	{
		
		if(t)if(ba/a[t-1]!=bz||ba>1000000000000000000)
		{
			cout<<"-1";
			return 0;
		}
		bz=ba;
		ba*=a[t];
	}
	if(ba/a[n-1]!=bz||ba>1000000000000000000)
	{
		cout<<"-1";
		return 0;
	}
	cout<<ba;
	return 0;
}

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

int h,w,r,c;

enum DIR { L, U, R, D };
int di[] = { 0, -1, 0, 1 };
int dj[] = { -1, 0, 1, 0 };
int open[510][510][4];
int win[510][510];

bool inner(int i, int j){
    return i >= 0 && j >= 0 && i < h && j < w;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    while(cin >> h >> w >> r >> c && h){
        --r; --c;
        memset(win, 0, sizeof win);
        memset(open, 0, sizeof open);
        rep(i,h*2+1){
            if(i%2 == 0){
                rep(j,w){
                    int x;
                    cin >> x;
                    open[i/2][j][U] = !x;
                    if(i/2) open[i/2-1][j][D] = !x;
                }
            } else {
                rep(j,w+1){
                    int x;
                    cin >> x;
                    open[i/2][j][L] = !x;
                    if(j) open[i/2][j-1][R] = !x;
                }
            }
        }
        queue<pair<int,int>> q;
        rep(i,h)rep(j,w) if(i == 0 || j == 0 || i == h-1 || j == w-1) q.emplace(i,j);
        while(q.size()){
            int ci,cj;
            tie(ci,cj) = q.front();
            q.pop();
            int cnt[2] = {};
            if(win[ci][cj]) continue;
            rep(d,4){
                int ni = ci + di[d];
                int nj = cj + dj[d];
                if(!inner(ni,nj) || win[ni][nj]) ++cnt[open[ci][cj][d]];
            }
            if(cnt[0] && cnt[1]){
                win[ci][cj] = true;
                rep(d,4){
                    int ni = ci + di[d];
                    int nj = cj + dj[d];
                    if(inner(ni,nj) && !win[ni][nj]) q.emplace(ni,nj);
                }
            }
        }
        bool ok = win[r][c];
        rep(d,4){
            int ni = r + di[d];
            int nj = c + dj[d];
            if(open[r][c][d] && (!inner(ni,nj) || win[ni][nj])) ok = true;
        }
        cout << (ok ? "Yes" : "No") << '\n';
    }
}

Measured memory_bytes: 8244
#include "bits/stdc++.h"
using namespace std;

#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 all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
#define INF 2e15
#define MOD 10e9 + 7

typedef vector <int> vint;
typedef long long    ll;



int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int n;
    cin >> n;

    rep(i, 50000) {
        if ((int) (i * 1.08) == n) {
            cout << i << endl;

            return 0;
        }
    }
    cout << ":(" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>

#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define IN(x) int (x); cin >> x
#define VINT(a,n) vector<int> a(n)
#define VIN(a,n) VINT(a,n); REP(i,n){cin >> a[i];}
#define ALL(x) (x).begin(),(x).end()

int main () {
  IN(n);
  VIN(a,n);
  int count=0;
  sort(ALL(a));

  REP(i,n){
    if (a[i]<0) {
      count++;
      a[i]*=-1;
    }
    else break;
  }
  ll ans;
  if (count%2 == 0){
    ans=accumulate(ALL(a),(ll)0);
  }
  else{
    sort(ALL(a));
    ans=-a[0]+accumulate(a.begin()+1, a.end(), (ll)0);
  }
  cout<<ans<<endl;
  
  
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n;
ll dp[65536];
ll flag[65536];
ll sc[65535];
ll a[16][16];

ll f(ll s){
	if(flag[s])return dp[s];
	flag[s]=1;
	ll temp=-INF;
	for (int i=(1LL<<n)-1;i>=0;i--){
		i&=s;
		temp=max(temp,sc[i]+f(s^i));
	}
	return dp[s]=temp;
}

int main(){
	scanf("%lld",&n);
	rep(i,0,n)rep(j,0,n)scanf("%lld",&a[i][j]);
	flag[0]=1;
	rep(x,0,1LL<<n){
		ll s=0;
		rep(i,0,n)if(bit(x,i))rep(j,i+1,n)if(bit(x,j))s+=a[i][j];
		sc[x]=s;
	}
	printf("%lld\n",f((1LL<<n)-1));
	return 0;
}

Measured memory_bytes: 1664
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000009
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	n := nextInt()
	m := nextInt()
	clearedlist := make([]bool, n)
	penaltycount := make([]int, n)
	clearcount := 0
	penalty := 0

	for i := 0; i < m; i++ {
		p := nextInt()
		s := nextLine()
		if clearedlist[p-1] == true {
			continue
		}
		if s == "AC" {
			clearedlist[p-1] = true
			clearcount++
		} else if s == "WA" {
			penaltycount[p-1]++
		}
	}
	for i, p := range penaltycount {
		if clearedlist[i] == true {
			penalty += p
		}
	}
	fmt.Println(clearcount, penalty)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 34560
#!/usr/bin/env python3
import sys


def solve(N: int, h: "List[int]"):
    print(watering(h))
    return

def watering(h):
    if sum(h) == 0:
        return 0
    else:
        max_height = max(h)
        s, e = max_sub_sequence(h, max_height)
        assert s >= 0 and e < len(h), "invalid s: {} & e: {}".format(s, e)
        if s == 0 and e == len(h)-1:
            return max_height
        elif s == 0:
            diff = max_height - h[e+1]
            h[s:e+1] = [h[e+1]] * (e+1-s)
            return watering(h) + diff
        elif e == len(h)-1:
            diff = max_height - h[s-1]
            h[s:e+1] = [h[s-1]] * (e+1-s)
            return watering(h) + diff
        else:
            if h[s-1] < h[e+1]:
                diff = max_height - h[e+1]
                h[s:e+1] = [h[e+1]] * (e+1-s)
                return watering(h) + diff
            else:
                diff = max_height - h[s-1]
                h[s:e+1] = [h[s-1]] * (e+1-s)
                return watering(h) + diff

def max_sub_sequence(h, max_height):
    i = 0
    j = 0
    while i < len(h):
        if h[i] == max_height:
            j = i + 1
            while j < len(h) and h[j] == max_height:
                j += 1
            j -= 1
            break
        i += 1
    return i, j

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    h = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, h)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		scan.close();
		int check=0;
		int a=0,z=0;
		for(int i=0;i<s.length();i++) {
			if(check>=1)check++;
			if(check==0&&s.charAt(i)=='A') {
				a=i;
				check=1;
			}
			else if(check>=1&&s.charAt(i)=='Z')z=i;
		}
		System.out.println(z-a+1);

	}
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int A, B, C; cin >> A >> B >> C;
  if(B <= A) swap(A, B);
  if(C <= B) swap(C, B);
  if(B <= A) swap(A, B);
  if((A+B+C) % 2 == C % 2) {
    cout << ((C*2) - (A+B)) / 2 << endl;
  } else {
    cout << ((C+1) * 2 - (A+B)) / 2 + 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
def main():
    n, *a = map(int, open(0).read().split())
    b = [i for i in a if i <= 0]
    *ab, = map(lambda x: abs(x), a)
    c, d = sum(a), sum(b)
    if len(b) % 2 == 0:
        print(c - 2 * d)
    else:
        print(c - 2 * d - 2 * min(ab))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14116
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1,
    x=-x;
  }
  while(x){
    f[s++]=x%10,
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int i, n, y;
  rd(n);
  rd(y);
  y /= 1000;
  for(i=0;i<n+1;i++){
    int j;
    for(j=0;j<n-i+1;j++){
      int k=n-i-j, sum=i*10+j*5+k;
      if (sum == y){
        wt_L(i);
        putchar_unlocked(' ');
        wt_L(j);
        putchar_unlocked(' ');
        wt_L(k);
        putchar_unlocked('\n');
        return 0;
      }
    }
  }
  wt_L(-1);
  putchar_unlocked(' ');
  wt_L(-1);
  putchar_unlocked(' ');
  wt_L(-1);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20170910-1

// --- original code ---
// {
//   int n, y;
//   rd(n,y);
//   y /= 1000;
//   rep(i,n+1)rep(j,n-i+1) {
//     int k = n-i-j;
//     int sum = i*10+j*5+k;
//     if (sum == y) {
//       wt(i,j,k);
//       return 0;
//     }
//   }
//   wt(-1,-1,-1);
// }

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) {
    cin >> p[i];
  }
  
  int min = 10000000;
  int ans = 0;
  rep(i, n) {
    int num = p[i];
    if (num < min) {
      ans++;
      min = num;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>

const int MAX_N=10010;
const int MAX_Q=510;

int search(const int S[],const int n,const int T[],const int q){
    int cnt=0;
   
    for(int j=0;j<q;j++){
         for(int i=0;i<n;i++){
               if(T[j]==S[i]){
               cnt++;
               break;
            }
        }
    }
    return cnt;
}

int main(void){
    int n,q;
    int S[MAX_N],T[MAX_Q];

    std::cin>>n;
    for(int i=0;i<n;i++) std::cin>>S[i];

    std::cin>>q;
    for(int i=0;i<q;i++) std::cin>>T[i];

    std::cout<<search(S,n,T,q)<<std::endl;    
    return 0;
}


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

int main() {
    int64_t a, b;
    cin >> a >> b;
    int64_t n = __gcd(a, b);

    set<int64_t> div;
    div.insert(1);
    for(int64_t i = 2; i * i <= n; i++){
        if(n % i == 0){
            div.insert(i);
            while(n % i == 0){
                n /= i;
            }
        }
    }
    cout << div.size() + (n > 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use feature qw/say/;

my $S = <STDIN>;
say join(' ', detect($S));

sub detect {
    my ($s) = @_;
    my @c = split(//, $s);
    for my $i (0..scalar(@c)-2) {
        if (($c[$i + 1] || '') eq $c[$i]) {
            return ($i + 1, $i + 2);
        } elsif (($c[$i + 2] || '') eq $c[$i]) {
            return ($i + 1, $i + 3);
        }
    }
    return (-1, -1);
}


Measured memory_bytes: 14336
// Problem : A - Air Conditioner
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int n;
    cin>>n;
    if(n >= 30) cout<<"Yes\n";
    else cout<<"No\n";
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3628
import sys
input = sys.stdin.readline
N,M= map(int,input().rstrip().split())
island = []
for _ in range(M):
  a, b = map(int,input().rstrip().split())
  island.append((a,b))
end_sort = sorted(island,key = lambda x:x[1])
ans = 0
cut = -float('inf')
for i in range(M):
  if cut <= end_sort[i][0]:
    ans += 1
    cut = end_sort[i][1]
print(ans)

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

using namespace std;
typedef long long ll;

const ll mod = 1e9 + 7;
ll fact[200010];

void init(void) {
  fact[0] = fact[1] = 1;
  for (int i = 2; i <= 200000; i++) {
    fact[i] = fact[i - 1] * i % mod;
  }
}

ll mod_pow(ll x, ll n) {
  if (n == 1) return x;
  ll res = mod_pow(x * x % mod, n / 2);
  if (n & 1) res = res * x % mod;
  return res;
}

ll nCk(int n, int k) {
  if (n < 0 || k < 0 || n < k) return 0;
  if (k == 0 || k == n) return 1;
  ll res = fact[n];
  res = res * mod_pow(fact[k], mod - 2) % mod;
  res = res * mod_pow(fact[n - k], mod - 2) % mod;
  return res;
}

int main(void) {
  init();

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

  ll ans = 0;
  for (int i = 0; i < w - b; i++) {
    ans = (ans + nCk(h - a + b - 1, b + i) * nCk(w + a - b - 1, a + i) % mod) % mod;
  }
  cout << ans << endl;

  return 0;
}

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

/*  */
int main() {
    int s;
    cin >> s;

    int n=s;
    int a[10000];

    a[0] = s;
    int index = 1;
    int ans = -1;
    while(true){
        if(n % 2 == 0){
            n = n /2;
        }else{
            n = 3*n + 1;
        }
        a[index] = n;
        rep(i, index){
            if(a[i] == a[index]){
                ans = index+1;
            }
        }
        index++;
        if(ans != -1){
            break;
        }
    }

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


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

using namespace std;

int main()
{
  int A, B, C, X, Y;

  cin >> A >> B >> C >> X >> Y;

  cout << min({A*X + B*Y, C*2*max(X, Y), C*2*min(X, Y) + ((X > Y) ? (X - Y)*A : (Y - X)*B)}) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int ans=0;
  int temp=0;
  for(int i=S.length()-1;i>=0;i--){
    if((S.at(i)-'0')+temp>5){
      ans+=10-(S.at(i)-'0'+temp);
      temp=1;
    }
    else if((S.at(i)-'0')+temp==5 && i>0){
      if(S.at(i-1)-'0'>4){
        ans+=10-(S.at(i)-'0'+temp);
        temp=1;
      } 
      else{
      ans+=(S.at(i)-'0')+temp;
      temp=0;        
      }      
    }
    else{
      ans+=(S.at(i)-'0')+temp;
      temp=0;
    }
    //cout<<i<<" "<<ans<<endl;
  }
  cout<<ans+temp<<endl;
  return 0;
}


Measured memory_bytes: 5344
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

int solve(int a, int b)
{
  int left = std::max(a / 0.08, b / 0.1);
  int right = std::min((a + 1) / 0.08, (b + 1) / 0.1);
  if (left > right) return -1;
  while (true) {
    int aa = left * 0.08;
    int bb = left * 0.1;
    if (aa == a && bb == b) return left;
    if (aa >= a + 1 || bb >= b + 1) return -1;
    ++left;
  }
  return -1;
}

int main()
{
  int a, b;
  std::cin >> a >> b;

  std::cout << std::setprecision(20);
  std::cout << solve(a, b) << std::endl;
}


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

int main()
{
    int n;
    map<string ,int > m1;
    cin>>n;
    set<string > set1;
    int max1=INT_MIN;
    while(n--)
    {

        string s;
        cin>>s;
        if(m1.find(s)!=m1.end())
        {
            m1[s]++;
            set1.insert(s);
          //  max1=max(max1,m1[s]);
        }
        else{
            m1.insert({s,1});
            //max1=max(max1,1);
        set1.insert(s);

        }
    }
    int m;
    cin>>m;
   // set<string ,int > m2;
    while(m--)
    {
        string s2;
        cin>>s2;
        if(m1.find(s2)!=m1.end())
        {
            m1[s2]--;
            //if(m1[s2]>=0)
            //max1=max(max1,m1[s2]);
            set1.insert(s2);

        }
        else
        {
            m1.insert({s2,-1});
            //max1=max(max1,-1);
            set1.insert(s2);

        }
    }
    for(auto it=set1.begin();it!=set1.end();it++)
    {
       // cout<<*it<<endl;
        max1=max(max1,m1[*it]);
       // cout<<m1[*it]<<endl;
    }
    if(max1>=0)
    cout<<max1<<endl;
    else cout<<"0"<<endl;
    return 0;
}


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

int main() {
  int n,m;
  cin>>n>>m;
  vector<int>a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a.begin(),a.end());
  int all=0;
  for(int i=0;i<n;i++) all+=a[i];
  if(all%(4*m)==0){
    all/=4*m;
    if(a[n-m]>=all) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  else{
    all/=4*m;
    if(a[n-m]>all) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	int n; cin>>n;
	vi v(n);
	rep(i,0,n) cin>>v[i];
	vi t=v;
	sort(all(t));
	rep(i,0,n){
		int k=v[i];
		rep(j,0,i){
			if(v[i]<v[j]){
				v.erase(v.begin()+i);
				v.insert(v.begin()+j,k);
			}
		}
		rep(l,0,n){
			cout<<v[l];
			if(l!=n-1)cout<<" ";
		}
		cout<<endl;
	}
				
	return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) c.begin(), c.end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    string s;
    cin >> s;
    int n = s.length();

    int ans = 1e9;
    for (char c = 'a'; c <= 'z'; c++){
        int temp = 0, x = 0;
        REP(i,n){
            if (s[i] == c){
                temp = max(temp, x);
                x = 0;
            }else{
                x++;
            }
        }
        temp = max(temp, x);
        ans = min(ans, temp);
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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();
    System.out.println(Math.max(0,(C - Math.max(A-B,0))));
  }
}

Measured memory_bytes: 21844
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	n := scanInt(sc)

	ns := make([]int, n)
	first := 0
	second := 0
	for i := 0; i < n; i++ {
		n := scanInt(sc)
		ns[i] = n

		if first < n {
			second = first
			first = n
		} else if second < n {
			second = n
		}
	}

	w := bufio.NewWriter(os.Stdout)
	for i := 0; i < n; i++ {
		if ns[i] == first {
			fmt.Fprintln(w, second)
		} else {
			fmt.Fprintln(w, first)
		}
	}
	w.Flush()
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}


Measured memory_bytes: 6016
#include <stdio.h>

int main(void)
{
	int N;
	int n[10000];
	int i;
	int count = 0;
	
	scanf("%d", &N);
	
	for (i = 0; i < N; i++) scanf("%d", &n[i]);
	
	for (i = 0; i < N; i++){
		while (n[i] % 2 == 0){
			n[i] /= 2;
			count++;
		}
	}
	
	printf("%d\n", count);
	
	return (0);
}

Measured memory_bytes: 256