akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = INT32_MIN;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

template<int index>
bool comp(tuple<ll, ll, ll, ll> a, tuple<ll, ll, ll, ll> b) {
	return get<index>(a) < get<index>(b);
}

int vector_finder(std::vector<ll> vec, ll number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return index;
	}
	else { // 発見できなかったとき
		return 0;
	}
}


int len(int x) {
	return (int)log10(x) + 1;
}

int same_vec(vector<int> a, vector<int> b) {
	int res = 1, num = a.size();
	for (int i = 0; i < num; i++) {
		if (a[i] != b[i]) {
			res = 0;
			break;
		}
 	}
	return res;
}


typedef struct _task {
	long day, mon;
}task;

bool comp_task(const task &a, const task &b) {
	printf("%d %d %d %d\n",a.day, a.mon, b.day, b.mon);
	bool res = true;
	if (a.day < b.day) res = true;
	else if (a.day > b.day) res = false;
	
	cout << res << endl;

	return res;
}

bool comp_task2(task a, task b) {
	return a.day < b.day;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	int A, B, K;
	cin >> A >> B >> K;

	vector<int> v;
	for (int i = 1;i <= A; i++) {
		if ((A % i == 0) && (B % i == 0)) {
			v.push_back(i);
		}
	}

	cout << v[v.size() - K] << endl;


ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}
/*

*/




Measured memory_bytes: 504
import sys
import math
import collections
from collections import deque
#x = int(input())
k, n = map(int, sys.stdin.readline().split())
#s = input()
a = list(map(int, sys.stdin.readline().split()))

d = []

for i in range(n-1):
    d.append(a[i+1] - a[i])

d.append(k-a[n-1]+a[0])
e = sum(d)
f = max(d)
print(e-f)


Measured memory_bytes: 25420
/* 만든 사람 <xrssa> */
/* 불타오르네, 불타오르네, 불타오르네 */
#include <bits/stdc++.h>
using namespace std;

#define f(i,n)        for(int i=0;i<n;i++)
#define fab(i,a,b)    for(int i=a;i<b;i++)
#define fa(elem, arr) for(auto &elem:arr)
#define all(a)        a.begin(),a.end()
#define INF 1e5+5
void solve(){
    int a,b;cin>>a>>b;
    f(i,1010){
        //cout << i << " " << floor(i*0.08) << " " << floor(i*0.1) << "\n";
        if (floor(i*0.08)==a && floor(i*0.1)==b){
            cout << i << "\n";
            exit(0);
        }

    }
    cout << -1 << "\n";
}

int main()
{   ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // 여러 테스트 사례 사용
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.12f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll dp[1005][1005];
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll H,W; cin >> H >> W;
    char field[1005][1005];
    rep(i,0,H){
        rep(j,0,W) cin >> field[i][j];
    }
    dp[0][0] = 1;

    rep(i,0,H){
        rep(j,0,W){
            if(field[i+1][j] == '.') dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % MOD;
            if(field[i][j+1] == '.') dp[i][j+1] = (dp[i][j+1] + dp[i][j]) % MOD; 
        }
    }
    ll ans = dp[H-1][W-1] %  MOD;
    cout << ans << ednl;
    return 0;
}


Measured memory_bytes: 12412
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	list := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&list[i])
	}

	result := "Yes"

	for i := n - 1; i > 0; i-- {
		if list[i-1]-list[i] >= 2 {
			result = "No"
			break
		} else if list[i] < list[i-1] {
			list[i-1]--
		}
	}
	for i := 0; i < n-1; i++ {
		if list[i+1] < list[i] {
			result = "No"
		}
	}
	fmt.Println(result)

}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n" 
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ll a,x;
  cin>>x;
  a=100;
  ll i=0;
  while(a<x)
  {
  	a*=1.01;
  	i++;
  }
  deb(i);
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstring>
using namespace std;
#define N 200005
int num[N],d[N];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;++i) cin>>num[i];
	for(int i=1;i<=k;++i)
	{
		memset(d,0,sizeof(d));
		for(int j=1;j<=n;++j)
		{
			int L=max(1,j-num[j]);
			int R=min(n,j+num[j])+1;
			++d[L];
			--d[R];
		}
		int flag=1;
		for(int j=1;j<=n;++j) 
		{
			num[j]=num[j-1]+d[j];
			if(num[j]!=n) flag=0;
		}
		if(flag) break;
	}
	for(int i=1;i<=n;++i) cout<<num[i]<<" ";
	return 0;
} 

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> l(m);
  vector<int> r(m);
  int i;
  int maxl = 0;
  int minr = 100001;
  for(i = 0; i < m; i++)
  {
    cin >> l.at(i) >> r.at(i);
    if(r.at(i) < minr)minr = r.at(i);
    if(l.at(i) > maxl)maxl = l.at(i);
  }
  cout << max(minr-maxl+1, 0) << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
  int n,x,sum,count;
  while(1){
            scanf("%d %d",&n,&x);
            if((n==0)&&(x==0)){
              break;
            } 
            count=0;
            for(int i=1;i<=n;i++){
               for(int j=i+1;j<=n;j++){
                  for(int h=j+1;h<=n;h++){
                     sum=i+j+h;
                     if(sum==x){
                         count++;
                     }
                  }    
               }
            }
            printf("%d\n",count);
         }
         return 0;
}


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

