akhauriyash/Code-Regression huggingface dataset:
def main():
    n = int(input())

    is_buy = False
    for i in range(n):
        if is_buy:
            break
        for j in range(n):
            if n == i * 4 + j * 7:
                is_buy = True
                break
    
    print('Yes' if is_buy else 'No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
// In the Name of God
#include<bits/stdc++.h>

#define test(t) int t; cin>>t; while(t--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORE(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ll long long int
#define em emplace_back
#define pb push_back
#define INF 1e7+5
#define MOD 1e9+7
#define print printf
#define in scanf
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

template<class type>
void displaySingle(type &arr)
{
	for(auto i:arr)
		cout<<i<<" ";
	cout<<endl;
}

template<class type>
void displayDouble(type &arr)
{
	for(auto &&i : arr) 
	{
    	for(auto &&j : i) 
    		cout << j << " ";
    	cout << std::endl;
  	}

}

int main()
{
	fast
	int a,b,c;
  	cin>>a>>b>>c;
  	int k;
  	cin>>k;
  	int count = 0;
  	while(b <= a)
    {
      b*=2;
      count++;
    }
  	while(c <= b)
    {
      c*=2;
      count++;
    }
  	if(count <= k)
      cout<<"Yes"<<endl;
  	else
      cout<<"No"<<endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#define N 35
using namespace std;
int Erase();
int Cnt(int,int,string);
int h,w,n;
string cp[N];
int main(){
  int r,flag,i,j,k;
  string in[N];
  cin >> h >> w >> n;
  for(i=0;i<=w+1;i++) in[0]+='x',in[h+1]+='x';
  for(i=1;i<=h;i++) cin >> in[i],in[i]='x'+in[i]+'x';
  flag=0;
  for(k=0;k<=h+1;k++) cp[k]=in[k];
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      if(cp[i][j]!=cp[i][j+1]){
	swap(cp[i][j],cp[i][j+1]);
	r=Erase();
	if(r==0){
	  flag=1;
	  break;
	}
	for(k=0;k<=h+1;k++) cp[k]=in[k];
      }
    }
    if(flag==1) break;
  }
  if(flag==1) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}
int Erase(){
  int i,j,x,y,cnt,flag,flag2,flag3,mark[h+2][w+2];
  while(1){
    while(1){
      flag2=0;
      for(i=h-1;i>=1;i--){
	for(j=1;j<=w;j++){
	  if('A'<=cp[i][j]&&cp[i][j]<='Z'&&cp[i+1][j]=='.'){
	    swap(cp[i][j],cp[i+1][j]);
	    flag2=1;
	  }
	}
      }
      if(flag2==0) break;
    }
    flag=0;
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
	mark[i][j]=0;
      }
    }
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
	if(cp[i][j]!='.'){
	  if(cp[i][j]==cp[i][j+1]){
	    cnt=Cnt(i,j,"Right");
	    if(cnt>=n){
	      flag=1;
	      y=i;
	      x=j;
	      while(cnt){
		mark[y][x]=1;
		x++;
		cnt--;
	      }
	    }
	  }
	  if(cp[i][j]==cp[i+1][j]){
	    cnt=Cnt(i,j,"Down");
	    if(cnt>=n){
	      flag=1;
	      y=i;
	      x=j;
	      while(cnt){
		mark[y][x]=1;
		y++;
		cnt--;
	      }
	    }
	  }
	}
      }
    }
    if(flag==0) break;
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
	if(mark[i][j]==1) cp[i][j]='.';
      }
    }
  }
  flag3=0;
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      if(cp[i][j]!='.'){
	flag3=1;
	break;
      }
    }
  }
  if(flag3==0) return 0;
  return 1;
}
int Cnt(int y,int x,string d){
  int cnt=0,py,px;
  char t=cp[y][x];
  if(d=="Right") py=0,px=1;
  else py=1,px=0;
  while(1){
    if(cp[y][x]==t){
      cnt++;
    }
    else break;
    y+=py,x+=px;
  }
  return cnt;
}

