akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("4 4");
            WillReturn.Add("1 2");
            WillReturn.Add("2 3");
            WillReturn.Add("3 4");
            WillReturn.Add("4 2");
            //Yes
            //1
            //2
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("6 9");
            WillReturn.Add("3 4");
            WillReturn.Add("6 1");
            WillReturn.Add("2 4");
            WillReturn.Add("5 3");
            WillReturn.Add("4 6");
            WillReturn.Add("1 5");
            WillReturn.Add("6 2");
            WillReturn.Add("4 5");
            WillReturn.Add("5 6");
            //Yes
            //6
            //5
            //5
            //1
            //1
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int N = wkArr[0];

        // 移動可能な座標のSetのDict
        var LinkListDict = new Dictionary<int, HashSet<int>>();

        Action<string> SplitAct = pStr =>
            wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();
        foreach (string EachStr in InputList.Skip(1)) {
            SplitAct(EachStr);
            int A = wkArr[0];
            int B = wkArr[1];

            Action<int, int> AddAct = (pFrom, pTo) =>
            {
                if (LinkListDict.ContainsKey(pFrom) == false) {
                    LinkListDict[pFrom] = new HashSet<int>();
                }
                LinkListDict[pFrom].Add(pTo);
            };
            AddAct(A, B);
            AddAct(B, A);
        }

        var Que = new Queue<int>();
        Que.Enqueue(1);

        var AnswerDict = new Dictionary<int, int>();
        var Visited = new HashSet<int>();
        Visited.Add(1);

        while (Que.Count > 0) {
            int Dequeued = Que.Dequeue();

            foreach(int EachInt in LinkListDict[Dequeued]){
                //再訪禁止
                if (Visited.Add(EachInt) == false) {
                    continue;
                }
                Que.Enqueue(EachInt);
                AnswerDict[EachInt] = Dequeued;
            }
        }
        Console.WriteLine("Yes");
        for (int I = 2; I <= N; I++) {
            Console.WriteLine(AnswerDict[I]);
        }
    }
}


Measured memory_bytes: 77752
#include<bits/stdc++.h>
using namespace  std;
#define ll long long
const int mod=1e9+7;
const int nmax=2e5+5;
int fact[nmax],inv_fact[nmax];
int mul(int a,int b)
{
    return (ll) a* b %mod;
}
int pow(int a,int b)
{
    int ans=1;
    while(b)
    {
        if(b%2) ans=mul(ans,a);
        a=mul(a,a);
        b/=2;
    }
   // cout<<ans%mod<<endl;
    return ans%mod;
}
int inverse(int a)
{
    return pow(a,mod-2);
}
int binomial(int a,int b)
{
    if(a<b||a<0||b<0) return 0;
    // cout<<fact[a]<<" ";
    // cout<<inverse(fact[b])<<endl;

    return mul(fact[a],mul(inverse(fact[b]),inverse(fact[a-b])))%mod;
}
int f(int a,int b)
{
    return binomial(a+b,b);
}
//int dp[3002];
int main()
{
     fact[0]=inv_fact[0]=1;
     for(int i=1;i<nmax;i++)
     {
         fact[i]=mul(i,fact[i-1]);
         inv_fact[i]=inverse(fact[i]);
     }
   //  cout<<(pow(2,4));
    //  cout<<binomial(23,10);
    int h,w,n;
    cin>>h>>w>>n;
    vector<pair<int,int> > points;
    for(int i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        points.push_back({a,b});

    }
    sort(points.begin(),points.end(),[](pair<int,int> a,pair<int,int> b){return a.first+a.second<b.first+b.second;});
    //dp[i] no of paths to this wall forr forst time not including pevious walls
    points.emplace_back(h,w);
    vector<int> dp(n+1);
    for(int i=0;i<=n;i++)
    {
        //dp[i]=binomial(points[i].first+points[i].second-2,points[i].first-1);
        int tmp=f(points[i].first-1,points[i].second-1);
        for(int j=0;j<i;j++)
        {
            if(points[j].first<=points[i].first&&points[j].second<=points[i].second)
            {
                tmp=(tmp-mul(dp[j],f(points[i].first-points[j].first,points[i].second-points[j].second))+mod)%mod;
            }
        }
        dp[i]=tmp%mod;
    }
    cout<<dp[n];
   


}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}







int main() {
  string s;
  cin >> s;
  int a = 0,b = 0,c = 0;
  rep (i,s.size()){
    if (s[i]=='a') a++;
    if (s[i]=='b') b++;
    if (s[i]=='c') c++;
  }
  if (abs(a-b)<=1&&abs(b-c)<=1&&abs(a-c)<=1){
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}

Measured memory_bytes: 3684
import sys
sys.setrecursionlimit(1000000)
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque, Counter as cnt

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]
def nlist(n, v):
    if not n: return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]

# エントリーポイント
def main():
    N, K, Q = input([int, 3])
    A = input([int, Q])

    ps = [0] * (N + 1)
    max_p = 0
    for a in A:
        ps[a] += 1
        max_p = max(max_p, ps[a])
    
    for p in ps[1:]:
        if p <= (Q - K):
            print("No")
        else:
            print("Yes")
    return

