akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)
#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pii pair<int,int>
#define pLL pair<long long,long long>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
typedef long long ll;
typedef long long int lln;
ll INF=1<<28;
//typedef long long lld;
const double pi=acos(-1.0);
int fx[]={1,-1,0,0}; //direction array
int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
const long double EPS=1e-7;
//#define INF 10000
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    return a/gcd(a,b)*b;
}

bool cmp(int a, int b)
{
    return a<b;
}

int vis[200000];
struct compare
{
  bool operator()(const int& l, const int& r)
  {
      return vis[l]>vis[r];
  }
};
ll inf=1e18;
int mod=1e9+7;
const int sz=300005;
ll dp[105][100005];
int n;
int arr[105];
ll fun(int pos,int baki)
{
    if(pos==0)
    {
        return baki==0;
    }
    if(dp[pos][baki]!=-1)
        return dp[pos][baki];
    ll ans=0;
    for(int i=0;i<=min(baki,arr[pos]);i++)
    {
        ans+=fun(pos-1,baki-i);
        ans%=mod;
    }
    return dp[pos][baki]=ans;
}
int main()
{
//    READ;
    int k;
    sf2(n,k);
    for(int i=1;i<=n;i++)
    {
        sf(arr[i]);
    }
    dp[0][0]=1;
//    mem(dp,-1);
//    cout<<fun(n,k)<<endl;
    ll ret=0;
    for(int pos=1;pos<=n;pos++)
    {
        ret=0;
        for(int baki=1;baki<=k;baki++)
        {
            dp[pos-1][baki]+=dp[pos-1][baki-1];
            dp[pos-1][baki]%=mod;
        }
        for(int baki=0;baki<=k;baki++)
        {
//            for(int i=0;i<=min(baki,arr[pos]);i++)
//            {
//                ret+=dp[pos-1][baki-i];
//                ret%=mod;
//            }
            dp[pos][baki]=dp[pos-1][baki];
            if(baki-arr[pos]-1>=0){
                    dp[pos][baki]-=dp[pos-1][baki-arr[pos]-1];
                    dp[pos][baki]+=mod;

            }
            dp[pos][baki]%=mod;
        }
    }
    cout<<dp[n][k]<<endl;

    return 0;
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;

int k;
int main(){
	// debug;
	ios;

	cin>>k;
	ll cur = 7%k,sum = cur,last = cur;
	int ans = -1;
	for(int i = 1;i<=10000000;i++){
		if(sum%k == 0){
			ans = i;
			break;
		}else{
			cur = cur*10%k;
			sum = (sum + cur)%k;
		}
	}
	cout<<ans<<'\n';


	
	return 0;
}


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

int main(void){
  while(true){
    int n;
    cin >> n;
    if(n == 0){ break; }

    vector<int> input(n);
    for(int i = 0; i < n; i++){ cin >> input[i]; }
    sort(input.begin(), input.end());
    
    int ans = 0;
    for(int i = 1; i < n - 1; i++){ ans += input[i]; }
    ans /= (n - 2);
    cout << ans << endl;
  }


  return 0;
}

Measured memory_bytes: 3020
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial



def main():
    if input() in ['a', 'e', 'i', 'o', 'u']:
        print('vowel')
    else:
        print('consonant')






if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
stair = [1, 1, 2]
for i in range(3, 31):
    stair.append(stair[i-1] + stair[i-2] + stair[i-3])

while 1:
    n = int(input())
    if n == 0:
        break

    print((stair[n]+3649) // 3650)



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

using namespace std;

int main(){
    int cnt[101] = {0};

    int ans = 0, i;
    while(cin >> i){
        cnt[i]++;
        ans = max(ans, cnt[i]);
    }
    for (int i = 0; i < 101; ++i){
        if(cnt[i] == ans) cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define  pb(x) push_back(x)
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define mod 1000000007
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
//i ll be the king
int main()
{
	sync;
	ll n;
	cin>>n;
	ll arr[n];
	input(arr,n);
	ll ans=0;
	for(ll i=1;i<n-1;i++)
	if((arr[i-1]>arr[i]&&arr[i+1]<arr[i])||(arr[i-1]<arr[i]&&arr[i+1]>arr[i]))
	ans++;
	cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pi pair<int, int>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define deb(x) cout << #x << ":" << x << endl;
#define deba(x) cerr << #x << endl; for (auto a : x) cerr << a << " "; cerr << endl;
/* freopen("input.txt", "r", stdin); */
/* freopen("output.txt", "w", stdout); */
const int mod = 1000000007;


int main() {
	fastio();
	string s, t;
	cin >> s >> t;
	int n = s.length(), m = t.length();
	int l[n+1][m+1];
	for(int i=0;i<=n;i++) {
		for(int j=0;j<=m;j++) {
			if(i==0 || j==0)
				l[i][j]=0;
			else if(s[i-1] == t[j-1])
				l[i][j] = l[i-1][j-1]+1;
			else
				l[i][j] = max(l[i-1][j], l[i][j-1]);
		}
	}
	string lcs(l[n][m], '.');
	int i=n, j=m;
	int pos = l[n][m]-1;
	while(i > 0 && j > 0) {
		if(s[i-1]==t[j-1]) {
			lcs[pos--] = s[i-1];
			i--;
			j--;
		}
		else if(l[i-1][j] > l[i][j-1])
			i--;
		else
			j--;
	}
	cout << lcs << "\n";
	return 0;
}



Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n;
    cin>>n;
    unordered_map<ll,ll> m;
    ll a;
    for(ll i=0;i<n;i++){
        cin>>a;
        m[a]++;
    
    }
    ll cnt=0;
    for(auto itr=m.begin();itr!=m.end();itr++)
    {
        if((itr->second)>=(itr->first))
        cnt=cnt+abs((itr->first)-(itr->second));
        else
        cnt=cnt+(itr->second);    }
    cout<<cnt<<endl;
   
}

Measured memory_bytes: 4260
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

const long long INF = LLONG_MAX / 4;

int q;
vector<string> s(1);
vector<vector<int> > to;
vector<long long> len;

void solve(long long a, long long b)
{
    stack<pair<int, int> > stk;
    stk.push(make_pair(0, 0));

    for(;;){
        int i = stk.top().first;
        int j = stk.top().second;
        stk.pop();

        while(j < (int)s[i].size()){
            int next = to[i][s[i][j]-'a'];
            if(next == -1){
                if(a <= 0)
                    cout << s[i][j];
                -- a;
                -- b;
            }else{
                if(a < len[next]){
                    stk.push(make_pair(i, j+1));
                    stk.push(make_pair(next, 0));
                    break;
                }else{
                    a -= len[next];
                    b -= len[next];
                }
            }
            if(b < 0){
                cout << endl;
                return;
            }
            ++ j;
        }
    }
}

int main()
{
    long long a, b;
    cin >> s[0] >> q >> a >> b;

    ++ q;
    s.resize(q);
    vector<char> c(q);
    for(int i=1; i<q; ++i){
        cin >> c[i] >> s[i];
        if(s[i] == ".")
            s[i] = "";
    }

    to.assign(q, vector<int>(26, -1));
    len.resize(q, 0);
    for(int i=q-1; i>=0; --i){
        for(unsigned j=0; j<s[i].size(); ++j){
            int next = to[i][s[i][j]-'a'];
            if(next == -1){
                ++ len[i];
            }else if(len[next] > 0){
                len[i] += len[next];
            }else{
                s[i].erase(s[i].begin() + j);
                -- j;
            }
            len[i] = min(len[i], INF);
        }

        if(i > 0){
            to[i-1] = to[i];
            if(s[i].size() == 1 && to[i][s[i][0]-'a'] != -1)
                to[i-1][c[i]-'a'] = to[i][s[i][0]-'a'];
            else
                to[i-1][c[i]-'a'] = i;
        }
    }

    if(b > len[0])
        cout << "." << endl;
    else
        solve(a-1, b-1);

    return 0;
}

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

int main(){
    int a, b;
    char c;
    while(cin >> a >> c >> b && c != '?'){
        int ans;
        if(c == '+') ans = a + b;
        else if(c == '-') ans = a - b;
        else if(c == '*') ans = a * b;
        else ans = a / b;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=5e5+5,M=2e2+5,INF=1e9,mod=998244353;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
il void gen(){freopen("data.in","w",stdout);}
int a[N],n;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int gao(){
	int c0=0,c1=0;
	rep(i,1,n)if(a[i]&1)c1++;else c0++;
	if(c0&1)return 1;if(c1>1)return 0;
	rep(i,1,n)if(a[i]&1){
		if(a[i]==1)return 0;
		a[i]--;
	}int g=a[1];rep(i,2,n)g=gcd(g,a[i]);
	rep(i,1,n)a[i]/=g;
	return !gao();
}
int main(){
	read(n);rep(i,1,n)read(a[i]);
	puts(gao()?"First":"Second");
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

const int n_max=1e5+1;
vector<int> g[n_max];
int dp[n_max][11];


void paint(int v, int p, int d, int q){
  if(dp[v][d]!=0) return;
  dp[v][d]=q;
  if(d!=0){
    paint(v, p, d-1, q);
    for(auto i:g[v]){
      if(i!=p) paint(i,v,d-1,q);
    }
  }
}



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]--;
    g[a[i]].pb(b[i]);
    g[b[i]].pb(a[i]);
  }
  rep(i,n)rep(j,11) dp[i][j]=0;
  int q;
  cin >> q;
  int v[q],d[q],c[q];
  rep(i,q) cin >> v[q-1-i] >> d[q-1-i] >> c[q-1-i];
  rep(i,q){
    paint(--v[i],-1,d[i],c[i]);
  }
  rep(i,n) cout << dp[i][0] << endl;
  
  
  return 0;

}


Measured memory_bytes: 12792
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	int s[4] = {0};
	cin>>a>>b;
	s[a]++;
	s[b]++;
	for(int i=1;i<4;i++)
	{
		if(s[i] == 0)cout<<i<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;
int main()
{
	int m, f, r;
	while (cin >> m >> f >> r, m != -1 || f != -1 || r != -1) {
		int s = m + f;
		if (m == -1 || f == -1) {
			cout << 'F' << endl;
		}
		else if (s>= 80) {
			cout << 'A' << endl;
		}
		else if (s < 80 && s >= 65) {
			cout << 'B' << endl;
		}
		else if (s < 65 && s >= 50) {
			cout << 'C' << endl;
		}
		else if (s < 50 && s >= 30) {
			if (r >= 50) {
				cout << 'C' << endl;
			}
			else {
				cout << 'D' << endl;
			}
		}
		else {
			cout << 'F' << endl;
		}
	}
}




Measured memory_bytes: 3076
// ------------------
// author: MatsuTaku
// date  : 19/02/2020
// ------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  ll H; cin>>H;
  auto h = H;
  int i = 0;
  ll t = 1;
  ll ans = 0;
  while (h) {
    ans += t;
    t *= 2;
    h>>=1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
using namespace std;
typedef unsigned long long ll;
const int maxn=2e5+50;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int HASH=131;



int main()
{
    int  n,x,t;
    cin>>n>>x>>t;
    int num;
    if(n%x==0)
        {
            num=n/x;
        }
    else num=n/x+1;
    printf("%d\n",num*t);
    return 0;
}


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

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

    int N;
    N = S.length() + 1;

    long long a[N];
    long long count1[N];
    long long count2[N];
    count1[0]=0;
    count2[N-1]=0;

    for(int i=0; i<N-1; i++){
        if(S[i]=='<'){
            count1[i+1] = count1[i] + 1;
        }else{
           count1[i+1] = 0;
        }
    }

    for(int i=N-2; i>=0; i--){
        if(S[i]=='>'){
            count2[i] = count2[i+1] + 1;
        }else{
           count2[i] = 0;
        }
    }

    long long ans=0;
    for(int i=0;i<N;i++){
      if(count1[i]>count2[i])
        a[i] = count1[i];
      else
        a[i] = count2[i];
      ans += a[i];
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 12548
#include <iostream>
#include<iomanip>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;

static long long gcd(long long a,long long b){
	int amari = a % b;
	int c = b;
	if(amari == 0){
		return b;
	}else{
		return gcd(b,amari);
	}
}
static long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}
int main() {
    int x,y,xa,ya;
    int ans = 2000000000;
    cin >> xa >> ya;
    x = xa % 2019;
    y = ya % 2019;
    if (y < x || (y > x && ya - xa > 2018)){
        ans = 0;
    }else{
        for (int i=x;i<y;i++){
            for (int j=x+1;j<=y;j++){
                if((i * j)% 2019 < ans){
                    ans = (j * i)% 2019;
                }
            }
        }
        if(x == 0 || y == 0){
            ans = 0;
        }
    }
    cout << ans;

}



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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> COUNT(N, 0);
	for (int i = 0; i < K; i++) {
		int D;
		cin >> D;
		for (int j = 0; j < D; j++) {
			int A;
			cin >> A;
			A--;
			COUNT[A]++;
		}
	}
	int ANS = 0;
	for (int i = 0; i < N; i++) {
		if (COUNT[i] == 0) ANS++;
	}
	cout << ANS << endl;
}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;
using vb=vector<bool>;using vs=vector<string>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template<typename T>T read(){T t;cin>>t;return t;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){o<<'('<<p.fst<<", "<<p.snd<<')';return o;}

void Main() {
  int n = read<int>();
  int k = read<int>();
  vector<int> A(n);

  rep(i, n) A[i] = read<int>();

  vector<ll> R(sz(A)+1);
  rep(ii, sz(A)) R[ii+1] = R[ii] + A[ii];


  vi P(n);
  rep(i, n) if (A[i] > 0) P[i] = A[i];
  vector<ll> S(sz(P)+1);
  rep(ii, sz(P)) S[ii+1] = S[ii] + P[ii];

  ll sum = 0;
  forr(a, A) if (a > 0) sum+=a;

  //cout << "A:"; rep(ii,sz(A)) cout << ' ' << A[ii]; cout << endl;
  //cout << "S:"; rep(ii,sz(S)) cout << ' ' << S[ii]; cout << endl;
  //cout << "sum: "<<sum << endl;

  ll ans = 0;

  rep(l, n) {
    ll s = S[l+k] - S[l];
    ll r = R[l+k] - R[l];
    if (l + k > n) break;
    ll cand = -1e9;
    // b
    cand = max(cand, sum - s + r);
    // w
    cand = max(cand, sum - s);
    //_p("%d:%lld,%lld,=%lld\n", l, s,r,cand);
    ans = max(ans, cand);
  }
  cout << ans << endl;
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 2560
def dfs(c):
    if c==[] or c==[0]:
        return 0
    mc = min(c)
    ans = mc
    for i in range(len(c)):
        c[i] -= mc
    st,i = 0,0
    while i<c.count(0):
        to = c.index(0,i)
        ans += dfs(c[st:to])
        st = to+1
        i += 1
    ans += dfs(c[st:])
    return ans

N = int(input())
h = list(map(int,input().split()))
print(dfs(h))


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

using ll = long long;

#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x; cin >> x;
    REP(i, 0, 120) {
    	ll pi = pow(i, 5);
    	REP(j, 0, 120) {
    		ll pj = pow(j, 5);
    		if(pi - pj == x) {
    			cout << i << " " << j << "\n";
    			return 0;
    		} else if(pi + pj == x) {
    			cout << i << " " << -j << "\n";
    			return 0;
    		}
    	}
    }
    assert(false);
    return 0;
}


Measured memory_bytes: 4128
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.parents = [i for i in range(n+1)]
        self.size = [1]*(n+1)
    def find(self,x):
        if self.parents[x]==x:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    def unite(self,x,y):
        xRoot = self.find(x)
        yRoot = self.find(y)
        if xRoot == yRoot:
            return
        if self.size[xRoot]>self.size[yRoot]:
            self.parents[yRoot] = xRoot
            self.size[xRoot] += self.size[yRoot]
            self.size[yRoot] = 0
        else:
            self.parents[xRoot] = yRoot
            self.size[yRoot] += self.size[xRoot]
            self.size[xRoot] = 0

N,M = map(int,input().split())
tree = UnionFind(N)
for _ in range(M):
    a,b = map(int,input().split())
    tree.unite(a,b)
cnt = 0
for i in range(1,N+1):
    if tree.size[i] > 0:
        cnt += 1
print(cnt-1)



Measured memory_bytes: 74596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int H,W,K;
    cin >> H >> W >> K;

    vector<vector<char>> data(H, vector<char>(W));
    
    
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> data.at(i).at(j);
        }
    }
    
    int ans = 0;
    for (int bith = 0; bith < (1<<H); ++bith){
        for(int bitw = 0; bitw < (1<<W); ++bitw){
            
            int sum = 0;
            for(int i = 0;i < H;i++){
                for(int j = 0;j < W;j++){
                    if(bith & (1<<i)){
                        continue;
                    }
                    if(bitw & (1<<j)){
                        continue;
                    }

                    if(data.at(i).at(j) == '#'){
                        sum++;
                    }
                }
            }
            if(sum == K){
                ans++;
            }

        }
    }
 cout << ans <<endl;


} 

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

void init(int array[201][201]){
	for(int i=0;i<201;i++)
		for(int j=0;j<201;j++)
			array[i][j]=0;
}

int getTreesNum(int array[201][201],int s,int t,int y, int x){
	int cnt=0;
	for(int i=y;i<y+t;i++){
		for(int j=x;j<x+s;j++){
			if(array[i][j]==1){
				cnt++;
			}
		}
	}
	return cnt;
}

int checkTreesNum(int array[201][201],int s,int t,int w,int h){
	int max = 0,num;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			num = getTreesNum(array,s,t,i,j);
			max = (max < num) ? num : max;
		}
	}
	return max;
}