Measured memory_bytes: 1220
// B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <iostream>
using namespace std;
int main()
{
	int a, b, c, d;

	cin >> a >> b >> c >> d;
	bool win;
	while (true) {

		c -= b;
		if (c <= 0) {
			win = true;
			break;
		}
		a -= d;
		if (a <= 0) {
			win = false;
			break;
		}
	}

	if (win) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



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

bool getSeven(vector<int>v,int index,int result,vector<char>&op)
{
    if(op.size()==4)
    {
        if(result==7)
        {
            cout<<v[0];
            for(int i=1;i<op.size();i++)
            {
                cout<<op[i];
                cout<<v[i];
            }   
            cout<<"=7";
            return true;
        }
        
        else
        return false;
    }
    else
    {
        vector<char>temp=op;
        temp.push_back('+');
        if(getSeven(v,index+1,result+v[index],temp)==true)
        {
            return true;
        }
        temp.pop_back();
        temp.push_back('-');
        if(getSeven(v,index+1,result-v[index],temp)){
            return true;
        }
    }
    return false;
}

int main(){
    int n;
    cin>>n;
    vector<int>v(4);
    for(int i=3;i>=0;i--){
        v[i]=n%10;
        n/=10;
    }
    vector<char>op;
    int index=0;
    getSeven(v,0,0,op);
    
}

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


class DisjointSet:
  def __init__(self, size):
    self.parent = list(range(size))
    self.rank = [0]*size
  
  def find(self, x):
    if self.parent[x] == x:
      return x
    else:
      self.parent[x] = self.find(self.parent[x])
      return self.parent[x]

  def union(self, x, y):
    xr = self.find(x)
    yr = self.find(y)
    if self.rank[xr] > self.rank[yr]:
      self.parent[yr] = xr
    elif self.rank[xr] < self.rank[yr]:
      self.parent[xr] = yr
    elif xr != yr:
      self.parent[yr] = xr
      self.rank[xr] += 1


X,Y = [],[]
for i in range(N):
  x,y = map(int, input().split())
  X.append((x,i))
  Y.append((y,i))

X.sort()
Y.sort()

def convert_to_dists(L):
  it = iter(L)
  it2 = iter(L)
  next(it2)

  D = []

  for a,b in zip(it, it2):
    ax, ai = a
    bx, bi = b
    d = abs(ax-bx)
    D.append((d,ai,bi))
  return D

dX = convert_to_dists(X)
dY = convert_to_dists(Y)

D = dX+dY
D.sort()

cost = 0
S = DisjointSet(N)
edge_count = 1

for d,i,j in D:
  if S.find(i) != S.find(j):
    S.union(i,j)
    cost += d
    edge_count += 1
    if edge_count >= N:
      break

print(cost)

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

def main():
    N = int(input().strip()[-1])
    
    if N in [2, 4, 5, 7, 9]:
        print("hon")
    elif N in [0, 1, 6, 8]:
        print("pon")
    else:
        print("bon")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9184
#include "bits/stdc++.h"
using namespace std;
using long_t = int64_t;

struct Solver {
	Solver() {
		ios::sync_with_stdio( false );
		cout << fixed << setprecision( 10 );
	}

	void solve() {
		int N;
		cin >> N;

		vector<int> e( N );
		for( int i = 0; i < N-1; ++i ) {
			int a;
			cin >> a;
			e[a-1] += 1;
		}

		for( int i = 0; i < N; ++i ) {
			cout << e[i] << '\n';
		}
	}
};

int main() {
	Solver().solve();
	return 0;
}


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

int main() {
  int N ;
  cin >> N ;
  
  int n=N;
  int sum=0;
  while(n>0){
    sum+=(n%10);
    n=n/10;
  }
  
  
  if(N%sum==0){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;


class Program
{
    static void Main(string[] args)
    {
        var arr = arrInt();
        double d = (double)arr[0];
        double t = (double)arr[1];
        double s = (double)arr[2];
        if (d / s <= t) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }




    //入力受け取り用
    static string crS() { return Console.ReadLine(); }
    static int crI() { return int.Parse(Console.ReadLine()); }
    static int[] arrInt() { return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray(); }
    static long[] arrLong() { return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray(); }
    static string[] arrStr() { return Console.ReadLine().Split(' ').ToArray(); }
    static List<int[]> mapInt(int h)
    {
        List<int[]> mapInt = new List<int[]>();
        for (int i = 0; i < h; i++)
        {
            mapInt.Add(arrInt());
        }
        return mapInt;
    }

    static List<string[]> mapStr(int h)
    {
        List<string[]> mapStr = new List<string[]>();
        for (int i = 0; i < h; i++)
        {
            mapStr.Add(arrStr());
        }
        return mapStr;
    }

    static List<char[]> mapChar(int h)
    {
        List<char[]> mapChar = new List<char[]>();
        for (int i = 0; i < h; i++)
        {
            string s = crS();
            mapChar.Add(s.ToCharArray());
        }
        return mapChar;
    }

    static List<char[]> mapCharCopy(List<char[]> map)
    {
        List<char[]> copyMap = new List<char[]>();
        foreach (var arr in map)
        {
            List<char> list = new List<char>();
            foreach (var ele in arr)
            {
                list.Add(ele);
            }
            copyMap.Add(list.ToArray());
        }
        return copyMap;
    }
}

Measured memory_bytes: 28240
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int n;
double r,l,p,e,t;
double f(int q,double a,double b){
	double h=(a+b)/2.0;
	if(q==0){
		if(t-e<h+EPS&&h<t+e+EPS)return 1;
		else return 0;
	}else if(t+e<a||b<t-e)return 0;
	else if(t-e<a&&b<t+e)return 1;
	if(t<=h)return p*f(q-1,a,h)+(1-p)*f(q-1,h,b);
	else return (1-p)*f(q-1,a,h)+p*f(q-1,h,b);
}
int main(){
	cin>>n>>l>>r>>p>>e>>t;
	p=1-p;
	printf("%.8f\n",f(n,l,r));
}

Measured memory_bytes: 1248
# -*- coding: utf-8 -*-
def main():
    N = int(input())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    ans = 0
    for i in range(N):
        left = min(A[i],B[i])
        ans+=left
        A[i]-=left
        B[i]-=left
        right = min(A[i+1],B[i])
        ans+=right
        A[i+1]-=right
        B[i]-=right
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 18476
#include<stdio.h>
int n,i,j,flg;
int data[3];
int min=100000000;
int main(void){
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&data[i]);
		if(min>data[i]){
			min=data[i];
		}
	}
	int han=min/2;
	
	for(i=1;i<=han;i++){
		flg=1;
		for(j=0;j<n;j++){
			if(data[j]%i!=0){
				flg=0;
			}
		}
		if(flg==1){
			printf("%d\n",i);
		}
	}
	flg=1;
	for(i=0;i<n;i++){
		if(data[i]%min!=0){
			flg=0;
		}
	}
	if(flg==1){
		printf("%d\n",min);
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int x, y, z, k;
    cin>>x>>y>>z>>k;
    vector<long long int> A(x),B(y),C(z);
    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.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    vector<long long int> D(x*y);
    int s=0;
    for(int i=0;i<x;i++)for(int j=0;j<y;j++)D[s++] = A[i] + B[j];
    sort(D.begin(),D.end(),greater<long long int>());
    int k1 = k;
    if(x*y < k){
        k1 = x*y;
    }
    vector<long long int> ans(k1*z);
    s = 0;
    
    for(int i=0;i<k1;i++){
        for(int j=0;j<z;j++){
            ans[s++]=D[i]+C[j];
        }
    }
    sort(ans.begin(),ans.end(),greater<long long int>());
    for (int i = 0; i < k; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC40(void);
void ABC41(void);
void ABC42(void);
void ABC43(void);
void ABC44(void);
void ABC45(void);
void ABC46(void);
void ABC47(void);
void ABC48(void);
void ABC49(void);

int main(void){
    ABC48();
}

void ABC48(){
    int h,w,i,j;
    cin>>h>>w;
    char s[h][w];
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cin>>s[i][j];
        }
    }
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cout<<s[i][j];
        }
        cout<<endl;
        for(j=0;j<w;j++){
            cout<<s[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int DIM = 1e5 + 5;
 
int arr[DIM], aux[DIM];
 
int main( void ) {
    ios::sync_with_stdio( false );
    cin.tie(); cout.tie();
    
    int n, a, b;
    cin >> n >> a >> b;
    
    for( int i = 1; i <= n; i ++ )
        cin >> arr[i];
    
    int pos = 1;
    for( int le = 1, ri = 1e9 / b + 1; le <= ri; ) {
        int md = ( le + ri ) >> 1;
        
        long long ans = 0;
        for( int i = 1; i <= n; i ++ ) {
            aux[i] = arr[i] - b * md;
            
            if( aux[i] >= 1 )
                ans += (int) ceil( 1.0 * aux[i] / (a - b) );
        }
        
        if( ans <= md )
            ri = md - 1;
        else
            le = pos = md + 1;
    }
    
    cout << pos << endl;
    return 0;
}

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

vector<string> mp;
int a[100][100];

bool solve(int y, int x){
  if(a[y][x]==1)return false;//すでに通った
  a[y][x]=1;

  if(mp[y][x]=='.'){cout<<x<<' '<<y<<endl; return true;}
  else if(mp[y][x]=='>')x++;
  else if(mp[y][x]=='v')y++;
  else if(mp[y][x]=='<')x--;
  else if(mp[y][x]=='^')y--;

  if(solve(y, x))return true;
  else return false;
}

int main(){
  int h, w;
  while(true){
    cin>>h>>w;
    if(h==0 && w==0)break;
    mp.clear();
    memset(a, 0, sizeof(a));
    for(int i=0; i<h; i++){
      string s;
      cin>>s;
      mp.push_back(s);
    }
    if(!solve(0, 0))cout<<"LOOP"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1312
#include <iostream>

using namespace std;

int main(){
  int a[3];
  int tmp;
  for(int i = 0;i < 3;i++){a[i] = 0;}
  for(int i = 0;i < 6;i++){
    cin>>tmp;
    a[tmp-1]++;
  }
  int two = 0;
  for(int i = 0;i < 3;i++){
    if(a[i] == 2)two++;
}
if(two == 2)cout<<"YES"; else cout<<"NO";

return 0;
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
//const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

int N;
const int maxn = 25;
int A[25];

int main()
{
    cin >> N;
    _for(i,0,N){
        scanf("%d",&A[i]);
    }
    int ans = 0;
    _for(i,1,N-1){
        int nn = 0;
        if(A[i] > A[i-1]) nn++;
        if(A[i] > A[i+1]) nn++;
        if(nn == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::{BufRead, Write};
use std::io;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    let k: usize = s.trim().parse().unwrap();
    let base: Vec<_> = (0..50)
        .map(|x| x + (k / 50 + if x < k % 50 { 1 } else { 0 }) * 51 - k)
        .map(|x| x.to_string())
        .collect();
    writeln!(output, "50").unwrap();
    writeln!(output, "{}", base.join(" ")).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A_1,A_2,A_3,b;
    cin>>A_1>>A_2>>A_3;
b=A_1+A_2+A_3;

if(b>=22)cout<<"bust";
else cout<<"win";


    return 0;

//47-025

}


Measured memory_bytes: 256
import java.util.Random;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        String s = sc.next();

        char[] chars = s.toCharArray();

        if(n%2==1) {
            System.out.println("No");
        } else {
            for (int i = 0; i < n / 2; i++) {
                if(chars[i] != chars[i+n/2]){
                    System.out.println("No");
                    return;
                }
            }
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 21844
A,B=map(int,input().split())
x=int(A/0.08)
y=int(B/0.1)
if int(x*0.08)!=A:
    x+=1
if int(y*0.1)!=B:
    y+=1
eight=[i for i in range(x,1251) if int(i*0.08)==A]
ten=[i for i in range(y,1001) if int(i*0.1)==B]
eight_set=set(eight)
ten_set=set(ten)
ans_set=eight_set&ten_set
ans=list(ans_set)
if len(ans)>0:
    print(min(ans))
else:
    print(-1)
       

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>

template<typename T>inline void check_max(T a,T &b){if(a>b)b=a;}
template<typename T>inline void read(T &x)
{
	char c=x=0;
	for(c=getchar();!isdigit(c);c=getchar());
	for(;isdigit(c);c=getchar())x=(x<<3)+(x<<1)+(c^48);
}
inline void write(int x){if(x>=10)write(x/10);putchar(48+x%10);}

namespace never
{
	typedef std::pair<int,int> pii;

	const int N=501000,M=N*4;

	int n,K;
	struct segt
	{
#define lt (p<<1)
#define rt (lt|1)
#define mid ((L+R)>>1)
#define ltr lt,L,mid
#define rtr rt,mid+1,R
		int w[M];
		void modify(int x,int y,int p=1,int L=1,int R=n)
		{
			if(L==R){w[p]=y;return;}
			if(x<=mid)modify(x,y,ltr);
			else modify(x,y,rtr);
			w[p]=std::max(w[lt],w[rt]);
		}
		int query(int s,int t,int p=1,int L=1,int R=n)
		{
			if(L>=s && R<=t)return w[p];
			int ret=0;
			if(s<=mid)check_max(query(s,t,ltr),ret);
			if(t>mid)check_max(query(s,t,rtr),ret);
			return ret;
		}
	}d;
	int begin[N],next[N],to[N];
	int minw[N];
	int s[N],t[N],nt[N];
	int pos[N];
	int tot,e;
	void add(int x,int y)
	{
		to[++e]=y;
		next[e]=begin[x];
		begin[x]=e;
	}
	void initialize()
	{
		read(n),read(K);
		for(int i=1;i<=n;i++)
			read(s[i]),t[s[i]]=i;
		for(int i=1;i<=n;i++)
		{
			pos[i]=d.query(t[i]+1,t[i]+K-1);
			d.modify(t[i],i);
			add(t[pos[i]],t[i]);
		}
	}
//	void predfs(int p=0)
//	{
//		minw[p]=p;
//		for(int i=begin[p];i;i=next[i])
//			predfs(to[i]),minw[p]=std::min(minw[p],minw[to[i]]);
//	}
	std::vector<int> V[N];
	void dfs(int p=0)
	{
//		printf(":%d\n",p);

		nt[tot++]=p;
		V[p].clear();
		for(int i=begin[p];i;i=next[i])V[p].push_back(to[i]);
		std::sort(V[p].begin(),V[p].end());
		std::vector<int>::iterator it;
		for(it=V[p].begin();it!=V[p].end();it++)
			dfs(*it);
	}
	void solve()
	{
		initialize();
//		for(int i=1;i<=n;i++)
//			printf("%d -> %d\n",t[pos[i]],t[i]);
//		printf("\n");
		tot=0;
//		predfs();
//		for(int i=1;i<=n;i++)
//			printf("%d : %d\n",i,minw[i]);
		dfs();

		for(int i=1;i<=n;i++)
			s[nt[i]]=i;
		for(int i=1;i<=n;i++)
			printf("%d\n",s[i]);
	}
}

int main()
{	never::solve();
	return 0;
}


Measured memory_bytes: 75392
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

N, K, L = mapint()
uf_road = UnionFind(N)
for _ in range(K):
    x, y = mapint()
    uf_road.union(x-1, y-1)

uf_rail = UnionFind(N)
for _ in range(L):
    x, y = mapint()
    uf_rail.union(x-1, y-1)
from collections import Counter
lis = []
for i in range(N):
    road = uf_road.find(i)
    rail = uf_rail.find(i)
    lis.append(road*(10**6)+rail)
c = Counter(lis)
ans = []
for i in range(N):
    road = uf_road.find(i)
    rail = uf_rail.find(i)
    ans.append(str(c[(road*(10**6)+rail)]))
print(' '.join(ans))


Measured memory_bytes: 120544
a,b,c,d,e,f=[int(i) for i in input().split()]

noudo=0
mizu=100*a
satou=0

an=int(f/100*a)+2

for i in range(an):
  bn=int((f-100*a*i)/(100*b))+2
  
  for j in range(bn):
    cn=int((f -100*a*i -100*b*j)/c)+2
    
    for k in range(cn):
      dn=int((f -100*a*i -100*b*j -c*k)/d)+2
      
      for l in range(dn):
        
        if 100*i*a + 100*j*b + k*c + l*d != 0 and 100*i*a + 100*j*b + k*c + l*d <= f:
          if noudo <  100*(k*c+l*d)/ (100*i*a + 100*j*b + k*c + l*d) <= 100*e/(100+e):
            noudo = 100 * (k*c+l*d) / (100*i*a + 100*j*b + k*c + l*d)
            mizu = 100*i*a + 100*j*b
            satou =  k*c+l*d

print(mizu+satou, satou)  
        
        
        

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  UnionFind uf(N);
  ll M;
  cin >> M;
  rep(i, M){
    ll a, b;
    cin >> a >> b;
    a--;b--;
    uf.con(a,b);
  }
  ll ans = 0;
  rep(i, N){
    //auto root = uf.root(i);
    ans = max(ans, uf.cnt[i]);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 6424
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <map>

using namespace std;

map<int, int> vmap;
vector<int> counts;

int main() {
	ios::sync_with_stdio(0);
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		vmap[x]++;
	}
	for (auto it : vmap)
		counts.push_back(it.second);
	sort(counts.begin(), counts.end());
	int ans = 0;
	int lim = max(((int)counts.size())-k,0);
	for (int i = 0; i < lim; i++)
		ans += counts[i];
	cout << ans;
	//system("pause");
	return 0;
}

Measured memory_bytes: 10744
#include<cstdio>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std;

const int N=4010,mod=998244353;
ll n,k,i,ans[N],p2[N],C[N][N];

ll f(ll t){
	ll p=0,ans=0;
	for(ll i=1; i<=k && t-i<=k && i<t-i; i++) p++;
	rep(q,0,p){
		ll now=p2[q]*C[p][q]%mod;
		ll a=k-2*p+q-!(t&1),b=n-q;
		now=now*(b<0?0:C[b+a-1][a-1])%mod;
		ans=(ans+now)%mod;
	}
	return ans;
}

int main(){
	scanf("%lld%lld",&k,&n); p2[0]=1;
	rep(i,1,2000) p2[i]=p2[i-1]*2%mod;
	rep(i,0,4000) C[i][0]=1;
	rep(i,1,4000) rep(j,1,i) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	rep(i,2,k+1){
		ans[i]=f(i);
		if (i%2==0) n--,ans[i]+=f(i),n++;
		printf("%lld\n",ans[i]%mod);
	}
	for (int i=k; i>1; i--) printf("%lld\n",ans[i]%mod);
	return 0;
}

Measured memory_bytes: 123776
#include <stdio.h>
#include <vector>
#include <algorithm>

int main(){
	//printf("Hello World!\n");
	std::vector<int> v;
	int x = -1;
	for(int i=0; i<10; i++){
		scanf("%d",&x);
		v.push_back(x);
	}
	std::sort(v.begin(),v.end());
	std::reverse(v.begin(),v.end());
	std::vector<int>::iterator begin = v.begin(); 
	for(int i =0; i<3; i++){
		int h = *begin;
		begin++;
		printf("%d\n",h);
	}

	
	return 0;
}

Measured memory_bytes: 1052
n = int(input())
l = list(map(int,input().split()))
l.sort()

ans = 10**15
c = l[-1]+l[0]
c //= 2
for i in range(l[0],l[-1]+1):
    check = 0
    for j in l:
        check += (i-j)**2
    ans = min(check,ans)

print(ans)


Measured memory_bytes: 3060
#include <cstdio>
#define getchar_unlocked getchar
void reader(int *x) {
	char k = getchar_unlocked(); *x = k - '0';
	while (1) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
void reader(long long *x) {
	char k = getchar_unlocked(); *x = k - '0';
	while (1) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
int n, b[100009]; long long a[100009];
int main() {
	reader(&n);
	for (int i = 0; i < n; i++) {
		reader(&a[i]);
		reader(&b[i]);
	}
	long long ret = 0;
	for (int i = n - 1; i >= 0; i--) {
		long long d = (a[i] + ret) % b[i];
		if (d) ret += b[i] - d;
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C
{
    class Program
    {
        static int N, M;
        static void Main(string[] args)
        {
            var temp = ReadLinesToIntListList(1);
            N = temp[0][0];
            M = temp[0][1];
            if (N > 2 && M > 2)
            {
                var naka = ((long)N - 2) * ((long)M - 2);

                Console.WriteLine(naka);
            }
            else if(N == 2 || M == 2)
            {
                Console.WriteLine(0);
            }else if (N == 1 && M == 1)
            {
                Console.WriteLine(1);
            }
            else
            {
                var large = N > M ? N : M;
                Console.WriteLine(large - 2);
            }

        }

        static List<List<int>> ReadLinesToIntListList(int n)
        {
            List<List<int>> list = new List<List<int>>();
            for (int i = 0; i < n; i++)
            {
                var temp = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
                list.Add(temp);
            }
            return list;
        }
    }
}


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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){
    string s;
    cin >> s;

    int n = s.length();
    int ans = 1;
    FOR(i, n){
        if((i%2 == 0 && (s[i] == 'R' || s[i] == 'U' || s[i] == 'D')) || 
           (i%2 != 0 && (s[i] == 'L' || s[i] == 'U' || s[i] == 'D'))){
            ans = 1;
        } else {
            ans = 0;
            break;
        }
    }

    if(ans == 1){
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}



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

int par[100003],fz[100005],bz[100005],cnt,dsz[100005];
vector<int>adj[100005],bdj[100005];

void dfs(int src,int pr)
{
    par[src]=pr; int sz=fz[src]; cnt++;

    for(int lp=0;lp<sz;lp++)
    {
        int u=adj[src][lp];

        if(par[u]==0)
        {
            dfs(u,pr);
        }

    }

}

int main()
{


    int n,m,k,a,b,c,i,j,fr,sc,tr;
    scanf("%d %d %d",&n,&m,&k);

    for(i=1;i<=m;i++)
    {
        scanf("%d %d",&a,&b); adj[a].push_back(b); fz[a]++; adj[b].push_back(a);  fz[b]++;
    }

    for(i=1;i<=k;i++)
    {
        scanf("%d %d",&a,&b); bdj[a].push_back(b); bz[a]++; bdj[b].push_back(a);  bz[b]++;
    }

    for(i=1;i<=n;i++)
    {
        if(par[i]==0)
        {
            cnt=0; dfs(i,i); cnt--; dsz[i]=cnt;

        }

    }

    for(i=1;i<=n;i++)
    {
        fr=dsz[par[i]]-fz[i]; int sz=bz[i];

        for(int lp=0;lp<sz;lp++)
        {
            int u=bdj[i][lp]; if(par[u]==par[i])fr--;
            if(fr==0)break;
        }

        printf("%d ",fr);

        //cout<<i<<"  "<<dsz[par[i]]<<"   "<<fz[i]<<endl;

    }



    return 0;
}





Measured memory_bytes: 16756
N, K = map(int, input().split())
Ai = list(map(int, input().split()))

D = 40 #10^12 の二進表記長さ

# 長さ40の二進表記に固定する
Bi = []
for a in Ai:
    b = bin(a)[2:] # 0b は不要
    b = ("0" * (D - len(b))) + b
    Bi.append(b)

result = ""
for i in range(D):
    count = 0 # 1の個数
    for i, b in enumerate(Bi):
        if b[0] == '1':
            count += 1
        Bi[i] = b[1:]
    if count >= N / 2:
        result += "0"
    else:
        result += "1"
    count = count // 2
x = 0
for i in range(D):
    if result[0] == '1':
        a = pow(2, D - i - 1)
        if x + a <= K:
            x += a
    result = result[1:]

ans = 0
for a in Ai:
    ans += (a ^ x)
print(ans)


Measured memory_bytes: 18308
n = int(input())
count = 0
sum_of_count_8 = 0
for i in range(1,n+1,2):
    count = 0
    for j in range(1,n+1):
        if i%j ==0:
            count+=1
    if count == 8:
        sum_of_count_8 += 1
print(sum_of_count_8)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

typedef char Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	int n, m, s, go;
	while (cin >> n >> m >> s >> go, n)
	{
		Graph g(n), rev(n);
		vector<tuple<int, int, string>> es;
		REP(i, m)
		{
			int a, b; cin >> a >> b;
			add_edge(rev, b, a, 0);
			string t; cin >> t;
			es.emplace_back(a, b, t);
		}
		vector<bool> vis(n);
		queue<int> que1;
		que1.push(go);
		vis[go] = true;
		while (que1.size())
		{
			int t = que1.front();
			que1.pop();
			REP(i, rev[t].size())
			{
				int nx = rev[t][i].to;
				if (!vis[nx])
				{
					vis[nx] = true;
					que1.push(nx);
				}
			}
		}
		REP(i, m)
		{
			int a = get<0>(es[i]), b = get<1>(es[i]);
			string t = get<2>(es[i]);
			if (!(vis[a] && vis[b]) || a == go) continue;		
			int tmp = a;
			REP(j, t.size() - 1)
			{
				g.resize(g.size() + 1);
				add_edge(g, tmp, g.size() - 1, t[j]);
				tmp = g.size() - 1;
			}
			add_edge(g, tmp, b, t.back());
		}

		string ans(2500, 'z');
		vs rec;
		REP(i, 3000) rec.push_back(string(i, 'z'));
		queue<pair<int, string>> que;
		que.push(make_pair(s, ""));
		bool f = false;
		int len = 0;
		while (que.size())
		{
			int tmp = que.front().first;
			string s = que.front().second;
			
			if (len < s.size())
			{
				set<pair<int, string>> st;
				int sz = que.size();
				REP(i, sz)
				{
					int tmp = que.front().first;
					string s = que.front().second;
					que.pop();
					if (s == rec[s.size()] && st.count(make_pair(tmp, s)) == 0)
					{
						st.insert(make_pair(tmp, s));
						que.emplace(tmp, s);
					}
				}
				len = s.size();
				continue;
			}

			que.pop();
			if (s > ans) continue;

			if (tmp == go)
			{
				chmin(ans, s);
				continue;
			}
			if (s.size() > 2500)
			{
				f = true;
				break;
			}
			REP(i, g[tmp].size())
			{
				int nn = g[tmp][i].to;
				string ns = s + g[tmp][i].cost;
				if (ns > rec[ns.size()]) continue;
				rec[ns.size()] = ns;
				que.push(make_pair(nn, ns));
			}
		}
		if (f || ans == string(2500, 'z')) puts("NO");
		else cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 14728
use proconio::{input};

fn main() {
    input! [
	N: i32,
	D: f64,
    ];

    let mut ans = 0;
    for i in 0..N {
	input![
	    X: f64,
	    Y: f64,
	];
	let tmp = X * X + Y * Y;
	let dist = tmp.sqrt();
	if dist <= D {
	    ans += 1;
	}
    }
    println!("{}", ans);
}


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

int main() {
  long long H,W,N;
  cin >>N;
 for(int i=1;i<11111;i++){
   H=5*i+1;
   for(int j=2;j<=H/2;j++){
     if(H%j==0){
       break;
     }
     if(j==H/2){
       cout<<H;
       if(N!=1){
         cout<<" ";
         N--;
         break;
       }
       return 0;
     }
   }
 }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int H, W, h, w;
int main() {
    cin >> H >> W >> h >> w;
    cout << (H-h) * (W-w) << endl;
}








Measured memory_bytes: 256
def solve(string):
    n, *a = map(int, string.split())
    l, c, r = 1, 2, 3
    sll, slr, srl, srr = sum(a[:l]), sum(a[l:c]), sum(a[c:r]), sum(a[r:])
    ans = max(sll, slr, srl, srr) - min(sll, slr, srl, srr)
    while c < n - 1:
        d = abs(sll - slr)
        dn = abs(sll + 2 * a[l] - slr)
        while dn < d:
            sll, slr = sll + a[l], slr - a[l]
            l += 1
            d = abs(sll - slr)
            dn = abs(sll + 2 * a[l] - slr)
        d = abs(srl - srr)
        dn = abs(srl + 2 * a[r] - srr)
        while dn < d:
            srl, srr = srl + a[r], srr - a[r]
            r += 1
            d = abs(srl - srr)
            dn = abs(srl + 2 * a[r] - srr)
        ans = min(ans, max(sll, slr, srl, srr) - min(sll, slr, srl, srr))
        slr += a[c]
        srl -= a[c]
        c += 1
    return str(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


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

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

using namespace std;

int n, m, a, b;
int d[1000];

int main(){
  cin >> n >> m >> a >> b;
  rep(i, n){
    cin >> d[i];
  }
  int p = -1;
  while(p + 1 < n && d[p + 1] >= a){
    ++p;
  }
  if(n - p - 1 < m){
    while(p >= 0 && d[p] <= b){
      --p;
    }
  }
  cout << p + 1 << endl;
  return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;

#define rep(i,a,b) for(int i=int(a),nn=int(b);i<=nn;++i)
#define vep(i,a,b) for(int i=int(a),nn=int(b);i>=nn;--i)
#define xep(i,b) for(int i=0,nn=int(b);i<nn;++i)


typedef long long ll;

ll n, a, b;
ll lw, hi;

int main() {

	cin >> n >> a >>b;
	if (a > b) return cout << 0 << endl, 0;
	if (n == 1 && a != b)
		return cout << 0 << endl, 0;
	hi = b*(n-1) + a;
	lw = a*(n-1) + b;
	cout << hi - lw + 1 <<endl;
	return 0;
}
	

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a < b) { cout << "a < b"<<endl; }
	else if (a > b) { cout << "a > b" << endl; }
	else if (a=b) { cout << "a == b" << endl; }
	return 0;
}

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

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

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

	int A, B;
	string S;
	cin >> A >> B >> S;

	for (int i = 0;i < S.size();i++){
		if(i != A && (S[i] < '0' || S[i] > '9')){
			cout << "No" << endl;
			return 0;
		}
		if(i == A && S[i] != '-'){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;

}


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

int N;
const int MAX_N = 100 + 10;
int a[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> a[i];

    sort(a, a+N, greater<>());

    int alice = 0;
    int bob = 0;

    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) alice += a[i];
        else bob += a[i];
    }

    cout << alice - bob << endl;
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contest
{
	class Program
	{
		static void Main()
		{
			var HW = Console.ReadLine().Split().Select(int.Parse);
			int H = HW.First(), W = HW.Last();
			for (int i = 0; i < W + 2; i++)
			{
				Console.Write("#");
			}
			Console.WriteLine();
			for (int i = 0; i < H; i++)
			{
				Console.WriteLine($"#{Console.ReadLine()}#");
			}
			for (int i = 0; i < W + 2; i++)
			{
				Console.Write("#");
			}
			Console.WriteLine();
#if DEBUG
			Console.ReadKey();
#endif
		}
	}
}

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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, i, j, k;
    cin >> n;
    vi a(n); cin >> a;
    int ans = 0;
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            for(k=j+1;k<n;k++){
                if(a[i] == a[j] || a[i] == a[k] || a[j] == a[k]) continue;
                vi tmp = {a[i], a[j], a[k]};
                sort(all(tmp));
                if(tmp[0] + tmp[1] > tmp[2]){
                    ans++;
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpl;
typedef vector<tuple<int, int, int>> vti;





int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    
    vector<vpi> table(n);
    rep(i, n-1){
        int t1, t2, t3;
        cin >> t1 >> t2 >> t3;
        t1--;t2--;
        table[t1].push_back({t2, t3});
        table[t2].push_back({t1, t3});
    }
    
    vi ans(n, -1);
    queue<int> q;
    ans[0] = 0;
    q.push(0);
    
    while(!q.empty()){
        int idx = q.front();q.pop();
        for (auto v: table[idx]){
            if (ans[v.first] != -1) continue;
            ans[v.first] = (v.second + ans[idx]) % 2;
            q.push(v.first);
        }
    }
    rep(i, n) cout << ans[i] << endl;
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n;cin>>n;
    VL a(n),b(n),c(n);
    REP(i,n) cin>>a[i];
    REP(i,n) cin>>b[i];
    REP(i,n) cin>>c[i];
    SORT_ASC(a);
    SORT_ASC(b);
    SORT_ASC(c);

    VL bc(n);

    REP(i,n){
        auto itr = upper_bound(ALL(c),b[i]);
        bc[i] = c.end()-itr;
    }
    PER(i,n-1) bc[i] += bc[i+1];

    LL result = 0;
    REP(i,n){
        auto itr = upper_bound(ALL(b),a[i]);
        if(itr!=b.end()){
            result += bc[itr-b.begin()];
        }
    }

    std::cout<<result<<endl;

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	std::cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

int main() {
        int n , i , x , min;
       while(true){ cin >> n;
    if(n!=0){
        min = 10000000;
        vector<int> v(n,0);
        for(i = 0;i<n;i++){
            cin >> v.at(i);
        }
        for(int j = 0;j<n;j++){
            for(i = 0;i<n;i++){
                if(j!=i){
                    if(v.at(j)>=v.at(i)){
                x = v.at(j)-v.at(i);
                if(x<min) min = x;
            }}
           }   
        }
        cout << min << endl;
    }
else{break;}
  
}
}



Measured memory_bytes: 3100