if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 16372
#include<stdio.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
const int maxn=200100;
typedef long long LL;
int n,m;LL a[maxn],b[maxn],t1,t2,tot,c[maxn];
LL ans,mod=1e9+7;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
	{
		scanf("%lld",&c[i]);
		if(c[i]>=0)
		{
			a[++t1]=c[i];
		}
		else
		{	
			b[++t2]=c[i];
		}
	}
	ans=1;
	sort(a+1,a+1+t1);
	sort(b+1,b+1+t2);
	if(t1==0&&m%2==1)
	{
		for(int i=t2;i>t2-m;--i)
		{
			ans=(ans%mod*b[i]%mod+mod)%mod;
		}
	}
	else
	{
		sort(c+1,c+1+n);
		int x=n,y=1;	
		LL k1,k2;
		while(m>0)
		{
			if(m%2==1)
			{
				ans=ans*c[x]%mod;
				x--;m--;
			}
			else if(m>=2)
			{
				k1=c[x]*c[x-1];
			//	cout<<a[x]<<" "<<a[x-1]<<" "<<a[x]*a[x-1]<<endl;
				k2=c[y]*c[y+1];
			//	cout<<k1<<" "<<k2<<endl;
				if(k1<k2)
				{
					ans=k2%mod*ans%mod;
					y+=2;
					m-=2;
				}
				else
				{
					ans=k1%mod*ans%mod;
					x-=2;
					m-=2;
					
				}
			//	cout<<ans<<endl;
			}
			
		}
		
	}
		
	printf("%lld\n",(ans%mod+mod)%mod);
	return 0;
}


Measured memory_bytes: 6908
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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 (b<a) { a=b; return 1; } return 0; }

int N,k,ans,two,four,fourteen,twentyfour,seventyfour;
bool prime[101];
int cnt[101]={};
void eratosthenes(bool prime[101]){
    rep(i,101) prime[i] = 1;
    prime[0] = prime[1] = 0;
    rep(i,101){
        if(prime[i]){
            for(int j = i + i; j < 101; j+=i){
                prime[j] = 0;
            }
        }
    }
}

int main(){
    cin>>N;
    eratosthenes(prime);
    repi(i,1,N+1){
        k=i;
        // out(k);
        while(k!=1){
            repi(j,2,101){
                if(!prime[j])continue;
                if(k%j==0){
                    k/=j;
                    cnt[j]++;
                    break;
                }
            }
        }
    }
    rep(i,101){
        if(cnt[i]>=74){
            seventyfour++;
        };
        if(cnt[i]>=24){
            twentyfour++;
            fourteen++;
            four++;
            two++;
        }
        else if(cnt[i]>=14){
            fourteen++;
            four++;
            two++;
        }
        else if(cnt[i]>=4){
            four++;
            two++;
        }
        else if(cnt[i]>=2){
            two++;
        }
    }
    // out(cnt[2]);

    ans+=(two-2)*(four*(four-1))/2;
    ans+=fourteen*(four-1);
    ans+=twentyfour*(two-1);
    ans+=seventyfour;
    out(ans);
}


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

using namespace std;