int main(){
	while(1){
		int n,w,h,s,t;
		int array[201][201];
		init(array);
		cin >> n;
		if(n==0) break;
		cin >> w >> h;
		while(n--){
			int x,y;
			cin >> x >> y;
			array[y][x]=1;
		}
		cin >> s >> t;
		cout << checkTreesNum(array,s,t,w,h) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1316
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, K;
  cin >> N >> K;
  vl A(N);
  vl F(N);
  REP(i, N) cin >> A[i];
  REP(i, N) cin >> F[i];
  ll left = -1;
  ll right = 1e12;
  sort(ALL(A));
  sort(ALL(F), REV(ll));

  while (abs(right - left) > 1) {
    ll mid = left + (right - left) / 2;
    ll po = 0;
    REP(i, N) {
      po += ceil((long double)max(((A[i] * F[i]) - mid), 0LL) / F[i]);
    }

    if (po <= K)
      right = mid;
    else
      left = mid;
  }
  cout << right << endl;
  return 0;
}


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

using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  uint64_t n, m;
  cin >> n >> m;

  uint64_t maxScc = (n * 2 + m) / 4;
  if (maxScc <= n) {
    cout << min(n, m/2) << "\n";
  } else {
    cout << maxScc << "\n";
  }
}


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

int main(){
    int n, W; cin >> n >> W; int w[n], v[n], i, j;
    for(i = 0; i < n; i++)  cin >> w[i] >> v[i];
    long long dp[n+1][W+1];
    for(j = 0; j <= W; j++)  dp[0][j] = 0;
    for(i = 0; i <= n; i++)  dp[i][0] = 0;
    for(i = 1; i <= n; i++){
        for(j = 1; j <= W; j++){
            if(w[i-1] <= j)   dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1]);
            else              dp[i][j] = dp[i-1][j];
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}