int main(){
  cout.precision(10);
	int N;
  	cin >>N;
  double counte;
  double counto;
  double ans;
 	for(int i = 1;i <= N;i++){
    	if(i%2 == 0){
        	counte++;
        }
      else{
      counto++;
      }
    }
  ans = counto/N;
  cout << ans << endl;
}

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

#define MAX_A   10000

struct  Card {
    char Suit;
    int Num;
    int Org;
};

int Partition(vector<Card> &A, int p, int r) {
    int x=A.at(r).Num;
    int i=p-1;
    for (int j=p; j<r; j++)
        if (A.at(j).Num<=x) {
            i++;
            swap(A.at(i), A.at(j));
        }
    swap(A.at(i+1), A.at(r));
    return (i+1);
};

void    Quicksort(vector<Card> &A, int p, int r) {
    if (p<r) {
        int q=Partition(A, p, r);
        Quicksort(A, p, q-1);
        Quicksort(A, q+1, r);
    }
    return;
}

int main() {
    int n;
    cin >>n;
    vector<Card> A(n);
    for (int i=0; i<n; i++) {
        cin >>A.at(i).Suit >>A.at(i).Num;
        A.at(i).Org=i;
    }
    Quicksort(A, 0, n-1);
    //
    bool Stable=true;
    for (int i=1; i<n; i++)
        if (A.at(i-1).Num==A.at(i).Num)
            if (A.at(i-1).Org>A.at(i).Org) {
                Stable=false;
                break;
            }
    if (Stable)
        cout <<"Stable" <<endl;
    else
        cout <<"Not stable" <<endl;
    for (int i=0; i<n; i++)
        cout <<A.at(i).Suit <<' ' <<A.at(i).Num <<endl;
    return 0;
}


Measured memory_bytes: 3900
import Data.List
import Data.Function

divisor :: Integral a => a -> [a]
divisor n = foldr f [] $ takeWhile ((<= n) . (^2)) [1..n]
  where
    f x xs
        | r == 0, q /= x = x : q : xs
        | r == 0         = x : xs
        | otherwise      = xs
      where
        (q, r) = n `divMod` x

main :: IO ()
main = do
    n <- readLn :: IO Int
    let d = sort $ divisor n
        (m,_) = minimumBy (compare `on` snd)
                [ (i, i + (n `div` i)) | i <- d]
    print $ (m-1) + (n `div` m) -1


Measured memory_bytes: 2556
use proconio;
use std::collections::BTreeSet;

#[proconio::fastout]
fn main() {
    proconio::input! {
        n: usize,
        mut aa: [u64; n],
    }
    aa.sort();
    // let mut aa: VecDeque<_> = aa.into();

    let duplicates: BTreeSet<u64> = {
        let mut new_aa = vec![];
        let mut last = aa[0];
        let mut cnt = 0;
        for &a in aa.iter().skip(1) {
            // println!("{:?}", new_aa);
            if last != a {
                if cnt != 0 {
                    new_aa.push(last);
                }
                cnt = 0;
            } else {
                cnt += 1;
            }
            last = a;
        }
        if cnt != 0 {
            new_aa.push(last);
        }
        new_aa.into_iter().collect()
    };
    // println!("{:?}", aa);
    //
    // let mut k = 0;
    // while aa.len() > 0 {
    //     k += 1;
    //     let target = aa.pop_front().unwrap();
    //     let diff = {
    //         let mut d = 0;
    //         while aa.len() > 0 && target == aa[0] {
    //             aa.pop_front();
    //             d = 1;
    //         }
    //         d
    //     };
    //     k -= diff;
    //     aa = aa.into_iter().filter(|a| a % target != 0).collect();
    // }

    let largest = aa[n - 1];
    let mut set: BTreeSet<u64> = aa.iter().map(|&a| a).collect();
    for a in aa {
        // println!("do {}", a);
        if duplicates.contains(&a) {
            // println!("dup");
            set.remove(&a);
        }
        let mut am = a + a;
        while am <= largest {
            set.remove(&am);
            am += a;
        }
    }

    println!("{}", set.len());
}