int main(){
    int n, t, a, ans, h[1001];
    double min = 1000.0;
    double s = 0.0;
    cin >> n >> t >> a;
    for(int i = 0; i < n; i++){
        cin >> h[i];
        s = t - 0.006*h[i];
        if(min > abs(a-s)){
            min = abs(a-s);
            ans = i+1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
#include<cstdlib>
#include<string>
#include<cmath>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define mod 1000000007
#define pi 3.14159265358979323846
#define fo(i,n) for(ll i=0;i<n;i++)
#define rf(i,n) for(ll i=n-1;i>=0;i--)
//Comment this while submitting as it might cause TLE
//It will change the WA from Integer Overflow to RE.
//#pragma GCC optimize "trapv"
using namespace std;
ll countDigits(ll n){ ll dig = floor(log10(n)+1);  return dig;}


int main(){
    FAST;
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<"\n";
    
}

Measured memory_bytes: 3632
import sys
from itertools import accumulate, combinations
n, k = [int(i) for i in sys.stdin.readline().split()]
a_ls = [int(i) for i in sys.stdin.readline().split()]
s_ls = [i for i in accumulate([0] + a_ls)]
s_ls = [s_ls[j] - s_ls[i] for i, j in combinations(range(n+1), 2)]
str_len = len(bin(max(s_ls))) - 2
def check(x):
    cnt = 0
    for s in s_ls:
        if x == (x & s):
            cnt += 1
        if cnt >= k:
            return 1
    return 0

x = 0
res = []
for i in range(str_len - 1, -1, -1):
    cnt = 0
    for s in s_ls:
        if x + 2**i == ((x + 2**i) & s):
            cnt += 1
        if cnt >= k:
            x += 2 ** i
            break
print(x)

Measured memory_bytes: 58840
#include <stdio.h>

int main(void) {
    
    int a, b;
    char op;
    while (scanf("%d %c %d", &a, &op, &b) == 3 && op != '?') {
    switch (op) {
        case '+': a += b; break;
        case '-': a -= b; break;
        case '*': a *= b; break;
        case '/': a /= b; break;
        default: continue;
    }
    printf("%d\n", a);
 }
 return 0;
}



Measured memory_bytes: 2052
import numpy as np
words = lambda t : list(map(t, input().split()))

n,a,b,c,d = words(int)
s = input()

def verify(x,y):
    posa = x
    res = True
    while posa < y:
        #print(posa,y)
        if (posa+1 == y or posa+2 == y) and s[y] == '.':
            break
        if s[posa+1] == '#' and s[posa+2] == '#':
            res = False
            break
        if s[posa+2] == '.':
            posa += 2
        elif s[posa+1] == '.':
            posa += 1
    return res

#print(c,d)
if c < d:
    if verify(a-1,c-1) and verify(b-1,d-1):
        print("Yes")
    else:
        print("No")
else:
    if verify(a-1,c-1) and verify(b-1,d-1):
        res2 = False
        for i in range(b-1,d):
            if s[i] == '.' and s[i-1] == '.' and s[i+1] == '.':
                res2 = True
                break
        if res2:
            print("Yes")
        else:
            print("No")
    else:
        print("No")


Measured memory_bytes: 21856
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	long long a[n],f[n+1]={};
	cin>>a[0];
	for(int i=1;i<n;i++){
		cin>>a[i];
	}
	f[n-1]=a[n-1];
	for(int i=n-2;i>0;i--){
		f[i]=f[i+1]+a[i];
		f[i]%=1000000007;
	}
	long long s=0;
	//for(int i=0;i<n;i++) cout<<f[i]<<' ';
	for(int i=0;i<n;i++){
		s=(s+a[i]*f[i+1])%(1000000007);
	}
	cout<<s;
}

Measured memory_bytes: 6712
*G=gets;puts [*$<.map{|l|eval"X="+l.split*?,;X.each{|a|G[a]=*G[a],*X}},*1..$.].map{|z|*w=z;f=w.size;[G.index{z=*z,*u=w;w=[];f*=[1,*u.map{|v|w=*w,*b=G[v]-z;b.size}].max;!u[0]},f]}.min

Measured memory_bytes: 4092
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }


int main() {
  int N; cin >> N;
  vector<array<int, 3>> abc(N);
  rep(i, N) cin >> abc[i][0] >> abc[i][1] >> abc[i][2];

  vector<array<int, 3>> dp(N+1);
  rep(i, N) rep(j, 3) rep(k, 3) {
    if (j == k) continue;
    chmax(dp[i+1][k], dp[i][j] + abc[i][k]);
  }

  int ans = *max_element(all(dp[N]));
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 5632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        String s = sc.next();

        System.out.println(s.substring(0, k - 1) + s.valueOf(s.charAt(k - 1)).toLowerCase() + s.substring(k));
    }
}


Measured memory_bytes: 39196
# -*- coding: utf-8 -*-
"""
Created on Sat Apr  6 11:50:13 2019

@author: Yamazaki Kenichi
"""
from collections import deque

n = int(input())
A = [[]] + [list(map(int,input().split())) for i in range(n)]

#B = [[0 for i in range(n+1)] for i in range(n+1)]
#for i in range(1,n+1):
#    for j in range(A[i][1]):
#        B[i][A[i][j+2]] = 1

T = [[-1, -1] for i in range(n+1)]
T[1][0], T[1][1] = 1, 0
q = deque([1])
def dfs():
    global depth
    while len(q) > 0:
        for i in range(A[q[0]][1]):
            if T[A[q[0]][i+2]][0] == -1:
                q.append(A[q[0]][i+2])
                T[q[-1]][0] = 1
                T[q[-1]][1] = T[q[0]][1] + 1
        q.popleft()
dfs()
for i in range(1,n+1):
    print(i,T[i][1])
    



Measured memory_bytes: 6048
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
using namespace std;
using ll = long long;
using lll = __int128_t;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;
const ll mod=1e9+7;


int keta(int k){
      int ret=0;
      while(k>0){
            ret++;
            k/=10;
      }
      return ret;
}

int main(){
      int n;
      cin>>n;
      int ans=0;
      for(int i=1;i<=n;i++){
            if(keta(i)&1) ans++;
            }
      cout<<ans<<endl;
      return 0;
}

Measured memory_bytes: 256
n=int(input())
s=[""]*n
t=[0]*n
for i in range(n):
    s[i],t[i]=input().split()
    t[i]=int(t[i])
x=input()
c=0
for i in range(n):
    if s[i]==x:
        c=i
        break
ans=0
for i in range(c+1,n):
    ans+=t[i]
print(ans)

Measured memory_bytes: 3064
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
from decimal import Decimal
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

D = I()
C = LI()
s = [LI() for _ in range(D)]

T = [I() for _ in range(D)]
#print(D,C)
#print(s)
#print(T)
def last(d,i):
    T_d = T[:d]
    n = [j for j, x in enumerate(T_d,1) if x == i]
    if n:
        #print(T_d,i,"n=",n)
        return max(n)
    else:
        return 0
        
        
score = 0
for d in range(1,D+1):
    sum_c = 0
    for i in range(1,26+1):
        sum_c += C[i-1] * (d -last(d,i))
    score += s[d-1][T[d-1]-1] - sum_c
    print(score)


Measured memory_bytes: 27120
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

int N;

