akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    n = int(input().strip())
    timetable = []
    profites = []
    ans = -(10**9)

    for _ in range(n):
        timetable.append([int(i) for i in input().strip().split()])
    for _ in range(n):
        profites.append([int(i) for i in input().strip().split()])

    for i in range(1, 2**10):
        on_service = [0] * 10
        overlaps = [0] * n
        for j in range(10):
            if i >> j & 1:
                on_service[j] = 1
                for k, table in enumerate(timetable):
                    if table[j] == 1:
                        overlaps[k] += 1
        _tmp = 0
        for m in range(n):
            ptr = overlaps[m]
            _tmp += profites[m][ptr]
        ans = max(ans, _tmp)
    print(ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 73576
// Created by: WeirdBugsButOkay

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ff first
#define ss second
#define PI 3.14159265358979323846
#define endl '\n'

using namespace std;

void solve()
{
	int x, y;
	bool ok = 0;
	cin >> x >> y;
	for(int i = 0; i <= x; i++)
	{
		if(2 * i + 4 * (x - i) == y)
			ok = 1;
	}
	if(ok)
		cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main()
{
	int q = 1;
	//scanf("%d", &q);
	for(int i = 1; i <= q; i++)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define N 200010
#define M 8010
typedef long long ll;
ll jc[M],ijc[M],f[M/2][M/2],a[N],b[N],n,va=2002;
#define mo 1000000007ll
ll qp(ll x,ll y){
	ll r=1;
	for(;y;y>>=1,x=x*x%mo)
		if(y&1)r=r*x%mo;
	return r;
}
ll c(int y,int x){return jc[y]*ijc[x]%mo*ijc[y-x]%mo;}
int main(){
	jc[0]=ijc[0]=1;
	cin>>n;
	for(ll i=1;i<M;i++)jc[i]=jc[i-1]*i%mo;
	ijc[M-1]=qp(jc[M-1],mo-2);
	for(ll i=M-2;~i;i--)ijc[i]=ijc[i+1]*(i+1ll)%mo;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		f[va-a[i]][va-b[i]]++;
	}
	for(int i=1;i<=va*2;i++)
		for(int j=1;j<=va*2;j++)
			f[i][j]=(f[i][j]+f[i-1][j]+f[i][j-1])%mo;
	ll r=0;
	for(int i=1;i<=n;i++){
		r=(r+f[a[i]+va][b[i]+va])%mo;
		r=(r-c(2*a[i]+2*b[i],2*a[i])+mo)%mo;
	}
	r=r*qp(2,mo-2)%mo;
	cout<<r;
}

Measured memory_bytes: 128768
s=list(input())
n=len(s)
for i in range(n):
  s[i]=int(s[i])
dec_flg=0
for i in range(n):
  if i==0:continue
  if dec_flg==0:
    if 0<=s[i]<=8 and s[i-1]>0:
      s[i-1]-=1
      s[i]=9
      dec_flg=1
  else:
    if 0<=s[i]<=8:
      s[i]=9
ans=0
for ss in s:
  ans+=ss
print(ans)

Measured memory_bytes: 9064
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pii;
typedef pair<ld, ld>  pld;
const ll mod = 1e9+7;
ll n, k;
ll a[100009];
ll inv(ll x){
    ll y = mod-2;
    ll ret = 1;
    while(y > 0){
        if(y%2)
            ret = ret*x%mod;
        x = x*x%mod;
        y /= 2;
    }
    return ret;
}
ll fact[100009];
ll factinv[100009];
ll comb(ll x, ll y){
    if(y > x)
        return 0;
    return fact[x]*factinv[x-y]%mod*factinv[y]%mod;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    
    fact[0] = factinv[0] = 1;
    for(ll i = 1; i <= 100000; ++i){
        fact[i] = i*fact[i-1]%mod;
        factinv[i] = inv(fact[i]);
    }

    cin >> n >> k;
    for(ll i = 0; i < n; ++i)
        cin >> a[i];
    sort(a, a+n);
    ll ans = 0;
    for(ll i = 0; i < n; ++i){
        ans += a[i]*comb(i, k-1)%mod;
        ans %= mod;
    }
    reverse(a, a+n);
    for(ll i = 0; i < n; ++i){
        ans -= a[i]*comb(i, k-1)%mod;
        ans += mod;
        ans %= mod;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define fst	first
#define scn second
#define bucnt(x)	__buildin__popcount(x)
#define debug(x)	cout<<"debug: "<<x<<endl

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };
ll fac[100005];
ll ifac[100005];

ll modpow(ll a, ll b) {
	ll ret = 1;
	while (b) {
		if (b & 1)	ret = (ret*a) % mod;
		a = (a*a) % mod;
		b >>= 1;
	}
	return ret;
}

ll modinv(ll a) {
	return modpow(a, mod - 2);
}

ll nCm(int n, int m) {
	if (n < m)	return 0;
	return fac[n] * (ifac[m] * ifac[n - m] % mod) % mod;
}

int main() {
	int n;	cin >> n;
	vint a(n + 1), cnt(n + 1, 0);
	int dub = 0;
	REP(i, n) {
		cin >> a[i];
		cnt[a[i] - 1]++;
		if (cnt[a[i] - 1] == 2) {
			dub = a[i];
		}
	}
	vint pos;
	REP(i, n) {
		if (dub == a[i])	pos.push_back(i);
	}
	fac[0] = ifac[0] = 1;
	for (int i = 1; i <= n + 1; i++) {
		fac[i] = (fac[i - 1] * i) % mod;
		ifac[i] = (ifac[i - 1] * modinv(i)) % mod;
	}
	for (int i = 1; i <= n + 1; i++) {
		ll all = nCm(n + 1, i);
		ll sub = nCm(n - (pos[1] - pos[0]), i - 1);
		cout << (mod + all - sub) % mod << endl;
	}
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, count = 0;
  string S;
  cin >> N >> S;
 
  for ( int i = 0; i < ( N - 2 ); i++ ) {    
    if( S.compare( i, 3, "ABC" ) == 0 ) {
      count++;
    }
  } 
  cout << count << endl;
  return 0;
}


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

maxcnt = 0
ixy = []

for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split())
        ixy.append([i, x - 1, y])

# print(ixy)

# bit全探索
for bit in range((1 << N)):
    # 2重ループがうまく抜けられない...
    break_flag = False
    for i, x, y in ixy:
        # 対応するbitが1のとき正直者、0のとき嘘つき
        # 正直者iの証言が
        if ((bit >> i) & 1):
            # bitの状態と一致しないとき矛盾
            if ((bit >> x) & 1 != y):
                break_flag = True
                # print("break1", i, x, y)
                break
    # 嘘つきは反対の証言になるわけではなく真偽不明として無視するらしい...
    # breakしてきたときはカウントしない
    if break_flag:
        continue
    # ここまで全て矛盾がなければ立っているbitの数 (= 正直者の数) をカウント
    # 最大値を更新
    else:
        # print(bin(bit))
        maxcnt = max(maxcnt, bin(bit).count("1"))

print(maxcnt)


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

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ld = long double;

constexpr int nax = 1000 * 1000 + 105;
constexpr int infty = 1000 * 1000 * 1000 + 5;
constexpr int mod = 1000 * 1000 * 1000 + 7;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll q, h, s, d, n;
  cin >> q >> h >> s >> d >> n;
  n *= 4;
  h = min(h, 2 * q);
  s = min(s, 2 * h);
  d = min(d, 2 * s);
  ll koszt = 0;
  koszt += d * (n / 8);
  n %= 8;
  koszt += s * (n / 4);
  n %= 4;
  koszt += h * (n / 2);
  n %= 2;
  koszt += q * n;
  cout << koszt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lowbit(x) (x & (-x))
#define mp(a, b) make_pair(a, b)
const int maxn = 2000 + 10;
typedef pair<int, int> pii;
int n, k, q, ans = 2e9;
vector<pii> b;
int a[maxn], C[maxn];
void add(int x)
{
	for(int i = x; i < maxn; i += lowbit(i))
		++C[i];
}
int sum(int x)
{
	int ret = 0;
	for(int i = x; i; i -= lowbit(i))
		ret += C[i];
	return ret;
}
bool solve(int now)
{
	memset(C, 0, sizeof(C));
	pii x = b[now];
	int val = x.first, pos = x.second;
	vector<int> S;
	S.push_back(0);
	for(int i = 1; i <= n; ++i)
		if(a[i] < val)
			S.push_back(i);
	S.push_back(n + 1);
	int cnt = 0;
	while(cnt < q && now < n)
	{
		val = b[now].first, pos = b[now].second;
		auto it = upper_bound(S.begin(), S.end(), pos);
		int r = *it;
		int l = *(--it);
		if(r - 1 - l - (sum(r - 1) - sum(l)) >= k)
		{
			++cnt;
			add(pos);
		}
		++now;
	}
	if(cnt == q)
	{
		ans = min(ans, b[now - 1].first - x.first);
		return 1;
	}
	else
		return 0;
}
int main()
{
	scanf("%d%d%d", &n, &k, &q);
	for(int i = 1; i <= n; ++i)
	{
		scanf("%d", &a[i]);
		b.push_back(mp(a[i], i));
	}
	sort(b.begin(), b.end());
	for(int i = 0; i < n; ++i)
		if(!solve(i))
			break;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
set <string> str;
string s[102];
int main()
{
	int N;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>s[i];
		str.insert(s[i]);
	}
	if(str.size()!=N){
		cout<<"No"<<endl;
		return 0;
	}
	for(int k=1;k<N;)
	{
		int t=k-1;
		int z=s[t].size();
		if(s[t][z-1]==s[k][0])
		k++;	
		else{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}     	

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

bool mem[2001][20001];
int a10, a5, a1;

bool fun(int n, int y){
    if(y == 0 && n == 0)
        return true;
    if(y < 0 || n < 0)
        return false;
    if(mem[n][y] == false)
        return false;
    a10++;
    if(fun(n-1, y-10))
        return true;
    a10--;
    a5++;
    if(fun((n-1), y-5))
        return true;
    a5--;
    a1++;
    if(fun(n-1, y-1))
        return true;
    a1--;
    mem[n][y] = false;
    return false;
}

int main(){
    int n, i, j;
    long y;
    cin>>n>>y;
    y/=1000;
    for(i = 0; i<=n; i++)
        for(j = 0; j<=y; j++)
            mem[i][j] = true;
    a10 = a5 = a1 = 0;
    if(fun(n, (int)y))
        cout<<a10<<" "<<a5<<" "<<a1<<endl;
    else cout<<"-1 -1 -1"<<endl;
    return 0;
}


Measured memory_bytes: 39424
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define pb push_back
#define in(x) int x; cin>>x;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
using namespace std;

//int gcd(int a, int b){
//	return b==0 ? a : gcd(b, a%b);
//}

int32_t main(void){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	
	string s;
	cin>>s;
	if(s[2] == s[3] && s[4] == s[5]) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

int main() {
    char s[8];
    int a,b;
    
    gets(s);
    a = atoi(s);
    b = atoi(s + 2);
    printf("%d %d\n",a * b, a + a + b + b);
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
using Graph = vector<vector<ll>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 1 << 29;
/****** define constant end ********/

/****** define variable start ******/
ll n, x;
vl l;
/******* define variable end *******/
ll solve()
{
    cin >> n >> x;
    l.resize(n);
    REP(i, n)
    {
        cin >> l[i];
    }
    vl sum(n + 1);
    sum[0] = 0;
    REP(i, n)
    {
        sum[i + 1] = sum[i] + l[i];
    }
    ll ans = 0;
    REP(i, n + 1)
    {
        if (sum[i] > x)
        {
            cout << ans << endl;
            return 0;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}
int main()
{
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */

    return (int)end_solve;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

class Combination{
    long long int maxn;
    long long int mod;
    std::vector<long long int> factorial;
    std::vector<long long int> inverse;

    public:

    Combination(long long int n,long long int m):maxn(n),mod(m){
        factorial.push_back(1);
        inverse.push_back(1);

        for(long long int i = 1; i <= n; i++){
            factorial.push_back((factorial.back()*i)%mod);
            inverse.push_back([&](long long int x,long long int n) -> long long int{
                long long int ret = 1;
                while(n > 0){
                    if(n&1)ret = (ret*x)%mod;
                    x = (x*x)%mod;
                    n >>= 1;
                }
                return ret;
            }(factorial.back(),mod-2));
        }
    }

    long long int getFactorial(int idx){
        if(idx > maxn || idx < 0)return -1;
        return factorial[idx];
    }

    long long int getInverse(int idx){
        if(idx > maxn || idx < 0)return -1;
        return inverse[idx];
    }

    long long int comb(long long int n,long long int r){
        return (((factorial[n]*inverse[n-r])%mod)*inverse[r])%mod;
    }
};

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret *= x;
            ret %= MOD;
        }
        x *= x;
        x %= MOD;
        n >>= 1;
    }
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;

    vector<vector<ll>> dp(b-a+2,vector<ll>(n+1,0));
    dp[0][0] = 1;
    Combination cb = Combination(n+1,MOD);
    
    for(ll i = 0; i < b-a+1; i++){
        for(ll j = 0; j < n+1; j++){
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= MOD;
            for(ll k = c; k <= d; k++){
                if((a+i)*k+j > n)break;
                dp[i+1][(a+i)*k+j] += (((((((dp[i][j]*cb.getInverse(j))%MOD)*cb.getFactorial((a+i)*k+j))%MOD)*mypow(cb.getInverse(a+i),k))%MOD)*cb.getInverse(k))%MOD;
                dp[i+1][(a+i)*k+j] %= MOD;
            }
        }
    }


    cout << dp.back()[n] << endl;
    
    return 0;
}

Measured memory_bytes: 8192
if __name__ == '__main__':
    N = int(input())
    A = [None]*N
    A = list(map(int, input().split()))
    Alice = 0
    Bob = 0
    while(A):
        Alice += max(A)
        A.remove(max(A))
        if A:
            Bob += max(A)
            A.remove(max(A))
    print(Alice - Bob)

Measured memory_bytes: 3064
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(Arr.length>1){
   var AL=Arr.shift();
   var hash={};
   for(var i=0;i<AL;i++){
      var arr=(Arr[i].trim()).split(" ");
      hash[arr[0]]=arr[1];
   }
   Arr=Arr.slice(AL,Arr.length+1);
   var AL=Arr.shift();
   var str="";
   for(var i=0;i<AL;i++){
      var k=Arr[i].trim();
      str+=(hash.hasOwnProperty(k))?hash[k]:k;
   }
   Arr=Arr.slice(AL,Arr.length+1);
   console.log(str);
   if(Arr[0]=="0")break;
}

Measured memory_bytes: 31748
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
void dfs(vector<int>graph[],int start,long int v,int visit[])
{
	int i;
	if(visit[start]==0)
	{
		visit[start]=1;
		for(i=0;i<graph[start].size();++i)
		{
			if(visit[graph[start][i]]==0)
				dfs(graph,graph[start][i],v,visit);
		}
	}	
}
int main()
{
	int n,m,i,count=0;
	scanf("%d %d",&n,&m);
	int x,y,z,visit[n+1];
	vector<int> graph[n+1];
	for(i=0;i<m;++i)
	{
		scanf("%d %d %d",&x,&y,&z);
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	for(i=1;i<=n;++i)
		visit[i]=0;
	for(i=1;i<=n;++i)
	{
		if(visit[i]==0)
		{
			dfs(graph,i,n,visit);
			++count;
		}
	}
	printf("%d",count);
}

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

using namespace std;

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

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

int a[MAXN];

void solve(int casi){
	cin>>n;
	ll sum = 0;
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		sum += a[i];
	}
	cin>>m;
	for(int i = 1; i <= m; i++){
		int x, y;
		scanf("%d%d", &x, &y);
		printf("%d\n", sum  - a[x] + y);
	}
}

void printans(){

}


int main(){
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a;
  cin>>a;
  if(a==22) cout<<"Christmas Eve Eve Eve"<<'\n';
  if(a==23) cout<<"Christmas Eve Eve"<<'\n';
  if(a==24) cout<<"Christmas Eve"<<'\n';
  if(a==25) cout<<"Christmas"<<'\n';
  return 0;
}


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

int zenka(int a){
    if (a % 2 == 0){
        return a/2;
    }
    else{
        return 3*a+1;
    }
}

int main(){
    int a[1000001];
    int b;
    int i=0;
    scanf("%d", &a[0]);
    for(i = 0; i <= 1000000; i++){
        a[i+1] = zenka(a[i]);
        for(int j = 0; j <= i; j++){
            if(a[i+1] == a[j]){
                printf("%d\n", i+2);
                exit(0);
            }
        }
    }

    return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i, a, b) for(int i = (a); i<(b); ++i)
#define pb push_back
#define INF 1000000005
#define MOD 1000000007
#define all(v) v.begin(), v.end()

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

ll power(ll x, ll y, ll p = MOD){  
  ll res = 1LL; 
  x = x % p;
  if (x == 0) return 0;
  while (y > 0){
    if (y & 1LL)  
      res = (res*x) % p;
    y = y>>1LL; 
    x = (x*x) % p;  
  }  
  return res;  
}  

int main(){
	IO
	int N;
	cin >> N;

	// {
	// 	int cnt = 1;
	// 	for(int C = 1; C < N - 1; ++C) {
	// 		int factors = 2;
	// 		int X = N - C;
	// 		for(int i = 2; i*i <= X; ++i) {
	// 			if(X%i == 0 ) {
	// 				if(i*i != X) factors+=2;
	// 				else factors+=1;
	// 			}
	// 		}
	// 		// cout << X << " " << factors << " " << endl;
	// 		cnt+=factors;
	// 	}

	// 	cout << cnt << endl;
	// }

	int cnt = 0;
	for(int A = 1; A <= 1000000; ++A) {
		for(int B = 1; A*B <= 1000000; ++B) {
			int C = N - A*B;
			if(C > 0) ++cnt;
		}
	}
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<vector<bool> > a(n+1, vector<bool>(n+1, false));
  for(int i = 1; i <= n; i++){
    int u;
    cin >> u;
    int k;
    cin >> k;
    for(int j = 0; j < k; j++){
      int v;
      cin >> v;
      a[i][v] = true;
    }
  }
  // ??????1??????????????¢???????????????
  // ?????????????????¨??????0??\???, ???????????????????????°-1
  vector<int> d(n+1, -1);
  d[1] = 0;

  queue<int> q;
  q.push(1);

  while(!q.empty()){
    int current = q.front();
    q.pop();
    for(int dst = 1; dst <= n; dst++){
      if(d[dst] < 0 && a[current][dst]){
        d[dst] = d[current] + 1;
        q.push(dst);
      }
    }
  }

  for(int i = 1; i <= n; i++){
    cout << i << " " << d[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3124
// AGC017-A Biscuits

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

void nCr(int n, long long ncr[]);

signed main() {
    int n, p, a, odd, even;
    long long sum_even, nco[51], nce[51], ans;

    cin >> n >> p;
    odd = 0;
    even = 0;

    for(int i=0 ;i<n ;i++ ) {
        cin >> a;

        if(a%2 == 1) {
            odd++;
        } else {
            even++;
        }
    }

    nCr(odd, nco);
    nCr(even, nce);

    sum_even = 0;
    for(int i=0 ;i<=even ; i++ ) {
        sum_even += nce[i];
    }

    ans = 0;
    if(p == 0) {
        for(int i=0 ;i<=odd ;i+=2 ) {
            ans += sum_even * nco[i];
        }
    } else {
        for(int i=1 ;i<=odd ;i+=2 ) {
            ans += sum_even * nco[i];
        }
    }

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

// [引数]
//          int n           : 選べる最大個数
//          long long ncr[] : 組み合わせを格納する配列
// [機能]
//          nC0 ~ nCnまでを求める
void nCr(int n, long long ncr[]) {
    ncr[0] = 1;
    int r = 1, N = n;

    for(int i=1 ;i<=N ;i++ ) {
        ncr[i] = ncr[i-1] * n / r;

        n--;
        r++;
    }

    return ;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    ll n;
    cin >> n;
    vector<ll> data(n);
    rep(i,0,n){
        cin >> data[i];
    }
    ll ans = 1;
    bool up = false;
    bool down = false;
    ll now_num = data[0];
    rep(i,0,n){
        if(!up&&!down){
            if(now_num<data[i]){
                up = true;
                now_num = data[i];
            }else if(now_num>data[i]){
                down = true;
                now_num = data[i];
            }
        }else if(up){
            if(now_num<data[i]){
                now_num = data[i];
            }else if(now_num > data[i]){
                ans++;
                now_num = data[i];
                up = false;
            }
        }else if(down){
            if(now_num>data[i]){
                now_num = data[i];
            }else if(now_num<data[i]){
                ans++;
                now_num = data[i];
                down = false;
            }
        }
    }
    cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4024
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var m = int.Parse(line[0]);
        var n = int.Parse(line[1]);
        var s = Console.ReadLine().Trim();
        var t = Console.ReadLine().Trim();
        var ans = goDP(s, m, t, n);
        Console.WriteLine(ans);
    }
    static void setDPTable(int[,,] dp, int m, int n, string s, string t)
    {
        for (int i = 1; i <= n; i++)
        {
            if (t[i - 1] == 'I') dp[0, i, 1] = dp[0, i - 1, 0] + 1;
            else dp[0, i, 0] = dp[0, i - 1, 1] == 0 ? 0 : dp[0, i - 1, 1] + 1;
        }
        for (int i = 1; i <= m; i++)
        {
            if (s[i - 1] == 'I') dp[i, 0, 1] = dp[i - 1, 0, 0] + 1;
            else dp[i, 0, 0] = dp[i - 1, 0, 1] == 0 ? 0 : dp[i - 1, 0, 1] + 1;
        }
    }
    static int goDP(string s, int m, string t, int n)
    {
        var ans = 0;
        var dp = new int[m + 1, n + 1, 2];
        setDPTable(dp, m, n, s, t);
        for (int i = 1; i <= m; i++)
        {
            var sc = s[i - 1];
            for (int j = 1; j <= n; j++)
            {
                var tc = t[j - 1];
                if (sc == 'O' && tc == 'O')
                {
                    var w = dp[i - 1, j, 1] == 0 ? 0 : dp[i - 1, j, 1] + 1;
                    var w2 = dp[i, j - 1, 1] == 0 ? 0 : dp[i, j - 1, 1] + 1;
                    dp[i, j, 0] = Max(w, w2);
                }
                else if (sc == 'I' && tc == 'I')
                {
                    dp[i, j, 1] = Max(dp[i - 1, j, 0], dp[i, j - 1, 0]) + 1;
                }
                else if (sc == 'I' && tc == 'O')
                {
                    dp[i, j, 1] = dp[i - 1, j, 0] + 1;
                    dp[i, j, 0] = dp[i, j - 1, 1] == 0 ? 0 : dp[i, j - 1, 1] + 1;
                }
                else
                {
                    dp[i, j, 1] = dp[i, j - 1, 0] + 1;
                    dp[i, j, 0] = dp[i - 1, j, 1] == 0 ? 0 : dp[i - 1, j, 1] + 1;
                }
                ans = Max(ans, Max(dp[i, j, 0] - 1, dp[i, j, 1]));
            }
        }
        return ans;
    }
}



Measured memory_bytes: 48732
import java.util.Scanner;
 
public class Main {
 
	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}
 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int answer,index;
		String s,t;
		
			// 整数の入力
		
		s = sc.next();
		sc.close();
		
		if(s.equals("Sunny")){
			System.out.print("Cloudy");
		}
		else if(s.equals("Cloudy")){
			System.out.print("Rainy");
		}
		else if(s.equals("Rainy")){
			System.out.print("Sunny");
		}

			// 出力
 
	}
}	

Measured memory_bytes: 21844
// clang-format off
	#include <bits/stdc++.h>
	using namespace std; using ll = long long; using uint = unsigned int; using ull = unsigned long long;
	#define SFINAE(x, ...)	template <class, class = void> struct x : false_type {}; template <class T> struct x<T, void_t<__VA_ARGS__>> : true_type {};
	SFINAE(DefaultIO, decltype(cout << declval<T &>()))
	SFINAE(IsTuple, typename tuple_size<T>::type)
	SFINAE(Iterable, decltype(begin(declval<T>())))
	template <class T> constexpr char Space(const T &) { return (Iterable<T>::value or IsTuple<T>::value) ? '\n' : ' '; }
	template <auto &os> struct Writer {
		template <class T> void Impl(T const &t) const {
			if constexpr (DefaultIO<T>::value) os << t;
			else if constexpr (Iterable<T>::value) { int i = 0; for (auto &&x : t) ((i++) ? (os << Space(x), Impl(x)) : Impl(x)); }
			else if constexpr (IsTuple<T>::value) apply([this](auto const &... args) { int i = 0; (((i++) ? (os << ' ', Impl(args)) : Impl(args)), ...);}, t);
			else static_assert(IsTuple<T>::value, "No matching type for print");
		}
		template <class F, class... Ts> auto &operator()(F const &f, Ts const &... ts) const { return Impl(f), ((os << ' ', Impl(ts)), ...), os << '\n', *this; }
	};
	template <auto &is> struct Reader {
		template <class T> auto& Rd(T &t) const {
			if constexpr (DefaultIO<T>::value) is >> t;
			else if constexpr (Iterable<T>::value) for (auto &x : t) Rd(x);
			else if constexpr (IsTuple<T>::value) apply([this](auto &... args) { (Rd(args), ...); }, t);
			else static_assert(IsTuple<T>::value, "No matching type for read");
			return *this;
		}
		template <class T> auto operator[](T t) const { Rd(t); return t; }
		template <class... Ts> auto operator()(Ts... ts) const { (Rd(ts), ...); return tuple{move(ts)...}; }
	};
	#ifdef NARUT_LOCAL
	#define Debug(...) cerr << "\033[0;31m", Writer<cerr>{}(__VA_ARGS__), cerr << "\033[0m"
	#define ASSERT(...) if(not(__VA_ARGS__)) throw runtime_error("local assertion failed")
	#define LOCAL_ONLY(...) __VA_ARGS__
	#else
	#define Debug(...) 0
	#define ASSERT(...) 0
	#define LOCAL_ONLY(...) 0;
	#endif
	[[maybe_unused]] constexpr Reader<cin> Cin; [[maybe_unused]] constexpr Writer<cout> Cout;
	#define FOR(i, j, n) for (int i = int(j); i < int(n); ++i)
	#define ROF(i, j, n) for (int i = int(n) - 1; i >= int(j); --i)
	#define let auto const

// clang-format on





auto Main() {
	let[n,x,t] = Cin(0,0,0);
	cout << t*((n+x-1)/x);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
#ifdef NARUT_LOCAL
	assert(freopen("io/test.in", "r", stdin));
	cin.exceptions(cin.badbit | cin.failbit);
	cerr << fixed << setprecision(10);
#endif

	Main();
}


Measured memory_bytes: 3604
import java.util.*;
import java.io.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        String S = sc.next();
        int[] num = new int[S.length()];
        for (int i = 0; i < S.length(); i++) {
            num[i] = Integer.parseInt(S.substring(i, i+1));
        }

        String ans = "";
        for (int i = 0; i < Math.pow(2, S.length()-1); i++) {
            ans = String.valueOf(num[0]);
            int result = num[0];
            for (int j = 0; j < S.length()-1; j++) {
                if ((1 & (i >> j)) == 1) {
                    result += num[j+1];
                    ans += "+" + String.valueOf(num[j+1]);
                } else {
                    result -= num[j+1];
                    ans += "-" + String.valueOf(num[j+1]);
                }
            }
            if (result == 7) {
                ans += "=7";
                break;
            }
        }
        out.printf("%s\n", ans);
        out.flush();
    }
}

Measured memory_bytes: 23892
#define _GLIBCXX_DEBUG
    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> pii;
    typedef map<int, int> mii;
    typedef map<char,int> mci;
    typedef vector<int> vi;
    typedef vector<vi> vvi;
    typedef vector<ll> vll;
    typedef vector<pair<int,int>> vii;
    typedef vector<char> vc;
    typedef vector<vc> vcc;
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()
    #define pb push_back
    #define mp make_pair
    #define F first
    #define S second
    #define in insert
    #define sz(v) v.size()
    #define mina(a,b) (a)=min((a),(b));
    #define maxa(a,b) (a)=max((a),(b));
    const int INF = 1e9 + 5;
    
    void solve(){
        int n,m; cin>>n>>m;
        vll v(n);
        vii oper(m);
        for(int i = 0; i < n; i++) cin>>v[i];
        for(int i = 0; i < m; i++){
            int a,b; cin>>a>>b;
            oper[i]={(ll)b,a};
        }
        sort(all(v));
        sort(rall(oper));
        int cur=0;
        for(int i = 0; i < m; i++){
            //cout<<oper[i].S;
            int curr=cur;
            for(int j = curr; j < min(curr+oper[i].S,n); j++){
                //cout<<"/"<<j<<"/"<<endl;
                if(v[j]<oper[i].F){
                    //cout<<v[j]<<"->"<<oper[i].F<<endl;
                    v[j]=oper[i].F;
                    cur++;
                }
                else break;
            }
        }
        ll sum=0;
        for(ll i:v) sum+=i;
        cout<<sum;
    }
    int main(){
        int T=1;
        //cin>>T;
        for(int i = 0; i < T; i++) solve(); 
    }

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << min(A,B) + min(C,D) << endl;
    return 0;
}


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

void push(int);
int pop(void); 
int main(void){
	int  x, y, n;
	char ch[100];
	while(scanf("%s",ch)!=EOF){
		if(ch[0]=='+'){
			x=pop();
			y=pop();
			push(x+y);
		}
		else if(ch[0]=='-'){
			y=pop();
			x=pop();
			push(x-y);
		}
		else if(ch[0]=='*'){
			x=pop();
			y=pop();
			push(x*y);
		}else{
			n = atoi(ch);
			push(n);
		}
	}
	printf("%d\n", pop());
	return 0;
} 
int S[100];
int top; 
void push(int x){
	if(top>=100-1){
	}
	++top;
	S[top] = x;
}
int pop(void){
	--top;
	return S[top+1];
}

Measured memory_bytes: 1828
#include <stdio.h>

void print(int A[], int N) {
	int i;
	for (i = 0; i < N; i++) {
		printf("%d",A[i]);
		if(i < N -1) {
			printf(" ");
		}
	}
	printf("\n");
}
int main(void) {
	int N, A[100], v;
	int i, j;
	scanf("%d",&N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	print(A, N);
	for (i = 1; i < N; i++) {
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		print(A, N);
	}
	return 0;
}

Measured memory_bytes: 604
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
const int N = 110;
typedef double db;
int n;
db ans; 
struct vec{
	db x,y;
}v[N];
bool cmp(vec a,vec b){
	db A=atan2(a.y, a.x);
	db B=atan2(b.y, b.x);
	if(A!=B){
		return A<B;
	}
	return a.x<b.x;
}
int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		scanf("%lf %lf",&v[i].x,&v[i].y); 
	}
	sort(v+1, v+1+n, cmp);
	for(int i=n+1; i<=2*n; i++){
		v[i]=v[i-n];
	}
	for(int i=1; i<=n; i++){
		db x=0,y=0;
		for(int j=i; j<=i+n-1; j++){
			x+=v[j].x;
			y+=v[j].y;
			ans=max(ans, x*x+y*y);
		}
	} 
	printf("%.15lf\n",sqrt(ans));
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef long long llint;
typedef vector<long long int> vint;
typedef vector< vector<int> > vvint;
typedef vector<string> vstr;


int main(void) {
	string S;
	char s;
	cin >> S;
	llint jur = 0;
	llint n = S.length();
	sort(S.begin(), S.end());
	if (S[0] != 'a')cout << 'a' << endl;
	else {
		for (int i = 1; i < n; i++) {
			if (S[i] != S[i - 1] && S[i] != S[i - 1] + 1) {
				s = S[i - 1] + 1;
				jur = 1;
				break;
			}
		}
		if (jur == 0 && S[n - 1] != 'z')cout << char(S[n - 1] + 1) << endl;
		else if (jur == 0)cout << "None" << endl;
		else cout << s << endl;

	}
}


Measured memory_bytes: 512
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
pair<long long,pair<long long,int> > ev[410000];
long long t[210000];
long long L[210000];
long long R[210000];
int main(){
	long long a,b,c;scanf("%lld%lld%lld",&a,&b,&c);
	if(c==0){
		if(b==0){
			printf("1\n");return 0;
		}
		printf("%lld\n",a+1);
		return 0;
	}
	for(int i=0;i<a;i++){
		t[i]=b+c*i;
	}
	for(int i=0;i<a;i++){
		L[i+1]=L[i]+t[i];
		R[i+1]=R[i]+t[a-1-i];
	}
	long long ret=0;
	for(int i=0;i<=a;i++){
		long long left=(L[i]-R[a-i]);
		long long right=(R[i]-L[a-i]);
		if(left>right)swap(left,right);
		ev[i*2]=make_pair((left%ABS(c*2)+ABS(c*2))%ABS(c*2),make_pair(left,1));
		ev[i*2+1]=make_pair((right%ABS(c*2)+ABS(c*2))%ABS(c*2),make_pair(right+ABS(c*2),-1));
		// printf("%d: %lld %lld %lld\n",(left%ABS(c*2)+ABS(c*2))%ABS(c*2),left,right+ABS(c*2));
	}
	std::sort(ev,ev+a*2+2);
	int cur=0;
	for(int i=0;i<a*2+2;i++){
		if(ev[i].second.second==1)cur++;
		else cur--;
		if(cur>0){
			ret+=(ev[i+1].second.first-ev[i].second.first)/ABS(c*2);
		}
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 14464
// Last Change: 04/01/2019 20:12:54.
/////////////////////////////////////////////////////////////////////////
//平均値ではなく中央値が良いらしい。
/////////////////////////////////////////////////////////////////////////
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

ll N;
vector<ll> A;

ll Cal(ll x) {
  ll ans = 0;
  for (ll i = 0; i < N; ++i) {
    ans += abs(A[i] - x);
  }
  return ans;
}

int main() {
  cin >> N;

  A.resize(N);
  for (ll i = 0; i < N; ++i) {
    cin >> A[i];
    A[i] -= (i + 1);
  }

  sort(A.begin(), A.end());

  ll center = (1 + N) / 2;
  --center;

  ll ans = Cal(A[center]);
  if ((1 + N) % 2 > 0) {
    ans = min(ans, Cal(A[center + 1]));
  }

  cout << ans << endl;

  //NS::LoopUntilZeroInpput();
}



Measured memory_bytes: 1792
from collections import deque
N=int(input())
G=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    a-=1;b-=1
    G[a].append(b)
    G[b].append(a)
j=0
for i in range(N):
    if len(G[i])>len(G[j]):
        j=i
c=sorted([int(i) for i in input().split()])
M=sum(c)-max(c)
d=[-1 for i in range(N)]
q=deque([j])
while(len(q)>0):
    r=q.popleft()
    d[r]=c.pop()
    for p in G[r]:
        if d[p]==-1:
            q.appendleft(p)
print(M)
print(" ".join([str(i) for i in d]))


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

int main(){
  char s[3];
  int a,b,c;
  for (size_t i = 0; i < 3; i++) {
    cin >> s[i];
  }
  if(s[1]!=s[2]&&s[2]!=s[0]&&s[0]!=s[1]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
    string s;
    cin >> s;
    for(char c = 'a'; c <= 'z'; c++){
        bool same = false;
        for(int i = 0; i < s.size(); i++){
            if(c == s[i]){
                same = true;
                break;
            }
        }
        if(!same){
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

int d[210000];

int main(){
    int N;
    cin>>N;
    vector<int> V[210000];
    for(int i=0;i<N-1;i++){
        int a,b;
        cin>>a>>b;
        a--; b--;
        V[a].push_back(b);
        V[b].push_back(a);
    }
    for(int i=0;i<210000;i++) d[i]=-1;
    queue<int> que;
    que.push(0);
    d[0]=0;
    int num,L;
    while(!que.empty()){
        int now=que.front(); que.pop();
        for(int i=0;i<(int)V[now].size();i++){
            int next=V[now][i];
            if(d[next]==-1){
                d[next]=d[now]+1;
                que.push(next);
                num=next;
            }
        }
    }
    for(int i=0;i<210000;i++) d[i]=-1;
    que.push(num);
    d[num]=0;
    while(!que.empty()){
        int now=que.front(); que.pop();
        for(int i=0;i<(int)V[now].size();i++){
            int next=V[now][i];
            if(d[next]==-1){
                d[next]=d[now]+1;
                que.push(next);
                num=next;
                L=d[next];
            }
        }
    }
    //cout<<L<<endl;
    if(L%3==1) cout<<"Second"<<endl;
    else cout<<"First"<<endl;
}



Measured memory_bytes: 13812
N = int(input())
A = [int(x) for x in input().split()]

data = {}
for a in A:
    for i in range(3): #a-1,a,a+1をカウント
        if a-1+i in data:
            data[a-1+i] += 1
        else:
            data[a-1+i] = 1
            
#カウントしたものの最大値が答え
ans = 0
for d in data.values():
    ans = max(ans, d)
print(ans)

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

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

    vector<long long int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    long long int ans   = 1000;
    long long int stock = 0;

    for(int i=0; i+1<n; i++){
        if(a[i] < a[i+1]){
            stock += ans / a[i];
            ans -= (ans / a[i]) * a[i];
        }
        if(a[i] > a[i+1]){
            ans += stock * a[i];
            stock = 0;
        }
    }
    ans += stock * a[n-1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
def d(x,y):
    return ((x[0]-y[0])**2+(x[1]-y[1])**2)**(1/2)
n= int(input())
x=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n):
    for j in range(n):
        ans+=d(x[i],x[j])
print(ans/n)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>
#include <iomanip>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    int N;
    cin >> N;
    vector<double> p(N);
    for(auto& x: p) cin >> x;

    vector<double> dp(N+1);
    dp[0] = 1;
    for(int i=0; i<N; i++){
        for(int j=i+1; j>=0; j--){
            dp[j] = dp[j]*p[i];
            if(j>0) dp[j] += dp[j-1]*(1-p[i]);
        }
    }

    double ans = 0;
    for(int i=0; i<=N/2; i++) ans += dp[i];
    cout << setprecision(20) << ans << endl;
}

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

int main(){
    int A,B;
    cin >> A >> B;
    if (A >= 2 * B){
        cout << A - 2 * B << endl;
    }
    else{
        cout << 0 << endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<n;++i)
#define FOR(i,s) for(int i=s;i>=0;--i)

using ll = long long;
using namespace std;

const ll INF = 1010101010;
const ll MOD = 1000000007;

int main() {
	ll n = 0, m = 0, o = 0;
	string s;
	bool k = true;
	cin >> s;
	rep(i, s.size()) {
		if (i == 0) { if (s[i] != 'A') m = 1; }
		else if (i > 1 && i < s.size() - 1) {
			if (s[i] == 'C')
				n++;
			else if (0 > s[i] - 'a' || s[i] - 'a' > 26) o = 1;
		}
		else if (0 > s[i] - 'a' || s[i] - 'a' > 26) o = 1;
	}
	if (n == 1 && m == 0 && o == 0) cout << "AC" << endl;
	else cout << "WA" << endl;
	return 0;
}

Measured memory_bytes: 256
strN = input()
keta, N = len(strN), int(strN)
if keta > 1:
  amari = N - (10**(keta-1))
  count = 0
  for i in range(1, keta):
    if i%2!=0:
      if i==1:
        count += 9
      else:
        count += (10**i) - (10**(i-1))  
  if keta%2!=0:
    count += amari+1
  print(count)
else:
  print(N)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <unordered_map> 
using namespace std; 
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI1 3.14159265358979311599796346854418516159057617187500

typedef long long int ll;  
ll MOD = 1e9 + 7;


int main() 
{ 
    FIO
    int t;
    t=1;
    while(t--)
    {
        ll x;
        cin >> x;

        for(ll i=-1100;i<=1100;i++)
        {
            for(ll j=-1100;j<=1100;j++)
            {
                ll num1 = i*i*i*i*i;
                ll num2 = j*j*j*j*j;
                
                if(num1-num2==x)
                {
                    //cout << num1 << " " << num2 << endl;
                    cout << i << " " << j << endl;
                    return 0;
                }
            }
        }
    }
    return 0; 
} 
        


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<string>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
//#include<chrono>
//#include<time.h>
//#include<windows.h>
using namespace std;
 
#define int ll
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define YESNO(x) puts((x)?"YES":"NO")
struct edge {int /*from,*/to,cost;};

bool a(int n){
    int ret = 0;
    REP(i,5){
        if((n>>i)&1) ret++;
    }
    return ret==3;
}

main(){
    int n;
    int march[5]={};
    cin >> n;
    REP(i,n){
        string tmp;
        cin >> tmp;
        char b = tmp[0];
        if(b=='M') march[0]++;
        if(b=='A') march[1]++;
        if(b=='R') march[2]++;
        if(b=='C') march[3]++;
        if(b=='H') march[4]++;
    }

    int ans = 0;

    REP(i,1<<5){
        if(a(i)){
            int t = 1;
            REP(j,5){
                if((i>>j)&1){
                    t *= march[j];
                }
            }
            ans += t;
        }
    }

    printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 256