akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <numeric>
#include <algorithm>
#include <cassert>

using namespace std;


int main()
{
    int n;
    cin >> n;
    string r = "1";
    while(--n){
        //cout << r << ',';
        const auto min_digit = *min_element(begin(r),end(r));
        if(min_digit == '9'){
            r = "1" + string(r.size(), '0');
            continue;
        }
        if(r.size() == 1)
        {
            r[0] += 1;
            continue;
        }
        for(auto d = rbegin(r); d != rend(r); ++d)
        {
            if(d+1 == rend(r) || *(d+1) >= *d){
                if(*d == '9') continue;
                *d += 1;
                if(d != rbegin(r)){
                    for(; d != rbegin(r); --d){
                        *(d-1) = *d == '0' ? '0' : *d - 1;
                    }
                }
                break;
            }
        }
    }
    cout << r << '\n';
    return 0;
    /*
    10
    11
    12
    21
    22
    23
    32
    33
    34
    43
    44
    45
    54
    55
    56
    ...
    98
    99
    100
    101
    110
    111
    112
    121
    122
    123
    210
    211
    212
    221
    222
    223
    232
    233
    234
    321
    322
    323
    332
    333
    334
    343
    344
    345
    
    1223
    
    */
    
    return 0;
}


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

is_DENIED = False

for a in A:
    if a % 2 == 0:
        if not (a % 3 == 0 or a % 5 == 0):
            is_DENIED = True
            break

if is_DENIED:
    print('DENIED')
else:
    print('APPROVED')


Measured memory_bytes: 2940
N,W = map(int,input().split())
w=[-1]
v=[-1]
for i in range(N):
   x,y = map(int,input().split())
   w.append(x)
   v.append(y)

dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(1,N+1):
    for j in range(1,W+1):
        if j-w[i]>=0:
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]]+v[i])
        else:
            dp[i][j] = dp[i-1][j]

print(dp[N][W])

Measured memory_bytes: 147548
import numpy as np
import itertools as ittr

def test_switch(e_balls, sw, p):
    for i, e_ball in enumerate(e_balls):
        si = sw[e_ball - 1]
        
        if p[i] != (np.sum(si == 1) % 2):
            return False
    
    return True

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

e_balls = []

for m in range(M):
    i = input().split()
    s = [int(si) for si in i[1:]]
    e_balls.append(np.asarray(s))

p = [int(pi) for pi in input().split()]

cnt = 0

for sw in ittr.product([0, 1], repeat = N):
    if test_switch(e_balls, np.array(sw), p):
        cnt += 1

print(cnt)

Measured memory_bytes: 14456
#include<bits/stdc++.h>
const int mod = 1000000007;

