akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){

int a, b; 
    char op; 
     while(1){ 
         scanf("%d %c %d", &a, &op, &b); 
         if(op=='?'){ 
             break; 
     	}else if(op=='+'){ 
     	    printf("%d\n", a+b); 
     	}else if(op=='-'){ 
     	    printf("%d\n", a-b); 
     	}else if(op=='*'){ 
     	    printf("%d\n", a*b); 
     	}else if(op=='/'){ 
     	    printf("%d\n", a/b); 
         } 
     } 

   
 return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll gcd(ll a, ll b)
{
    if (a < b)
        swap(a, b);
    ll c = a % b;
    if (c == 0)
        return b;
    return gcd(b, c);
}

string solve(ll a, ll b, ll c, ll d)
{
    if (a < b)
        return "No";
    if (d < b)
        return "No";
    if (b <= c)
        return "Yes";

    ll e = gcd(b, d);
    ll f = a % b;
    ll g = (b - f + e - 1) / e - 1;

    if (f + g * e > c)
        return "No";
    return "Yes";
}

int main()
{
    ll T;
    cin >> T;
    REP(i, T)
    {
        ll A, B, C, D;
        cin >> A >> B >> C >> D;
        cout << solve(A, B, C, D) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
s= str(input())
s1, s2, s3, s4 = [int(i) for i in s]
if (s1 == 0 and 1 <= s2 and s2 <= 9) or (s2 == 1 and 0 <= s2 and s2 <= 2):
    if (s3 == 0 and 1 <= s4 and s4 <= 9) or (s3 == 1 and 0 <= s4 and s4 <= 2):
        print("AMBIGUOUS")
    
    else:
        print("MMYY")
else:
    if (s3 == 0 and 1 <= s4 and s4 <= 9) or (s3 == 1 and 0 <= s4 and s4 <= 2):
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3064
N = int(input())

i = 0
j = 0
list = [1]

while(N >= 9**i):
    i += 1
    list.append(9**i)
while(N >= 6**j):
    j += 1
    list.append(6**j)

list.remove(9**i)
list.remove(6**j)
list.sort()

a = [[0 for i in range(N+1)] for j in range(len(list))]

for j in range(N+1):
    a[0][j] = j

for i in range(1,len(list)):
    for j in range(N+1):
        if j < list[i]:
            a[i][j] = min(a[i-1][j], a[i][j-1]+1)
        else:
            a[i][j] = min(a[i-1][j], a[i][j - list[i]]+1)

print(a[len(list)-1][N])


Measured memory_bytes: 28696
// Aizu 1102:   Calculation of Expressions
// 2017.9.12 bal4u@uu

#include <stdio.h>
#include <ctype.h>

#define abs(a) ((a)>=0?(a):-(a))
#define OVER 10000

char buf[200], *p;

int factor(int *r, int *i)
{
	int r1, i1;
	int calc();

	if (*p == '(') { p++; if (!calc(&r1, &i1)) return 0; p++; }
	else if (*p == 'i') p++, r1 = 0, i1 = 1;
	else {
		r1 = i1 = 0;
		while (isdigit(*p)) {
			r1 = 10 * r1 + (*p++ - '0'); if (r1 > OVER) return 0;
		}
	}
	*r = r1, *i = i1;
	return 1;
}

int term(int *r, int *i)
{
	int r1, r2, i1, i2, t;
	long long t1, t2;

	if (!factor(&r1, &i1)) return 0;
	while (1) {
		if (*p == '*') p++;
		else break;
		if (!factor(&r2, &i2)) return 0;

//		rr = r1*r2-i1*i2, ii = r1*i2+i1*r2;
		t1 = (long long)r1 * (long long)r2, t2 = (long long)i1 * (long long)i2,	t1 -= t2;
		if (abs(t1) > 10000ULL) return 0;
		t = (int)t1;
		t1 = (long long)r1 * (long long)i2, t2 = (long long)i1 * (long long)r2,	t1 += t2;
		if (abs(t1) > 10000ULL) return 0;
		r1 = t, i1 = (int)t1;
	}
	*r = r1, *i = i1;
	return 1;
}

int calc(int *r, int *i)
{
	int r1, r2, i1, i2, op;
	
	if (!term(&r1, &i1)) return 0;
	while (1) {
		if      (*p == '+') op = 1;
		else if (*p == '-') op = 0;
		else break;
		p++;
		if (!term(&r2, &i2)) return 0;
		if (op) r1 += r2, i1 += i2;
		else    r1 -= r2, i1 -= i2;
		if (abs(r1) > OVER || abs(i1) > OVER) return 0;
	}
	*r = r1, *i = i1;
	return 1;
}

int main()
{
	int r, i;

	while (fgets(p = buf, 150, stdin) != NULL) {
		if (!calc(&r, &i)) puts("overflow");
		else {
			if (r == 0 && i == 0) puts("0");
			else if (i == 0) printf("%d\n", r);
			else if (r == 0) printf("%di\n", i);
			else printf("%d%+di\n", r, i);
		}
	}
	return 0;
}

Measured memory_bytes: 1760
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 日  9/23 21:01:19 2018

# Usage
#
"""
def get_input():
    return [i for i in input().split(" ")]

def make_it(num_list):
    """
    >>> make_it(['1','5','2'])
    """
    res = list(sorted(num_list, reverse=True))
    st = res[0] + res[1]
    return int(st) + int(res[2])

if __name__ == '__main__':
    print(make_it(get_input()))

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long LL;
LL num[2];
int main(){
	while(~scanf("%lld %lld", &num[0], &num[1])){
		if(abs(num[0] - num[1]) <= 1) printf("Brown\n");
		else printf("Alice\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
#define int long long
// int MOD = 2147483647LL;
int MOD = 2305266692540551LL;
int BASE = 4001;
signed main() {
  ios::sync_with_stdio(false);
  string S, T; cin >> S >> T;
  if(S.size() < T.size()) swap(S, T);
  vector<vector<int>> u(T.size() + 1);
  int alpha[26];
  alpha[0] = 1;
  for(int i = 1; i < 26; ++i) {
    alpha[i] = (alpha[i - 1] * BASE) % MOD;
  }
  for(int l = 1; l <= (int)T.size(); ++l) {
    int hash = 0;
    REP(i,l) {
      hash += alpha[T[i] - 'a'];
      hash %= MOD;
    }
    u[l].push_back(hash);
    // cerr << T.substr(0, l) << " => " << hash << endl;
    for(int i = 1; i < (int)T.size() - l + 1; ++i) {
      hash -= alpha[T[i - 1] - 'a'];
      if(hash < 0) hash += MOD;
      hash += alpha[T[i - 1 + l] - 'a'];
      hash %= MOD;
      u[l].push_back(hash);
      // cerr << T.substr(i, l) << " => " << hash << endl;
    }
    sort(u[l].begin(), u[l].end());
  }
  for(int l = (int)T.size(); l >= 1; --l) {
    int hash = 0;
    REP(i,l) {
      hash += alpha[S[i] - 'a'];
      hash %= MOD;
    }
    if(binary_search(u[l].begin(), u[l].end(), hash)) {
      cout << l << endl;
      return 0;
    }
    // cerr << S.substr(0, l) << " => " << hash << endl;
    for(int i = 1; i < (int)S.size() - l + 1; ++i) {
      hash -= alpha[S[i - 1] - 'a'];
      if(hash < 0) hash += MOD;
      hash += alpha[S[i - 1 + l] - 'a'];
      hash %= MOD;
      // cerr << S.substr(i, l) << " => " << hash << endl;
      if(binary_search(u[l].begin(), u[l].end(), hash)) {
        cout << l << endl;
        return 0;
      }
    }
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 77024
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n,k;
double a[K],s[K],ans;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i]=(a[i]+1.0)/2.0;
		s[i]=s[i-1]+a[i];
	}
	for(int i=1;i<=n-k+1;i++)
		ans=max(ans,s[i+k-1]-s[i-1]);
	cout<<fixed<<setprecision(10)<<ans;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD (int64_t)1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} // input vector

int count(int c, VI &num){
    int res = 0;
    for (int n: num){
        if (n >= c - 1) ++res;
    }
    return res;
}

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

int N; cin >> N;

int cnt = 0;
VI num(N+1, 0); // N! の素因数の個数
rep(i, 2, N+1){
    int n = i;
    for(int j = 2; j * j <= i; ++j){
        while (n % j == 0) {
            ++num[j];
            n /= j;
        }
    }
    if (n != 1) ++num[n];
}

cnt = count(75, num) + count(15, num) * (count(5, num)-1) + count(25, num) * (count(3, num)-1)
    + (count(3, num)-2) * count(5, num) * (count(5, num) -1) / 2;

cout << cnt << "\n";

return 0;
}
// 書いて考える．場合分け．情報整理．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 int A[200005],B[200005],dp[100005][1],i,n,sum,say,a,b,c,d,e,f,mak,S,g,sum2,x,y,m,j,C[1000005],l,r=-1,D[200005],k,T,say1,say2,say3,I,K,bas,son,mid,t,h ;
 //char s[1000005],ch;
vector<int> v1,v2,v;
string s,s1,s2;
 map<char,int> mp[1005];

int main(){

scanf("%d",&n);
//for(i=1;i<=n;i++ ){scanf("%d",&A[i] ); }
cin>>s;
if(n>=3200){cout<<s; return 0; }
else{printf("red"); return 0; }



	return 0;
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;

constexpr int MAXN = 1e5 + 15;

vi g[MAXN];
bool used[MAXN][3];

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

	int n , m;
	cin >> n >> m;
	
	rep(i , m)
	{
		int u , v;
		cin >> u >> v;
		--u;
		--v;
		g[u].pb(v);
		//ep(j , 3) g[u][j].pb(v);
	}
	
	int s , t;
	cin >> s >> t;
	--s;
	--t;
	
	vector<vi> dp(MAXN , vi(3 , INF));
	
	queue<pii> q;
	q.emplace(s , 0);
	used[s][0] = true;
	dp[s][0] = 0;
	
	while(!q.empty())
	{
		auto cur = q.front();
		q.pop();
		
		for(auto to : g[cur.fi])
		{
			if(!used[to][(cur.se + 1) % 3])
			{
				q.emplace(to , (cur.se + 1) % 3);
				dp[to][(cur.se + 1) % 3] = dp[cur.fi][cur.se] + 1;
				used[to][(cur.se + 1) % 3] = 1;
			}
		}
	}
	
	if(!used[t][0]) dier(-1);
	
	cout << dp[t][0] / 3 << nl;
	
	

	return 0;
}

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

int main()
{
    int n,k;
    cin>>n>>k;
    int a[n+1];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int sum=0;
    for(int i=0;i<k;i++)
        sum+=a[i];
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3608
N, K = map(int, input().split(" "))
S = input().split(" ")

ans = 0
S = "x"+"".join(S)+"x"
for i in range(len(S)):
    if (S[i-1]=="L" and S[i]=="L") or (S[i]=="R" and S[i+1]=="R"): ans += 1
print(min(ans+K*2, N-1))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define fi first
#define se second


signed main(){
  int n,k,a[1009],MAX=0,cnt[50]={};
  //r(i,64)cout<<((int)1<<i)<<endl;
  cin>>n>>k;
  r(i,n)cin>>a[i];
  vector<int>v;
  r(i,n){
    int sum=0;
    for(int j=i;j<n;j++){
      sum+=a[j];
      for(int l=0;l<50;l++){
        if((sum&((int)1<<l))==((int)1<<l)){
          cnt[l]++;//cout<<sum<<' '<<l<<' '<<(sum&((int)1<<l))<<' '<<((int)1<<l)<< endl;
          MAX=max(MAX,(int)l);
        }
      }
      v.push_back(sum);
    }
  }
  //cout<<MAX<<endl;
  int idx=-1,ans=0;
  for(int i=49;i>=0;i--){
    if(cnt[i]>=k){
      idx=i;
      break;
    }
  }
  int mask=0;
  if(idx==-1){
    cout<<0<<endl;
    return 0;
  }
  mask+=((int)1<<idx);
  for(int i=MAX-1;i>=0;i--){
    mask+=((int)1<<i);
    int cnt=0;
    r(j,v.size()){
      if((v[j]&mask)==mask){
        cnt++;
      }
    }
    if(cnt<k)mask-=((int)1<<i);
  }
  cout<<mask<<endl;
}

Measured memory_bytes: 6512
S=str(input())
if int(S[0:2])>0 and int(S[0:2])<13 and int(S[2:4])>0 and int(S[2:4])<13:
  print("AMBIGUOUS")
elif int(S[0:2])>0 and int(S[0:2])<13:
  print("MMYY")
elif int(S[2:4])>0 and int(S[2:4])<13:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  if(s=="SUN") cout<<7<<endl;
  if(s=="MON") cout<<6<<endl;
  if(s=="TUE") cout<<5<<endl;
  if(s=="WED") cout<<4<<endl;
  if(s=="THU") cout<<3<<endl;
  if(s=="FRI") cout<<2<<endl;
  if(s=="SAT") cout<<1<<endl;
}
 


Measured memory_bytes: 636
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <ctime>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main()
{
    int n;
    while(cin>>n)
    {
        if(n==0) break;
        int sum = 0;
        int mini = 10000000;
        int maxi = 0;
        for(int c=0;c<n;c++)
        {
            int z;
            cin>>z;
            mini = min(mini,z);
            maxi = max(maxi,z);
            sum += z;
        }
        cout<<(sum-mini-maxi)/(n-2)<<endl;
    }
}

Measured memory_bytes: 1160
//Xcode main は一つまで
//競プロのデバッグにでも使おう
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    vector <int> a(3,0);
    cin>>a[0]>>a[1]>>a[2];
    sort(a.begin(),a.end());
    cout<<a[2]-a[1]+a[1]-a[0]<<endl;
    return 0;
}



Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto str = readln.chomp.dup;
  auto q = readln.chomp.to!size_t;

  foreach (_; 0..q) {
    auto rd = readln.split, cmd = rd[0];
    auto a = rd[1].to!int, b = rd[2].to!int;

    switch (cmd) {
    case "print":
      writeln(str[a..b+1]);
      break;
    case "reverse":
      auto t = str[a..b+1];
      t.reverse();
      break;
    case "replace":
      auto p = rd[3];
      str[a..b+1][] = p[];
      break;
    default:
      assert(0);
    }
  }
}

Measured memory_bytes: 2516
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 3e5 + 5;
const int mod = 1e9 + 7;
int n, top, h[N];
ll ans, C, f[N];
ll x[N], y[N];
ll F(int i, int q) {
	return y[q] - x[q] * h[i] + (ll)h[i] * h[i] + C;
} 
void add(ll xx, ll yy) {
	while (top > 1 && (xx - x[top - 1]) * (y[top] - y[top - 1]) - (yy - y[top - 1]) * (x[top] - x[top - 1]) >= 0) --top;
	++top;
	x[top] = xx;
	y[top] = yy;
}
int main() {
	cin >> n >> C;
	for (int i = 1; i <= n; ++i) scanf("%d", h + i);
	add(2 * h[1], f[1] + (ll)h[1] * h[1]);
	int q = 1;
	for (int i = 2; i <= n; ++i) {
		q = min(q, top);
		while (q < top && F(i, q) >= F(i, q + 1)) ++q;
		f[i] = F(i, q);
		add(2 * h[i], f[i] + (ll)h[i] * h[i]);
		//ans = min(ans, f[i]);
	}
	cout << f[n];
}




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

int main(){
    int n;
    cin>>n;
    if (n%10==9||n/10==9)
    {
        /* code */
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); // number of 
#define ll long long                      //element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after sort  use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;                     
using namespace __gnu_pbds;
// assert(a[i]<n ) // if we want to check for special cond , used for debug
// make less_equal in order to make a multiset pbds
const ll Mod = (int)1e9;
ll CaseN=1;
ll fast_power(ll a,ll b,ll mod){
	ll ans=1;
	while(b>0){
	if(b&1){
	ans=(a*ans)%mod;
	}
	b=b>>1;
	a=(a*a)%mod;
	}
	return ans;
	}


ll nCr(ll n ,ll r)
{
ll p= n;
r = min(r,n-r);
ll a =1;
ll b=1;	
while(r)
{
	a = a*p;
	b = b*r;
	
	int g = __gcd(a,b);
	
	a = a/g;
	b = b/g;
	
	p--;
	r--;	
}	
return a;
	
}



void solve()
{
	
	vector<ll> fp;
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=2;i*i<=n;i++)
	{
	if(n%i==0)
	{
	ll cnt=0;
	while(n%i==0)
	{
	cnt++;	
	n =n/i;	
	}	
		fp.push_back(cnt);
	}
	}
	if(n!=1)
	{
	fp.push_back(1);	
	}
	for(ll i=0;i<(ll)fp.size();i++)
	{
	ll z = fp[i];
	ld x = (ld)z;
	ld xx = (sqrt(1+(8.00*x)) -1)/2.0 ;
	ans += (ll)xx ;
	}
	


   //cout<<"Case #"<<CaseN<<": ";
   CaseN++;
	// print your ans below;
 cout<<ans<<endl;
return ;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
	solve();	
	}
}

/*
 if(ans)
  {
  cout<<"YES"<<endl; 
  }
  else
   {
  cout<<"NO"<<endl;
  }
 
 
*/


Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<int>a(n), b(n);
	int suma = 0; int sumb = 0;
	rep(i, n) {
		cin >> a[i]; suma += a[i];
	}
	rep(i, n) {
		cin >> b[i]; sumb += b[i];
	}
	int k = sumb - suma;
	int cnt1 = 0, cnt2 = 0;
	rep(i, n) {
		if (a[i] > b[i]) {
			cnt1 += a[i] - b[i];
		}
		else {
			cnt2 += (b[i] - a[i] + 1) / 2;
		}
	}
	if (k < cnt1 || k < cnt2)cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 384
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

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

    int n;
    cin >> n;
    vector adjs(n, vector<int>());
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        adjs[a].push_back(b);
        adjs[b].push_back(a);
    }

    vector parents(n, 0);
    vector depth(n, 0);
    auto dfs1 = [&](auto self, int v, int pa, int d) -> void {
        parents[v] = pa;
        depth[v] = d;
        for (auto u : adjs[v])
        {
            if (u == pa)
            {
                continue;
            }
            self(self, u, v, d + 1);
        }
    };
    dfs1(dfs1, 0, -1, 0);

    int m;
    cin >> m;
    // vector restr(m, pair<int, int>());
    vector thru(m, 0LL);
    rep(j, m)
    {
        int u, v;
        cin >> u >> v;
        --u;
        --v;
        if (depth[u] < depth[v])
        {
            swap(u,v);
        }
        while (depth[u] > depth[v])
        {
            thru[j] |= (1LL << u);
            u = parents[u];
        }
        while (u != v)
        {
            thru[j] |= (1LL << u);
            u = parents[u];
            thru[j] |= (1LL << v);
            v = parents[v];
        }
    }
    debug(parents, depth, thru);

    i64 ans = 0;
    rep(s, (1 << m))
    {
        int p = __builtin_popcount(s) % 2;
        i64 e = 0; // 白の辺
        rep(j, m)
        {
            if ((s >> j) & 1)
            {
                e |= thru[j];
            }
        }
        ans += (1 - 2 * p) * (1LL << (n - 1 - static_cast<int>(bitset<63>(e).count())));
        debug(s, p, e, ans, bitset<63>(e).count());
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) throws NumberFormatException, IOException {
        String s;
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
            s = Arrays.stream(br.readLine().split(" "))
                    .mapToInt(Integer::parseInt)
                    .sorted()
                    .mapToObj(String::valueOf)
                    .collect(Collectors.joining(" "));
        }

        System.out.println(s);
    }

}



Measured memory_bytes: 31084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s,x;
  
ll a,n;
    cin>>a;
    if(a==1)cout<<"1.0000000000\n";
  else if(a%2==0)
  cout<<"0.5000000000\n";
  else {
        n=(a+1)/2;
    double x=n/(a*1.0);
    printf("%0.10f\n",x);
}
    
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define     FasterIO        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     bug(a,b)        cout<<a<<"\t"<<b<<"\n";
#define     Case(a,b)       cout<<"Case "<<a<<": "<<b<<"\n";
#define     watch(a)        cout<<fixed<<setprecision(a)
#define     lp(i,a,b)       for(int i=a;i<b;i++)
#define     Endl            "\n";
#define     tab             "\t"
#define     reset(a,b)      memset(a,b,sizeof(a));
#define     sf(a)           scanf(" %d", &a);
#define     srt(a)          sort(a.begin(),a.end());
#define     pi              2*acos(0.0)
#define     inf             INT_MAX
const int sz=1e5+9;
int n,x,arr[sz][3],dp[sz][3],ans=0;

int clac(int i,int ignore ,int value){
    if(i>n)return value;
    if(dp[i][ignore]!=-1)return dp[i][ignore];
    int ret=0;
    for(int j=0;j<3;j++){
        if(j==ignore)
            continue;
        ret=max(ret,value+clac(i+1,j,arr[i][j]));
    }
    return dp[i][ignore]=ret;
}

void solve(){
    cin>>n;
    reset(dp,-1);
    lp(i,1,n+1)cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    lp(i,0,3)ans=max(ans,clac(2,i,arr[1][i]));
    cout<<ans<<"\n";
}

int main(){
    //FasterIO;
    #ifndef ONLINE_JUDGE
       //freopen("1.txt","r",stdin);
    #endif
    //int t;
    //cin>>t;
    //while(t--)
        solve();
}


Measured memory_bytes: 10368
n, m = map(int,raw_input().split())
mod = 10 ** 9 + 7
dp=[[[0] * (n + 1) for _ in xrange(n + 1)] for _ in xrange(2)]
dp[0][1][1] = 1
for i in xrange(m):
    for j in xrange(n + 1):
        for k in xrange(n + 1):
            dp[(i+1)%2][j][k] = 0
    for j in xrange(1, n + 1):
        for k in xrange(1, j + 1):
            dp[(i+1)%2][min(j+1,n)][k] += dp[i%2][j][k] * (n - j) % mod
            dp[(i+1)%2][j][k] += dp[i%2][j][k] * (j - k) % mod
            dp[(i+1)%2][j][j] += dp[i%2][j][k] * k % mod
print dp[m%2][n][n] % mod


Measured memory_bytes: 34920
N,M=list(map(int,input().split()))

bag = []
for n in range(2**N):
    bag_ = []
    for n_ in range(N):
        bag_.append((n >> n_)&1)
    bag.append(bag_)

def get_ON_list(b):
    ON_list=[]
    for m in range(M):
        S_on=0
        for s in S[m]:
            S_on += b[s-1]

        ON_list.append(S_on%2)
    return ON_list

S=[]
for m in range(M):
    S_=list(map(int,input().split()))[1:]
    S.append(S_)
P=list(map(int,input().split()))

ans=0
for b in bag:
    ON_list=get_ON_list(b)
    ans_=1
    for on_idx,on in enumerate(ON_list):
        p=P[on_idx]
        if on != p:
            ans_=0
            break
    ans += ans_
print(ans)

Measured memory_bytes: 74516
#include<iostream>
using namespace std;
int main(){
  int n[10];
  char l[10];
  while(cin>>l){
    for(int i=0;i<10;i++) n[i] = l[i] - '0';
    for(int i=9;i>0;i--){
      for(int j=0;j<i;j++) n[j] = (n[j]+n[j+1])%10;
    }
    cout << n[0] << endl;
  }   
  return 0;
}

Measured memory_bytes: 1140
#include <iostream>
using namespace std;
long long N;
int main()
{
    cin>>N;
    for(long long a=1;a<=3500;a++)
    {
        for(long long b=1;b<=3500;b++)
        {
            if((4*a*b-a*N-b*N)>0&&(N*a*b)%(4*a*b-a*N-b*N)==0&&(N*a*b)/(4*a*b-a*N-b*N)>0)
            {
                cout<<a<<" "<<b<<" "<<N*a*b/(4*a*b-a*N-b*N);
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

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

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )

#define fst first
#define snd second

const int dir[][2] = {
	1, 0,
	0, 1,
	-1, 0,
	0, -1
};

// 座標圧縮
int comp( VI &x1, VI &x2, int W )
{
	const int N = x1.size();

	VI xs;

	REP( i, 0, N )
	{
		REP( j, -1, 2 )
		{
			// 変化のある座標の前後の座標について、有効な範囲なら追加

			int tmp1 = x1[i] + j, tmp2 = x2[i] + j;

			if ( 0 <= tmp1 && tmp1 < W )
			{
				xs.PB( tmp1 );
			}

			if ( 0 <= tmp2 && tmp2 < W )
			{
				xs.PB( tmp2 );
			}
		}
	}

	//　重複要素を消す
	sort( ALL( xs ) );
	xs.erase( unique( ALL( xs ) ), xs.end() );

	REP( i, 0, N )
	{
		// 新しい座標の取得
		
		x1[i] = lower_bound( ALL( xs ), x1[i] ) - xs.begin();
		x2[i] = lower_bound( ALL( xs ), x2[i] ) - xs.begin();
	}

	return xs.size();
}

// 矩形範囲を 1 で埋める
void paint( VVI &board, int x1, int y1, int x2, int y2 )
{
	REP( i, y1, y2 )
	{
		REP( j, x1, x2 )
		{
			board[i][j] = 1;
		}
	}

	return;
}

// BFS で塗り潰し
void bfs( VVI &board, int y, int x )
{
	const int H = board.size(), W = board[0].size();

	queue< PII > que;
	que.push( MP( y, x ) );

	while ( !que.empty() )
	{
		auto cur = que.front();
		que.pop();

		if ( board[ cur.fst ][ cur.snd ] )
		{
			continue;
		}

		board[ cur.fst ][ cur.snd ] = 1;

		REP( d, 0, 4 )
		{
			auto next = cur;

			next.fst += dir[d][0];
			next.snd += dir[d][1];

			if ( !( 0 <= next.fst && next.fst < H && 0 <= next.snd && next.snd < W ) )
			{
				continue;
			}

			que.push( next );
		}
	}

	return;
}

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

	while ( true )
	{
		int w, h;
		cin >> w >> h;

		if ( !( w | h ) )
		{
			break;
		}

		int n;
		cin >> n;

		VI x1( n ), y1( n ), x2( n ), y2( n );

		REP( i, 0, n )
		{
			cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
		}

		const int W = comp( x1, x2, w ), H = comp( y1, y2, h );


		VVI board( H, VI( W, 0 ) );

		REP( i, 0, n )
		{
			paint( board, x1[i], y1[i], x2[i], y2[i] );
		}

		int res = 0;

		REP( i, 0, H )
		{
			REP( j, 0, W )
			{
				if ( board[i][j] )
				{
					continue;
				}

				res++;

				bfs( board, i, j );
			}
		}

		cout << res << endl;
	}

	return 0;
}



Measured memory_bytes: 9912
#include<iostream>
#include<algorithm>
#include<cmath>
#define INF 1000000
using namespace std;

int main() {
	int n;
	while (cin >> n, n) {
		int a[1000];
		for (int i = 0;i < n;i++)cin >> a[i];
		sort(a, a + n);
		int ans=INF ;
		for (int i = 0;i < n - 1;i++) {
			int b = a[i + 1] - a[i];
			if (ans > b)ans = b;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3036
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int count = 0;
    int n_ = n;
    while(n_ > 0){
      count += n_ % 10;
      n_ /= 10;
    }
    if(n % count == 0)
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}


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

bool CmpIgnoCase( string &s1, string &s2) {
    for (int i = 0; i < s1.length(); ++i) {
        if (s1[i]>='A'&&s1[i]<='Z')
            s1[i] = static_cast<const char>(s1[i] + 32);
    }
    for (int i = 0; i < s2.length(); ++i) {
        if (s2[i]>='A'&&s2[i]<='Z')
            s2[i] = static_cast<const char>(s2[i] + 32);
    }
    return s1 == s2;
}
int main() {
    string w,t;
    int count = 0;
    cin>>w;
    cin>>t;
    while (t!="END_OF_TEXT")
    {
        if (CmpIgnoCase(w,t))
            count++;
        cin>>t;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3192
import java.util.*;

class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}
	
	Scanner in = new Scanner(System.in);

	void solve(){
		while(in.hasNext()){
			int n = in.nextInt(), m = in.nextInt();
			if(n == 0 && m == 0) return;
			int[] x = new int[n];
			int[] w = new int[m];
			for(int i = 0; i < n; i++) x[i] = in.nextInt();
			for(int i = 0; i < m; i++) w[i] = in.nextInt();
			int pos = 0, t = 0;
			for(t = 0; t < m; t++) {
				if(pos >= n) break;
				pos += x[pos];
				if(pos >= n) break;
				pos += w[t];
			}
			System.out.println(t);
		}
	}
	
	
}

Measured memory_bytes: 36528
## 合計は2^NからnCaとnCbを引いたものに等しいので
n,a,b = list(map(int,input().split()))

mod = int(1e9+7)
ans = 1

def calc(n,mod):
  if n>25:
    return ( (calc(n//2,mod) **2 ) * (2 if n%2 == 1 else 1) )% mod
  else:
    return (2**n) % mod
    
ans = calc(n,mod)
  
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m
  
a1 = 1
for i in range(1,a+1):
  a1 = int((a1*(n-a+i))*modinv(i,mod))%mod

b1 = 1
for i in range(1,b+1):
  b1 = int((b1*(n-b+i))*modinv(i,mod))%mod
  
print(int((ans-1-b1-a1))%mod)

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

using namespace std;

int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  if(a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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

using namespace std;

int n, a[123123], dp[123123];

int main() {
	cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
	dp[2] = abs(a[1] - a[2]);
    for(int i = 3; i <= n; i++)
      dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
    cout << dp[n];
}

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

int n,q;
int a[30][1000005];

char s[500005];

int lowbit(int n)
{
	return n&(-n);
}

int get(char x)
{
	return x-'a'+1;
}

void change(int num,int rt,int plus)
{
	if(rt>n){
		return ;
	}
	a[num][rt]+=plus;
	change(num,rt+lowbit(rt),plus);
	
}

inline int get_sum(int num,int r)
{
	int sum=0;
	while (r)
	{
		sum+=a[num][r];
		r-=lowbit(r);
	}
	return sum;
}

int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>s[i];
		change(get(s[i]),i,1);
	}
	cin>>q;
	
	while (q--)
	{
		int t1;
		cin>>t1;
		if (t1==1)
		{
			int t2;
			char x;
			cin>>t2>>x;
			change(get(s[t2]),t2,-1);
			change(get(x),t2,1);
			s[t2]=x;
		}
		else
		{
			int tot=0;
			int t2,t3;
			cin>>t2>>t3;
			for (int i=1;i<=26;i++)
			{
				if (get_sum(i,t3)-get_sum(i,t2-1)){
					tot++;
				}
			}
			cout<<tot<<endl;
		}
	}
	return 0;
}

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

using namespace std;

void f(vector<vector<pair<int, int>>>& edges, int i, int len, vector<int>& ans){
    ans[i]=len%2==0 ? 1 : 2;
    for(auto& adj : edges[i]){
        if(ans[adj.first]) continue;
        f(edges, adj.first, adj.second+len, ans);
    }
}

int main(){
    int n; cin >> n;
    vector<int> degs(n);
    vector<vector<pair<int, int>>> edges(n);
    for(int i=0; i<n-1; ++i){
        int u, v, w; cin >> u >> v >> w;
        --u; --v;
        edges[u].push_back(make_pair(v, w%2));
        edges[v].push_back(make_pair(u, w%2));
        ++degs[u];
        ++degs[v];
    }
    int root=0;
    for(int i=0; i<n; ++i){
        if(degs[i]==1){
            root=i;
            break;
        }
    }
    vector<int> ans(n);
    f(edges, root, 0, ans);
    for(int i=0; i<n; ++i){
        cout << ans[i]-1 << endl;
    }
    return 0;
}


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

int main(){
    using namespace std;
    unsigned long N, D, A;
    cin >> N >> D >> A;
    priority_queue<pair<unsigned long, unsigned long>> pq;
    vector<pair<unsigned long, unsigned long>> enemies(N);
    for(auto& i : enemies){
        cin >> i.first >> i.second;
        (i.first *= 2) += 10000000000;
        (i.second += A - 1) /= A;
    }
    sort(enemies.begin(), enemies.end(), greater<>());
    unsigned long ans{0}, now{0};
    pq.emplace(0, 0);
    for(const auto& i : enemies){
        while(pq.top().first > i.first && (now -= pq.top().second) | 1)pq.pop();
        auto k = i.second - min(i.second, now);
        if(k)pq.emplace(i.first - D * 4 - 1, k);
        ans += k;
        now += k;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5492
#include "bits/stdc++.h"

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int N;
	string S;
	cin >> N >> S;
	int ans = 1;
	rep(i,N-1) {
		if (S[i+1]!=S[i]) {
			ans++;
		}
	}
	print(ans);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a,b,k;
	cin>>k>>a>>b;
	if (b/k>a/k||a%k==0||b%k==0)
		cout<<"OK"<<endl;
	else cout<<"NG"<<endl;
	return 0;
} 

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

int main() {
    int N, M, p;
    cin >> N >> M;
    string S;
    map<int, int> mpAC, mpWA;
    int AC = 0;
    int WA = 0;
    rep(i,M) {
        cin >> p >> S;
        if (S == "AC") mpAC[p] = 1;
        else {
            if (mpAC[p] == 0) ++mpWA[p];
        }
    }
    for (auto x : mpAC) {
        if (x.second) ++AC;
    }
    for (auto x : mpWA) {
        if (mpAC[x.first]) WA += x.second;
    }
    cout << AC << " " << WA << endl;
}


Measured memory_bytes: 9460
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
#include <complex>
typedef complex<double> Point;
typedef vector<Point> Polygon;
double cross(Point a, Point b){
  return imag(conj(a) * b);
}
double area(Polygon P){
  double A = 0;
  REP(i, P.size()){
    A += cross(P[i], P[(i + 1) % P.size()]);
  }
  if(A < 0) A *= -1.0;
  return A / 2.0;
}
int main(){
  Point p;
  Polygon P;
  while(scanf("%lf,%lf", &p.real(), &p.imag()) != EOF){
    P.push_back(p);
  }
  printf("%.8lf\n", area(P));
  return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

std::vector<int> build_KMP_table(const std::string &S) {
	std::vector<int> table(S.size() + 1);
	table[0] = -1;
	int j = -1;
	for (int i = 1; i <= S.size(); ++i) {
		while (j >= 0 && S[i - 1] != S[j]) j = table[j];
		++j;
		table[i] = i == S.size() || S[i] != S[j] ? j : table[j];
	}
	return table;
}

std::vector<std::size_t> search_KMP(const std::string &T, const std::string &S, const std::vector<int> &table) {
	std::vector<std::size_t> res;
	int i = 0, j = 0;
	while (i < T.size()) {
		while (j >= 0 && T[i] != S[j]) j = table[j];
		++i; ++j;
		if (j == S.size()) {
			res.emplace_back(i - S.size());
			j = table[S.size()];
		}
	}
	return res;
}

vector<int> g[1123456];
int indeg[1123456];
int dp[1123456];

int main() {
	string S, T;
	cin >> S >> T;
	
	while (T.size() > S.size()) S += S;
	auto v = search_KMP(S + S, T, build_KMP_table(T));
	
	for (int u : v) {
		if (u < S.size()) {
			g[u].emplace_back((u + T.size()) % S.size());
			++indeg[(u + T.size()) % S.size()];
		}
	}
	
	queue<int> que;
	REP(i, S.size()) if (indeg[i] == 0) que.push(i);
	
	int ans = 0;
	while (!que.empty()) {
		int u = que.front();
		que.pop();
		chmax(ans, dp[u]);
		
		for (int v : g[u]) {
			chmax(dp[v], dp[u] + 1);
			if (--indeg[v] == 0) que.push(v);
		}
	}
	
	REP(i, S.size()) if (indeg[i]) ans = -1;
	cout << ans << endl;
	return 0;
}


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

vector<int> par;
vector<int> rnk;
vector<int> sze;

void makeSets(int n) {
    par.resize(n);
    rnk.resize(n);
    sze.resize(n);
    for(int i=0; i<n; i++) {
        par[i] = i;
        rnk[i] = 0;
        sze[i] = 1;
    }
}

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

bool same(int x, int y) {
    return find(x) == find(y);
}

void unite(int xp, int yp) {
    int x = find(xp);
    int y = find(yp);
    if(x == y) return;
    if(rnk[x] > rnk[y]) {
        sze[find(x)] += sze[find(y)];
        par[y] = x;
    } else {
        sze[find(y)] += sze[find(x)];
        par[x] = y;
    }
    if(rnk[x] == rnk[y]) rnk[y]++;
}

int main() {
    long long N,M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    for(int i=0; i<M; ++i) {
        cin >> A[i] >> B[i];
        --A[i];
        --B[i];
    }

    makeSets(N);
    vector<long long> res(M + 1);
    res[M] = N * (N - 1) / 2;

    for(int i=M-1; i>=1; --i) {
        if(same(A[i], B[i])) res[i] = res[i + 1];
        else res[i] = res[i + 1] - sze[find(A[i])] * sze[find(B[i])];
        unite(A[i], B[i]);
    }

    for(int i=1; i<=M; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 4096
def main():
    def trial_division(n):
        divs = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divs.append(i)
                if i != n//i:
                    divs.append(n//i)
        return divs

    N = int(input())
    divs = trial_division(N)
    ans = 0
    for d in divs:
        if d != 1 and N//(d-1) == N % (d-1):
            ans += (d-1)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39024
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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;}

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(a,b);
  OUT(a-b+1);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

long long  factorial(long long n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}

//int ()



int main()
{
  int a ,b, c, d, e, X, Y;
//  long long  a, b, c, d, e, X, Y;
  //  double  c;
//  int  A[200003]={};
  long long  A[100003]={};
  long long  B[100003]={};
  int  C[100003][11]={};

  int  flg=0;

//  long long  a, b, c, d, X, Y;
  char s[101][101]={};
  char t[101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p,q;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int len=0;
  int l=0;
  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  long long ans=1;
  int max=0;
  int sum=0;
  int addr=0;
  int ptn=0;
  long long  tmp=0;
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
  scanf("%d%d%d", &a, &b, &c);
  if(a>=b+c) cnt=0;
  else cnt=c-(a-b);
  printf("%lld\n",cnt);
 
  

    
//    printf("%s %d %d\n", s[i],C[i][0],C[i][1]);
   // printf("%d\n", C[i][1]);
/*  for(i=0;i<addr;i++){
//  scanf("%lld%lld", &B[0][i],&B[1][i]);
//    ans=ans+A[i];
    printf("%lld ", A[i]);
  }
*/
//    printf("%d ", cnt);
   

return 0;
}


Measured memory_bytes: 128