Measured memory_bytes: 79104
n,k = gets.split(' ').map(&:to_i)
r,s,p = gets.split(' ').map(&:to_i)
t = gets.chomp.split('')
score = 0 
t_hand = []
(0..n-1).each do |i| 
  if t[i] == 'r' 
    t_hand << 'p' 
    score += p
  elsif t[i] == 's' 
    t_hand << 'r' 
    score += r
  elsif t[i] == 'p' 
    t_hand << 's' 
    score += s
  end 
end
temp = 's' 
(k..n-1).each do |i| 
  flag1 = 0 

  if t_hand[i] == t_hand[i-k]
    score -= r if t_hand[i] == 'r' 
    score -= s if t_hand[i] == 's' 
    score -= p if t_hand[i] == 'p' 
    flag1 = 1 
    temp = t_hand[i]
  end 
  if flag1 == 1
    t_hand[i] = 'p' if temp == 's' 
    t_hand[i] = 's' if temp == 'r' 
    t_hand[i] = 'r' if temp == 'p' 
    flag = 0 
    if t_hand[i] == t_hand[i+k]
      flag = 1 
      temp = t_hand[i]
    end 
    if flag == 1
      t_hand[i] = 'p' if temp == 's' 
      t_hand[i] = 's' if temp == 'r' 
      t_hand[i] = 'r' if temp == 'p'                                                                     
    end 
  end 
