akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(100000)

N = int(input())
adj = [ [] for _ in range(N) ]
for _ in range(N-1):
  u,v,w = map(int,input().split())
  u -= 1
  v -= 1
  adj[u].append((v,w))
  adj[v].append((u,w))

color = [None] * N
def dfs(n,l):
  if l%2==0:
    color[n] = 1
  else:
    color[n] = 0

  for nei, nl in adj[n]:
    if color[nei] is not None:
      if (l+nl) % 2 == 0 and color[nei] != 1:
        return False
      if (l+nl) % 2 == 1 and color[nei] != 0:
        return False
    else:
      dfs(nei, l+nl)

  return True

for i in range(N):
  if color[i] is None:
    if not dfs(i,0):
      print(-1)
      exit()

for c in color: print(c)


Measured memory_bytes: 165280
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

int main()
{    
    int n, k, q;
    cin >> n >> k >> q;
    
    vector<int> p(n, k - q);
    
    for (int i = 0; i < q; i++) {
        int a;
        cin >> a;
        
        p[a - 1]++;
    }
    
    
    for (int i = 0; i < n; i++) {
        if (p[i] > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }   
}


Measured memory_bytes: 1024
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double t,x;
  cin>>t>>x;
  cout<<fixed<<t/x;
  return(0);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cassert>
using namespace std;
typedef long long ll;
int n,A,B,C,P=1;
char str[5],ans[100005];
char ss[100005][5];
void SolveRR() {
	for(int i=P; i<=n; i++) {
		scanf("%s",ss[i]);
	}
	for(int i=P; i<=n; i++) {
		if(ss[i][0]=='A'&&ss[i][1]=='B') {
			if(max(A,B)<=0)return puts("No"),void();
			if(A==0)ans[i]='A',A++,B--;
			else if(B==0)ans[i]='B',B++,A--;
			else if(i==n||(ss[i+1][0]=='A'&&ss[i+1][1]=='B')){
				if(i%2==0)ans[i]='A',A++,B--;
				else ans[i]='B',A--,B++;
			}
			else if(ss[i+1][0]=='A')ans[i]='A',B--,A++;
			else ans[i]='B',A--,B++;
		}
		if(ss[i][0]=='A'&&ss[i][1]=='C') {
			if(max(A,C)<=0)return puts("No"),void();
			if(A==0)ans[i]='A',A++,C--;
			else if(C==0)ans[i]='C',C++,A--;
			else if(i==n||(ss[i+1][0]=='A'&&ss[i+1][1]=='C')){
				if(i%2==0)ans[i]='A',A++,C--;
				else ans[i]='C',A--,C++;
			}
			else if(ss[i+1][0]=='A')ans[i]='A',C--,A++;
			else ans[i]='C',A--,C++;
		}
		if(ss[i][0]=='B'&&ss[i][1]=='C') {
			if(max(B,C)<=0)return puts("No"),void();
			if(B==0)ans[i]='B',B++,C--;
			else if(C==0)ans[i]='C',C++,B--;
			else if(i==n||(ss[i+1][0]=='B'&&ss[i+1][1]=='C')){
				if(i%2==0)ans[i]='B',B++,C--;
				else ans[i]='C',B--,C++;
			}
			else if(ss[i+1][0]=='B'||ss[i+1][1]=='B')ans[i]='B',C--,B++;
			else ans[i]='C',B--,C++;
		}
	}
	puts("Yes");
	for(int i=1; i<=n; i++)cout<<ans[i]<<'\n';
}
int main() {
	cin>>n>>A>>B>>C;
	int cnt=0;
	if(A)cnt++;
	if(B)cnt++;
	if(C)cnt++;
	if(cnt>1) {
		SolveRR();
		return 0;
	}
	if(!cnt)return puts("No"),0;
	scanf("%s",str);
	if(str[0]=='A'&&str[1]=='B') {
		if(max(A,B)<=0)return puts("No"),0;
		if(A<B)ans[1]='A',A++,B--;
		else ans[1]='B',B++,A--;
	}
	if(str[0]=='A'&&str[1]=='C') {
		if(max(A,C)<=0)return puts("No"),0;
		if(A<C)ans[1]='A',A++,C--;
		else ans[1]='C',C++,A--;
	} 
	if(str[0]=='B'&&str[1]=='C') {
		if(max(B,C)<=0)return puts("No"),0;
		if(B<C)ans[1]='B',B++,C--;
		else ans[1]='C',C++,B--;
	}
	P=2;
	SolveRR();
}



Measured memory_bytes: 4348
import std.stdio;
import std.algorithm;
import std.conv;
import std.string;

void main()
{
	auto tokens = split(chomp(readln()));
	auto n = to!int(tokens[0]);
	auto x = to!int(tokens[1]);
	int[] a;
	foreach (token; split(chomp(readln())))
	{
		a ~= to!int(token);
	}
	a.sort();
	
	ulong result = a.length;
	foreach (i, e; a)
	{
		if (e <= x)
		{
			x -= e;
		}
		else
		{
			result = i;
			break;
		}
	}
	if (result == a.length && x != 0) --result;

	writeln(result);
	stdout.flush();
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)

if n % 2 == 0:
  ans = sum(A[:n//2]) * 2 - A[0]
else:
  ans = sum(A[:n//2]) * 2 - A[0] + A[n//2]
  
print(ans)

Measured memory_bytes: 31720
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int prime[5*100001];
	for (int i = 0; i < 5*100001; ++i)
	{
		prime[i] = 1;
	}
	prime[0] = prime[1] = 0;
	for (int i = 0; i < 5*100001; ++i)
	{
		if(prime[i])
		{
			for (int j = i + i; j < 5*100001; j += i)
			{
				prime[j] = 0;
			}
		}
	}
 
	int x;
	cin >> x;
	for (int i = x; i < 5*100001; ++i)
	{
		if (prime[i])
		{
			cout << i << endl;
			break;
		}
	}
	return 0;
}

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

ULL gcd(ULL a, ULL b) { return b ? gcd(b, a % b) : a; }

int main() {
	set<pair<pair<UL, UL>, UL>> S;
	UL N; cin >> N;
	rep(i, N) {
		UL A[3]; rep(j, 3) cin >> A[j];
		sort(A, A + 3);
		S.insert({ {A[0],A[1]},A[2] });
	}
	cout << (N - S.size()) << endl;
	return 0;
}



Measured memory_bytes: 3216
x, y = map(int, input().split())
group1 = [4, 6, 9, 11]
group2 = [1, 3, 5, 7, 8, 10, 12]

if x == y == 2:
    print('Yes')
elif x in group1 and y in group1:
    print('Yes')
elif x in group2 and y in group2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#include <bitset>
#define INF 100000000000
#define N 100001
#define ll long long
using namespace std;

int main() {
	vector<int> A;
	A.push_back(1);
	for(int i = 1; pow(6, i) <= 1000000; i++) {
		A.push_back(pow(6, i));
	}
	for(int i = 1; pow(9, i) <= 1000000; i++) {
		A.push_back(pow(9, i));
	}
	int n;
	cin>>n;
	sort(A.begin(),A.end());
	
	ll dp[n+1];
	dp[0]=0;
	dp[1]=1;
	
	for (ll i=2; i<=n; i++){
	    auto it = lower_bound(A.begin(), A.end(), i+1);

        ll index = it - A.begin() - 1;
        
        if (i>=A[index]){
            dp[i]=min(dp[i-A[index]]+1,dp[i-1]+1);
            dp[i]=min(dp[i],dp[i-A[index-1]]+1);
        }
	}
	
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
import java.util.*;
import java.lang.*;
import java.io.*;
class Pair<E,F>{
    E first;
    F second;
    public Pair(E first, F second){
        this.first=first;
        this.second=second;
    }
    public E getFirst(){return first;}
    public F getSecond(){return second;}
    public String toString(){
        return "<"+first.toString()+","+second.toString()+">";
    }
    public int hashCode(){
        return first.hashCode()*30011+second.hashCode()+2;
    }
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Pair another = (Pair) obj;
        return this.getFirst().equals(another.getFirst())&&this.getSecond().equals(another.getSecond());
    }
}
public class Main {
    public static Pair<Integer,Integer> numToCood(int H, int W, int n){
        int h = n/(2*W);
        int w = n%(2*W);
        if(w<W) return new Pair<>(2*h,w);
        else return new Pair<>(2*h+1,2*W-w-1);
    }
    public static void printArray(int[] array){
        int W = array.length;
        for(int w=0;w<W;w++){
        	System.out.print(array[w]);
        	if(w==W-1)System.out.println();
        	else System.out.print(" ");
        }
    }
    public static void printArray(int[][] array){
        int H = array.length;
        for(int h=0;h<H;h++) printArray(array[h]);
    }
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int N = sc.nextInt();
        int[] a = new int[N];
        for(int n=0;n<N;n++) a[n]=sc.nextInt();
        int[][] grid = new int[H][W];
        int color=1;
        int painted=0;
        for(int i=0;i<H*W;i++){
        	if(painted<a[color-1]){
        	    Pair<Integer,Integer> cood = numToCood(H,W,i);
        	    grid[cood.getFirst()][cood.getSecond()] = color;
        	    painted++;
        	}else{
        	    color++;
        	    painted=0;
        	    i--;
        	}
        }
        printArray(grid);
    }
}


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

// Problem https://atcoder.jp/contests/diverta2019/tasks/diverta2019_b

int solver(int rCntPB,int gCntPB,int bCntPB,int allB){
    int rmax = allB / rCntPB;
    int gmax = allB / gCntPB;

    int result = 0;
    for(int r=0;r <= rmax;r++){
        for(int g=0;g <= gmax;g++){
            int remain = allB - r*rCntPB - g * gCntPB;
            int bModQ = remain % bCntPB;
            if( 0 <= remain and bModQ == 0){
                result = result + 1;
            }
        }
    }
    return result;
}

int main(void){
    int R,G,B,N,answer;
    cin >> R >> G >> B >> N;
    answer = solver(R,G,B,N);
    cout << answer << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 9999999999999999
#define MOD 1000000007

ll cnt;

void dfs(ll s,vector<ll> adj[],bool vis[]){
    vis[s]=true;
    ++cnt;
    for(auto u:adj[s]){
        if(!vis[u]){
            dfs(u,adj,vis);
        }
    }
}

void func()
{
    ll n;
    cin>>n;
    ll a[n];
    loop(i,0,n){
        cin>>a[i];
    }
    ll g=a[0];
    loop(i,0,n){
        g=__gcd(g,a[i]);
    }
    vector<ll> sieve(1000005);
    for(int i=2;i<=1000005;i++){
        if(sieve[i]) continue;
        for(int j=i;j<=1000005;j+=i){
            sieve[j]=i;
        }
    }
    unordered_set<ll> s;
    bool flag=true;
    revloop(i,n-1,0){
        while(a[i]>1){
            if(s.find(sieve[a[i]])!=s.end()){
                flag=false;
                break;
            }
            else{
                s.insert(sieve[a[i]]);
            }
            ll t=sieve[a[i]];
            while(a[i]%t==0){
                a[i]=a[i]/t;
            }
        }
        if(!flag){
            break;
        }
    }
    if(flag){
        cout<<"pairwise coprime"<<"\n";
    }
    else{
        if(g==1){
            cout<<"setwise coprime"<<"\n";
        }
        else{
            cout<<"not coprime"<<"\n";
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif
 
    ll t=1;
    //cin>>t;
    //solve();
    while(t--)
    {
        func();
    }

}


Measured memory_bytes: 18760
#include<math.h>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#include<map>
using namespace std;

int ser[1000010];
int main()
{
	int c1, c2, c4;
	int n,temp;
	c1 = c2 = c4 = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &temp);
		if (temp % 4 == 0)
			c4++;
		else if (temp % 2 == 0)
			c2++;
		else
			c1++;
	}
	if (c2 != 0)
	{
		if (c1 <= c4)
			printf("Yes\n");
		else
			printf("No\n");
	}
	else
	{
		if(c1<=c4+1)
			printf("Yes\n");
		else
			printf("No\n");
	}
 	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<queue>
#include<string.h>
using namespace std;
inline long long gcd(long long  a,long long b)
{return b?gcd(b,a%b):a;}
inline long long lcm(long long a,long long b)
{return a/gcd(a,b)*b;}
long long x,y;
int main()
{
	while(~scanf("%lld %lld",&x,&y))
	{
		printf("%lld %lld\n",gcd(x,y),lcm(x,y));
	}
}



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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int> > vp;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define out(n) cout << (n) << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  ll n, k;
  cin >> n >> k;

  vp a(n);

  rep(i, 0, n) {
    cin >> a[i].first >> a[i].second;
  }

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

  ll count = 0;

  rep(i, 0, n) {
    count += a[i].second;
    if(count >= k) {
      out(a[i].first)
      return 0;
    }
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  ll r,d,x; cin >>r >>d >>x;
  for(int i=0; i<10; i++){
    x=r*x-d; cout <<x<<'\n';
  }
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  solve();
return 0;}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int64 A, B, Q; cin >> A >> B >> Q;
	vector<int64> S(A + 2, 0);
	S[0] = -INFL; S[A + 1] = INFL;
	for (int i = 1; i <= A; ++i) {
		cin >> S[i];
	}
	vector<int64> T(B + 2, 0);
	T[0] = -INFL; T[B + 1] = INFL;
	for (int i = 1; i <= B; ++i) {
		cin >> T[i];
	}
	vector<int64> CS(A + 2, 0);
	vector<int64> CT(B + 2, 0);
	for (int i = 1; i <= A; ++i) {
		auto p = lower_bound(all(T), S[i]);
		CS[i] = min(S[i] - p[-1], p[0] - S[i]);
	}
	for (int i = 1; i <= B; ++i) {
		auto p = lower_bound(all(S), T[i]);
		CT[i] = min(T[i] - p[-1], p[0] - T[i]);
	}
	CS[0] = CS[A + 1] = CT[0] = CT[B + 1] = INFL;
	for (int i = 0; i < Q; ++i) {
		int64 X; cin >> X;
		int64 ans = INFL;
		auto P = lower_bound(S.begin(), S.begin() + A + 2, X), Q = lower_bound(T.begin(), T.begin() + B + 2, X);
		ans = min(ans, P[0] - X + CS[P - S.begin()]);
		ans = min(ans, X - P[-1] + CS[P - S.begin() - 1]);
		ans = min(ans, Q[0] - X + CT[Q - T.begin()]);
		ans = min(ans, X - Q[-1] + CT[Q - T.begin()- 1]);
		cout << ans << endl;
	}
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 4480
#include <stdio.h>

int CountDivisors(int s, int e, int d){
	int i;
	int count = 0;
	
	for(i = s; i <= e; i++){
		if(d % i == 0){
			count++;
		}
	}
	
	return count;
}

int main(void){
	int start, end, divisor;
	
	scanf("%d %d %d", &start, &end, &divisor);
	printf("%d\n", CountDivisors(start, end, divisor));
	
	return 0;
}

Measured memory_bytes: 596
A, B, C, K = map(int, input().split())

n_a = 0
n_b = 0
n_c = 0

# a
if K > 0:
  
  if K >= A:
    n_a = A
    K = K - A
  else:
    n_a = K
    K = K - A

else:
  n_a = 0


if K > 0:

  if K >= B:
    n_b = B
    K = K - B
  else:
    n_b = K
    K = K - B

else:
  n_b = 0

if K > 0:

  if K >= C:
    n_c = C
    K = K - C
  else:
    n_c = K
    K = K - C

else:
  n_c = 0

ans = (n_a * 1) + (n_b * 0) + (n_c * (-1))
print(ans)

Measured memory_bytes: 9220
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n, i;
	cin >> n;
	int arr[n - 1];
	fo(i, 0, n - 1)
	cin >> arr[i];
	map <int, int> mp;
	fo(i, 0, n - 1)
	mp[arr[i]]++;
	foe(i, 1, n)
	cout << mp[i] << '\n';
}


Measured memory_bytes: 13808
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define RG register
#define maxn 1000005
#define maxm 205
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
inline ll read(){
    ll x = 0, f = 1;
    char ch = getchar();
    while(ch > '9' || ch < '0') {if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x *10 + ch -'0';ch = getchar();}
    return x * f;
}
 
int n, m, k, po[2][maxn];
int qpow(int a, int b){
	int ans = 1, base = a;
	while(b){
		if(b & 1) ans = 1ll * ans * base % mod;
		base= 1ll * base * base % mod;
		b >>= 1;
	}
	return ans;
}
int fac[maxn], inv[maxn], ans;
int C(int n, int m){return 1ll * fac[n] * inv[m] % mod *inv[n - m] % mod;}
int main(){
	int i, j, x, l, r, mid;
	fac[0] = po[0][0] = po[1][0] = 1;
	for(i = 1;i <= maxn - 5;i++) fac[i] = 1ll * fac[i - 1] * i % mod, po[0][i] = po[0][i - 1] * 2ll % mod, po[1][i] = po[1][i - 1] * 3ll % mod;
	inv[maxn - 5] = qpow(fac[maxn - 5], mod - 2);
	for(i = maxn - 6;i >= 0;i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod; 
	n = read(), m = read(), k = read();
	int las = 1;
	for(i = 0;i <= m + k;i++){
		ans = (ans + 1ll * C(n + i - 1, n - 1) * po[1][m + k -i] % mod * las % mod) % mod;
		if(i + 1 <= m && i + 1 <= k) las = las * 2ll % mod;
		else{
			if(i + 1 <= k) las = ((las * 2ll - C(i, m)) % mod + mod) % mod; 
			else if(i + 1 <= m) las = ((las * 2ll - C(i, i - k)) % mod + mod) % mod;
			else las = (((las * 2ll - C(i, i - k)) % mod + mod - C(i, m) ) % mod + mod ) % mod;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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


int main() {
int n,a,b;
  cin >> n>>a>>b;
  int ans =0;
  for(int i=1;i<=n;i++){
    int k =(i/10000)+((i%10000)/1000)+((i%1000)/100)+((i%100)/10)+(i%10);
   if(k<=b && k>=a) ans += i;
  }
  cout << ans <<endl;
}
  


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

int main() {
  int N, Y;  
  cin >> N >> Y;
  bool tmp = false;
  for (int i=0; i<N+1; i++){
    if (tmp) {
      break;
    }
    for (int j=0; j+i<N+1; j++) {
      if (tmp) {
        break;
      }
      int k = N - j - i;

      int y = 10000*i+5000*j+1000*k;
      if (y == Y) {
        cout << i << " " << j << " "  << k << endl;
        tmp = true;
      }
    }
  }
  if (tmp == false) {
    cout << -1 << " " << -1 << " "  << -1 << endl;
  }
}


Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def No(): print('No')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()

def enum_divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if N % i == 0:
            divisors.add(i)
            divisors.add(N//i)
    return sorted(divisors)

def F(a, b):
    return max(len(str(a)), len(str(b)))

divisors = enum_divisors(N)
ans = 10**10
for d in divisors:
    ans = min(ans, F(d, N//d))
print(ans)




Measured memory_bytes: 5928
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main()
{
    string s;cin>>s;
    int n=s.size()+1;
    vector<ll> a(n,-1);
    vector<ll> vall(n,0);
    bool flag=true;//1なら谷から
    if(s[0]=='<'){
        vall[0]=1;
    }
    for(int i=0;i<n-2;i++){
        if(s[i]=='>'&&s[i+1]=='<'){
            vall[i+1]=1;
        }
    }
    if(s.back()=='>'){
        vall[n-1]=1;
    }
    for(int i=0;i<n;i++){
        if(vall[i]){
            int p=0;
        while(s[i+p]=='<'&&i+p<n-1){
            a[i+p]=p;
            p++;
        }
        a[i+p]=p;
        int q=0;
        while(s[i-q-1]=='>'&&i-q-1>=0){
            a[i-q]=q;
            q++;
        }
        a[i-q]=max(a[i-q],(ll)q);
        }
    }
    ll ans=0;
    for(auto e:a){
        ans+=e;
    }
    cout<<ans<<endl;
}

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

const long long INF = 1e18;

void solve(long long A, long long B, long long C, long long X, long long Y){
    long long ans = INF;
    for(long long i = 0; i <= 100000; ++i){
        ans = min(ans, i * 2 * C + max(0LL, X-i) * A + max(0LL, Y-i) * B);
    }
    cout << ans << endl;
    return;
}


int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(A, B, C, X, Y);
    return 0;
}


Measured memory_bytes: 3792
#include <iostream>
#include <cstdio>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <math.h>

using namespace std;

#define ll long long
#define vec vector
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll n;
	double ans = 0, pi = 6.28318530717958623200/2;
	string s = "Yes";

	cin >> n;

	ans = n * 2 * pi;

	cout << fixed;
	cout << setprecision(8) << ans;


}

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

int main() {
  int N,R;
  cin >> N >> R;
  
  if (N >= 10) {
    cout << R << endl;
  }
  
  else if (N < 10) {
    cout << R + 100 * (10 - N) << endl;
  }
  
  
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int p = 1000000007;
int N_MAX = 101;
int main()
{
  int n;
  cin >> n;
  long long a[N_MAX][19];
  long long *pi,*pm;
  long long res=0;
  fill(a[2],a[2]+16,1);
  fill(a[2]+16,a[2]+19,0);
  for(int i=3;i<=n;i++){
    pi=a[i];
    pm=a[i-1];
    pi[0]=pi[2]=pi[3]=(pm[0]+pm[4]+pm[8]+pm[12])%p;
    pi[4]=pi[5]=pi[7]=(pm[1]+pm[5]+pm[9]+pm[13])%p;
    pi[8]=(pm[2]+pm[6]+pm[10]+pm[14]+pm[16]+pm[17])%p;
    pi[12]=pi[15]=(pm[3]+pm[7]+pm[11]+pm[15]+pm[18])%p;
    pi[1]=(pm[0]+pm[4]+pm[12])%p;
    pi[6]=(pm[5]+pm[9]+pm[13])%p;
    pi[9]=(pm[6]+pm[10]+pm[14])%p;
    pi[10]=pi[11]=(pm[6]+pm[10]+pm[14]+pm[16]+pm[17])%p;
    pi[13]=(pm[3]+pm[7]+pm[11]+pm[15])%p;
    pi[14]=(pm[7]+pm[11]+pm[15]+pm[18])%p;
    pi[16]=pi[18]=pm[2];
    pi[17]=pm[3];
  }
  for(int i=0;i<19;i++){
    res+=a[n][i];
    res=res%p;
  }
  cout << res << endl;
  return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class UnionFind{
public:
	vector<ll> par;
	vector<ll> num;

	UnionFind(ll N):par(N),num(N){
		for(ll i=0;i<N;i++){
			par[i]=i;
			num[i]=1;
		}
	}

	ll root(ll x){
		if(par[x]==x){
			return x;
		}
		return par[x]=root(par[x]);
	}

	void unite(ll x,ll y){
		ll rx = root(x);
		ll ry = root(y);
		if (rx == ry) return;
		par[rx] = ry;
		num[ry] += num[rx];
	}

	bool same(ll x,ll y){
		ll rx = root(x);
		ll ry = root(y);
		return rx == ry;
	}

	ll getsize(ll x){
		return num[root(x)];
	}
};

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

	int N=in(),M=in();
	UnionFind uf(N);
	REP(i,M){
		int u=in(),v=in();
		uf.unite(u,v);
	}
	int Q=in();
	REP(i,Q){
		int u=in(),v=in();
		out(uf.same(u,v)?"yes":"no");
	}

	return 0;
}



Measured memory_bytes: 4548
#include <iostream>
#include <string>
#include <map>
#include <queue>
using namespace std;

typedef pair<string, int> P;

int bfs(string worm){
	queue<P> que;
	que.push(P(worm, 0));

	map<string, int> d;
	
	while(!que.empty()){
		P p = que.front();
		que.pop();

		//?????????????????????continue
		if(d[p.first]) continue;

		string str = p.first;

		//??¨?????????????????????????????§??????
		bool flag = false;
		for(int i=0;i<str.size()-1;i++){
			if(str[i] != str[i+1]){
				flag = true;
				break;
			}
		}
		//????????????return
		if(!flag) return p.second;

		//???????????????????????\??¨
		d[p.first] = p.second;

		for(int i=0;i<str.size()-1;i++){
			//??£??????????????§????????°????????¨???
			if(str[i] != str[i+1]){
				char temp;
				string next;

				//temp?????????????????????????????£??\
				if(str[i] != 'b' && str[i+1] != 'b'){
					temp = 'b';
				}else if(str[i] != 'g' && str[i+1] != 'g'){
					temp = 'g';
				}else{
					temp = 'r';
				}

				//?????????????????????next?????°?????????
				next = str;
				next[i] = next[i+1] = temp;

				//?????\?????????????????\
				que.push(P(next, p.second+1));
			}
		}
	}
	return -1;
}

int main(){
	string worm;
	while(cin >> worm && worm != "0"){
		int ret = bfs(worm);
		if(ret>=0) cout << ret << endl;
		else cout << "NA" << endl;
	}
}

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

int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	int n=s.size();
	long long tmp=1LL,ans=0LL,memo=0LL;
	for (int i = 0; i < n-1; ++i)
	{
		if (s[i]!=s[i+1])
		{
			ans+=(tmp+1LL)*tmp/2LL;
			if (s[i]=='<')
			{
				ans-=tmp;
				memo=tmp;
			}
			else if (memo>tmp)
			{
				ans-=tmp;
				ans+=memo;
			}
			tmp=1LL;
		}
		else
		{
			++tmp;
		}
	}
	ans+=(tmp+1LL)*tmp/2LL;
	if (s[n-1]=='>'&&memo>tmp)
	{
		ans-=tmp;
		ans+=memo;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll A,B,T;
  cin >> A >> B >> T;
  cout << (T/A)*B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  int N;
  string S;
  cin >> N;
  cin >> S;
  bool repeat = true;
  if (N % 2 == 1)
  {
    repeat = false;
    cout << "No" << endl;
  }
  else
  {
    for (int i = 0; i < N/2; i++)
    {
      if (S[i] != S[N / 2 + i])
      {
        repeat = false;
        cout << "No" <<endl;
      }
    }
  }
  if (repeat == true)
  {
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){function t(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=[],n=!0,o=!1,u=void 0;try{for(var i,f=e[Symbol.iterator]();!(n=(i=f.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(e){o=!0,u=e}finally{try{n||null==f.return||f.return()}finally{if(o)throw u}}return t}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}e.exports=function(e){for(var r=t(e.split("\n")[0].split(" ").map(function(e){return Number(e)}),3),n=r[0],o=r[1],u=r[2],i=1;i<=10;i++)u=n*u-o,console.log(u)}},function(e,r){e.exports=require("fs")}]);

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

int main(){
    int K,l,count=0;
    string S;
    cin>>S>>K;

    for (int i=0;i<S.length();i++){
        l = S[i] - '0';
        if (l==1){
            count+=l;
            if (count<K){
                continue;
            }
            else{
                cout << S[i] << endl;
                break;
            }
        }
        
        else{
            cout << S[i] << endl;
            break;
        }
        }
    }

Measured memory_bytes: 256
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;
const auto MOD = 1000000007;
const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef vector<int> VI;
typedef vector<long long> VLL;


int n, m;
string s;

int main() {
	cin >> n>>m;
	cout << (n+2*m)/(2*m+1) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string.h>
const int MAXN = 2000000+7;
using namespace std;
int a[MAXN];
int b[MAXN];
int c[MAXN];
int n;
void countSort(){
	memset(c, 0, sizeof(int)*MAXN);
	int maxm;
	for(int i = 0; i < n; i++){
		if(i == 0) maxm = a[i];
		else maxm = max(maxm,a[i]);
		c[a[i]] += 1;
	}
	for(int i = 1; i <= maxm; i++){
		c[i] = c[i-1] + c[i];
	}
	for(int i = n-1; i >= 0; i--){
		b[c[a[i]]-1] = a[i];
		c[a[i]] -= 1;
	}
} 
int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	countSort();
	for(int i = 0; i < n; i++){
		if(i!=0) printf(" ");
		printf("%d", b[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 26660
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

struct point {
  int x, y;

  point() {}

  point(int _x, int _y): x(_x), y(_y) {}

  point operator - (const point &p) const {
    return point(x - p.x, y - p.y);
  }

  long long slen() const {
    return (long long) x * x + (long long) y * y;
  }

  ld len() const {
    return sqrt(slen());
  }
};

const int maxn = 16, pown = (1 << maxn);
int n;
point p[maxn];
int a[maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", &p[i].x, &p[i].y, &a[i]);
  }
  return true;
}

ld mst[pown];
ld val[pown];
ld dp[pown];

void solve() {
  mst[0] = 0;
  for (int i = 1; i < (1 << n); i++) {
    if (__builtin_popcount(i) == 1) {
      mst[i] = 0;
    } else {
      mst[i] = 100. * inf;
      for (int j = 0; j < n; j++) {
        if (i & (1 << j)) {
          for (int k = 0; k < n; k++) {
            if (k != j && (i & (1 << k))) {
              mst[i] = min(mst[i], mst[i ^ (1 << j)] + (p[j] - p[k]).len());
            }
          }
        }
      }
    }
    val[i] = 0;
    for (int j = 0; j < n; j++) {
      if (i & (1 << j)) {
        val[i] += a[j];
      }
    }
    val[i] -= mst[i];
    val[i] /= __builtin_popcount(i);
  }
  dp[0] = inf;
  for (int i = 1; i < (1 << n); i++) {
    dp[i] = 0;
    for (int j = i;; j = ((j - 1) & i)) {
      dp[i] = max(dp[i], min(dp[i ^ j], val[j]));
      if (!j) {
        break;
      }
    }
  }
  printf("%.20f\n", (double) dp[(1 << n) - 1]);
}

int main() {
  precalc();
#ifdef LOCAL
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)


//template functions
/////////////////////////
long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}
long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}
/////////////////////////



//Answer


int main() {
long N;
cin>>N;
long M;
vector<long> a(10001);
for(long x=1;x<100;x++){
    for(long y=1;y<100;y++){
        for(long z=1;z<100;z++){
            M=x*x+y*y+z*z+x*y+y*z+z*x;
            if(M<=10000){
                a.at(M)++;
            }
        }
    }
}
for(long i=1;i<N+1;i++){
    cout<<a.at(i)<<endl;
}


}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> pint;

const int SIZE=100010;
const int INF=1e18;

int N,M;
vector<int> G[SIZE];
int dist[SIZE][3];

void bfs(int s)
{
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            dist[i][j]=INF;
        }
    }
    dist[s][0]=0;
    queue<pint> Q;
    Q.push({s,0});

    while(!Q.empty()){
        int v=Q.front().first;
        int x=Q.front().second;
        Q.pop();
        for(int u:G[v]){
            int y=(x+1)%3;
            if(dist[u][y]==INF){
                dist[u][y]=dist[v][x]+1;
                Q.push({u,y});
            }
        }
    }
}

signed main(){
    cin>>N>>M;
    for(int i=0;i<M;i++){
        int u,v; cin>>u>>v;
        u--; v--;
        G[u].push_back(v);
    }
    int s,t; cin>>s>>t;
    s--; t--;
    
    bfs(s);
    cout<<(dist[t][0]==INF? -1:dist[t][0]/3)<<endl;
    return 0;
}

Measured memory_bytes: 8064
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

//		System.setIn(new FileInputStream("tc/1.txt"));
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();

		int[] C = new int[N];
		for (int i = 0; i < N; i++) {
			C[i] = sc.nextInt();
		}
		
		int min = Integer.MAX_VALUE;
		int start = 0;
		int end = K - 1;
		while (end < N) {
			int doubleDis = Integer.min(Math.abs(C[start]), Math.abs(C[end]));
			min = Integer.min(min, C[end] - C[start] + doubleDis);
			start++;
			end = start + K - 1;
		}
		System.out.println(min);
		sc.close();
	}
}

Measured memory_bytes: 50676
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a[3],b[3];
	int d=0;
	for(int i=0;i<=2;++i)cin>>a[i];
	for(int i=0;i<=2;++i)cin>>b[i];
	for(int i=0;i<=2;++i){
		if(a[i]==b[2-i])++d;
	}
  if(d==3)cout<<"YES";
  else cout<<"NO";
}

Measured memory_bytes: 256
S = input()
ans = 'NA'
mmyy = False
yymm = False
if S[0]=='0' and S[1]!='0':
  mmyy = True
if S[0]=='1' and (S[1]=='0' or S[1]=='1' or S[1]=='2'):
  mmyy = True
if S[2]=='0' and S[3]!='0':
  yymm = True
if S[2]=='1' and (S[3]=='0' or S[3]=='1' or S[3]=='2'):
  yymm = True
lis = [['NA','YYMM'],['MMYY','AMBIGUOUS']]
ans = lis[mmyy][yymm]

print(ans)

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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int a, b; cin >> a >> b;
  cout << max(0, a - 2 * b) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, (b)<(e)?1:-1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define FOR(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)(__VA_ARGS__)
#ifdef LOCAL
#define dbg(x) cerr << '[' << #x << ":" << (x) << "]\n"
#else
#define dbg(x)
#endif
int v[200000],x[200000];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;cin>>n;
	FOR(n)cin>>v[i],x[i]=v[i];
	FOR(i,n-2,-1)x[i]^=x[i+1];
	ll xs=0;
	FOR(i,n){
		ll ans=0;
		if(i&1){
			ans=v[i-1];
			if(i+1<n)ans^=x[i+1];
			ans^=xs;
			xs^=v[i]^v[i-1];
		}else{
			ans=v[i+1];
			if(i+2<n)ans^=x[i+2];
			ans^=xs;
		}
		cout<<ans<<' ';
	}
}

Measured memory_bytes: 5228
#include <bits/stdc++.h>
#include <math.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define ept 1e-9

using namespace std;
inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}
const int mod = 1e9 + 7;
ll ps[200010], as[200010];
vector<int>pos;
void cut(ll &val, int pos1, int pos2)
{
    if (pos1 > pos2) return;
    val -= as[pos2] - as[pos1 - 1];
}

int main()
{
    int n = read();
    int val = read();
    ps[1] = val;
    as[1] = val;
    rep(i, 2, n)
    {
        int val;
        char op;
        cin >> op;
        scanf("%d", &val);
        if (op == '+') ps[i] = ps[i - 1] + val;
       	else ps[i] = ps[i - 1] - val, pos.push_back(i);
        as[i] = as[i - 1] + val;
    }
    ll ans = ps[n];
    int nn = pos.size() - 2;
    rep(i, 0, nn)
    {
        int p1 = pos[i], p2 = pos[i + 1];
        ll tans = as[n] - as[p2 - 1];
        tans += ps[p1];
        cut(tans, p1 + 1, p2 - 1);
        ans = max(ans, tans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2296
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
#include <thread>
using namespace std;

int main(int argc, char *argv[]) {
	vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;
	cout << v[k - 1] << endl;

}









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

int bombCheck(char);

int bombnum(int,int,vector<string>&);

int main(){

    int H=0,W=0;

    cin >> H >> W;

    vector<string> sin(H+2);
    string s;

    for(int j=0;j<W+2;j++){
        sin.at(0) += ".";
        sin.at(H+1) += ".";
    }

    for(int i=1;i<H+1;i++){
        cin >> s;
        sin.at(i) = "." + s + ".";
    }

    for(int i=1;i<H+1;i++){
        for(int j=1;j<W+1;j++){
            if(sin.at(i).at(j) == '.'){
                cout << bombnum(i,j,sin);
            }else{
                cout << sin.at(i).at(j);
            }
        }
        cout << endl;
    }

    return 0;
}

int bombnum(int i,int j,vector<string>& s){
    int num=0;
    num +=  bombCheck(s.at(i-1).at(j-1))+
            bombCheck(s.at(i-1).at(j))+
            bombCheck(s.at(i-1).at(j+1))+
            bombCheck(s.at(i).at(j-1))+
            bombCheck(s.at(i).at(j+1))+
            bombCheck(s.at(i+1).at(j-1))+
            bombCheck(s.at(i+1).at(j))+
            bombCheck(s.at(i+1).at(j+1));
    return num;
}

int bombCheck(char s){
    if(s == '#'){
        return 1;
    }else{
        return 0;
    }
}


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

int main(){
  vector<string> s;
  int n, l; cin >> n >> l;
  for (int i = 0; i < n; i++) {
    string k; cin >> k;
    s.push_back(k);
  }
  sort(s.begin(), s.end());
  for (int i = 0; i < n; i++) {
    cout << s[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int w = sc.nextInt();
        if (s <= w) {
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }
    }
}

Measured memory_bytes: 35772
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void solve()
{
    set<int> psa,psb;
    int a,b,i;
    cin>>a>>b;
    for(i=ceil(a/.08);i<floor((a+1)/0.08);++i)
        psa.insert(i);
    for(i=ceil(b/.1);i<floor((b+1)/0.1);++i)
        psb.insert(i);
    for(auto it=psa.begin();it!=psa.end();++it)
        {
            if(psb.find(*it)!=psb.end())
            {
                cout<<*it<<endl;
                return ;
            }

        }
        cout<<-1<<endl;
}
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //int _t;cin>>_t;while(_t--)
    solve();
    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>
#include<math.h>

using namespace std;

void Solution()
{
    string taro, hanako;
    int sTaro = 0; 
    int sHanako = 0;
    
    int n;
    
    cin>>n;
    while(n--)
    {
        cin>>taro>>hanako;
        
        if(taro > hanako) //alphabet comparison is based on ASC||
        {
            sTaro += 3; 
        }
        else if (taro == hanako)
        {
            sTaro++;
            sHanako++;
        }
        else
        {
            sHanako += 3;
        }
    }
    
    cout<<sTaro<<" "<<sHanako<<endl; 
}

int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1212
INF = float('inf')

N, M = map(int, input().split())
a = list(map(int, input().split()))

num = [N + 1, 2, 5, 5, 4, 5, 6, 3, 7, 6]
# num[数字] = 必要なマッチ棒の本数
# 数字0は使用できない

dp = [-INF for _ in range(N + 1)]
dp[0] = 0
# dp[マッチ棒の本数] = 構成可能な最大桁数
# 最大桁数を求めるので、初期値-INFとして、maxで更新

for i in range(1, N + 1):
    for aa in a:
        # aa: 使用可能な数字
        idx = i - num[aa]
        if idx >= 0:
            dp[i] = max(dp[i], dp[idx] + 1)

a = list(sorted(a, reverse=True))
# 降順ソート

need = dp[N]
# 構成可能な最大整数が必要とする桁数

rest = N
# 使用可能なマッチ棒の本数

ans = ''

while need > 0:
    for aa in a:
        # aa: 使用可能な数字（降順）
        idx = rest - num[aa]
        if idx >= 0:
            # マッチ棒の本数が足りるため、数字aaを使用できる場合
            if dp[idx] == need - 1:
                ans += str(aa)
                # ans末尾にaaを追記

                rest -= num[aa]
                need -= 1

                break
                # 次の桁の調査でaa[0]から試すため
print(ans)


Measured memory_bytes: 3316