Measured memory_bytes: 9056
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const int INF=0x3f3f3f3f,max_n=100005,mod=1e9+7;
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
char ma[25][25];
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
int n,m;
struct Node
{
	int a,b,c;
};
queue<Node>q;
int vis[25][25];
int f(int x,int y)
{
	int ans=0;
	q.push({x,y,0});
	while(!q.empty())
	{
		Node now=q.front();
		ans=max(ans,now.c);
		q.pop();
		if(vis[now.a][now.b])
		{
			continue;
		}
		else if(ma[now.a][now.b]=='#')
		{
			continue;
		}
		else
		{
			vis[now.a][now.b]=1;
			for(int k=0;k<4;k++)
			{
				int nx=now.a+dx[k];
				int ny=now.b+dy[k];
				if(nx>=1&&nx<=n&&ny>=1&&ny<=m&&ma[nx][ny]=='.'&&vis[nx][ny]==0)
				{
					q.push({nx,ny,now.c+1});
				}
			}
		}
	}
	return ans;
}
int max1;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>ma[i][j];
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(ma[i][j]=='.')
			{
				max1=max(max1,f(i,j));
				mem0(vis);
			}
		}
	}
	cout<<max1;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	printf("%d\n",min(b/a,c));
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

int main(void) {

  char s[51],t[51];
  scanf("%s %s", s, t);
  int s_length = strlen(s);
  int t_length = strlen(t);
  int flag;
  for (int i = s_length-1; i >= t_length-1; i--) {
    flag = 1;
    for (int j = 0; j < t_length; j++) {
      if (s[i-j] != t[t_length-1-j] && s[i-j] != '?') {
        flag = 0;
        break;
      }
    }
    if (flag == 1) {
      for (int j = 0; j < s_length; j++) {
        if (j >= i-t_length+1 && j <= i) {
          s[j] = t[j-(i-t_length+1)];
        } else {
          if (s[j] == '?') {
            s[j] = 'a';
          }
        }
      }
      printf("%s\n", s);
      return 0;
    }
  }
  printf("UNRESTORABLE\n");

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(ll i=0;i<n;i++)
#define rev(i,n) for(ll i=n;i>=0;i--)
#define rep_a(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
const long long mod = 1000000007;
const long long INF = mod*mod;
ll weights[110];
ll values[110];
ll dp[2][1100000];
int solve()
{
	ll n,w;
	cin >> n >> w;
	rep_a(i,1,1100000)dp[0][i] = INF;
	for(int i = 0;i<n;i++)
	{
		cin>>weights[i]>>values[i];
	}
	for (int i = 1;i<=n;i++)
	{
		int t = i%2;
		rep(j,1100000){dp[t][j] = INF;}
		rep(j,1100000)
		{
			dp[t][j] = min(dp[t][j],dp[!t][j]);
			if(values[i-1]<=j)
			{
				dp[t][j] = min(dp[t][j],dp[!t][j - values[i-1]] + weights[i-1]);
			}
		}
	}
	ll ans = 0;
	rep(i,1100000)
	{
		if(dp[n%2][i]<=w)
		ans = i;
	}
	cout<<ans<<endl;
	return 0;
}
int main()
{
	/* #ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#else
	#endif */
	solve();
	/* #ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: "<<1.0*clock()/ CLOCKS_PER_SEC<<" Sec\n";
	#endif */

	return 0;
} 

Measured memory_bytes: 17408
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var a,b int
    fmt.Scan(&a,&b)
    ans := "Yes"
    if a*b%2==0{
        ans = "No"
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main()
{
	string a, b, c;
	char d = 'A' - 'a';
	cin >> a >> b >> c;
	printf("%c%c%c\n", a[0] + d, b[0] + d, c[0] + d);
	return 0;
}



Measured memory_bytes: 256
using System;

class MainClass
{
	public static void Main (string[] args)
	{

		while (true)
		{
			string str = Console.ReadLine ();
			string[] spStr = str.Split (' ');

			int a = int.Parse (spStr [0]);
			string op = spStr [1];
			int b = int.Parse (spStr [2]);

			if (op == "+") 
			{
				Console.WriteLine (a + b);
			} 
			else if (op == "-")
			{
				Console.WriteLine (a - b);
			} 
			else if (op == "*")
			{
				Console.WriteLine (a * b);
			}
			else if (op == "/")
			{
				Console.WriteLine (a / b);
			} 
			else if (op == "?")
			{
				break;
			}
		}
	}
}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	set<string > ss;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		ss.insert(s);
	}
	cout<<ss.size()<<endl;
	return 0;
}


