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

int main()
{
    int a,b,c,d;

    cin >> a >> b >> c >> d;

    if ((a == 1 || a == 3 || a == 5 || a == 7 || a == 8 || a == 10 || a == 12) && b == 31){
        puts("1");
    } else if((a == 4 || a == 6 || a == 9 || a == 11) && b == 30){
        puts("1");
    } else if((a == 2) && b == 28){
        puts("1");
    } else {
        puts("0");
    }
    return 0;
}

Measured memory_bytes: 256
def function(X):
    if X < 600:
        return 8
    elif X < 800:
        return 7
    elif X < 1000:
        return 6
    elif X < 1200:
        return 5
    elif X < 1400:
        return 4
    elif X < 1600:
        return 3
    elif X < 1800:
        return 2
    else:
        return 1


if __name__ == '__main__':
    X = int(input())
    print(function(X))


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

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

  vector<int> obs(n + 1);
  vector<vector<int> > roads(n + 1);
  vector<int> has_road(n + 1, 0);

  rep(i, n) {
    int h;
    cin >> h;
    obs[i + 1] = h;
  }

  rep(i, m) {
    int a, b;
    cin >> a >> b;

    if (obs[a] < obs[b]) {
      roads[a].push_back(b);
    }

    if (obs[b] < obs[a]) {
      roads[b].push_back(a);
    }

    if (obs[a] == obs[b]) {
      has_road[a] = 1;
      has_road[b] = 1;
    }
  }

  int count = 0;

  rep(i, n) {
    if (roads[i + 1].size() == 0) {
      if (!has_road[i + 1]) {
        count++;
      }
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 8240
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5+3;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	int h,w;
	cin>>h>>w;
	vector<string> s;
	rep(i,h){
		string s_;
		cin>>s_;
		bool ok = true;
		rep(j,w){
			if(s_[j] == '#'){
				ok = false;
				break;
			}
		}
		if(ok) continue;
		s.push_back(s_);
	}
	vector<string> ans;
	rep(i,s.size()){
		ans.push_back("");
	}
	rep(j,s[0].size()){
		bool ok = true;
		rep(i,s.size()){
			if(s[i][j] == '#'){
				ok = false;
				break;
			}
		}
		if(ok) continue;
		rep(i,s.size()){
			ans[i].push_back(s[i][j]);
		}
	}
	rep(i,s.size()){
		cout<<ans[i]<<endl;
	}


	return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string str;
    getline(cin, str);
    for(int i=str.length()-1; i>=0; --i) {
        cout.put(str[i]);
    }
    cout.put('\n');
    return 0;
}



Measured memory_bytes: 3136
#include<stdio.h>

int main()
{
    char s[105];
    int a[26]={0};
    scanf("%s",s);
    int i;
    for(i=0;s[i]!='\0';i++)
    {
        a[s[i]-97]++;
    }
    int f=0;
    for(i=0;i<26;i++)
    {
        if(a[i]%2==1){
            f=1;
            break;
        }
    }
    if(f==0) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, k; cin >> n >> k;
	int mx = (n - 1)*(n - 2) / 2;
	if (mx < k)
	{
		puts("-1");
		return 0;
	}

	vector<pair<int,int>> ans;
	rep(i, 2, n)ans.push_back({ 1,i });
	int rem = mx - k;
	rep(i, 2, n)rep(j, i + 1, n)
	{
		if (rem <= 0)break;

		ans.push_back({ i,j });
		--rem;
	}
	cout << ans.size() << endl;
	for (pair<int, int> x : ans)cout << x.first << " " << x.second << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include <string>
#include<algorithm>
#include <set>
#include <cmath>
using namespace std;
typedef long long lint;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep0(i,n) rep(i,0,n)

int main(void){
	ios::sync_with_stdio(false);
	int A, B, i, j, k, num;
	cin >> A >> B;
	num = 1;
	for (i = 0; i <= 20; i++) {
		if (num >= B) {
			k = i;
			break;
		}
		num += A - 1;
	}
	cout << k;
	return 0;
}
//
////sort Ｎ個の配列a
//sort(a, a + N); //昇順
//sort(a, a + N, greater<int>()); //降順
//
////最大公約数（ユークリッドの互除法利用）
//int gcd(int a, int b) {
//	if (a == 0) return b;
//	if (b == 0) return a;
//	int m = max(a, b);
//	int n = min(a, b);
//	if (m%n == 0) return n;
//	else return gcd(n, m%n);
//
//}
//
////最小公倍数
//int lca(int a, int b) {
//	if (a == 0) return 0;
//	if (b == 0) return 0;
//	return a * b / gcm(a, b);
//}
//
////n^k(整数)
//int pow_int(int n, int k) {
//	int re = 1;
//	for (int i = 0; i < k; i++) re *= n;
//	return re;
//}


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


int near_x(set<int> p, int x, int width){
    if(!(p.count(x - width))){
        return x - width;
    }
    else if (!(p.count(x + width))){
        return x + width;
    }
    else{
        return near_x(p, x, width+1);
    }
}

int main(){
    int x, n;
    cin >> x >> n;
    set<int> p;
    for (int i = 0; i < n; i++){
        int a;
        cin >> a;
        p.insert(a);
    }
    if(p.count(x)){
        int ans = near_x(p, x, 1);
        cout << ans << endl;
    }
    else{
        cout << x << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3836
#include<stdio.h>
int main(){
	int baris, kolom;
	for(int i=0; ; i++){
		scanf("%d %d", &baris, &kolom);
		if(baris==0 && kolom == 0){
			break;
		}
		else{
			for(int j=0; j<baris; j++){
				for(int k=0; k<kolom; k++){
					if((j+k)%2==0)printf("#");
					else printf(".");
				}
				printf("\n");
			}
			printf("\n");
		}
	}
}


Measured memory_bytes: 2600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if((a+11)%13>(b+11)%13){cout<<"Alice";}
  else if((a+11)%13<(b+11)%13){cout<<"Bob";}
  else{cout<<"Draw";}
}


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

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define EACH(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

struct HeavyLight {
  int pathCount,n;
  vector<int>size,parent,in,out,path,pathRoot;
  vector<vector<int> > tree;

  HeavyLight(vector<vector<int> > t)
    :pathCount(0),n(t.size()),size(n),parent(n),in(n),out(n),
     path(n),pathRoot(n),tree(t){
    int time=0;
    dfs(0,-1,time);
    buildPaths(0,newPath(0));
  }

  void dfs(int u, int p, int &k){
    in[u]=k++, parent[u]=p, size[u]=1;
    EACH(v,tree[u])if(*v!=p)dfs(*v, u, k),size[u]+=size[*v];
    out[u]=k++;
  }

  int newPath(int u){ pathRoot[pathCount]=u; return pathCount++; }

  void buildPaths(int u, int pt){
    path[u]=pt;
    EACH(v,tree[u])if(*v != parent[u])
      buildPaths(*v, 2*size[*v] >= size[u] ? pt : newPath(*v));
  }

  bool isAncestor(int p, int ch){
    return in[p] <= in[ch] && out[ch] <= out[p];
  }

  int lca(int a,int b){
    for(int root; !isAncestor(root=pathRoot[path[a]],b);a=parent[root]);
    for(int root; !isAncestor(root=pathRoot[path[b]],a);b=parent[root]);
    return isAncestor(a,b)?a:b;
  }
};

//Usage: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_C
int main(void){
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<vector<int> >tree(n);
  
  REP(i,n){
    int k;
    cin >> k;
    REP(j,k){
      int ch;
      cin >> ch;
      tree[i].push_back(ch);
    }
  }

  HeavyLight hl = HeavyLight(tree);

  int q;
  cin >> q;
  while(q--){
    int u,v;
    cin >> u >> v;
    cout << hl.lca(u,v) << "\n";
  }
  
  return 0;
}

Measured memory_bytes: 23904
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
int mo[12]={31,28,31,30,31,30,31,31,30,31,30,31};
bool is_leap(int a){
	if(a%400==0) return true;
	if(a%100==0) return false;
	if(a%4==0) return true;
	return false;
}
int foo2(int y1,int m1,int d1,int y2,int m2,int d2){
	int ret=0;
	while(!(y1==y2&&m1==m2&&d1==d2)){
		ret++;
		// int t;
		// cin>>t;
		// cout<<y1<<" "<<m1<<" "<<d1<<endl;
		if(m1==12&&d1==31){
			y1++;
			m1=1;
			d1=1;
		}
		else if(is_leap(y1)&&m1==2){
			if(d1==29){
				m1++;
				d1=1;
			}
			else{
				d1++;
			}
		}
		else if(mo[m1-1]>d1){
			d1++;
		}
		else{
			m1++;
			d1=1;
		}
	}
	return ret;
}
int foo(int y,int m,int d){
	bool f=is_leap(y);
	int ret=0;
	while(m<=12){
		if(m==2&&f){
			ret+=mo[m-1]-d+2;
		}
		else{
			ret+=mo[m-1]-d+1;
		}
		m++;
		d=1;
	}
	// cout<<"ret "<<ret<<endl;
	return ret;
}


void mainmain(){
	vint a(6);
	while(1){
		rep(i,6){
			cin>>a[i];
			if(a[i]==-1) return;
		}
		cout<<foo2(a[0],a[1],a[2],a[3],a[4],a[5])<<endl;
		continue;
		int ans=0;
		if(a[0]==a[3]){
			cout<<-foo(a[3],a[4],a[5])+foo(a[0],a[1],a[2])<<endl;
			continue;
		}
		rep(i,2) ans+=foo(a[0+i*3],a[1+i*3],a[2+i*3]);
		ans-=365;
		if(is_leap(a[3])&&(a[4]==1||a[4]==2)) ans--;
		a[0]++;
		while(a[0]!=a[3]){
			 if(is_leap(a[0])) ans++;
			 ans+=365;
			 a[0]++;
		}
		cout<<ans<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1192
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
i=0
mx=0
lol=0
while i<n and a[i]<=k:
    k-=a[i]
    i+=1
    mx+=1
    lol=1
j=0
while j<m and b[j]<=k:
    k-=b[j]
    j+=1
    mx+=1
cou=mx

i-=1
while i>=0 and j<m:
    k+=a[i]
    i-=1
    cou-=1
    while j<m and b[j]<=k:
        k-=b[j]
        cou+=1
        j+=1
    mx=max(cou,mx)
print(mx)

Measured memory_bytes: 117368
#include <iostream>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

int main() {
    int n,m;cin>>n>>m;
    int ans=0,a[n],b[n];
    int from,to;
    
    rep(i,n)a[i]=1,b[i]=0;
    b[0]=1;

    rep(i,m){
        cin>>from>>to;
        if(b[from-1]==1 )b[to-1]=1;
        if(a[from-1]==1 && b[from-1]==1)b[from-1]=0;
        a[from-1]-=1;
        a[to-1]+=1;
    }
    rep(i,n)ans+=b[i];
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

ll c[11][11] = {};
void warshalfloyd(int n) {
	rep(k, 0, n) {
		rep(i, 0, n) {
			rep(j, 0, n) {
				c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
			}
		}
	}
}

int main() {
	ll h, w; cin >> h >> w;
	rep(i, 0, 10)rep(j, 0, 10)cin >> c[i][j];
	warshalfloyd(10);

	ll ans = 0;
	rep(i, 0, h)rep(j, 0, w) {
		ll a; cin >> a;
		if (a != -1 && a != 1) {
			ans += c[a][1];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mx 1002
#define endl "\n"
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define fi first
#define se second
#define fr(i,a,b) for(int i=a;i<=b;i++  )
#define pii pair<int,int>
using namespace std;
int main()
{
    int x,y,a,b;
    cin>>x>>y;
    cin>>a>>b;
    int ans;
    ans=(x-a)*(y-b);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int a, b, d, r;
  double f;
  scanf("%d %d" ,&a ,&b);

  if ((1<=a && a<=1000000000)&&(1<=b && b<=1000000000)) {
    d=a/b;
    r=a%b;
    f=(double)a/b;
  }
  printf("%d %d %8.5f\n" ,d ,r ,f);
  return 0;

}

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

char str[20];
int dp[20][2];
void solve(int i, int j, int k, int d){
	if(k)dp[i+1][1] = max(dp[i+1][1], j+dp[i][1]);
	else {
		if(j < d)dp[i+1][1] = max(dp[i+1][1], j+dp[i][0]);
		if(j == d)dp[i+1][0] = max(dp[i+1][0], j+dp[i][0]);
	}
}

int main(){
	scanf("%s", str);
	int n = strlen(str);
	fill((int*)dp, (int*)(dp+20), -inf);
	dp[0][0] = 0;
	rep(i,n)rep(j,10)rep(k,2){
		int d = str[i]-'0';
		solve(i, j, k, d);
	}
	printf("%d\n", max(dp[n][0], dp[n][1]));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(int i=p;i<n;++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

int N;

const int MAXN = 100000;
ll A[MAXN], B[MAXN], C[MAXN];

ll R[MAXN];
vector<ll> G[MAXN];

ll CC[MAXN];

int main()
{
    cin >> N;

    ll max_rv = 0;
    ll max_ri = -1;

    rep(i, N - 1)
    {
        ll a, b;
        cin >> a >> b;
        --a;
        --b;

        ++R[a];
        ++R[b];

        if (R[a] >= max_rv)
        {
            max_rv = R[a];
            max_ri = a;
        }

        if (R[b] >= max_rv)
        {
            max_rv = R[b];
            max_ri = b;
        }

        G[a].push_back(b);
        G[b].push_back(a);

        A[i] = a;
        B[i] = b;
    }

    rep(i, N)
    {
        cin >> C[i];
    }

    sort(C, C + N);
    reverse(C, C + N);

    fill(CC, CC + N, -1);

    priority_queue<pll> Q;
    Q.push(pll(max_rv, max_ri));

    ll ci = 0;

    while (!Q.empty())
    {
        const auto p = Q.top(); Q.pop();

        const auto value = p.first;
        const auto index = p.second;

        // cout << "index=" << index << ", value=" << value << ", C=" << C[ci] << endl;

        CC[index] = C[ci];
        ++ci;

        for (const auto nextIndex : G[index])
        {
            if (CC[nextIndex] != -1) { continue; }
            Q.push(pll(R[nextIndex], nextIndex));
        }
    }

    ll ans = 0;

    rep (i, N - 1)
    {
        const auto ca = CC[A[i]];
        const auto cb = CC[B[i]];

        ans += min(ca, cb);
    }

    // cout << "ans=" << ans << endl;
    cout << ans << endl;

    rep (i, N)
    {
        cout << CC[i] << endl;
    }

    return 0;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    cout << (A - 1) * (B - 1) << endl;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	int count = 0;
	for (int i = 1;i <= n; i++) {
		if (to_string(i).length() % 2 == 1) {
			count += 1;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
/*  */
#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <deque>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <cctype>
#include <cassert>
#include <functional>
#include <iterator>
#include <iomanip>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,1024000")

#define sti				set<int>
#define stpii			set<pair<int, int> >
#define mpii			map<int,int>
#define vi				vector<int>
#define pii				pair<int,int>
#define vpii			vector<pair<int,int> >
#define rep(i, a, n) 	for (int i=a;i<n;++i)
#define per(i, a, n) 	for (int i=n-1;i>=a;--i)
#define clr				clear
#define pb 				push_back
#define mp 				make_pair
#define fir				first
#define sec				second
#define all(x) 			(x).begin(),(x).end()
#define SZ(x) 			((int)(x).size())
#define lson			l, mid, rt<<1
#define rson			mid+1, r, rt<<1|1
#define getBits(x)		__builtin_popcount(x)
#define getBitIdx(x)	__builtin_ffs(x)


typedef long long LL;
int a[15];

void init() {
	{
		int b[] = {1,3,5,7,8,10,12};
		int n = sizeof(b) / sizeof(int);
		rep(i, 0, n)
			a[b[i]] = 1;
	}
	{
		int b[] = {4,6,9,11};
		int n = sizeof(b) / sizeof(int);
		rep(i, 0, n)
			a[b[i]] = 2;
	}
	{
		a[2] = 3;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// #ifndef ONLINE_JUDGE
		// freopen("data.in", "r", stdin);
		// freopen("data.out", "w", stdout);
	// #endif
	
	int x, y;
	
	init();
	cin >> x >> y;
	if (a[x] == a[y])
		puts("Yes");
	else
		puts("No");

	// #ifndef ONLINE_JUDGE
		// printf("time = %ldms.\n", clock());
	// #endif

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int V[N],C[N],R[N];
  for (int i=0;i<N;i++){
    cin >> V[i];
  }
  for (int i=0;i<N;i++){
    cin >> C[i];
  }
  int sum=0;
  for (int i=0;i<N;i++){
    int R=V[i]-C[i];
    if (R>0){
      sum+=R;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;

int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        for(int j=i+1;j<s.length();j++){
            if(s[i]==s[j]){
                cout<<"no"<<endl;
                return 0;
            }
        }
    }
        cout<<"yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
// AOJ 1284 The Teacher's Side of Math
// 2018.3.9 bal4u

#include <stdio.h>
#include <string.h>
#include <math.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

#define EPS        1e-8
#define N 23

double A[N][N], C[N];		// 行列の係数と右側
double X[N];				// 解
double B[N][N];				// ワーキング行列

// AX=C, 不定解時のリターン値はゼロ、正常な終了値は１
int gauss_jordan(int n)		// n x n 行列の大きさ
{
	int i, j, k, pivot;
	double t;

	for (i = 0; i < n; i++) for (j = 0; j < n; j++) B[i][j] = A[i][j];
	for (i = 0; i < n; i++) B[i][n] = C[i];

	for (i = 0; i < n; i++) {
		pivot = i;
		for (j = i; j < n; j++) {
			if (fabs(B[j][i]) > fabs(B[pivot][i])) pivot = j;
		}
		for (j = 0; j <= n; j++) {					// swap(B[i],B[pivot]);
			t = B[i][j], B[i][j] = B[pivot][j], B[pivot][j] = t;
		}
		if (fabs(B[i][i]) < EPS) return 0;			// error

		for (j = i+1; j <= n; j++) B[i][j] /= B[i][i];
		for (j = 0; j < n; j++) if (i != j) {
			for (k = i+1; k <= n; k++) B[j][k] -= B[j][i]*B[i][k];
		}
	}
	for (i = 0; i < n; i++) X[i] = B[i][n];
	return 1;
}

long long comb[N][N];

long long calc(int a, int p)
{
	long long ans = 1;
	while (p--) ans *= a;
	return ans;
}

int main()
{
	int a, m, b, n, mn, i, j;
	long long c;

	for (i = 0; i <= 21; i++) for (j = 0; j <= i; j++) {
		if (j == 0 || j == i) comb[i][j] = 1;
		else comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
	}

	while (a = in()) {
		m = in(), b = in(), n = in(), mn = m*n;

		memset(A, 0, sizeof(A));
		memset(C, 0, sizeof(A));
		A[0][0] = 1, C[0] = 1;
		for (i = 0; i <= mn; i++) for (j = 0; j <= i; j++) {
			c = comb[i][j] * calc(a, j/m) * calc(b, (i-j)/n);
			A[(j%m)*n+(i-j)%n+1][i<mn? i+1: 0] += c;
		}

		gauss_jordan(mn+1);
		putchar('1');
		for (i = mn; i > 0; i--) printf(" %d", (int)round(X[i]));
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 1924
import java.util.Scanner;

/**
 * https://abc057.contest.atcoder.jp/tasks/abc057_c
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		sc.close();
		
		long a = (int) Math.sqrt(N)+1;
		long b = 0;
		for(; a>=1; a--){
			if(N%a==0){
				b=N/a;
				break;
			}
		}
		
		System.out.println(Math.max(String.valueOf(a).length(), String.valueOf(b).length()));

	}

}

Measured memory_bytes: 21716
//#include<bits/stdc++.h>
#include<iostream>
//#include<vector>
//#include<algorithm>
using namespace std;
//#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, n,m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i,n) for(int i = (int)(n - 1);i > -1;i--)

//#define ALL(V) (V).begin(),(V).end()
//#define SORT(V) sort(ALL(V))

typedef long long ll;

//vector<string> split(string,string);

//template<typename T>
//void swap(T*,T*);

//char ToUpper (char cX) { return toupper(cX); }

//void isR(string s);

//ll pow(ll,ll);


int main()
{
    ll N,A,B;
    cin >> N >> A >> B;
    ll times = N / (A+B);
    ll count = times * A;
    ll remain = N % (A+B);
    if(remain < A)
    {
        cout << count + remain;
    }
    else
    {
        cout << count + A;
    }
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

int main(void) {
    string s;
    cin >> s;

    int first_zero = 0;
    REP(i, s.length()) {
        if (i % 2 == 0 && s[i] != '0') first_zero++;
        else if (i % 2 == 1 && s[i] != '1') first_zero++;
    }

    int first_one = 0;
    REP(i, s.length()) {
        if (i % 2 == 0 && s[i] != '1') first_one++;
        else if (i % 2 == 1 && s[i] != '0') first_one++;
    }

    cout << min(first_zero, first_one) << endl;

    return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int ans;
		int count = S.length();
		String[] colorArray = S.split("");;

		int start0 = 0;
		int start1 = 0;

		String lastLetter = "0";
		for(int i=0; i<count; i++){
			if(!colorArray[i].equals(lastLetter)){
				start0++;
			}
			if(lastLetter.equals("0")){
				lastLetter = "1";
			}else{
				lastLetter = "0";
			}
		}

		lastLetter = "1";

		for(int i=0; i<count; i++){
			if(!colorArray[i].equals(lastLetter)){
				start1++;
			}
			if(lastLetter.equals("0")){
				lastLetter = "1";
			}else{
				lastLetter = "0";
			}
		}


		System.out.println(Math.min(start0, start1));

	}


}


Measured memory_bytes: 34384
solve [a, b] = f 0 (b-a) (a-1)
    where f n x y
            | x <= n*y  = n + 1
            | otherwise = f (n+1) x y

main = map read . words <$> getLine >>= print . f
    where f [a, b] = if b == 1 then 0 else solve [a, b]


Measured memory_bytes: 508
n,k = map(int, input().split())
r,s,p = map(int, input().split())
t = input()

ans=0
win=[0]*n
for i in range(len(t)):
    if i-k>=0 and win[i-k] == 1 and t[i]==t[i-k]:
        pass
    else:
        if t[i] == "r":
          ans+=p
        if t[i] == "s":
            ans+=r
        if t[i] == "p":
            ans+=s
        win[i]=1

print(ans)

Measured memory_bytes: 42864
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,k=map(int,input().split())
    H=[0]+list(map(int,input().split()))

    # dp[i][j] : i番目の要素をj個目に採用したときのcostのmin
    dp=[[INF]*(n-k+1) for i in range(n+1)]
    dp[0][0]=0

    for i in range(1,n+1):
        for j in range(1,n-k+1):
            dp[i][j]=min(dp[k][j-1]+max(0,H[i]-H[k]) for k in range(i))


    print(min(dp[i][n-k] for i in range(n+1)))
resolve()

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

int main(void){
    int a,b,c;
    cin >> a >> b >> c;

    if(0 <= a && a <= 100 && 0 <= b && b <= 100 && 0 <= c && c <= 100){
        if(a < b && b < c && a < c){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  long long x; // typedef long long ll;
  mint(long long x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint choose(int n, int a){
  mint x = 1, y=1;
  for(int i=0;i<a;i++){
    x *= n-i;
    y *= i+1;
  }
  return x/y;
}

int main(){
  long long n,a,b;
  cin >> n >> a >> b;

  mint ans=2, ans1, ans2;
  ans = ans.pow(n)-1;
  ans1 = choose(n, a);
  ans2 = choose(n, b);
  // cout << ans.x << endl;
  // cout << ans1.x << endl;
  // cout << ans2.x << endl;
  ans -= ans1;
  ans -= ans2;
  cout << ans.x;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define endl "\n"

const double PI = acos(-1.0);
 
int main ()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //#define int ll
  
  double a, b, h, m;
  cin >> a >> b >> h >> m;

  double angle = (60*h - 11*m)/2;

  angle *= PI;
  angle /= 180;

  cout << fixed << setprecision(12);
  double ans = a*a + b*b - 2*a*b*cos(angle);
  cout << sqrt(ans) << endl;

  return 0;
  
}


Measured memory_bytes: 4128
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

int l[100] = {0};
int main()
{
  int n, maxHen = 0, maxHenIdx = 0;
  int sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> l[i];
    if (max(maxHen, l[i]) == l[i]) {
      maxHen = l[i];
      maxHenIdx = i;
    }
  }
  l[maxHenIdx] = 0;

  for (int i = 0; i < n; i++) {
    sum += l[i];
  }

  if (maxHen < sum) {
    cout << "Yes"<< endl;
  } else {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
/////////////////////////////////
int main()
{
    int n;
    cin >> n;
    vector<ll> a(n + 1), b(n);
    rep(i, n + 1) cin >> a[i];
    rep(i, n) cin >> b[i];
    ll ans = 0;
    rep(i, n)
    {
        ll k;
        k = min(a[i], b[i]);
        ans += k;
        b[i] -= k;
        k = min(a[i + 1], b[i]);
        ans += k;
        a[i + 1] -= k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4752
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll N,M;
  cin >> N >> M;
  int A[N],B[M];
  int Acnt[1100000];
  int Bcnt[1100000];
  ll a = 0;
  ll b = 0;
  ll ans = 1;
  for (int i = 0; i < 1100000; i++) {
    Acnt[i] = 0; Bcnt[i] = 0;
  }
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    Acnt[A[i]]++;
  }
  for (int i = 0; i < M; i++) {
    cin >> B[i];
    Bcnt[B[i]]++;
  }
  for (int i = N*M; i >= 1; i--) {
    int s = Acnt[i] + Bcnt[i];
    if (s > 2) {
      ans = 0;
    } else if (s == 2) {
      ans *= 1;
      a++; b++;
    } else if (s == 1) {
      if (Acnt[i] == 1) {
        ans *= b;
        a++;
      } else {
        ans *= a;
        b++;
      }
    } else {
      ll c = a*b;
      c -= ((N*M) - i);
      ans *= c;
    }
    ans %= Mod;
  }
  if (a == N && b == M) {
    cout << ans << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}

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

class Program
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var datas = Enumerable.Range(0, n - 1).Select(index => {
			var csf = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number));
			return new {
				C = csf[0],
				S = csf[1],
				F = csf[2],
			};
		}).ToArray();

		var counts = new List<int>();
		for (var i = 0; i < n - 1; ++i) {
			var count = 0;
			for(var j = i; j < n - 1; ++j) {
				var data = datas[j];
				if (count == 0) {
					count = data.S + data.C;
				} else {
					if (count > data.S) {
						if (count % data.F == 0) {
							count += data.C;
						} else {
							var wait = data.F - (count % data.F);
							count += wait + data.C;
						}
					} else {
						count = data.S + data.C;
					}
				}
			}

			counts.Add(count);
		}

		counts.ForEach(count => Console.WriteLine(count));
		Console.WriteLine(0);

		Console.ReadKey();
	}
}


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define ins insert
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)9e18);
const int ninf=((int)-9e18);
const int mod=1000000007;

using namespace std;

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int n,r;
    cin>>n>>r;

    if(n>=10)
    {
        cout<<r;
    }
    else
    {
        cout<<r+100*(10-n);
    }


    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  rep(i, N) cin >> H[i];
  sort(H.begin(), H.end());
  K = min(K, N);
  rep(i, K) H.pop_back();
  ll ans = 0;
  rep(i, sz(H)) ans += H[i];
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 4028
// AOJ 2242 "Era Name" (ICPC模擬地区予選 2010 Problem A)
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        while (true) {
            int n = sc.nextInt();
            int q = sc.nextInt();
            if (n == 0) {
                break;
            }
            
            Era[] era = new Era[n];
            for (int i = 0; i < n; i++) {
                String name = sc.next();
                int eraBasedYear = sc.nextInt();
                int westernYear = sc.nextInt();
                era[i] = new Era(name, eraBasedYear, westernYear);
            }
            Arrays.sort(era);
            
            for (int i = 0; i < q; i++) {
                int year = sc.nextInt();
                
                for (int j = 0; j < era.length; j++) {
                    if (era[j].first <= year && year <= era[j].last) {
                        System.out.println(era[j].name + " " + (year - era[j].first + 1));
                        break;
                    } else if (year < era[j].first || j == era.length - 1) {
                        System.out.println("Unknown");
                        break;
                    }
                }
            }
        }
    }
}

class Era implements Comparable<Era> {
    String name;
    int first;
    int last;
    
    Era(String name, int base, int western) {
        this.name = name;
        this.first = western - base + 1;
        this.last = western;
    }
    
    public int compareTo(Era o) {
        return this.first - o.first;
    }
}

Measured memory_bytes: 63988
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <cfenv>
using ll = unsigned long long;
using namespace std;
int gcd(int x,int y){
    if(y==0){
        return x;
    }else{
        return gcd(y,x%y);
    }
}
int lcm(int x,int y){
    return x/gcd(x,y)*y;
}
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b&&b==c){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fore(i,a,b) for(int i = a; i < b; i++)
#define fst first
#define snd second
#define ll long long
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int>
#define piii pair<int, pii>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;

const int N_MAX = 1e6+15;

int main(){
    int A,B;
    cin>>A>>B;
    cout<<A*B<<endl;
    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    System.out.println(Math.max(c - (a - b), 0));

  }
}

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

ll n;
string s;

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

    cin>>s;
    n=s.size();

    for(ll i=0;i<26;i++)
    {
        char c='a'+i;
        for(ll i=1;i<n;i++)
        {
            if(s[i]==s[i-1])
            {
                cout<<i-1+1<<" "<<i+1<<endl;
                return 0;
            }
        }
        for(ll i=2;i<n;i++)
        {
            if(s[i]==s[i-2])
            {
                cout<<i-2+1<<" "<<i+1<<endl;
                return 0;
            }
        }
    }


    cout<<-1<<" "<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int m[101][101][210];

bool f(int x, int y, int k){
    if(m[x][y][k] != -1) return m[x][y][k];
    if(x <= 1 && y <= 1){
        // cout << x << " " << y << " " << k << " " << 0 << endl;
        return m[x][y][k] = false;
    }
    bool res = true;
    rep(i, 1, x / 2 + 1){
        res &= f(x - 2 * i, y + i, k + 1);
    }
    rep(i, 1, y / 2 + 1){
        res &= f(x + i, y - 2 * i, k + 1);
    }
    // cout << x << " " << y << " " << k << " " << res << " " << !res << endl;
    return m[x][y][k] = !res;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, y;
    cin >> x >> y;
    // memset(m, -1, sizeof(m));
    // // cout << f(x, y, 0) << endl;
    // rep(i, 0, x + 1){
    //     rep(j, 0, y + 1){
    //         cout << f(i, j, 0) << " ";
    //     }
    //     cout << endl;
    // }
    if(abs(x - y) <= 1) cout << "Brown" << endl;
    else cout << "Alice" << endl;
}

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

map<ll, ll> mp;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int k;cin>>k;
  cout<<k/2*(k/2+(k%2==0?0:1))<<endl;

  return 0;
}


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

// calculate |gcd|.
// if  ether num is 0, return 0
long long GCD(long long left, long long right) {
  if(left == 0 || right == 0) return 0;
  if(left < 0) left *= -1;
  if(right < 0) right *= -1;
  if(left < right) swap(left, right);
  long long nextnum, ansgcd = -1;
  while(ansgcd == -1) {
    nextnum = left % right;
    if(nextnum == 0) ansgcd = right;
    left = right;
    right = nextnum;
  }
  return ansgcd;
}

long long LCM(long long left, long long right) {
  return left / GCD(left, right) * right;
}

long long n, ans = 1;

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    ans = LCM(ans, x);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<string>
#include <iomanip> 
#include <stack> 
#include <cmath> 

#define maxn 100001
#define LL long long
#define inf 10000000000
#define mod 1000000007
#define pi 3.14159265359
using namespace std;
int dx[9] = { 1,0,-1,0,1,1,-1,-1 };
int dy[9] = { 0,1,0,1,1,-1,1,-1 };


LL n, m, k;
LL arr[maxn];
LL arr2[maxn];
int visit[maxn][2];
//int cache[maxn];
//int c[maxn];
//int g[maxn];
//int dfsnum = 0;
//vector<vector<int>>rvi;
//vector<vector<int>>scc;
//vector<pair<int, int>>ett;
//stack<int>st;
//bool flg = 1;
//LL s, d;
//
//int findp(int a) {
//	if (a == c[a])return a;
//	return c[a] = findp(c[a]);
//}
//void unionp(int a, int b) {
//	a = findp(a);
//	b = findp(b);
//
//	if (g[a] < g[b])swap(a, b);
//	c[b] = a;
//	g[a] += g[b];
//	g[b] = 1;
//
//}
//LL power(LL x, LL y) {
//	LL ret = 1;
//	while (y > 0) {
//		if (y % 2) {
//			ret *= x;
//			ret %= mod;
//		}
//		x *= x;
//		x %= mod;
//		y /= 2;
//	}
//	return ret;
//}
//void dfs2(int v) {
//	cache[v] = 1;
//	scc.back().push_back(v);
//	for (int nv : rvi[v]) {
//		if (cache[nv])continue;
//		dfs2(nv);
//	}
//
//}
//LL fac(LL n) {
//	if (n == 1) return 1;        
//	return (n * fac(n - 1) - power(2,n-1) )%mod;
//}
//int fac2(LL n) {
//	LL res, i;
//	if (n == 1)return n;
//	res = n;
//	for (int i = n - 1; i > 0; --i) {
//		res *= i;
//		res %= mod;
//	}
//	return res;
//}

LL gcd(LL a, LL b) {
	while (b != 0) {
		LL r = a % b;
		a = b;
		b = r;
	}
	return a;
}
vector<LL>vi;
vector<vector<int>>graph;
void dfs(int v, int p) {
	arr2[v] = 1;
	for (int nv : graph[v]) {
		if (nv == p)continue;
		dfs(nv, v);
		arr2[v] += arr2[nv];
	}
	if (p != 0)
		vi.push_back(arr2[v] * (n - arr2[v]));
}

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

	//int t;   cin >> t; cin.ignore();
	int t = 1;
	for (int test_case = 0; test_case < t; ++test_case) {
		int flg = 1;
		LL ans1 = 0, ans2 = 0;
		string ans[2] = { "No","Yes"};
		string s;
		cin >> s;
		LL sum = 0;
		for (int i = 0; i < s.size(); ++i) {
			sum += s[i] -'0';
		}
		if (sum % 9)flg = 0;


		cout << ans[flg]<< '\n';
	}
	return 0;
}


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

// one-based numbering
template<class Abel> struct UnionFind {
    vector<int> data;
    vector<Abel> diff_weight;

    UnionFind(int n, Abel identity) {
      data.resize(n+1, -1);
      diff_weight.resize(n+1, identity);
    }
    int find(int x) {
        if(data[x] < 0) return x;
        else {
          int root = find(data[x]);
          diff_weight[x] += diff_weight[data[x]];
          return data[x] = root;
        }
    }
    int size(int x) {
      return -data[find(x)];
    }
    bool same(int x, int y) {
        x = find(x); y = find(y);
        return x == y;
    }
    bool unite(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = find(x); y = find(y);
        if(x == y) return false;
        if (data[x] > data[y]) swap(x, y), w = -w;
        data[x] += data[y];
        data[y] = x;
        diff_weight[y] = w;
        return true;
    }
    Abel weight(int x) {
        find(x);
        return diff_weight[x];
    }
    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};


int main(){
  int n, m; cin >> n >> m;
  UnionFind<int> uf(n, 0);
  for (int i = 0; i < m; i++) {
    int left, right, dist; cin >> left >> right >> dist;
    if (uf.same(left, right)) {
      if (uf.diff(left, right) != dist) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      uf.unite(left, right, dist);
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashMap;
import java.util.NoSuchElementException;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		long[] A = new long[N];
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextLong();
		}
		Arrays.sort(A);
		boolean even = true;
		for (int i = 0; i < N; ++i) {
			even &= A[i] % 2 == 0;
		}
		if (even) {
			System.out.println("second");
		} else {
			System.out.println("first");
		}
	}

	void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

}

class Scanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}
}


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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int i=0; i<n; i++)
#define FOR1(i, n) for(int i=1; i<=n; i++)
#define FORI(i, n) for(int i=n-1; i>=0; i--)
template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}
template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}
template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, (T)x); }
template<class T, class U, typename... W> void init(vector<T> &v, U x, size_t n, W... m) { v=vector<T>(n);  for(auto& a : v) init(a, x, m...); }

vector<bool> vis;
vector<set<int>> edges;
int dfs(int u){
    int ret = 1;
    vis[u] = 1;
    for(auto v : edges[u]) if (!vis[v]) ret += dfs(v);
    return ret;
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int n, m;
    cin >> n >> m;
    edges.resize(n+1);
    vis = vector<bool>(n+1);
    FOR(i, m){
        int u, v;
        cin >> u >> v;
        edges[u].insert(v);
        edges[v].insert(u);
    }

    int sol = 1;
    FOR1(u, n){
        int nrc = dfs(u);
        umax(sol, nrc);
    }
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}



Measured memory_bytes: 40616
import sys
import os
import itertools
import numpy as np
from collections import deque

def main():
    if os.getenv("ENV")=='LOCAL':
        sys.stdin = open(os.path.dirname(__file__)+'/input.txt', 'r')

    N=int(input())

    # divisors=sieve(N)
    #
    # # print(divisors)
    # sum=0
    # for i,n in enumerate(divisors):
    #     sum+=i*n

    # print(5*(2+5-1)//2)
    print(sieve(N))

def sieve(n):
    # is_prime = [i for i in range(n+1)]
    sum=n*(2+n-1)//2
    # sum=0

    for i in range(2, n+1):
        # print(is_prime)
        d=n//i
        # print(d)
        sum+=d*((d+1)*i)//2
        # sum += i
        # j = 2 * i
        # while j <= n:
        #     sum += j
        #     j += i

    return sum


if __name__ == '__main__':
    main()


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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DBG(a)      cout << #a << " = " << a << endl

const ll inf = 1e15;
const ll mod = 1e9+7;

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

ll C[51][51];

void comb(ll N) {
    memset(C, 0, sizeof(C));
    REP(i, N+1) REP(j, i+1) {
        if (j == 0 or j == i) C[i][j] = 1;
        else C[i][j] = C[i-1][j-1] + C[i-1][j];
    }
}

int main() {
    ll N, A, B; cin >> N >> A >> B;
    vector<ll> v(N); REP(i, N) cin >> v[i];
    
    sort(ALL(v), greater<ll>());
    
    double ans1;
    REP(i, A) ans1 += v[i];
    ans1 /= A;
    
    ll num = 0;
    ll pos = 0;
    REP(i, N) if (v[i] == v[A-1]) {
        num++;
        if (i < A) pos++;
    }
    
    ll ans2 = 0;
    comb(N);
    if (pos == A) FOR(i, A, B+1) ans2 += C[num][i];
    else ans2 += C[num][pos];
    
    cout << fixed << setprecision(9);
    cout << ans1 << endl;
    cout << ans2 << endl;
    
    return 0;
}


Measured memory_bytes: 256
#B
x,y = map(int,input().split())
flg = False
for i in range(101):
    if x - i >= 0:
        a = i
        b = x - a
        if a * 2 + 4 * b == y:
            flg = True
            break
        
if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9180