end
puts score

Measured memory_bytes: 20604
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
#define int long long
#define ll long long
template <typename T> void read(T &x) {
    x=0;int f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9') x =(x<<1)+(x<<3)+c-'0',c=getchar();x *= f;
}
ll sum;
int n,a[N];
signed main() {
	read(n);
	for(int i=1;i<=n;i++)read(a[i]),sum+=a[i];
	if(sum%(n*(n+1)/2)!=0)return puts("NO")*0;
	sum/=(n*(n+1)/2);
	for(int i=1;i<n;i++){
		int diff=a[i+1]-a[i],tmp=(sum-diff)/n;
		if(tmp<0||tmp*n!=(sum-diff)){
			return puts("NO")*0;
		}
	}
	return puts("YES")*0;
}


Measured memory_bytes: 1024
import sys
input=sys.stdin.readline

def main():
    _ = int(input())
    A = list(map(int,input().split()))
    A.sort()
    a = A.pop()
    b = 0
    for x in A:
        if abs(a/2-x) < abs(a/2-b):
            b = x
    print(a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14040
n = gets.to_i
V = gets.chomp.split(" ")
i, j = 0, 1
hash0 = Hash.new(0)
hash1 = Hash.new(0)
(n / 2).times do
    hash0[V[i]] += 1
    hash1[V[j]] += 1
    i += 2
    j += 2
end

hash0 = hash0.sort_by{|_, v| v}.to_a
hash1 = hash1.sort_by{|_, v| v}.to_a

if V.uniq.size == 1 
    puts n / 2
elsif hash0[-1][0] == hash1[-1][0]
    puts [(n - hash0[-1][1] - hash1[-2][1]), (n - hash0[-2][1] - hash1[-1][1])].min
else
    puts n - hash0[-1][1] - hash1[-1][1]
end

Measured memory_bytes: 31212
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#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>
#endif

// 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 <atomic>
#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>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll gcd(ll a, ll b){//計算量はO(log(max(a,b))
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

ll kai(ll x){
  if(x == 1) return 1;
  return x * kai(x-1) % MOD;
}

int main(){
  ll N; cin >> N;
  cout << kai(N) << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define DIVCEIL(a,b) ((a+b-1)/b)
//int CHMAX

int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int MODFACT(int a, int mod) {
	if (a == 0)
		return 1;
	else
		return (a * FACT(a - 1))%mod;
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
int MODnPr(int n, int r, int mod) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++) {
		sum *= i;
		sum = sum % MOD;
	}
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
int NUMOFDIV(int n) {
	//約数の数（だっけ？）
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
int CEIL1(int n) {
	//1桁目切り上げ
	return (n + 9) / 10 * 10;
}
int DIGIT(int n,int k) {
	//nのk桁目
	rep(i, k-1)
		n /= 10;
	return n % 10;
}
int DIGITSUM(int n) {
	int sum = 0, dig;
	while (n) {
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}
int DIVTIME(int n, int k) {
	//nをkで何回割れるか的な
	int div = 0;
	while (n % k == 0) {
		div++;
		n /= k;
	}
	return div;
}
int MODPOW(int a, int n, int mod) {
	// a^n mod
	int ans = 1;
	while (n > 0) {
		if (n & 1)
			ans = ans * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return ans;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool between(int x, int min, int max) {
	if (min < x && x < max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion
signed main() {
	double L;
	cin >> L;
	L /= 3;
	cout << setprecision(15)<< L*L*L;
}

Measured memory_bytes: 256
s = int(input())
list_a = []
list_a.append(s)
a = s
for i in range(10000):
    if a % 2:
        f = int(3 * a + 1)
        if f in list_a:
            print(i + 2)
            break
        list_a.append(f)
        a = f
    else:
        f = int(a / 2)
        if f in list_a:
            print(i + 2)
            break
        list_a.append(f)
        a = f


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

int cnt;
void insertionSort(int [], int, int);
void shellSort(int [], int);

void insertionSort(int A[], int n, int g){
    int i, j;
    
    for(i = g; i < n; i++){
        int v = A[i];
        j = i - g;
        
        while(j >= 0 && A[j] > v){
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shellSort(int A[], int n){
    int m;
    int g;
    int *G;
    int i;
    
    cnt = 0;
    
    for(g = m = 1; 3*g + 1 < n; g = 3*g + 1) m++;
    cout << m << endl;
    
    G = new int[m];
    for(i = 0; i < m; i++){
        G[i] = g;
        if(i) cout << " ";
        cout << G[i];
        g = (g - 1) / 3;
        insertionSort(A, n, G[i]);
    }
    cout << endl;
    delete [] G;
    G = 0;
}

int main(void){
    int n;
    int *input;
    int i;
    
    cin >> n;
    input = new int[n];
    for(i = 0; i < n; i++){
        cin >> input[i];
    }
    
    shellSort(input, n);
    
    cout << cnt << endl;
    for(i = 0; i < n; i++){
        cout << input[i] << endl;
    }
    
    delete [] input;
    input = 0;
    return 0;
}

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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var aaa = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var H = aaa[0];
            var W = aaa[1];
            var mas = new List<string>();
            var row = new bool[W];

            for (var i = 0; i < H; i++)
            {
                var bbb = Console.ReadLine();
                var emptyline = true;

                for(int j=0; j<W; j++)
                {
                    if(bbb[j] == '#')
                    {
                        row[j] = true;
                        emptyline = false;
                    }                    
                }
                if (!emptyline)
                {
                    mas.Add(bbb);
                }
            }

            foreach (var line in mas)
            {
                for (var i = 0; i < W; i++)
                {
                    if(row[i])
                    {
                        Console.Write(line[i]);
                    }
                }
                Console.WriteLine();
            }
        }
    }
}


Measured memory_bytes: 13268
n = gets.to_i
# nが奇数のとき、s0 = 1
ans = []
while true do
  if n % 2 == 1
    ans.unshift(1)
    n -= 1
  else
    ans.unshift(0)
  end
  break if n == 0 || n == 1
  n /= -2
end
puts ans.join('')

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

int main()
{
    int A, B, K;
    cin >> A >> B >> K;
    for(int i = 0; i < K; i++) {
        if((i%2) == 0) {
            if((A%2) == 1) {
                A -= 1;
            }
            B += A/2;
            A /= 2;
        } else {
            if((B%2) == 1) {
                B -= 1;
            }
            A += B/2;
            B /= 2;
        }
    }
    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<map>
#include<algorithm>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <vector>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <list>


constexpr int INF = 1050000000;
constexpr int MOD = 1000000007;
constexpr long long LONGINF = 1005000000000000000;
using namespace std;

using ll = long long;

class UnionFind {
private:
	std::vector<int> parent;
	std::vector<int> height;
	std::vector<int> m_size;

public:
	UnionFind(int size_) : parent(size_), height(size_, 0), m_size(size_, 1) {
		for (int i = 0; i < size_; ++i) parent[i] = i;
	}
	void init(int size_) {
		parent.resize(size_);
		height.resize(size_, 0);
		m_size.resize(size_, 1);
		for (int i = 0; i < size_; ++i) parent[i] = i;
	}
	int find(int x) {
		if (parent[x] == x) return x;
		return parent[x] = find(parent[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		int t = size(x) + size(y);
		m_size[x] = m_size[y] = t;
		if (height[x] < height[y]) parent[x] = y;
		else parent[y] = x;
		if (height[x] == height[y]) ++height[x];
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		if (parent[x] == x) return m_size[x];
		return size(parent[x] = find(parent[x]));
	}
};


int main() {

	int n, m, p;
	
	while (1) {
		cin >> n >> m >> p;
		if (n == 0 && m == 0 && p == 0) { return 0; }

		int sum = 0;

		int x[1005];

		for (int i = 1; i <= n; i++) {
			cin >> x[i];
			sum += x[i] * 100;
		}

		if (x[m] == 0) { cout << 0 << endl; }
		else {
			cout << (sum * (100 - p) / 100) / x[m] << endl;
		}
	}

}


Measured memory_bytes: 3088
#include <cstdio>

using namespace std;

int main()
{
	int year, month, day;
	bool flag;
	
	while (scanf("%d %d %d", &year, &month, &day) != EOF){
		flag = true;
		if (year >= 1989){
			if (year == 1989 && month == 1 && day < 8){
			}
			else {
				year -= 1989 - 1;
				printf("heisei %d %d %d\n", year, month, day);
				flag = false;
			}
		}
		if (year >= 1926){
			if (year == 1926 && month <= 12 && day < 25){
			}
			else {
				year -= 1926 - 1;
				printf("showa %d %d %d\n", year, month, day);
				flag = false;
			}
		}
		if (year >= 1912){
			
			if (year == 1912 && month <= 7 && day < 30){
			}
			else {
				year -= 1912 - 1;
				printf("taisho %d %d %d\n", year, month, day);
				flag = false;
			}
		}
		if (year >= 1868){
			if (year == 1868 && month <= 9 && day < 8){
			}
			else {
				year -= 1868 - 1;
				printf("meiji %d %d %d\n", year, month, day);
				flag = false;
			}
		}
		if (year <= 1868 && flag){
			printf("pre-meiji\n");
		}
	}
}

Measured memory_bytes: 1036
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

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

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; 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 true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class CMultiplication3 {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll a; cin >> a;
      string b; cin >> b;
      reverse(all(b));
      int d = 0;
      int base = 1;
      for(auto c: b) {
        if (c != '.') {
          d += (c - '0')*base;
          base *= 10;
        }
      }

      ll ret = (a*d)/100;
      cout << ret << endl;

    }
};

signed main() {
  CMultiplication3 solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3640
#include <cstdio>

inline int readin(){
	int x=0,c;
	for (;(c=getchar())<'0'||c>'9';);
	for (;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+c-48;
	return x;
}

int a[2333][2333],b[2333][2333],n,m;

int nex(int &x,int &y){
	if (x%2==1){
		y++;
		if (y>m) x++,y=m;
	}else{
		y--;
		if (y<1) x++,y=1;
	}
}

int main(){
	n=readin(),m=readin();
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++) a[i][j]=b[i][j]=readin();
	int x1=1,y1=1,x2=1,y2=1;
	nex(x2,y2);
	int ans=0;
	for (int i=1;i<n*m;i++){
		if (a[x1][y1]%2) a[x1][y1]--,a[x2][y2]++,ans++;
		nex(x1,y1),nex(x2,y2);
	}
	x1=y1=x2=y2=1;
	nex(x2,y2);
	printf("%d",ans);
	for (int i=1;i<n*m;i++){
		if (b[x1][y1]%2) b[x1][y1]--,b[x2][y2]++,printf("\n%d %d %d %d",x1,y1,x2,y2);
		nex(x1,y1),nex(x2,y2);
	}
}

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

typedef long long ll;

int main() {
    ll MOD = 998244353;
    int N, K;
    cin >> N >> K;
    vector<int> L(K), R(K);
    rep(i, K) cin >> L[i] >> R[i];
    vector<ll> s(N + 1, 0), d(N + 1, 0);
    d[0] = 1;
    d[1] = MOD - 1;
    rep (i, N) {
        s[i + 1] = (s[i] + d[i]) % MOD;
        rep(j, K) {
            int l = i + 1 + L[j] - 1;
            if (l > N) continue;
            d[l] += s[i + 1];
            d[l] %= MOD;
            int r = i + 1 + R[j];
            if (r > N) continue;
            d[r] -= s[i + 1];
            d[r] += MOD;
            d[r] %= MOD;
        }
        //cout << "s[" << i + 1 << "]=" << s[i + 1] << "\n";
        //rep(i, N + 1) cout << "d[" << i << "]=" << d[i] << "\n";
    }
    cout << s[N] << "\n";
    //rep(i, N + 1) cout << "s[" << i << "]=" << s[i] << "\n";
}

Measured memory_bytes: 6356
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  int A, B;
  cin >> A >> B;
  int ans = max(A, B);
  if (ans == A) {
    A--;
  } else {
    B--;
  }
  ans += max(A, B);
  cout << ans;
  return 0;
}

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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<int> open(n);
    for (int i = 0; i < n; i++) {
        int x = 0;
        for (int j = 0; j < 10; j++) {
            int k; cin >> k;
            x |= k<<j;
        }
        open[i] = x;
    }
    vector<array<int,11>> p(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= 10; j++) {
            cin >> p[i][j];
        }
    }
    int mx = -2e9;
    for (int msk = 1; msk < (1<<10); msk++) {
        int sum = 0;
        for (int i = 0; i < n; i++) {
            int k = __builtin_popcount(msk & open[i]);
            sum += p[i][k];
        }
        mx = max(mx, sum);
    }
    cout << mx;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
import scala.io.StdIn.readInt

object Main extends App {
  val n = readInt
  for(i <- 1 to n) {
    var m = readInt

    println("Case " + i + ":")
    for(j <- 1 to 10){
      m = "%08d".format(m*m).substring(2,6).toInt
      println(m)
    }
  }
}

Measured memory_bytes: 44208
#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>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
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 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 complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    int ans = 0;
    rep(i, N) {
        int a; cin >> a;
        ans += (a - 1);
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
N=int(input())
list =[input() for i in range(N)]
count_AC=0
count_WA=0
count_TLE=0
count_RE=0
for i in range(N):
    if list[i] == "AC":
        count_AC+=1
    elif list[i] == "WA":
        count_WA+=1
    elif list[i] == "TLE":
        count_TLE+=1
    elif list[i] == "RE":
        count_RE+=1
print("AC x "+str(count_AC))
print("WA x "+str(count_WA))
print("TLE x "+str(count_TLE))
print("RE x "+str(count_RE))


Measured memory_bytes: 16292
import sys
sys.setrecursionlimit(500000)

N = int(sys.stdin.buffer.readline())

neighbor = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, sys.stdin.buffer.readline().split())
    neighbor[a-1].append([b-1, i])
    neighbor[b-1].append([a-1, i])

K = max(len(l) for l in neighbor)
print(K)
ans = [-1]*(N-1)

def dfs(current_point, parent_point, parent_edge_color):
    color = 1
    for next_point, idx in neighbor[current_point]:
        if next_point != parent_point:
            if parent_edge_color == color:
                color += 1
            ans[idx] = color
            dfs(next_point, current_point, color)
            color += 1

dfs(0, -1, -1)
print("\n".join(map(str, ans)))

Measured memory_bytes: 78360