Measured memory_bytes: 19128
#include<bits/stdc++.h>
#define ll long long 
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const double pi=3.1415926535898;
int main()
{
    fastio;
    ll n;
    cin>>n;
    ll x=n%10;
    if(x==3)
    {
        cout<<"bon";
    }
    else if(x==0||x==1||x==6||x==8)
    {
        cout<<"pon";
    }
    else
    {
        cout<<"hon";
    }
    return 0;
}

Measured memory_bytes: 3652
abc = [int(input()) for i in range(3)]
x = int(input())

count = 0

for i in range(abc[0] + 1):
    for j in range(abc[1] +1):
        for k in range(abc[2] +1):
            if 500*i + 100*j + 50*k == x:
                count += 1
print(count)

Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    int sub=b-a;
    int tri=0;
    for(int i=1;i<sub+1;i++){
        tri+=i;
    }
    cout<<tri-b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define VI vector<int>
#define VL vector<lint>
#define VC vector<char>
#define VVI vector<VI>
#define rep(i, n) for(int i = 0 ; i < n ; i++)

using namespace std;

int main(){
    while(true){
        int n, m, t, p;
        cin >> n >> m >> t >> p;
        if(n == 0 && m == 0 && t == 0 && p == 0){
            break;
        }
        VVI paper(m*23);
        rep(i, m*23){
            paper[i].resize(n*23);
        }
        rep(i, m){
            rep(j, n){
                paper[i][j] = 1;
            }
        }
        int sx = 0, sy = 0;
        rep(k, t){
            int d, c;
            cin >> d >> c;
            if(d == 1){
                rep(j, c){
                    rep(i, 23*m - sy - 1){
                        paper[sy+i][sx+2*c-j-1] += paper[sy+i][sx+j];
                        paper[sy+i][sx+j] = 0;
                    }
                }
                sx += c;
            }else{
                rep(i, c){
                    rep(j, 23*n - sx - 1){
                        paper[sy+2*c-i-1][sx+j] += paper[sy+i][sx+j];
                        paper[sy+i][sx+j] = 0;
                    }
                }
                sy += c;
            }
        }
        rep(i, p){
            int x, y;
            cin >> x >> y;
            cout << paper[sy+y][sx+x] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	ll k;
	cin>>k;
	cin>>s;
	string ans = "";
	for(ll i=0;i<min((ll)s.length(),k);i++)
		ans+=s[i];

	if (s.length()>k)
		ans+="...";
	cout<<ans;
}

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

vector<int> to[10];
vector<int> past;
int n,m;
int ans;

void dfs(int v){
  for(auto x : to[v]){
    if(past[x] == 1)continue;
    past[x]=1;
    dfs(x);
    past[x]=0;
  }
  bool flag=1;
  rep(i,n){
    if(past[i]==0)flag=0;
  }
  if(flag)ans++;
  return;
}

int main(){
  cin>>n>>m;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  past.resize(n,0);
  past[0]=1;
  ans=0;
  dfs(0);
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <cstdio>

#define maxn 100000
#define ll long long
#define MOD 1000000007

inline int lgput (int a, int n) {
    int rez = 1;
    while (n) {
        if (n % 2 == 1)
            rez = (1LL * rez * a) % MOD;
        a = (1LL * a * a) % MOD, n /= 2;
    }
    return rez;
}

ll xx[maxn + 2];
ll yy[maxn + 2];

int main() {
    ll n, m;
    scanf("%lld%lld", &n, &m);
    for (ll i = 1; i <= n; i++)
        scanf("%lld", &xx[i]);

    for (ll i = 1; i <= m; i++)
        scanf("%lld", &yy[i]);
    ll p = 0;
    for (ll i = 1; i <= m - 1; i++) {
        p = (p + (yy[i + 1] - yy[i]) % MOD * i % MOD * (m - i) % MOD) % MOD;
    }
    ll rez = 0;
    for (ll i = 1; i <= n - 1; i++) {
        rez = (rez + p * (xx[i + 1] - xx[i]) % MOD * i % MOD * (n - i) % MOD) % MOD;
    }
    printf("%lld", rez);
    return 0;
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N;
int A[100010];
ll ret;

int main() {
	cin >> N;
	int ma = 0;

	rep(i, N) {
		cin >> A[i];
		int t = ma + 1;

		if (A[i] <= t) {
			ma = max(ma, A[i]);
		} else {
			int ad = A[i] / t;
			if (ad > 0 && A[i] % t == 0) {
				--ad;
			}
			ret += ad;
		}
		if (i == 0) ma = 1;
	}

	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>


using namespace std;

int main(){

	int N, K, ans;

	cin >> N >> K;

	if(N % K == 0){
		ans = 0;
	} else {
		ans = 1;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int a,b;
    cin >> a >> b;
    int ans=0;
    for(int i=a;i<=b;i++){
        string str;
        str=to_string(i);
        if(str.at(1)==str.at(3)&&str.at(0)==str.at(4)) ans++;
    }
    cout << ans << endl;
}

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

public class Main{
    public static void main(String[] args)throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String line = br.readLine();
        String[] temp = line.split("\\s");
        br.close();

        int num1 = Integer.parseInt(temp[0]);
        int num2 = Integer.parseInt(temp[1]);
        
        int a1 = num1 / num2;
        int a2 = num1 % num2;
        double a3 = (double)num1 / (double)num2;
        String sa3 = String.format("%.5f",a3);

        String ans = a1 + " " + a2 + " " + sa3;
        System.out.println(ans);

    }
}

Measured memory_bytes: 24724
#![allow(non_snake_case)]
use proconio::{input, fastout};
use proconio::marker::{Chars, Bytes, Usize1};

#[fastout]
fn main() {
    input!{
        n: usize,
        mut l: [i32; n]
    }
    l.sort();
    let mut ans = 0;
    for i in 0..n {
        for j in 0..n {
            if j <= i {continue;}
            for k in 0..n {
                if k <= j {continue;}
                if l[i] < l[j] && l[j] < l[k] && l[k] < l[i] + l[j] {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2208
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

string S,T;

int main(){

	cin>>S;
	cin>>T;

	int i,j;

	int ans=0;
	int idx=0;

	if(S.size()<T.size()){
	printf("UNRESTORABLE\n");
	return 0;
	}

	for(i=0;i<=S.size()-T.size();i++){
		string sub_str=S.substr(i,T.size());
		int flag=0;
		for(j=0;j<T.size();j++){
			if(sub_str[j]=='?'||T[j]==sub_str[j]);
			else{flag=1;}
		}
		if(flag==0){
			ans=1;
			idx=i;
		}
	}

	if(ans==0){
	printf("UNRESTORABLE\n");
	}
	else{
		string S_ans=S;
		for(i=idx;i<idx+T.size();i++){
			S_ans[i]=T[i-idx];
		}
		for(i=0;i<S_ans.size();i++){
			if(S_ans[i]=='?'){S_ans[i]='a';}
		}
		cout<<S_ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
    int a, b, c, d, e, f;
    
    while (cin >> a >> b >> c >> d >> e >> f)
    {
        double x = (b * f - c * e) * 1.0 / (b * d - a * e);
        double y = (a * f - c * d) * 1.0 / (a * e - b * d);
        if (x == 0.0f)
            x = 0;
        if (y == 0.0f)
            y = 0;
        cout << setprecision (3) << fixed << x << " " << y << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3272
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int h, w;
	string s[8];
	int y=0, x=0;
	cin >> h >> w;
	rep(i,h) {
		cin >> s[i];
	}
	int v[8][8] = {};

	while (1) {
		v[y][x] = 1;
		if (y+1<h&&s[y+1][x]=='#') {
			y++;
		}
		else if (x+1<w&&s[y][x+1]=='#') {
			x++;
		}
		else break;
	}
	bool ok = true;
	rep(i,h) rep(j,w){
		if (v[i][j] != (s[i][j] == '#'))ok = false;
	}
	cout << (ok ? "Possible" : "Impossible") << endl;


	return 0;
}

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

s = input().rstrip()
t = input().rstrip()
n = len(s)
m = len(t)

from collections import deque

dic = {}
for i in range(ord("a"), ord("z") + 1):
    dic[chr(i)] = deque([])


for i in range(n):
    dic[s[i]].append(i + 1)

cnt = 0
res = 0
from bisect import bisect

for i in t:
    if len(dic[i]) == 0:
        print(-1)
        sys.exit()
    idx = bisect(dic[i], cnt)
    if idx >= len(dic[i]):
        res += 1
        cnt = dic[i][0]
    else:
        cnt = dic[i][idx]

print(n * res + cnt)


Measured memory_bytes: 46956
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
 
class DandA {
    static void Main(string[] args) {
        long[] ab = ReadLineLongArray();
        long min = 0;
        long max = 0;
        if (ab[0] < ab[1]) {
            min = ab[0];
            max = ab[1];
        } else {
            min = ab[1];
            max = ab[0];
        }
        long wk = min;
        long i = 2;
        while (wk % max != 0) {
            wk = min * i;
            i++;
        }
        Console.WriteLine(wk);
    }
  
    static private string ReadLineStr() {return Console.ReadLine();}
    static private int ReadLineInt() {return int.Parse(Console.ReadLine());}
    static private string[] ReadLineStrArray() {return Console.ReadLine().Trim().Split();}
    static private int[] ReadLineIntArray() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToArray();}
    static private long[] ReadLineLongArray() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToArray();}
    static private string[][] ReadMLineStrArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split()).ToArray();}
    static private int[][] ReadMLineIntArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();}

    static private bool IsPrime(int num) {
        if (num < 2) return false;
        if (num == 2) return true;
        else if (num % 2 == 0) return false;
        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) return false;
        }
        return true;
    }
}

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

using namespace std;

const int MAX_N = 1000;
int N,K,p[MAX_N];

int main(void){
    int sum = 0;
    cin >> N >> K;
    for(int i=0;i < N;i++){
        cin >> p[i];
    }

    sort(p,p+N);

    for(int i=0;i < K;i++){
        sum += p[i];
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;


int main()
{
   int d,n;
   cin>>d>>n;
   if( d==0 )
   {
       if( n!= 100)
           cout<<n;
       else cout<<101;
   }
   if( d==1)
   {
       if( n!= 100)
           cout<<n*100;
       else cout<<10100;
   }
   if( d== 2)
   {
       if( n!= 100)
       cout<<n*10000;
       else cout<<1010000;
   }
}

Measured memory_bytes: 3592
/**
 *    author:  tourist
 *    created: 15.12.2019 11:26:08       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  cout << (1LL << (n + 2)) - 2 << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int ans,ls;
int main()
{
	cin>>s;
	ls=s.size();
	for(int i=0;i<ls/2;i++)
	if(s[i]!=s[ls-i-1])
	ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort(reverse=True)
if n<=k:
    print(0)
    quit()
for i in range(k):
    h[i]=0
print(sum(h))

Measured memory_bytes: 108364
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}

int main(){
    long long N;
    scanf("%lld",&N);

    ll sum=0;
    for (long long i = 1; i <= N; i++) {
        ll y=N/i;
        sum+=(y*(y+1)*i/2);
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

ll cut(ll x, ll y)
{
    ll ans = INF;

    reple(i, 1, x)
    {
        ll w = x - i;

        //同じ方向に3枚にスライス
        if (w >= 2)
        {
            vll v(3);
            v[0] = y * i;
            v[1] = y * (w / 2);
            v[2] = y * (w / 2 + w % 2);

            chmin(ans, *max_element(all(v)) - *min_element(all(v)));
        }

        //T字型に切る
        {
            vll v(3);
            v[0] = y * i;
            v[1] = (y / 2) * w;
            v[2] = (y / 2 + y % 2) * w;

            chmin(ans, *max_element(all(v)) - *min_element(all(v)));
        }
    }

    return ans;
}

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

    ll H, W;
    cin >> H >> W;

    ll ans = INF;

    chmin(ans, cut(H, W));
    chmin(ans, cut(W, H));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
n=int(input())
arr=list(map(int,input().split()))
arr=[[arr[i],i+1] for i in range(n)]
mins=10**18
minpos=0
maxs=-10**18
maxpos=0
for i in range(n):
  a=arr[i][0]
  if a<mins:
    mins=a
    minpos=i+1
  if maxs<a:
    maxs=a
    maxpos=i+1
ans=[]
if maxs<=0:
  flag=False
elif mins>=0:
  flag=True
else:
  if maxs>=abs(mins):
    flag=True
    for i in range(n):
      arr[i][0]+=maxs
      ans.append([maxpos,arr[i][1]])
  else:
    flag=False
    for i in range(n):
      arr[i][0]+=mins
      ans.append([minpos,arr[i][1]])
if flag==True:
  for i in range(1,n):
    ans.append([i,i+1])
else:
  for i in range(n,1,-1):
    ans.append([i,i-1])
print(len(ans))
for i in range(len(ans)):
  print(*ans[i])

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

using namespace std;

typedef long long ll;

const int MAXN = 200000;
ll a[MAXN+1];
ll acc[MAXN+1];

ll split_search(int s, int t, ll sum){
  // はじめてacc[i] >= sum - acc[i]となる最小のiを二分探索して、i-1またはiで分割する
  ll left = s, right = t;
  while(right - left > 1){
    ll mid = (left + right)/2;
    if(acc[mid] >= sum - acc[mid]){
      // midが条件を満たせば、解の存在範囲は(left, mid]
      right = mid;
    }else{
      // 解の存在範囲は(mid, right]
      left = mid;
    }
  }
  // 初めの要素で条件を満たす場合
  if(right == s+1) return right;

  if(abs(sum - 2*acc[right-1]) <= abs(sum - 2*acc[right])){
    return right - 1;
  }else{
    return right;
  }
}

// 二分探索ver
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll N; cin >> N;
  acc[0] = 0;
  for(int i=1;i<=N;i++){
    cin >> a[i];
    acc[i] = acc[i-1] + a[i];
  }
  ll ans = 1e15;
  // a[d]とa[d+1]の間で切る
  for(int d=2;d<=N-2;d++){
    ll leftsum = acc[d];
    ll rightsum = acc[N] - acc[d];
    // leftの操作
    int pleft = split_search(0, d, leftsum);
    // rightの操作
    int pright = split_search(d, N, rightsum+2*leftsum);
    ll p = acc[pleft];
    ll q = leftsum - acc[pleft];
    ll r = acc[pright] - leftsum;
    ll s = acc[N] - acc[pright];
    // cout << pleft << " " << pright << endl;
    // cout << p << " " << q << " " << r << " " << s << endl;
    ll curr = max(max(p, q), max(r, s)) - min(min(p, q), min(r, s));
    ans = min(curr, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3328
// Created by sz
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
#ifdef LOCAL
	freopen("./input.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	cout << (n + 1) / 2 << endl;

	
	return 0;
}


Measured memory_bytes: 256
def dfs(i,v,d,c):
  if dp[v][d]==-1:
    dp[v][d]=i
    if d>0:
      dfs(i,v,d-1,c)
      for u in g[v]:
        dfs(i,u,d-1,c)
  
n,m=map(int,input().split())
g=[[] for _ in range(n+1)]
for _ in range(m):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
q=int(input())
arr=[]
for i in range(q):
  v,d,c=map(int,input().split())
  arr.append((i,v,d,c))
dp=[[-1]*11 for _ in range(n+1)]
for i,v,d,c in arr[::-1]:
  dfs(i,v,d,c)
ans=[]
for i in range(1,n+1):
  if dp[i][0]==-1:
    ans.append(0)
  else:
    ans.append(arr[dp[i][0]][3])
for i in range(n):
  print(ans[i])

Measured memory_bytes: 57060
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n,k; cin >> n >> k;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  sort(ALL(a),greater<int>());

  int ng = 0, ok = a[0];
  while (abs(ok-ng)>1) {
    int mid = (ok+ng)/2,cnt=0;
    REP(i,n) {
      if (k < cnt) break;
      if (a[i] <= mid) break;
      cnt+=a[i]/mid;
      if (a[i]%mid == 0) cnt--;
    }
    if (k < cnt) ng = mid;
    else ok = mid;
  }

  COUT(ok);
  return 0;
}

Measured memory_bytes: 3912
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std; using namespace placeholders;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector< int > VI;
typedef vector< vector< int > > VVI;
typedef vector< string > VS;
typedef stringstream SS;
typedef pair< int, int > PII;
typedef vector< pair< int, int > > VPII;
#define VT( T ) vector< T >
#define VVT( T ) vector< vector< T > >
#define LIM( T ) numeric_limits< T >

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; };
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &e : c )
#define ALL( c ) ( c ).begin(), ( c ).end()
#define AALL( a, t ) ( t* )a, ( t* )a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + p, ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

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

	int N, H;
	cin >> N >> H;

	VS S( N );
	VI T( N );
	REP( i, N )
	{
		cin >> S[i] >> T[i];
	}

	int success = 0, total = 0;

	REP( i, N )
	{
		int pos = 0, miss = 0;
		while ( pos < SZ( S[i] ) )
		{
			cout << "? " << S[i] << endl;

			char c;
			cin >> c;

			++total;

			if ( tolower( S[i][ pos ] ) == c )
			{
				S[i][ pos++ ] = '_';
				++success;
			}
			else
			{
				++miss;
			}

			if ( T[i] < miss )
			{
				--H;

				if ( H == 0 )
				{
					cout << "! Game Over" << endl;
					return 0;
				}

				pos = SZ( S[i] );
			}
		}
	}

	cout << "! Game Clear " << setprecision( 1 ) << fixed << int( 1. * success / total * 1000 ) / 10. << endl;

	return 0;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define pb push_back
#define mp make_pair
#define INF 3e9
#define mod 998244353
#define eps 1e-6
#define abs(x) ((x)>=0?(x):-(x))
#define y1 solai
#define fi first
#define se second
typedef long long ll;
void read(ll &x)
{
	scanf("%lld",&x);
}
void read(ll &x, ll &y)
{
	scanf("%lld%lld",&x,&y);
}
void read(ll &x, ll &y, ll &z)
{
	scanf("%lld%lld%lld",&x,&y,&z);
}
void print(ll x)
{
	printf("%lld ",x);
}
void println(ll x)
{
	printf("%lld\n",x);
}
const ll N=300100;
ll n,a,b,c,d;
char s[N];
int main()
{
	cin>>n>>a>>b>>c>>d;
	scanf("\n%s",s);
	a--;
	b--;
	c--;
	d--;
	for(ll i=a+1;i<=c;i++)
		if(s[i]==s[i-1]&&s[i]=='#')
		{
			cout<<"No";
			return 0;
		}

	for(ll i=b+1;i<=d;i++)
		if(s[i]==s[i-1]&&s[i]=='#')
		{
			cout<<"No";
			return 0;
		}
	if(d>c)
	{
		cout<<"Yes";
		return 0;
	}
	for(ll i=b;i<=d;i++)
		if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.')
		{
			cout<<"Yes";
			return 0;
		}
	cout<<"No";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int h, w, a, b;
int main(){
	cin>>h>>w>>a>>b;
	for(int i = 0; i < h - b; ++i){
		for(int j = 0; j < a; ++j){
			cout<<'1';
		}
		for(int j = a; j < w; ++j){
			cout<<'0';
		}
		cout<<endl;
	}
	for(int i = h - b; i < h; ++i){
		for(int j = 0; j < a; ++j){
			cout<<'0';
		}
		for(int j = a; j < w; ++j){
			cout<<'1';
		}
		cout<<endl;
	}
	return 0;
}


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

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

long long gcd(long long a, long long b) { return b ? gcd(b, a%b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b ; }

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

    long long l = 1;
    for(int i=0;i<N;i++){
        long long t;
        cin >> t;
        l = lcm(l,t);
    }

    cout << l;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,t,a[200005],l,r,j;
long long s;
int main()
{
	cin>>n>>t;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}

	for(int i=1;i<=n;i++)
	{
	  if(i==n)s+=t;
	  else if(a[i+1]-a[i]<=t)s=s+a[i+1]-a[i];
	  else if(a[i+1]-a[i]>t)s+=t;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 1024
points = []
while true
  line = STDIN.gets.chomp
  if line == "-1 -1 -1" then break end
  point = Array.new(3) { |i|  i = line.split(" ")[i].to_i}
  points << point
end

# print points

points.each do |point|
  grade = ""
  if point[0] == -1 || point[1] == -1 then
    grade = "F"
  elsif point[0] + point[1] >= 80 then
    grade = "A"
  elsif point[0] + point[1] >= 65 then
    grade = "B"
  elsif point[0] + point[1] >= 50 then
    grade = "C"
  elsif point[0] + point[1] >= 30 then
    if point[2] >= 50 then
      grade = "C"
    else
      grade = "D"
    end
  else
    grade = "F"
  end
  puts grade
end

Measured memory_bytes: 6104