long long pow_mod(long long base,long long exp,long long mod){
    long long res = 1;
    while(exp>0){
        if(exp & 1)res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for(int i = 0; i < n; i++)std::cin >> a[i];
    std::sort(a.begin(),a.end());
    if(n  & 1){
        bool res = true;
        if(a[0] != 0)res = false;
        for(int i = 1; i < n; i+=2){
            if(a[i] != a[i + 1] || a[i] != ((i+1) / 2) * 2)res = false;
        }
        if(!res) std::cout << 0 << std::endl;
        else std::cout << pow_mod(2,n / 2,mod) << std::endl;
    }else{
        bool res = true;
        for(int i = 0; i < n; i += 2){
            if(a[i] != a[i + 1] || a[i] != i + 1)res = false;
        }
        if(!res)std::cout << 0 << std::endl;
        else std::cout << pow_mod(2,n / 2, mod) << std::endl;
    }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int ans=0,ans2=0;
int main()
{
	int n;
	string s;
	cin>>n>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='I')
			ans2++;
		else
			ans2--;
		ans=max(ans,ans2);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
using namespace std;
int main ()
{
   int a,b;
   scanf("%d %d",&a,&b);
   int c = 0,s = 0;
   s = a*b;
   c = (a+b)*2;
   printf("%d %d\n",s,c);
  return 0 ;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

int get(int a, int b) {
    return (a + b - 1) / b;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, d;
    cin >> n >> d;
    cout << get(n, 2 * d + 1);
    return 0;
}


Measured memory_bytes: 256
/* SmartCoder Apr 7, 2019 */
#include <bits/stdc++.h>
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end();i++)
#define present(c,x)  ( (c).find(x) !=(c).end())
#define cpresent(c,x) (find(all(c),x)!= (c).end() )
#define minei(x)  min_element(x.begin(),x.end())-(x).begin()
#define maxei(x)  max_element(x.begin(),x.end())-(x).begin()

#define uns(v)     sort((v).begin(),(v).end()),v.erase(unique(v.begin(),v.end()),v.end())
#define acusum(x)  accumulate(x.begin(),x.end(),0)
#define acumul(x)  accumulate(x.begin(),x.end(),1, multiplies<int>());
#define bits(x)     __builtin_popcount( x )
#define oo INT_MAX
#define inf 1000000000

const double pi = acos(-1.0);
const double eps = 1e-11;
#define MAXN 100007
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
void fastIO() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
vector<int> adj[MAXN];
int nodes[MAXN];
int inDegree[MAXN];
vector<int> zeroInDegree;
int dp[MAXN];
int res = 0;
void dfs(int a) {
	for (int i = 0; i < sz(adj[a]); i++) {
		int b = adj[a][i];
		dp[b] = max(dp[b], dp[a] + 1);
		res = max(res, dp[b]);
		inDegree[b]--;
		if (inDegree[b] == 0)
			dfs(b);
	}
}
int main() {
	fastIO();
	int n, m, a, b;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		adj[a].pb(b);
		inDegree[b]++;
	}
	for (int i = 1; i <= n; i++) {
		if (inDegree[i] == 0)
			zeroInDegree.pb(i);
	}

	for (int i = 0; i < sz(zeroInDegree); i++) {
		dfs(zeroInDegree[i]);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 11264
s = input()
k = int(input())
l=len(s)
s+='?'
ch = 1
ans=0
j=0

for i in range(l):
    if s[i]==s[i+1]:
        ch+=1
    else:
        ans+=ch//2
        if j==0:
            st=ch
        if s[i+1]=='?':
            gl=ch
        ch=1
        j=1
ans*=k
if st%2==1 and gl%2==1 and s[0]==s[l-1]:
    ans+=k-1

if st==l:
    ans=l*k//2

print(ans)


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

long n, m;
long cnt[100005];

int main(){
	scanf("%ld %ld", &n, &m);
	for(int i = 0; i < m; i++){
		long a, b;
		scanf("%ld %ld", &a, &b);
		cnt[a]++;
		cnt[b]++;
	}
	for(int i = 1; i <= n; i++){
		if(cnt[i] % 2 == 1){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int a, b, c;

int main() {
	cin >> a >> b >> c;
	bool flag = false;
	inc1(i, b) {
		if(a * i % b == c) { flag = true; break; }
	}
	
	cout << (flag ? "YES" : "NO") << endl;
	
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import bisect


def divisors(n):
    ds = []
    for i in range(1, int(n ** 0.5) + 1):
        d, m = divmod(n, i)
        if m == 0:
            ds.append(i)
            ds.append(d)
    ds.sort()
    return ds


def find_ge(a, x):
    i = bisect.bisect_left(a, x)
    if i != len(a):
        return a[i]
    raise ValueError


def solve(n, m):
    ds = divisors(m)
    t = find_ge(ds, n)
    return m // t


def main():
    n, m = (int(z) for z in input().split())
    res = solve(n, m)
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, x;
  int count = 0;
  cin >> a >> b >> c >> x;
  for (int i = 0; 500 * i <= x; i++) {
    for (int j = 0; 100 * j <= x - 500 * i; j++) {
      if (a >= i && b >= j && c >= (x - 500 * i - 100 * j) / 50){
        count++;
      }
    }
  }
cout << count <<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define in insert
#define ff first
#define ss second
#define mp make_pair
#define int long long
#define uint unsigned long long
#define rep(i,x,m) for(int i=x;i<m;i++)
#define repr(i,x,m) for(int i=x;i>=m;i--)
#define MOD 1000000007
#define endl "\n"
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define vi vector<int>
#define vs vector<string>
#define print(v) for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
using namespace std;
#define noob ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void ram5564()
{
    string s1,s2;
    cin>>s1>>s2;
    int a,b;
    cin>>a>>b;
    map<string ,int>mpp;
    mpp[s1]=a;
    mpp[s2]=b;
    string u;
    cin>>u;
    mpp[u]--;
    cout<<mpp[s1]<<" "<<mpp[s2];
}

signed main()
{
        noob
        // #ifndef ONLINE_JUDGE
        //  freopen("input.txt","r",stdin);
        //  freopen("output.txt","w",stdout);
        //  #endif   
        
        int t=1;
        //  cin>>t;
        while(t--)
        ram5564();
        return 0;
}

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

int main(){
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  
  vector<int> Time = {a, b, c, d, e};
  
  int n = 5;
  vector<int> NextTime(n);
  
  //time containing the waiting loss
  for (int i = 0; i < n; i++) {
    int nextTenMultiple = (Time.at(i) + 9) / 10 * 10;
    NextTime.at(i) = nextTenMultiple;
  }
 
  
  int diff = 0;
  int position = 0;
  
  //find where the largest difference is located
  for (int i = 0; i < n; i++) {
    if (NextTime.at(i) - Time.at(i) > diff) {
      diff = NextTime.at(i) - Time.at(i);
      position = i;
    }
  }
  
  int sum = 0;
  
  for (int i = 0; i < n; i++) {
    if (i != position) {
      sum += NextTime.at(i);
    }
    else {
      sum += Time.at(i);
    }
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 256
fun main(a:Array<String>){
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map{ it.toInt() }
    val list = IntArray(n)
    for (i in 0 until n) {
        list[a[i]-1] = i + 1
    }
    println(list.joinToString(" "))
}

Measured memory_bytes: 56068
import sys
from collections import deque
input = sys.stdin.readline

STEPS = [
    (0, 1),
    (1, 0)
]
BLACK = '#'
WHITE = '.'
CHECKED = 't'
INF = float('INF')

def main():
    H, W = map(int, input().split())
    board = [list(input().strip()) for _ in range(H)]
    scores = [[INF] * W for _ in range(H)]


    if board[0][0] == WHITE:
        scores[0][0] = 0
    else:
        scores[0][0] = 1

    que = deque([[0, 0, board[0][0]]])


    while que:
        y, x, color = que.popleft()
        score = scores[y][x]

        for (i,j) in STEPS:
            ny, nx = y + i, x + j
            if ny >= H or nx >= W:
                continue

            target = board[ny][nx]
            n_score = score

            if color == WHITE and target == BLACK:
                n_score += 1

            if n_score < scores[ny][nx]:
                scores[ny][nx] = n_score
                que.append([ny, nx, target])

    print(scores[H-1][W-1])


if __name__ == "__main__":
    main()


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

#define pb push_back
#define F first
#define S second
#define rep(i,n) for(int i = 0; i < (n); i++)

using ll = long long;
using ld = long double;
using ul = unsigned long long;
using ii = pair<int, int>;
#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ReadFile            freopen("input.in","r",stdin)
#define WriteFile           freopen("output.txt","w",stdout)
const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;
const ld EPS = 1e-7;
double Pi=acos(-1);
const ld rad=Pi/180.0;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll nCr (ll n,ll m)
{
        return(m == 0)?1:n*nCr(n-1,m-1)/m;
}
/*****************************************************/


map<ll, ll> factorize(ll n) {
    map<ll, ll> res;
    res[1] = 1;

    for (ll i = 2; i * i <= n; i++) {
        if (n % i != 0) {
            continue;
        }
        res[i] = 0;
        while (n % i == 0) {
            n /= i;
            res[i]++;
        }
    }

    if (n != 1) res[n] = 1;
    return res;

}

int main() {
    ll a, b;
    cin >> a >> b;

    map<ll, ll> f1 = factorize(a), f2 = factorize(b);

    int i = 0;
    for (auto e : f1) {
        if (f2.find(e.first) != f2.end()) i++;
    }
    cout << i << endl;

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
   int n,k;
   string s;
   cin>>n>>k>>s;
   int cnt=0;
  //区切りをカウント
   for (int i = 0; i < n-1; i++)
   {
       if(s[i]!=s[i+1]) cnt++;
   }
    cout<<n-1-max(0,(cnt-2*k))<<endl;
   
   
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <list>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<ll> H(N);
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    vector<ll> dp(N+100);
    dp[0]=0;
    for(int i=1;i<N;i++){
        if(i==1){
            dp[i]=llabs(H[i]-H[0]);
        }
        else dp[i]=min(dp[i-2]+llabs(H[i]-H[i-2]),dp[i-1]+llabs(H[i]-H[i-1]));
    }
    cout << dp[N-1] << endl;

}

Measured memory_bytes: 1792
#include <stdio.h>

/*  選択ソート(0オリジン) */
int selectionSort(int A[], int N) {
    int i, j, t, sw =0, minj;
    for(i=0;i<N-1;i++) {
        minj = i;
        for(j=i;j<N;j++) {
            if(A[j]<A[minj]) minj = j;
        }
        t=A[i]; A[i]=A[minj]; A[minj]=t;
        if(i!=minj) sw++;
    }
    return sw;
}

int main(void) {
    int A[100], N, i, sw;

    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = selectionSort(A,N);

    for(i=0;i<N;i++) {
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",sw);

    return 0;
}


Measured memory_bytes: 2096
def conv(str)
    eval(?[ + str.gsub(?[, '').gsub(?], ?,).gsub(?(, ?[).gsub(?), '],') + ?])
end

def merge(a, b)
    return [] if a.empty? or b.empty?
    [merge(a[0], b[0]), a[1] + b[1], merge(a[2], b[2])]
end

def inv(a)
    return '()' if a.empty?
    "(#{inv(a[0])}[#{a[1]}]#{inv(a[2])})"
end

a = conv(gets.chomp)
b = conv(gets.chomp)

puts inv(merge(a, b))[1..-2]

Measured memory_bytes: 8948
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}


int main(){
#ifdef LOCAL_REDIR
  freopen("/home/hog/Dropbox/pg/working/in.txt","r",stdin);
#endif
  int h,w,K;cin>>h>>w>>K;

  REP(i,h+1) REP(j,w+1){
      if(i*j+(h-i)*(w-j)==K){
        puts("Yes");
        return 0;
      }
    }
  puts("No");

  return 0;
}






Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>

std::string s;

int main(){
	std::cin >> s;
	for(int i=1; 2*i<s.size(); ++i){
		std::string a, b;
		a = s.substr(0, (s.size()-2*i)/2);
		b = s.substr((s.size()-2*i)/2, (s.size()-2*i)/2);
		if(a == b){
			std::cout << s.size() - 2*i << std::endl;
			break;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define all(vec) vec.begin(), vec.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl
#define isEven(t) t % 2 == 0

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


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

	int A,B,C,D;
	cin>>A>>B>>C>>D;
	cout << min(A, B) + min(C, D) << endl;

	return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "2018", "218" ].parse.expand.solve == "Yes" );
	assert( [ "2763", "0" ].parse.expand.solve == "No" );
	assert( [ "37", "514" ].parse.expand.solve == "Yes" );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	input.popFront;
	auto a = input.front.strip.to!( long );
	return tuple( n, a );
}

auto solve( long n, long a )
{
	return ( n % 500 <= a ) ? "Yes" : "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define N 100005

using namespace std;
typedef pair<int,int> Pair;
typedef long long ll;

const long double Pi = 3.14159265358979323846l;
const int mod = 1e9 + 7;
inline int add(int x, int y) { return (x += y) - (x >= mod ? mod : 0); }
inline void inc(int &x, int y) { (x += y) -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = mul(res, x);
		x = mul(x, x), y >>= 1;
	} return res;
}

template <class T> inline T	input() {
	T x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

template <class T> inline void chkmin(T &x, T &y) { x = x < y ? x : y; }
template <class T> inline void chkmax(T &x, T &y) { x = x > y ? x : y; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

int n, K;
int a[N], vis[N];
vector<int> T[N];
priority_queue<Pair> que;

inline void AddEdge(int x, int y) {
	T[x].push_back(y);
	T[y].push_back(x);
}

int main() {
	read(n);
	for (int i = 1; i < n; ++i) AddEdge(read, read);
	read(K);
	for (int i = 1, u, val; i <= K; ++i) {
		read(u, val), a[u] = val, vis[u] = 1;
		que.push(MP(val, u));
	}

	while (!que.empty()) {
		int u = que.top().se; que.pop();
		for (int v : T[u]) {
			if (!vis[v]) {
				vis[v] = 1, a[v] = a[u] - 1;
				que.push(MP(a[v], v));
			} else if (abs(a[v] - a[u]) != 1) return puts("No"), 0;
		}
	}

	puts("Yes");
	for (int i = 1; i <= n; ++i)
		printf("%d\n", a[i]);
	return 0;
}


Measured memory_bytes: 8308
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int x[10], y[10];

double aaa(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> x[i] >> y[i];
    }
    vector<int> v(n);
    rep(i, n) v[i] = i+1;
    double sum = 0.0;
    do{
        for(int i = 0; i < n-1; i++) sum += aaa(v[i], v[i+1]);
    }while(next_permutation(all(v)));
    int ju = 1;
    for(int i = 2; i <= n; i++) ju *= i;
    double ans = sum / ju;
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

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

int main(){
    string S, T; cin >> S >> T;
    int s = S.size(); int t = T.size();
    int maxi = 0;
    for (int i = 0; i <= s - t; i++){
        int cnt = 0;
        for (int j = 0; j < t; j++){
            if (S[i+j] == T[j]){
                cnt++;
            }
        }
        if (cnt > maxi){
            maxi = cnt;
        }
    }
    cout << t - maxi << '\n';
}

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

const int N = 1e5 + 5;

int n, a[N], root;
vector<int> edge[N];

void dfs(int u, int p) {
	int sum = 0, mx = 0;
	for(int i = 0; i < edge[u].size(); ++i) {
		int v = edge[u][i];
		if(v == p) continue;
		dfs(v, u);
		sum += a[v];
		mx = max(mx, a[v]);
	}
	if(edge[u].size() == 1) return;
	int x = sum - a[u], y = sum - 2 * x;
	if(x < 0 || y < 0) { cout << "NO"; exit(0); }
	if(mx <= sum / 2 && x > sum / 2) { cout << "NO"; exit(0); }
	if(mx > sum / 2 && x > sum - mx) { cout << "NO"; exit(0); } 
	a[u] = y;
}

int main() {
	cin >> n;
	for(int i = 1; i <= n; ++i) cin >> a[i];
	for(int i = 1; i < n; ++i) {
		int u, v;
		cin >> u >> v;
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	for(int i = 1; i <= n; ++i) if(edge[i].size() > 1) root = i;
	if(root) dfs(root, root);
	else if(a[1] != a[2]) { cout << "NO"; exit(0); }
	if(a[root]) { cout << "NO"; exit(0); }
	cout << "YES";
}

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

int n,m,s,t;

vector<P>v1[200007],v2[200007];

int dist[200005];
int dist2[200005];

void dij(int s,int tt){
  priority_queue<P,vector<P>,greater<P> >q;
  q.push(P(0,s));
  dist[s]=0;
  while(!q.empty()){
    P p=q.top();q.pop();
    int cost=p.first;
    int now=p.second;//cout<<now<<cost<<endl;
    if(dist[now]<cost)continue;
    r(i,v1[now].size()){
      int nex=v1[now][i].first;
      int c=v1[now][i].second+cost;
      if(dist[nex]<=c)continue;
      //cout<<now<<' '<<nex<<' '<<c<<' '<<dist[nex]<<endl;
      dist[nex]=c;
      q.push(P(c,nex));
    }
  }
}

void dij2(int s,int tt){
  priority_queue<P,vector<P>,greater<P> >q;
  q.push(P(0,s));
  dist2[s]=0;
  while(!q.empty()){
    P p=q.top();q.pop();
    int cost=p.first;
    int now=p.second;
    if(dist2[now]<cost)continue;
    r(i,v2[now].size()){
      int nex=v2[now][i].first;
      int c=v2[now][i].second+cost;
      if(dist2[nex]<=c)continue;
      dist2[nex]=c;
      q.push(P(c,nex));
    }
  }
}

signed main(){
  r(i,200007)dist[i]=dist2[i]=1e15;
  cin>>n>>m>>s>>t;
  s--;t--;
  r(i,m){
    int x,y,z,q;
    scanf("%ld%ld%ld%ld",&x,&y,&z,&q);
    x--;y--;
    v1[x].push_back(P(y,z));
    v1[y].push_back(P(x,z));
    v2[x].push_back(P(y,q));
    v2[y].push_back(P(x,q));
  }
  dij(s,0);
  dij2(t,0);
  int ans=1e15;
  int A[n];
  for(int i=n-1;i>=0;i--){
    //cout<<dist[i]<<endl;
    A[i]=dist[i]+dist2[i];
  }
  for(int i=n-2;i>=0;i--){
    //cout<<A[i]<<' '<<A[i+1]<<endl;
    A[i]=min(A[i],A[i+1]);
  }
  r(i,n)cout<<(int)1e15-A[i]<<endl;
}

Measured memory_bytes: 25468
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
			
		System.out.println(Math.min(n*a, b));
	}
	
	private static int getDigitSum(int num) {
		int res = 0;
		while (num > 0) {
			res += (num % 10);
			num /= 10;
		}
		return res;
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 21204
package main

import (
	"fmt"
	"strings"
)

func main() {
	var w string
	fmt.Scan(&w)
	for _, c := range w {
		if strings.Count(w, string(c))%2 != 0 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    if(n>=k)
    {
    ll a=k*x;
    ll b=y*(n-k);
    ll c=a+b;
    cout<<c<<endl;
    }
    else
    {
        ll c=n*x;
        cout<<c<<endl;
    }

}


Measured memory_bytes: 3588
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		boolean ok = ((a+b)%3==0 || a%3==0 || b%3==0);
		System.out.println(ok ? "Possible" : "Impossible");
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}


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

using ll = long long;
const int INF = 1e9+100;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin>>n;
	ll ans = 0;
	for (int i = 1; i <= n; i++){
		ans += (n-1)/i;
	}
	cout<<ans<<'\n';
	return 0;
}

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

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

using namespace std;


int main()
{
	long long N;
	long long K;
	cin>>N>>K;
	
	vector<pair<int,int> >pairs(N);
	
	for(int i=0;i<N;++i){
		int a,b;
		cin>>a>>b;
		
		pairs.push_back(make_pair(a,b));
	}
	
	sort(pairs.begin(),pairs.end());
	
	int i=0;
	while(true){
		int a = pairs[i].first;
		int b = pairs[i].second;
		
		K = K - b;
 
		if (K <= 0){
			cout<<a<<endl;
			return 0;
		}
		
		
		i++;
	}
		
	
	
	
	}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <unordered_map>

int main() {
    int N;
    std::cin >> N;

    std::vector<int> A(N + 1);
    std::unordered_map<int, int> m;
    for (int i = 1; i <= N; i++) {
        std::cin >> A[i];
        m[i - A[i]]++;
    }

    long long ans = 0;
    for (int i = 1; i <= N; i++) {
        m[i - A[i]]--;
        ans += m[A[i] + i];
    }
    
    std::cout << ans << "\n";
}

Measured memory_bytes: 19292
# -*- coding: utf-8 -*-

n = int(input())
money = []
sum = 0
for i in range(0,n):
    money.append(input().split())
for i in money:
    if i[1] == "JPY":
        sum += float(i[0])
    else:
        sum += float(i[0]) * 380000.0
print(sum)


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

using namespace std;

int main(int argc, char* argv[]){
    string s,before,after;
    long long int count=0;
    cin >> s;
    before += s[0];
    after ="";
    for(int i=1;i<s.size();i++){
        after +=s[i];
        if(before!=after) {
            before = after;
            after = "";
            count++;
        }
    }
    count++;
    cout << count<<endl;
    return 0;
}

Measured memory_bytes: 640
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2253

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

#define MAX 121
#define CONT 60

int T,N;

void dfs(int x, int y, int turn, vector< vector<int> > &field)
{
	int dx[6] = {0, 1, 1, 0, -1, -1};
	int dy[6] = {1, 1, 0, -1, -1, 0};

	if(x < 0 || x >= MAX || y < 0 || y >= MAX){ return; } //範囲外

	if(turn > T){ return; } //ターン数オーバー

	if(field[x][y] <= turn && field[x][y]){ return; } //到達修正
	if(field[x][y] == -1){ return; } //障害物

	field[x][y] = turn;
	
	rep(i,6){
		dfs(x+dx[i], y+dy[i], turn+1, field);
	}
}

int main()
{
	while(cin >> T >> N )
	{
		if(T == 0 && N == 0){ break; }

		vector< vector<int> > field(MAX,vector<int>(MAX,0));
	
		int X,Y;
		rep(nth,N)
		{
			cin >> X >> Y;
			field[X+CONT][Y+CONT] = -1;
		}

		int sx,sy;
		cin >> sx >> sy;
	
		int ans = 0;
		dfs(sx+CONT,sy+CONT,0,field);
		field[sx+CONT][sy+CONT] = 1;
		
		rep(y,MAX){
			rep(x,MAX){
				if(field[x][y] > 0){ ans++; }
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
using namespace std;
typedef long long lli;
lli h,w,n;
map<pair<lli,lli>,lli> m;
vector<lli> ans;
int main(int argc, char const *argv[]) {
    cin >> h >> w >> n;
    for(lli i = 0;i < n;i++){
        lli a,b;
        cin >> a >> b;
        for(lli x = -1;x <= 1;x++){
            for(lli y = -1;y <= 1;y++){
                m[make_pair(a+x,b+y)]++;
            }
        }
    }
    ans = vector<lli> (10);
    for(auto x : m){
        if(x.first.first <= 1 || x.first.first >= h || x.first.second <= 1 || x.first.second >= w) continue;
        ans[x.second]++;
    }
    ans[0] = (h-2)*(w-2)-accumulate(ans.begin(),ans.end(),0);
    for(lli i = 0;i < 10;i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 56448
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        boolean flag = false;
        for(int i = 0; i <= N/4; i++){
            for(int j = 0; j <= N/7; j++){
                if( i * 4 + j * 7 == N ){
                    flag = true;
                    break;
                }
            }
        }
        
        System.out.println( flag ? "Yes" : "No" );
        
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)




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

    int N; cin >> N;
    vei t(N+1), x(N+1), y(N+1);
    rep1(i,N+1) cin >> t[i] >> x[i] >> y[i];
    x[0] = 0;
    y[0] = 0;
    t[0] = 0;

    rep(i,N) {
        int delta_x = abs(x[i+1] - x[i]);
        int delta_y = abs(y[i+1] - y[i]);
        int delta_t = t[i+1] - t[i];

        if(delta_x + delta_y > delta_t) {
            cout << "No" << endl;
            return 0;
        }

        else {
            if((delta_x + delta_y - delta_t) % 2 == 0) continue;
            else {
                cout << "No" <<endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main(void){
    int n,m,i=0,allday=0,day;
    cin >> n >> m;
    while(i<m){
        cin >> day;
        allday += day;
        i++;
    }
    if(n>=allday) cout << n-allday << endl;
    else cout << -1 << endl;
}


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

int main()
{
	string S, T;
	cin >> S >> T;
	int N = S.size();
	bool ok = false;
	for (int i = 0; i < N + 1; i++) {
		if (S == T) {
			ok = true;
			break;
		}
		rotate(S.begin(), S.begin() + 1, S.end());
	}
	puts(ok ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int k = stdIn.nextInt();
		
		if(k>= b-a+1) {
			for(int i = a; i<=b;i++) {
				System.out.println(i);	
			}
			System.exit(0);
		}
		if(Math.ceil((b-a+1)/2.0) <= k){
			for(int i = a; i<=b;i++) {
				System.out.println(i);	
			}
			System.exit(0);
		
		}
		
		for(int i = a; i <a+k;i++) {
			System.out.println(i);
		}
		for(int i = b-k+1; i <= b; i++) {
			System.out.println(i);
		}
		
		
		
	}

}


Measured memory_bytes: 23252
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Set;
import java.util.StringTokenizer;

class Main{

	static class FastReader {

		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	public static void main(String[] args) throws IOException {
		FastReader sc = new FastReader();
int n =sc.nextInt();
System.out.println(n/3);
}
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

typedef string::const_iterator State;

int expression(State &begin);
int term(State &begin);
int number(State &begin);
int factor(State &begin);

// 四則演算の式をパースして、その評価結果を返す
int expression(State &begin){
    int ret = term(begin);
    while(1){
        if(*begin == '+'){
            begin++;
            ret += term(begin);
        }else if(*begin == '-'){
            begin++;
            ret -= term(begin);
        }else{
            break;
        }
    }
    return ret;
}

// 乗算除算の式をパースして、その評価結果を返す
int term(State &begin){
    int ret = factor(begin);
    while(1){
        if(*begin == '*'){
            begin++;
            ret *= factor(begin);
        }else if(*begin == '/'){
            begin++;
            ret /= factor(begin);
        }else{
            break;
        }
    }
    return ret;
}

// 括弧か数をパースして、その評価を返す
int factor(State &begin){
    if(*begin == '('){
        begin++;
        int ret = expression(begin);
        begin++;
        return ret;
    }else{
        return number(begin);
    }
}

// 数字の列をパースして、その数を返す
int number(State &begin){
    int ret = 0;
    while(isdigit(*begin)){
        ret *= 10;
        ret += *begin - '0';
        begin++;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    cin.ignore();
    for(int i=0; i<N; i++){
        string S;
        getline(cin,S);
        State begin = S.begin();
        int ans = expression(begin);
        cout << ans << enld;
    }
    return 0;
}


Measured memory_bytes: 3168
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 998244353

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def to_char(a):
    return chr(a + ord("a"))

def main():
    N = int(input()) - 1

    res = ""
    while N >= 26:
        res = to_char(N % 26) + res
        N //= 26
        N -= 1

    print(to_char(N) + res)


if __name__ == "__main__":
    main()



Measured memory_bytes: 68836
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
#define il inline
#define re register
#define pb push_back
#define db double
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define puu pair<ull,ull>
#define MP make_pair
#define lowbit(x) x&(-x)
#define fi first
#define se second
const int mod = 1e9+7;
il ll read()
{
	char ch = getchar();
	ll p = 1,data = 0;
	while(ch<'0'||ch>'9')
	{
		if(ch == '-')p = -1;
		ch = getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		data = data*10+(ch^48);
		ch = getchar();
	}
	return p*data;
}
il ll qpow(ll a,ll b)
{
	ll r = 1;
	while(b)
	{
		if(b&1)r = a*r;
		a = a*a;
		b>>=1;
	}
	return r;
}
il ll gcd(ll a,ll b)
{
	while(b ^= a ^= b ^= a %= b);
	return a;
}
il ll lcm(ll a,ll b)
{
	return a*b/gcd(a,b);
}
il void exgcd(ll a,ll b,ll &x,ll &y)
{
	if(!b)
	{
		x = 1,y = 0;
		return;
	}
	exgcd(b,a%b,y,x);
	y -= (a/b)*x;
}
il ll inv(ll a,ll p)
{
	return qpow(a,p-2);
}
const int maxn = 1e3+5;
int a[maxn];
int main()
{
	int n = read(),M,m = read();
	ll sum = 0;
	M = m;
	for(int i = 1; i <= n; i++)
		a[i] = read(),sum += a[i];
	sort(a+1,a+1+n,greater<int>());
	for(int i = 1; i <= n && m; i++)
		if(1LL*a[i]*4*M >= sum)
			m--;
	if(m <= 0)
		puts("Yes");
	else
		puts("No");				
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>
#include <cstdint>
#include <set>
#include <deque>
#include <iomanip>
#include <queue>

using namespace std;
using ull = unsigned long long;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

#define EPS (1e-7)
#define ALL(x) begin(x), end(x)


int countAC(const string& s) {
	const std::string find_word("AC");
	std::string::size_type pos = s.find(find_word);
	int count = 0;
	while (pos != std::string::npos) {
		count++;
		pos = s.find(find_word, pos + find_word.length());
	}
	return count;
}

int main() {
	ll N, Q;
	cin >> N >> Q;
	string S;
	cin >> S;

	vector<pair<ll, ll>> LRs(Q);

	for (size_t i = 0; i < Q; i++) {
		cin >> LRs[i].first >> LRs[i].second;
	}

	// 最初に全部見つけておく。
	vector<ll> ACpos(N, 0);
	for (size_t i = 0; i < N - 1; i++) {
		if (S[i] == 'A' && S[i + 1] == 'C') {
			ACpos[i] = 1;
		}
	}

	// そして累積和を作る
	vector<ll> Sums(N + 1);
	for (size_t i = 0; i < N; i++) {
		Sums[i + 1] = Sums[i] + ACpos[i];
	}

	// 累積和を使って回答する
	for_each(ALL(LRs), [S, Sums](auto lr) {
		const ll ans = Sums[lr.second - 1] - Sums[lr.first - 1];
		cout << ans << endl;
	});

	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//for(int i = ; i < ; i++){}

int main(){
    int n;
    cin>>n;
    if(n%2==0)cout<<n<<endl;
    else cout<<n*2<<endl;
    return 0;
}


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

int main() {
  int n;
  string s;
  cin >>n>>s;
  
  if(n%2==1){
    cout << "No" << endl;
    return 0;
  }
  
  string p,q;
  p = s.substr(0,n/2);
  q = s.substr(n/2,n/2);

  if(p==q) cout << "Yes" <<endl;
  else cout << "No" <<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    string S; cin >> S;
    if(S.back() == 's') Out(S + "es");
    else Out(S + "s");

    return 0;
}


Measured memory_bytes: 3664
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc=new Scanner(System.in);
		int a,b;
		a=sc.nextInt();
		b=sc.nextInt();
		int n1=a+b;
		int n2=a-b;
		int n3=a*b;
		if(n1>=n2&&n1>=n3){
			System.out.println(n1);
		}else if(n2>=n3){
			System.out.println(n2);
		}else{
			
			System.out.println(n3);
		
		}
		
		
	}

}


Measured memory_bytes: 22100
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    string s;
    cin >> s;
    rep(i, s.size()) {
        if (i % 2 == 0)
            cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <cstdio>
#include <numeric>

using namespace std;
int main() {
    int N;
    cin >> N;

    vector<int> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }

    bool flg = true;
    for (int i = 1; i < N; i++) {
        if (H[i-1] < H[i]) {
            H[i]--;
        } else if (H[i-1] == H[i]){
            continue;
        } else {
            flg = false;
            break;
        }
    }

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

    return 0;
}


Measured memory_bytes: 640