int main()
{
    cin >> N;
    cout << N * (N + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
const long long MOD = 998244353;
const int MAXN = 300010;
long long fac[MAXN], ifac[MAXN];
long long exGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long g = exGCD(b, a % b, x, y);
	long long temp = x;
	x = y;
	y = temp - a / b * y;
	return g;
}
int inverse(long long a) {
	long long x, y;
	exGCD(a, MOD, x, y);
	return (x % MOD + MOD) % MOD;
}
long long C(long long n, long long m) {
	return fac[n] * ifac[m] % MOD * ifac[n - m] % MOD;
}
int main() {
	long long n, a, b, k;
	scanf("%lld%lld%lld%lld", &n, &a, &b, &k);
	fac[0] = 1;
	for (int i = 1; i <= n; ++i) {
		fac[i] = fac[i - 1] * i % MOD;
	}
	ifac[n] = inverse(fac[n]);
	for (int i = n; i >= 1; --i) {
		ifac[i - 1] = ifac[i] * i % MOD;
	}
	long long ans = 0;
	for (int i = 0; i <= n && i * a <= k; ++i) {
		if ((k - i * a) % b == 0 && (k - i * a) / b <= n) {
			ans = (ans + C(n, i) * C(n, (k - i * a) / b) % MOD) % MOD;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4864
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n m
a1 b1 c1
..
am bm cm

n 1000
m 2000
ci -10^9 10^9
 */
const ll INF = pow(10,13);
int n,m,a[2000],b[2000];
int c[2000];
ll d[1000];


int main(){
  cin>>n>>m;
  REP(i,m){
    cin>>a[i]>>b[i]>>c[i];
    a[i]--;
    b[i]--;
  }

  REP(i,n){
    d[i] = -INF;
  }
  d[0] = 0;

  int st_cnt=0;
  REP(k,100000){
    bool update = false;
    REP(i,m){
      if(d[b[i]] < d[a[i]] + c[i] && d[a[i]]!=-INF){
        d[b[i]] = d[a[i]] + c[i];
        if(b[i]==n-1)
          update = true;
      }
    }

    if(update){
      st_cnt=0;
    } else {
      st_cnt++;
    }
      
    if(st_cnt > 8000){
      cout << d[n-1] <<endl;
      return 0;
    }
  }

  cout<<"inf\n";

  return 0;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.buffer.readline
import bisect
import copy
from collections import deque
sys.setrecursionlimit(10**7)

def main():
    N = int(input())
    a = list(map(int,input().split()))
    INF = 10**12
    
    edge = [[] for _ in range(N)]
    for _ in range(N-1):
        u,v = map(int,input().split())
        edge[u-1].append(v-1)
        edge[v-1].append(u-1)
        
    def LIS(dp,num):
        ind = bisect.bisect_left(dp,num)
        ret = dp[ind]
        dp[ind] = num
        return ind,ret
    
    dp = [INF]*(N+2)
    dp[0] = -INF

    ans = [0]*N
    q = deque([])
    
    def DFS(prev,now,dp):
        while q:
            s,t,ind,num = q.pop()
            if t == prev:
                q.append((s,t,ind,num))
                break
            else:
                dp[ind] = num
        ind,num = LIS(dp,a[now])
        ans[now] = max(ind,ans[prev])
        q.append((prev,now,ind,num))
        for fol in edge[now]:
            if fol != prev:
                DFS(now,fol,dp)

    DFS(-1,0,dp)
    print(*ans,sep="\n")
 
if __name__ == "__main__":
    main()


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

int n, num = 0;
vector<int> a, cnt, ans, anscnt;

void solve();

int main() {
  cin >> n;
  a.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  solve();
  for(int i = 0; i < ans.size(); ++i) {
    if(i != 0) cout << " ";
    cout << ans[i];
  }
  cout << endl;

  return 0;
}

void solve() {
  for(int i = 0; i < n; ++i) num = max(num, a[i]);
  cnt.assign(num + 1, 0);
  for(int i = 0; i < n; ++i) ++cnt[a[i]];
  for(int i = 0; i < num + 1; ++i)
    if(cnt[i] != 0) {
      for(int j = 0; j < cnt[i]; ++j) ans.push_back(i);
      anscnt.push_back(cnt[i]);
    }
}


Measured memory_bytes: 19044
/*  In the name of ALLAH */

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define int long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define w(x) int x;cin>>x;while(t--)
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int POSITIVE_INFINITY = 9223372036854775807;
const int NEGATIVE_INFINITY = -9223372036854775807;
const int MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif



int32_t main() {
    io;
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
  

    int x,y;
    cin>>x>>y;
    if (abs(x-y)<2){
        cout<<"Brown";
    return 0;
    }
    cout<<"Alice";

 
    
 
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = Integer.parseInt(sc.next());
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		sc.close();

		for(int i = A; i <= B ; i++) {
			if(i % K == 0) {
				System.out.println("OK");
				break;
			}

			if(i == B && i % K != 0) {
				System.out.println("NG");
			}
		}
	}

}

Measured memory_bytes: 35696
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#define sz(v) (int)v.size()
#define ll long long
#define ull unsigned long long
using namespace std;
const int PI = 3.14159265;
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
}
int main()
{
	//freopen("file.in","r",stdin);
	//freopen("file.out","w",stdout);
	fast();

	int t;
	cin >> t;
	int wa = 0, tle = 0, re = 0, ac = 0;
	while (t--)
	{
		string s;
		cin >> s;
		if (s == "WA") {
			wa++;
		}
		else if (s == "TLE") {
			tle++;
		}
		else if (s == "RE") {
			re++;
		}
		else {
			ac++;
		}
	}
	cout << "AC x " << ac << '\n';
	cout << "WA x " << wa << '\n';
	cout << "TLE x " << tle << '\n';
	cout << "RE x " << re << '\n';

	return 0;
}


Measured memory_bytes: 3668
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPL(i,f,n) for(int i=f, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

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

	int N;
	int a[300010];
	cin >> N;

	REP(i, 3*N) cin >> a[i];
	sort(a, a + 3*N,greater<int>());
	ll sum = 0;
	for (int i = 1; i < 2 * N;i+=2) {
		sum += a[i];
	}

	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS

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

/* define */
#define Yes(X) puts ( (X) ? "Yes" : "No")
#define YES(X) puts ( (X) ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = (a); i < (b) ; i++)
#define REP(i, n) for ( int i = 0; i < (n) ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1000000007;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}


/* main */
int main() {
	int n, k, r = 1;
	scanf("%d%d", &n, &k);
	REP(i, n) {
		if (2 * r < r + k) r *= 2;
		else r += k;
	}
	printf("%d", r);
	return 0;
}

Measured memory_bytes: 128
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    read = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    read = raw_input
readint = lambda: int(rr())
readlist = lambda: map(int, read().split())

####
def solve(X, Y):
    # a+b = X
    # 2a+4b = Y
    # a+2b = Y/2
    if Y & 1: return False
    Y //= 2
    b = Y - X
    if b < 0: return False
    a = X - b
    return a >= 0

print "Yes" if solve(*readlist()) else "No"


Measured memory_bytes: 64204
X,Y,A,B,C = map(int,input().split())
*P, = map(int,input().split())
*Q, = map(int,input().split())
*R, = map(int,input().split())

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

SP = [0]*(A+1)
SQ = [0]*(B+1)
SR = [0]*(C+1)
for i,a in enumerate(P):
    SP[i+1] = SP[i] + a
for i,b in enumerate(Q):
    SQ[i+1] = SQ[i] + b
for i,c in enumerate(R):
    SR[i+1] = SR[i] + c

ans = 0
for i in range(max(0,X-C),X+1):
    d = C-(X-i)
    l0 = max(0,Y-d)
    l = l0
    r = Y
    while l+1<r:
        j = (l+r)//2
        k = (X-i) + (Y-j)
        if (Q[j] < R[k]):
            r = j
        else:
            l = j
    tmp = SP[i] + SQ[r] + SR[X+Y-i-r]
    tmp = max(tmp,SP[i]+SQ[l]+SR[X+Y-i-l])
    ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 111340
import std;

long calc(long n) {
    if (n == 1) return 0;

    int ans = 0;
    foreach (p; factor(n)) {

        long k = p[1];
        for (int i = 1; ; i++) {
            if (k >= i) {
                k -= i;
                ans++;
            } else break;
        }
    }
    return ans;
}

void main() {
    long n; scan(n);
    writeln(calc(n));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;

// 素因数分解([[素因数, 個数], ...])
T[][] factor(T)(T n) {
    if (n == 1) return [[1, 1]];
    long[][] res;
    for (T i = 2; i * i <= n; i++) {
        if (n % i != 0) continue;
        int k = 0;
        while (n % i == 0) { n /= i; k++; }
        res ~= [i, k];
    }
    if (n > 1) res ~= [n, 1];
    return res;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll m,n,t = 0,a,b,c = 0,r = 0,w = 0;
    string s;
    cin>>n;
    cin>>s;
    for(int i = 0; i < n; i++)
    {
        if(s[i]=='R')
        {
            r++;
        }
    }

    //cout<<r<<endl;

    for(int i = 0; i < n; i++)
    {
        if(s[i]=='W')
        {
            if(r > 0)
            {
                c++,r--;
            }
        }
        else if(s[i]=='R')
        {
            r--;
            //cout<<r<<"  "<<i<<endl;
        }
    }

    cout<<c<<endl;
}


Measured memory_bytes: 3704
#include <iostream>

using namespace std;

int main(){
    int h,w;
    cin >> h >> w;
    string c[101];
    for(int i = 0; i < h; i++){
        cin >> c[i];
    }

    for(int i = 0; i < h; i++){
        cout << c[i] << endl;
        cout << c[i] << endl;
    }
}


Measured memory_bytes: 888
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int n,m,k;
char s[15][10005];
int cnt[15][1005];
int query(int x1,int y1,int x2,int y2){
    //cout<<y1<<' '<<y2<<' '<<cnt[x2][y2]-cnt[x1-1][y2]-cnt[x2][y1-1]+cnt[x1-1][y1-1]<<endl;
    return cnt[x2][y2]-cnt[x1-1][y2]-cnt[x2][y1-1]+cnt[x1-1][y1-1];
}
int main(){
    scanf("%d%d%d",&n,&m,&k);
    for(int i=1;i<=n;i++)scanf(" %s",s[i]+1);
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)cnt[i][j]=cnt[i-1][j]+(s[i][j]=='1');
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)cnt[i][j]+=cnt[i][j-1];
    }
    
    int ans=inf; 
    for(int mask=0;mask<(1<<(n-1));mask++){
        vector<int> line;
        line.push_back(0);
        int res=0;
        for(int i=0;i<n-1;i++)if(mask>>i&1)line.push_back(i+1),res++;
        line.push_back(n);
        int pre=0;
        for(int j=1;j<=m;j++){
            for(int i=1;i<line.size();i++){
                int x1=line[i-1]+1,y1=pre+1,x2=line[i],y2=j;
                int c=query(x1,y1,x2,y2);
                //cout<<c<<endl;
                if(c>k){
                    //cout<<c<<endl;
                    res++;
                    pre=j-1;
                    int x1=line[i-1]+1,y1=pre+1,x2=line[i],y2=j;
                    if(query(x1,y1,x2,y2)>k){
                        res=inf;
                        break;
                    }
                }
            }
        }
        ans=min(ans,res);
        //break;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int r,d,x;
	cin >> r >> d >> x;
	rep(i,10){
		x = r * x - d;
		cout << x << endl;
	}
}


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

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

    for (int i = 0; i < n; ++i) {
        double a;
        cin >> a;
        sum += 1.0 / a;
    }

    cout << (1.0 / sum) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 			1000000007
#define tc(t) 			int t;cin >> t;while(t--)
#define for0(i , n)		for(int i=0;i<n;i++)
#define loop(i , a, b)	for(int i=a;i<=b;i++)
#define endl 			'\n'
#define inf 			1e18
#define fi 				first
#define se 				second

int XX[8] = { +1, +1, +1, 0, 0, -1, -1, -1};
int YY[8] = { +1, 0, -1, +1, -1, +1, 0, -1};
int dx[4] = { -1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int dp[100005][4];
int a[100005], b[100005], c[100005];
int n;

int vacation(int ind, int fl) {
	if (ind >= n) return 0;
	if (dp[ind][fl] != -1) return dp[ind][fl];
	int ans = 0;
	if (fl == 0) {
		int c1 = a[ind] + vacation(ind + 1, 1);
		int c2 = b[ind] + vacation(ind + 1, 2);
		int c3 = c[ind] + vacation(ind + 1, 3);
		ans = max({c1, c2, c3});
	} else if (fl == 1) {
		int c2 = b[ind] + vacation(ind + 1, 2);
		int c3 = c[ind] + vacation(ind + 1, 3);
		ans += max(c2, c3);
	} else if (fl == 2) {
		int c1 = a[ind] + vacation(ind + 1, 1);
		int c3 = c[ind] + vacation(ind + 1, 3);
		ans += max(c1, c3);
	} else {
		int c1 = a[ind] + vacation(ind + 1, 1);
		int c2 = b[ind] + vacation(ind + 1, 2);
		ans += max(c1, c2);
	}

	return dp[ind][fl] = ans;
}

signed main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif

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

	memset(dp, -1, sizeof(dp));

	cout << vacation(0, 0);

	return 0;
}

Measured memory_bytes: 15288
if __name__ == "__main__":
 
    n = int(input())
    b_list = [int(b) for b in input().split()]
    a_list = []

    for i, b in enumerate(b_list):
        if i != 0:
            a_list.append(min(b_list[i], b_list[i - 1]))
            
    a_list.insert(0, b_list[0])
    a_list.append(b_list[len(b_list) - 1])
    print('{0}'.format(sum(a_list)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
	long int n; cin >> n;
	long long int a;
	long long int x[200005];
	long long int s = 0;
	for(long int i=0;i<n;i++){
		cin >> a;
		s += a;
		x[i] = s;
	}
	//long long int ans = 1000000000000000005;
	long long int ans = LLONG_MAX;
	for(long int i=0;i<n-1;i++){
		ans = min(abs(2*x[i]-s), ans);
	}
	cout << ans << endl;
	return 0;
}

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

bit = [0]*(N+1)

for i in range(2,N+1):
    cur = i
    for j in range(2,i+1):
        while cur%j==0:
            bit[j]+=1
            cur//=j

def nu(m):
    return len(list(filter(lambda x:x>=m-1,bit)))
#75, 25 3, 5 5 3, 15 5, 

print(nu(75)+nu(25)*(nu(3)-1)+nu(5)*(nu(5)-1)//2*(nu(3)-2)+ nu(15)*(nu(5)-1))

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

int x, y, z, k;
long long a[1000], b[1000], c[1000];

int main() {
  cin >> x >> y >> z >> k;
  for (int i = 0; i < x; ++i) cin >> a[i];
  for (int i = 0; i < y; ++i) cin >> b[i];
  for (int i = 0; i < z; ++i) cin >> c[i];
  
  sort(a, a+x), reverse(a, a+x);
  sort(b, b+y), reverse(b, b+y);
  sort(c, c+z), reverse(c, c+z);
  
  vector<long long> v;
  for (int i = 0; i < x; ++i) for (int j = 0; j < y; ++j) if ((i+1) * (j+1) <= k)
    v.push_back(a[i] + b[j]);
  
  sort(v.rbegin(), v.rend());
  
  vector<long long> w;
  for (int i = 0; i < v.size(); ++i) for (int j = 0; j < z; ++j) if ((i+1) * (j+1) <= k)
    w.push_back(v[i] + c[j]);
  
  sort(w.rbegin(), w.rend());
  
  for (int i = 0; i < k; ++i) cout << w[i] << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

struct UnionFind{
  vector<int> par;

  UnionFind(int N): par(N){
    for(int i=0;i<N;i++) par[i]=i;
  }

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

  void unite(int x,int y){
    int rx=root(x);
    int ry=root(y);
    if(rx!=ry) par[rx]=ry;
  }

  bool sameroot(int x,int y){
    return root(x)==root(y);
  }

};


int main(){
    int N,M;
    cin>>N>>M;
    if(M%2==1){
        cout<<-1<<endl;
        return 0;
    }
    UnionFind uf(N);
    vector<int> from(N,0);
    vector<int> layer(N,0);
    vector<int> tonari[100001];
    vector<bool> visit(N,false);
    int a,b;
    for (int i = 0; i < M; ++i) {
        cin>>a>>b; a--; b--;
        if(uf.sameroot(a,b)){
            from[a]++;
            cout<<a+1<<" "<<b+1<<endl;
        }else{
            uf.unite(a,b);
            tonari[a].push_back(b);
            tonari[b].push_back(a);
        }
    }
    queue<int> q;
    priority_queue<pair<int,int>> pq;
    q.push(0);
    visit[0]=true;
    while(!q.empty()){
        int node=q.front();
        q.pop();
        pq.push({layer[node],node});
        for(auto adj:tonari[node]){
            if(visit[adj]) continue;
            layer[adj]=layer[node]+1;
            visit[adj]=true;
            q.push(adj);
        }
    }

    while(!pq.empty()){
        pair<int,int> tmp=pq.top();
        pq.pop();
        int lay=tmp.first,node=tmp.second;
        if(lay==0) break;
        int par=-5;
        for(auto adj:tonari[node]) {
            if (layer[adj] == lay - 1){
                par = adj;
                break;
            }
        }

        if(from[node]%2==1){
            from[node]++;
            cout<<node+1<<" "<<par+1<<endl;
        }else{
            from[par]++;
            cout<<par+1<<" "<<node+1<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 9460
from heapq import heapify, heappop, heappush

N = int(input())

V = list(map(int, input().split()))
heapify(V)

while len(V) > 1:

    # 1st, 2nd
    a = heappop(V)
    b = heappop(V)

    new = (a + b) / 2
    heappush(V, new)

print(V[0])


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

int main(){
    int W,A,B;
    cin>>W>>A>>B;
    int res = 0;
  
    if(B>=A){
        while(A+W < B){
            B--;
            res++;
        }

    }
    else{
        while(B+W < A){
            A--;
            res++;
        }
    }

    cout<<res<<endl;


}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int X, S;
	scanf("%d%d", &X, &S);
	int i,j,k,a;
	for (i = 0; i <= X; i++) {
		for (j = 0; j <= X; j++) {
          k=S-i-j;
          if(0<=k&&X>=k){
            a++;
          }
		}
	}
	printf("%d", a);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long


using namespace std;
#define N 200005

int dp[1001][1001];


void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int ways(int r, int c) {

    if (dp[0][0] == -1)
        return 0;

    for (int j = 0; j < c; j++) {
        if (dp[0][j] == -1) {
            break;
        }
        dp[0][j] = 1;
    }
    for (int i = 0; i < r; i++) {
        if (dp[i][0] == -1) {
            break;
        }
        dp[i][0] = 1;
    }
    for (int i = 1; i < r; i++) {
        for (int j = 1; j < c; j++) {
            if (dp[i][j] == -1)
                continue;

            dp[i][j] = 0;
            if (dp[i][j - 1] != -1)
                dp[i][j] = dp[i][j - 1] % 1000000007;
            if (dp[i - 1][j] != -1)
                dp[i][j] = (dp[i][j] + dp[i - 1][j]) % 1000000007;

        }
    }
    if (dp[r - 1][c - 1] == -1)
        return 0;
    // for (int i = 0; i < r; i++) {
    //     for (int j = 0; j < c; j++) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    return dp[r - 1][c - 1];


}
int32_t main() {
    c_p_c();
    memset(dp, 0, sizeof dp);
    int r, c;
    cin >> r >> c;

    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            char no;
            cin >> no;
            if (no == '#') {
                dp[i][j] = -1;
            }
        }

    }
    cout << ways(r, c);
}


Measured memory_bytes: 11476
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    string x = "keyence";

    string s;
    cin >> s;

    if(s == x) {
        out("YES");
        re0;
    }

    ll n = s.size();

    rep(l, n) {
        exrep(r, l+1, n) {
            string mae = s.substr(0, l);
            string ushiro = s.substr(r, n-r);
            if(mae + ushiro == x) {
                out("YES");
                re0;
            }
        }
    }

    out("NO");
    re0;
}

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

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

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

const int N = (int)2e5 + 123, inf = 1e9, mod = 998244353;
const ll INF = 1e18;

int n, m, d[N];
ll a[N], dp[N], ans;
char s[N];
bool check(int x){
	for(int i = x; i < n; i++){
		int val = ('1' ^ '0' ^ s[i - x]);
		if(val == s[i])
			continue;
		if(val < s[i])
			return 1;
		if(val > s[i])
			return 0;
	}
	return 1;
}
int main()
{
	scanf("%d", &n);
	scanf("%s", &s);
	for(int i = 1; i <= n; i++){
		a[i] = a[i - 1] * 2 % mod;
		if(s[i - 1] == '1')
			a[i]++;
	}
	for(int i = 1; i <= n; i++)
		if((i & 1) && n % i == 0)
			d[m++] = n / i;	
	for(int i = 0; i < m; i++)
		dp[i] = (a[d[i]] + check(d[i]) + mod) % mod;		
    for(int i = m - 1; i >= 0; i--){
	    for(int j = 0; j < i; j++)
			if(d[j] % d[i] == 0)
				dp[j] = (dp[j] - dp[i] + mod) % mod;				 
	}                                  
	for(int i = 0; i < m; i++)
		ans = (ans + dp[i] * d[i]) % mod;
	cout << 2 * ans % mod;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  if(N==1){
    cout << 1 << endl;
    return 0;
  }
  
  vector<int> P(N);
  for (int i=0; i<N; i++){
    cin >> P.at(i);
  }
  
  int min=P.at(0);
  int ans=1;
  for(int i=1; i<N; i++){
    if(min>=P.at(i)){
      ans++;
      min=P.at(i);
    }
  }
  
  cout << ans << endl;
  
}

// int型の2次元配列(3×4要素の)の宣言
  //vector<vector<int>> data(3, vector<int>(4));

  // 入力 (2重ループを用いる)
  //for (int i = 0; i < 3; i++) {
    //for (int j = 0; j < 4; j++) {
      //cin >> data.at(i).at(j);
    //}
  //}

Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        
        //int r = stdIn.nextInt();
        //int k = stdIn.nextInt();
        //int b = stdIn.nextInt();
        int num[] = new int[3];
        //String s = stdIn.next();
        //char c[] = s.toCharArray();
        //boolean flag = true;
        
        for(int i = 0; i < 3; i++){
            num[i] = stdIn.nextInt();
        }
        
        Arrays.sort(num);
        
        System.out.println(num[2] - num[0]);
        
        //System.out.println();
        //System.out.print();
    }
}


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

dp=[[0 for i in range(2*N+1)] for j in range(3*N+1)]

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

for i in range(1,3*N+1):
    for j in range(2*N+1):
        if 2*N-1>=j>=1:
            dp[i][j]=(dp[i-1][j-1]+dp[i-2][j+1]*(i-1)+dp[i-3][j]*(i-1)*(i-2))%M
        elif j==0:
            dp[i][j]=(dp[i-1][j]+dp[i-2][j+1]*(i-1)+dp[i-3][j]*(i-1)*(i-2))%M
        else:
            dp[i][j]=(dp[i-1][j-1]+dp[i-3][j]*(i-1)*(i-2))%M

print(dp[3*N][N]%M)


Measured memory_bytes: 274072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 2e9;

int main() {
  int n;
  cin >> n;
  ll k;
  cin >> k;
  vector<ll> a(n), f(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> f[i];
  sort(f.begin(), f.end(), greater<ll>());
  sort(a.begin(), a.end());

  auto ok = [&](ll m){
    ll cnt = 0;
    for (int i = 0; i < n; i++) cnt += max(0LL, a[i] - m / f[i]);
    return cnt <= k;
  };
  ll l = -1, r = 1e12;

  while (r - l > 1) {
    ll m = (r + l) / 2;
    if (ok(m)) r = m;
    else l = m;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
 
 
using namespace std;
#define out(s) cout<<(s)<<endl;
using ll = long long;
 
 
int main()
{
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;
	int result = 0;
	for (size_t i = 0; i < N; i++)
	{
		if (i < K) {
			result += X;
		}
		else {
			result += Y;
		}
	}
	out(result);
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))
'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

x=int(input())
a=100
cnt=0

while x>a:
    a=int(a*1.01)
    cnt+=1
    #print(a)
print(cnt)

Measured memory_bytes: 9172
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>
#include <cstdio>

using namespace std;

const int INF = 1 << 29;
typedef pair<int, int> P;

int n;
const int MAX_N = 100001;
const int MAX_A = 10;
double dp[MAX_N + 1][MAX_A + 1] = {0};//日にち、連続
double ans[MAX_N] = {0};

int main(void)
{
	dp[0][0] = 1;
	double sum = 0;
	for (int i = 0; i < MAX_N; i++)
	{
		for (int j = 0; j < MAX_A; j++)
		{
			if(!dp[i][j]) continue;
			sum += dp[i][j] * 1.0 / (1 << j);
			dp[i+1][j+1] = dp[i][j] * 1.0 / (1 << j);
			dp[i+1][0] += dp[i][j] * (1.0 - 1.0 / (1 << j));
		}
		ans[i] = sum;
	}
	while(cin >> n && n)
	{
		printf("%.8f\n", ans[n-1]);
	}
	return 0;
}

Measured memory_bytes: 10568