akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

const int N = 2e3 + 10;

int n , x , y , ans[N];

int dis(int u , int v){
	return min(v - u , abs(x - u) + abs(y - v) + 1);
}

int main(){
	scanf("%d %d %d" , &n , &x , &y);
	for(int u = 1; u <= n; u++)
		for(int v = u + 1; v <= n; v++)
			ans[dis(u , v)]++;
	for(int i = 1; i < n; i++)
		printf("%d\n" , ans[i]);
	return 0;
} 

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

n = INT()
arr = []
for i in range(n):
    arr.append(INT())
b = Counter(arr)
c = list(set(arr))
ans = []
for i in c:
    if b[i] % 2:
        ans.append(i)
print(len(ans))

Measured memory_bytes: 85208
#include <stdio.h>

#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 2000000000

int n, m[N][N], color[N], d[N], p[N];

int prim(void);


int main() {
  int i, j, sum = 0;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      scanf("%d", &m[i][j]);
      if (m[i][j] == -1) m[i][j] = INF;
    }
  }

  sum = prim();

  printf("%d\n", sum);

  return 0;
}


int prim(void) {
  int i, j, u, v, minc, sum = 0;

  for (i = 0; i < n; i++) {
    d[i] = INF;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;
  
  while(1) {
    minc = INF;
    for (i = 0; i < n; i++) {
      if (color[i] != BLACK && d[i] < minc) {
	minc = d[i];
	u = i;
      }
    }
    
    if (minc == INF) break;

    color[u] = BLACK;

    for (v = 0; v < n; v++) {
      if (color[v] != BLACK && m[u][v] != INF) {
	if (d[v] > m[u][v]) {
	  d[v] = m[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  for (i = 0; i < n; i++) {
    if (p[i] != -1) sum += m[i][p[i]];
  }
  return sum;
}



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

int main() {
  int x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;

  vector<long long> p(a);
  vector<long long> q(b);
  vector<long long> r(c);
  rep(i,a)
    cin >> p.at(i);
  rep(i,b)
    cin >> q.at(i);
  rep(i,c)
    cin >> r.at(i);

  sort(p.begin(),p.end(),greater<long long>());
  sort(q.begin(),q.end(),greater<long long>());

  vector<long long> s(x+y+c);
  rep(i,x){
    s.at(i) = p.at(i);
  }
  rep(j,y){
    s.at(x+j) = q.at(j);
  }
  rep(k,c){
    s.at(x+y+k) = r.at(k);
  }
  
  sort(s.begin(),s.end(),greater<long long>());

  long long result = 0;    
  rep(i,x+y){
    result += s.at(i);
  }
  cout << result << endl;
  
}


Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
using namespace std;

int f(int d, vector<int> &s, int q)
{
	if( s.back()<=q){
		return min(q-s.back(),d-q);
	}

	int x=0;
	int y=s.size()-1;
	while(x<=y){
		int h= (x+y)/2;
		if(s[h]==q) return 0;
		if(s[h]<q){
			x=h+1;
		}else{
			y=h-1;
		}
	}
	int mind=d;
	for(int i=max(x-2,0);i<=min(x+2,d-1);i++){
		int dd = abs(q-s[i]);
		if(dd>d-dd) dd=d-dd;
		if(dd<mind) mind=dd;
	}
	return mind;
}	

int main() {
	int d,n,m,q;
	istream &sin=cin;
	ostream &sout=cout;
//	fstream sin("input.txt",fstream::in);
//	fstream sout("output.txt",fstream::out);

	while(true){
	sin >> d >> n >> m;
	if(d==0)break;
	
	vector<int> s(n);
	for(int i=1;i<n;i++){
		sin >> s[i];
	}
	sort(s.begin(),s.end());
	int ans=0;
	for(int i=0;i<m;i++){
		sin >> q;
		int mind = f(d,s,q);
/*		int mind=d;
		for(int j=0;j<n;j++){
			int dd = abs(s[j]-q);
			if(dd*2>d) dd=d-dd;
			if(dd<mind){
				mind=dd;
			}
		}
		sout << mind << endl;
*/		ans+=mind;
	}
	sout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1524
import sys
from collections import deque

sys.setrecursionlimit(10**7)

H, W = map(int, input().split())
s = []
black = 0

for i in range(H):
    line = list(input())
    s.append(line)
    black += line.count('#')

dirs = [(0, 1), (1, 0), (0, -1), (-1, 0)]

q = deque()
dq = deque()
q.append((0, 0))
dq.append(1)

visited = [(0, 0)]
while len(q) != 0:
    pos = q.popleft()
    if pos == (W - 1, H - 1):
        break
    d = dq.popleft()
    for dir in dirs:
        next = (pos[0] + dir[0], pos[1] + dir[1])
        if 0 <= next[0] <= W - 1 and 0 <= next[1] <= H - 1 and \
                next not in visited and s[next[1]][next[0]] == '.':
            q.append(next)
            dq.append(d + 1)
            visited.append(next)
else:
    print(-1)
    sys.exit()

min_d = dq.popleft()
print(H * W - black - min_d)


Measured memory_bytes: 41580
#include <stdio.h>


int main()
{
    int dice[6],dice2[6],box,flg=0,cnt=0,cnt2=0;
    for(int i=0;i<6;i++)    scanf("%d",&dice[i]);
    for(int i=0;i<6;i++)    scanf("%d",&dice2[i]);
    while(1)
    {
        if(dice[1]==dice2[1]||4 < cnt){
            cnt = 0;
            cnt2 += 1;
            box = dice[5];
            dice[5] = dice[2];
            dice[2] = dice[0];
            dice[0] = dice[3];
            dice[3] = box;
            if(dice[0]==dice2[0]&&dice[1]==dice2[1]&&dice[2]==dice2[2]&&dice[3]==dice2[3]&&dice[4]==dice2[4]&&dice[5]==dice2[5]){
                printf("Yes\n");
                break;
            }else if(4 < cnt2){
                printf("No\n");
                break;
            }
        }else {
            cnt += 1;
            box = dice[5];
            dice[5] = dice[1];
            dice[1] = dice[0];
            dice[0] = dice[4];
            dice[4] = box;
        }
    }
    return 0;
}


Measured memory_bytes: 2116
//2020年4月17日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }
template <class T, class... A>
void printd(const T &first, const A &... rest) { cout << fixed << setprecision(15) << first; prints_rest(rest...); }


namespace {
    // printElems(&a[0], &a[n]);　みたいな感じで使う。
    void printElems(const int* begin, const int* end)
    {
        for (const int* p = begin; p != end; ++p) {
            std::cout << *p << ' ';
        }
        std::cout << std::endl;
    }
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
const ll BIG = 1LL<<60;


vi e[100005];
int ans[100005];

int main(){
	int n,m;
	cin >> n >> m;
	rep(i,m){
		int a,b;
		cin >> a >> b;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	prints("Yes");

	queue<pii> q; //現在地　親
	q.push(mp(1,1));
	while(!q.empty()){
		pii tmp = q.front();
		q.pop();
		if(ans[tmp.F] != 0) continue;
		ans[tmp.F] = tmp.S;
		for(const auto& x : e[tmp.F]){
			if(ans[x]!=0) continue;
			q.push(mp(x,tmp.F));
		}
	}
	for(int i = 2; i < n+1; i++){
		prints(ans[i]);
	}


	return 0;
}



Measured memory_bytes: 10824
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	// your code goes here
	int n;
	cin>>n;
	
	int sum=0;
	
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			for(int k=1;k<=n;k++)
			{
				sum = sum + __gcd(i,__gcd(j,k));
			}
		}
	}
	
	cout<<sum;
	
	
	
	return 0;
}

Measured memory_bytes: 3636
#!/usr/bin/env python

import sys
from operator import itemgetter

n = int( sys.stdin.readline() )
tm = dict()
for _ in range(n):
    a,b = [ int(x) for x in sys.stdin.readline().split() ]
    tm[b] = tm.get(b,0) + a
#
s = 0
ans = 'Yes'
for b,a in sorted(tm.items(),key=itemgetter(0)):
    s += a
    if s>b:
        ans='No'
        break
#
print( ans )


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

int main(void){
    long long n,l1=2,l2=1;
    cin>>n;
    for(int i=1;i<n;i++){
        long long tmp = l2;
        l2 += l1;
        l1 = tmp;
    }
    cout<<l2<<endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#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>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int N, H, W;
    cin >> N;
    cin >> H;
    cin >> W;
    
    cout << (N-H+1) * (N-W+1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr first
#define se second
#define ll long long
#define pb push_back
using namespace std;
const ll N = 3e5 + 7;
long long n , m , a , cnt ;
vector< string >v;
string z ="O";
map<int,int>mp;
int main() {
    cin >> n >> m;
    ll arr[n];
    for( int i=  0;i < n;i ++ ){
        cin >> arr[i];
        cnt+=arr[i];
    }
    sort( arr , arr + n );
    reverse( arr  , arr + n );
    for( int i = 0;i < min(n,m);i ++ )
            cnt-=arr[i];
            cout << cnt;
}


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



using namespace std;



typedef long long LL;


int n,m,k,now,dq,d;
int f[5005][5005];


int main()

{
	scanf("%d%d%d",&n,&m,&d);
	//(x,y)->(x-y,x+y)
	now=1;
	for (int i=-m+m;i<=n+m;i+=d)
	{
		for (int j=0;j<=n+m;j+=d)
		{
			for (int p=i;p<i+d;++p)
				for (int q=j;q<j+d;++q)
					f[p][q]=now;
			now^=1;
		}
		now^=2;
	}
	for (int i=1;i<=n;++i){
		for (int j=1;j<=m;++j)
		{
			dq=f[i-j+m][i+j]+1;
			if (dq==1) cout<<"R";
			else if (dq==2) cout<<"Y";
			else if (dq==3) cout<<"G";
			else if (dq==4) cout<<"B";
		}
		cout<<endl;
	}

	return 0;

}

Measured memory_bytes: 40576
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn print_array<T: std::string::ToString>(array: &VecDeque<T>) {
    println!(
        "{}",
        array
            .iter()
            .map(|ref x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}

fn main() {
    let v = read_vec::<usize>();
    let (n, m) = (v[0], v[1]);
    let mut edges = vec![vec![]; n];
    for i in 0..m {
        let v = read_vec::<usize>();
        let (a, b) = (v[0] - 1, v[1] - 1);
        edges[a].push(b);
        edges[b].push(a);
    }

    let mut cur_pointer = 0;
    let mut used = HashSet::new();
    let mut answers = VecDeque::new();
    'outer: loop {
        used.insert(cur_pointer);
        answers.push_back(cur_pointer + 1);

        for &to in edges[cur_pointer].iter() {
            if !used.contains(&to) {
                cur_pointer = to;
                continue 'outer;
            }
        }
        break;
    }
    cur_pointer = 0;
    'outer2: loop {
        for &to in edges[cur_pointer].iter() {
            if !used.contains(&to) {
                cur_pointer = to;
                used.insert(cur_pointer);
                answers.push_front(cur_pointer + 1);
                continue 'outer2;
            }
        }
        break;
    }
    println!("{:?}", answers.len());
    print_array(&answers);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 19696
#include <math.h>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <set>
#include <unordered_map>
#include <vector>

using namespace std;

int main(void) {
  int N;
  cin >> N;
  char S[200];
  for (int i = 0; i < N; i++) cin >> S[i];
  int ans;
  for (int i = 1; i < N; i++) {
    set<char> A, B;
    for (int j = 0; j < N; j++) {
      if (j < i) {
        A.insert(S[j]);
      } else {
        B.insert(S[j]);
      }
    }
    vector<char> v;
    set_intersection(A.begin(), A.end(), B.begin(), B.end(), back_inserter(v));
    int p = v.size();
    if (p > ans) ans = p;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<random>
#include<map>
#include<queue>
using namespace std;

int main(){

  int n, r;
  while(cin >> n >> r){
    if( n == 0 && r == 0 ) break;
    vector<int> p(r);
    vector<int> c(r);
    for(int i=0; i<r; i++) cin >> p[i] >> c[i];

    vector<int> d(n);
    for(int i=0; i<n; i++) d[i] = n-i;

    for(int i=0; i<r; i++){
      vector<int> tmp;
      for(int j=0; j<c[i]; j++){
        tmp.push_back( d[ p[i]-1+j ] );
        d[ p[i]-1+j ] = -1;
      }
      for(int j=0; j<n; j++){
        if( d[j] == -1 ) continue;
        tmp.push_back( d[j] );
      }
      d = tmp;
      // for(int j=0; j<n; j++) cerr << d[j] << " ";
      // cerr << endl;
    }
    cout << d[0] << endl;
  }

  return 0;
}

Measured memory_bytes: 3076
import Data.List
main=do
 [x,y,a,b,c]<-map read.words<$>getLine
 p<-sort.map read.words<$>getLine
 q<-sort.map read.words<$>getLine
 r<-map read.words<$>getLine
 print$sum$drop c$sort$(drop(a-x)p)++(drop(b-y)q)++r

Measured memory_bytes: 175788
import java.util.Scanner;

public class Main {

	static long bignum = 1000000000+7;

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long k = sc.nextLong();



		if(a>=k) {
			System.out.println(k);
		}else {
			if(a+b>=k) {
				System.out.println(a);
			}else {
				System.out.println(a-(k-a-b));
			}
		}


	}

	static long divn(int target, int times) {//10_9+7のあまり累乗版
		int sqtimes = (int)Math.sqrt(times);
		long ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		long holder = ans;
		ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans*holder)%(1000000000+7);
		}
		for(int i=0;i<times - sqtimes*sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		return ans;
	}

	static long div(long a) {//10_9+7のあまり
		if(a<0)a+=1000000000+7;
		return a%(1000000000+7);
	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 35780
fun main(args: Array<String>){
  val n = readInt()
  val s =readString()
  if (s.length %2 == 1) {
    println("No")
  } else {
    val s1 = s.substring(0, s.length / 2)
    val s2 = s.substring(s.length / 2)
    println(if (s1 == s2) "Yes" else "No")
  }
}

fun readString() = readLine()!!
fun readStrings() = readString().split(' ')
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }



Measured memory_bytes: 29768
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main() {
	double s,l;
	while (~fscanf(stdin, "%lf%lf", &s, &l)) {
		if (s < 35.5&&l < 71.0) puts("AAA");
		else if (s < 37.5&& l < 77.0) puts("AA");
		else if (s < 40.0&& l < 83.0) puts("A");
		else if (s < 43.0&& l < 89.0) puts("B");
		else if (s < 50.0&& l < 105.0) puts("C");
		else if (s < 55.0&& l < 116.0) puts("D");
		else if (s < 70.0&& l < 148.0) puts("E");
		else puts("NA");
	}
	return 0;
}

Measured memory_bytes: 612
#include <iostream>
using namespace std;
int main(void){
    int m,f,b;
    cin >> m >> f >> b;
    
    if( (m + f) < b ){
        cout << "NA";
    }
    else if( m >= b ){
        cout << 0;
    }
    else if( m < b ){
        cout << b - m;
    }
    
    cout << endl;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end(),greater<ll>())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define db(x) cout<<#x<<"="<<x<<endl
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
#define EPS 1e(-9);
using namespace std;
typedef long long ll;

void Main(){

  int X,Y,Z,K; cin>>X>>Y>>Z>>K;

  vector<ll> a,b,c,ab,abc;
  rep(i,X){
    ll aa; cin>>aa;
    a.emplace_back(aa);
  }
  rep(i,Y){
    ll aa; cin>>aa;
    b.emplace_back(aa);
  }
  rep(i,Z){
    ll aa; cin>>aa;
    c.emplace_back(aa);
  }

  SORT(a);
  SORT(b);
  SORT(c);

  int ka=min(K,X);
  int kb=min(K,Y);

  rep(i,ka){
    rep(j,kb){
      ab.emplace_back(a[i]+b[j]);
    }
  }

  SORT(ab);

  int kab=min(K,X*Y);
  int kc=min(K,Z);

  rep(i,kab){
    rep(j,kc){
      abc.emplace_back(ab[i]+c[j]);
    }
  }

  SORT(abc);

  rep(i,K){
    cout<< abc[i]<<"\n";
  }

}

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


Measured memory_bytes: 43384
#include<iostream>
#include<algorithm>
#include<vector>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
int main(){
    int k;
    cin >> k;
    int l;
    if(k%7==0){
        l = 9*k/7;
    }else{
        l = 9*k;
    }
    int i;
    int r=10%l;
    if(r==1){
        cout << 1 << endl;
    }else{
        for(i=2;i<=l;i++){
            r = (r*10)%l;
            if(r==1){
                cout << i << endl;
                break;
            }
        }
    }
    if(i==l+1 && r!=1)
        cout << -1 << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >> n;
  map<string,int> s;
  int count_m=0;
  rep(i,n) {
    string x;
    cin >> x;
    s[x]++;
    if(count_m<s[x]){
      count_m=s[x];
    }
  }
  for(auto itr = s.begin(); itr != s.end(); itr++) {
    if(itr->second==count_m){
      cout << itr->first<< endl;;
      }
    }
  return 0;
}

Measured memory_bytes: 25216
n = int(input())
s = list(input())
left_w = 0
right_e = s[1:].count("E")
ans = right_e
for i in range(1,n):
    if s[i-1] == "W":
        left_w += 1
    if s[i] == "E":
        right_e -= 1
    ans = min(ans,right_e +left_w)
print(ans)
    

Measured memory_bytes: 8268
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd,numbers)

n =int(input())
c=0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            c+=gcd(i,j,k)
print(c)

Measured memory_bytes: 74948
#include<iostream>
#include<vector>
#include<unordered_map>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    vector<int>v1(26,0),v2(26,0);
    for(int i=0;i<s.size();i++)
    {
        v1[s[i]-'a']++;
    }
    unordered_map<int,int>ump1,ump2;
    for(int i=0;i<t.size();i++)
    {
        v2[t[i]-'a']++;
    }
    for(int i=0;i<26;i++)
    {
        ump1[v1[i]]++;
    }
    for(int i=0;i<26;i++)
    {
        ump2[v2[i]]++;
    }
    bool no=false;
    for(auto it=ump1.begin();it!=ump1.end();it++){
        if(ump2[it->first]!=it->second){
            no=true;
            break;
        }
    }
    if(no){
        cout<<"No\n";
    }
    else{
        cout<<"Yes\n";
    }   
}

Measured memory_bytes: 3924
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007


int main() {
	int n;
	scanf("%d", &n);
	VI a(n);
	REP(i, n)scanf("%d", &a[i]);
	int cnt = 0;
	REP(i, n) if (a[i] < 0)cnt++;
	cnt = cnt % 2;
	REP(i, n)a[i] = abs(a[i]);
	SORT(a);
	LL ret = (cnt==1)?-a[0]:a[0];
	FOR(i, 1, n)ret += a[i];
	cout << ret << endl;
	
	return 0;
}

Measured memory_bytes: 640
#pragma G++ optimize (2)
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <queue>
#define INF 0x3f3f3f3f
#define NO 200005
#define MO 100005
typedef long long ll;
using namespace std;
inline ll read()
{
	char ch = ' ', last;
	ll ans = 0;
	while (ch < '0' || ch > '9')
		last = ch, ch = getchar();
	while (ch >= '0' && ch <= '9')
		ans = ans * 10 + int(ch - '0'), ch = getchar();
	if (last == '-')
		return -ans;
	return ans;
}
void write(ll x)
{
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
//head

int pre[NO], suf[NO], n, a[NO], ans;
//variable

int gcd(int x, int y)
{
	if (!x)
		return y;
	return gcd(y % x, x);
}
void init()
{
	n = read();
	for (int i = 1; i <= n; i++)
		a[i] = read();
	int now = a[1];
	for (int i = 1; i <= n; i++)
		now = pre[i] = gcd(a[i], now);//, cout << pre[i] << ' ';
	now = a[n];
	for (int i = n; i >= 1; i--)
		now = suf[i] = gcd(a[i], now);//, cout << suf[i] << ' ';
}
//functions

int main()
{
	init();
	ans = max(pre[n - 1], suf[2]);
	for (int i = 2; i < n; i++)
		ans = max(ans, gcd(pre[i - 1], suf[i + 1]));
	cout << ans << endl;
	return 0;
}
//main

Measured memory_bytes: 1408
#include <stdio.h>
#define swap(a,b) {a^=b;b^=a;a^=b;}
#define M 10
#define TOP 3

int main(){

  int mt[M], i, j;

  // input 10 Mt.
  for(i = 0; i < M; i++) scanf("%d", &mt[i]);

  // bubble sort
  for(i = 0 ; i < M-1 ; i++)
    for(j = M-1 ; j>i ; j--) 
      if(mt[j] > mt[j-1])
	swap(mt[j], mt[j-1]);

  // output top 3 Mt.
  for(i = 0; i < TOP; i++) printf("%d\n", mt[i]);

  return 0;
}

Measured memory_bytes: 600
H,W=map(int,input().split())
s=[list(input()) for i in range(H)]

for i in range(H):
  for j in range(W):
    if s[i][j]=="#":
      if i>0 and s[i-1][j]=="#":
        continue
      elif i<H-1 and s[i+1][j]=="#":
        continue
      elif j>0 and s[i][j-1]=="#":
        continue
      elif j<W-1 and s[i][j+1]=="#":
        continue
      else:
        print("No")
        exit(0)
print("Yes")
      

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iterator>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(v) begin(v), end(v)
#define rreps(i, a, n) for (ll i = (a); i <= (ll)(n); ++i)
#define rrep(i, n) rreps(i, 0, n)
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define each(i, n) for (auto&& i : n)
#define fill(x, y) memset(x,y,sizeof(x))
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
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 T> inline void print(const T& x) {cout << x << '\n';}

signed main()
{ 
  int a,b,c; cin>>a>>b>>c;
  ull k; cin>>k;
  if(k==0) print(a-b);
  else if(k%2==1) print(b-a);
  else print(a-b);

  return 0;
}

Measured memory_bytes: 256
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long


const int D = 80 * 160 + 10;
const int D2 = 2 * D;
typedef bitset<D2> bs;
int H,W;
int A[90][90];
bs dp[90][90];
//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> H >> W;
  for(int i = 0 ; i < H ; i++){
  	for(int j = 0 ; j < W ; j++){
  		cin >> A[i][j];
  	}
  }

  for(int i = 0 ; i < H ; i++){
  	for(int j = 0 ; j < W ; j++){
  		int b;
  		cin >> b;
  		A[i][j] = abs(A[i][j] - b);
  	}
  }

  dp[0][0][D - A[0][0]] = 1;
  dp[0][0][D + A[0][0]] = 1;
  for(int h = 0 ; h < H ; h++){
  	for(int w = 0 ; w < W ; w++){
  		if(h){
			dp[h][w] |= dp[h - 1][w] << A[h][w];
			dp[h][w] |= dp[h - 1][w] >> A[h][w];
  		}
  		if(w){
			dp[h][w] |= dp[h][w - 1] << A[h][w];
			dp[h][w] |= dp[h][w - 1] >> A[h][w];
  		}
  	}
  }

  int ans = D2;
  for(int i = 0 ; i < D2; i++){
  	if(dp[H - 1][W - 1][i]){
  		ans = min(ans,abs(i - D));
  	}
  }
  cout << ans << endl;
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 24704
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
using namespace  std;

const int N = 1e6+5;
int vis[N];
vector<int> prime;
void getprime(){
    rep(i,2,N-5){
        if(!vis[i]){
            prime.push_back(i);
        }
        for(int p:prime){
            ll v= (ll)i*p;
            if(v>N-5) break;
            vis[v] = 1;
            if(i%p==0) break;
        }
    }
}
int main(){
    ios::sync_with_stdio(0);
    ll n;cin>>n;
    //getprime();
    ll sq = sqrt(n+0.5);
    //cout<<sq<<'\n';
    for(ll i = sq;i>=1;--i){
        if(n%i==0){
            cout<<i-1+(n/i)-1;break;
        }
    }
    
}

Measured memory_bytes: 3708
// AOJ 2013: Osaki
// 2017.11.1 bal4u@uu

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

int tbl[86400];  // 24*60*60 

char buf[30], *p;
int getint2()
{
	int n;
	n = *p++ & 0xf;
	n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, i, h, m, s, t, ans, min, max;

	while (fgets(buf, 10, stdin) && *buf != '0') {
		memset(tbl, 0, sizeof(tbl));
		n = atoi(buf);
		min = 86400, max = 0;
		while (n--) {
			fgets(p=buf, 30, stdin);
			h = getint2(), p++, m = getint2(), p++, s = getint2(), p++;
			t = ((h*60)+m)*60+s, tbl[t]++;
			if (t < min) min = t;

			h = getint2(), p++, m = getint2(), p++, s = getint2();
			t = ((h*60)+m)*60+s, tbl[t]--;
			if (t > max) max = t;
		}
		if (!min) min++;
		for (ans = 0, i = min; i < max; i++) {
			tbl[i] += tbl[i-1];
			if (tbl[i] > ans) ans = tbl[i];
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

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

    REP(i, pow(2, 3)) {
        ll sum = S[0] - '0';
        REP(j, 3) {
            ll m = S[j + 1] - '0';
            if ((i >> j) & 1)
                sum += m;
            else
                sum -= m;
        }
        if (sum != 7)
            continue;

        string s = "";
        s.push_back(S[0]);
        REP(j, 3) {
            if ((i >> j) & 1)
                s.push_back('+');
            else
                s.push_back('-');
            s.push_back(S[j + 1]);
        }

        s += "=7";
        cout << s << endl;
        break;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	char[] s1;//原文1
	char[] s2;//原文2
	int index;//今なん文字目か
	int[] table;//PQRの値
	public static void main(String[] args) {
		new Main().run();
	}
	void run(){
		Scanner sc=new Scanner(System.in);
		while(true){
			String str[]=sc.nextLine().split("=");
			if(str[0].equals("#")) break;
			//なぜこの番兵みたいな$を先輩はつけたのか？
			//必要性を考えたい。これがないとダメな場合がある？
			//s=(str+"$").toCharArray();
			s1=str[0].toCharArray();
			s2=str[1].toCharArray();
			table=new int[11];
			//int ans=0;
			boolean flag=true;
			equation :
				for(int a=0; a<2; a++){
					table[0]=a;
					for(int b=0; b<2; b++){
						table[1]=b;
						for(int c=0; c<2; c++){
							table[2]=c;
							for(int d=0; d<2; d++){
								table[3]=d;
								for(int e=0; e<2; e++){
									table[4]=e;
									for(int f=0; f<2; f++){
										table[5]=f;
										for(int g=0; g<2; g++){
											table[6]=g;
											for(int h=0; h<2; h++){
												table[7]=h;
												for(int i=0; i<2; i++){
													table[8]=i;
													for(int j=0; j<2; j++){
														table[9]=j;
														for(int k=0; k<2; k++){
															table[10]=k;
															index=0;
															int ans1=formura(s1);
															index=0;
															int ans2=formura(s2);
															if(ans1 != ans2){
																//not equation
																flag=false;
																break equation;
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			if(flag) System.out.println("YES");
			else System.out.println("NO");
		}
	}
	int formura(char s[]){
		char c=c(s);
		
		if(c=='('){
			int a = formura(s);
			char c2 = c(s);
			if(c2 == '*'){
				int b = formura(s);
				c(s);
				return Math.min(a, b);
			}
			else if(c2 == '+'){
				int b = formura(s);
				c(s);
				return Math.max(a, b);
			}
			else{
				c(s);
				int b = formura(s);
				c(s);
				if(a==1 && b==0){
					return 0;
				}
				return 1;
			}
		}
		else if(c=='-'){
			int r=formura(s);
			if(r==0){
				return 1;
			}
			else if(r==1){
				return 0;
			}
		}
		else if(c=='T'){
			return 1;
		}
		else if(c=='F'){
			return 0;
		}
		else{
			return table[c-'a'];
		}
		
		return -1;
	}

	char c(char s[]){
		return s[index++];
	}
}

Measured memory_bytes: 39356
x, n = map(int, input().split())
p = [int(_) for _ in input().split()]

not_in_p = [i for i in range(0, 102) if i not in p]
nip_temp = list(map(lambda s: abs(x - s), not_in_p))

address = nip_temp.index(min(nip_temp))
print(not_in_p[address])


Measured memory_bytes: 9180
from itertools import permutations

N=int(input())

P=list(map(str,input().split()))
Q=list(map(str,input().split()))

Ps="".join(P)

Qs="".join(Q)

li=[str(i) for i in range(1,N+1)]

Per=list(permutations(li,N))
idxP=0
idxQ=0
for idx,x in enumerate(Per):
    temp="".join(x)
    if Ps==temp:
        idxP=idx+1
    if Qs==temp:
        idxQ=idx+1
    if  (idxP!=0 and idxQ!=0):
        break

print(abs(idxP-idxQ))



Measured memory_bytes: 8052
Scanf.(Array.(scanf " %d %d" @@ fun n m ->
  let a = make m 0 in
  init n (fun _ -> scanf " %d" @@ fun v ->
    init v (fun _ -> scanf " %d" @@ fun w ->
      a.(w-1) <- a.(w-1) + 1));
  print_int @@ fold_left (fun sum v -> if v=n then sum+1 else sum) 0 a))

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int num[3];
	cin>>num[0]>>num[1]>>num[2];
	sort(num,num+3);
	int k=0;
	k=num[2]-num[1];
	num[1]=num[2];
	num[0]+=k;
	int f=num[2]-num[0];
	if(f%2==1){
		num[2]++;
		num[1]++;
		f=num[2]-num[0];
		k=k+1+f/2;
	}
	else
		k+=f/2;
	cout<<k;
	return 0; 
}

Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K = ii()
    e = K // 2
    o = (K + 1) // 2
    print(e * o)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9944
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,D;
  cin>>N>>D;
  
  vector<vector<int>> X(N,vector<int>(D));
  for(int i=0;i<N;i++){
  for(int j=0;j<D;j++){
   cin>>X.at(i).at(j);
    }
  }
  int ans=0;
  for(int i=0;i<N-1;i++){
  for(int j=i+1;j<N;j++){
  int sum=0;
    for(int k=0;k<D;k++)
      sum+=pow(X.at(i).at(k)-X.at(j).at(k),2);
    
    for(int l=0;l*l<=sum;l++){
     if(l*l==sum)
       ans++;
    }
  
  
  
  
  
  }
  
  
  }cout<<ans<<endl;
  
  
  
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author noob_coder
 */
public class Main {
        public static void main(String[] args) {
                InputStream inputStream = System.in;
                OutputStream outputStream = System.out;
                InputReader in = new InputReader(inputStream);
                PrintWriter out = new PrintWriter(outputStream);
                TaskA solver = new TaskA();
                solver.solve(1, in, out);
                out.close();
        }

        static class TaskA {
                public void solve(int testNumber, InputReader in, PrintWriter out) {
                        int a = in.i();
                        int b = in.i();
                        int c = in.i();
                        if (a + b >= c) out.println("Yes");
                        else out.println("No");
                }

        }

        static class InputReader {
                InputStream is;
                private byte[] inbuf = new byte[1024];
                public int lenbuf = 0;
                public int ptrbuf = 0;

                public InputReader(InputStream is) {
                        this.is = is;
                }

                private int readByte() {
                        if (lenbuf == -1) throw new InputMismatchException();
                        if (ptrbuf >= lenbuf) {
                                ptrbuf = 0;
                                try {
                                        lenbuf = is.read(inbuf);
                                } catch (IOException e) {
                                        throw new InputMismatchException();
                                }
                                if (lenbuf <= 0) return -1;
                        }
                        return inbuf[ptrbuf++];
                }

                public int i() {
                        int num = 0, b;
                        boolean minus = false;
                        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
                        if (b == '-') {
                                minus = true;
                                b = readByte();
                        }

                        while (true) {
                                if (b >= '0' && b <= '9') {
                                        num = num * 10 + (b - '0');
                                } else {
                                        return minus ? -num : num;
                                }
                                b = readByte();
                        }
                }

        }
}



Measured memory_bytes: 23380
#include <unordered_set>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <tuple>
#include <functional>
#include <set>
 
int N;
long long H;
long long a[100010];
long long b[100010];
long long c[100010];
 
void run() {
	std::cin >> N;
	std::cin >> H;
	for (int i = 0; i < N; ++i) {
		std::cin >> a[i] >> b[i];
		c[i] = std::max(a[i], b[i]) << 32 | a[i];
	}
	std::sort(c, c + N);
	long long d = 0;
	long long ans = 1LL << 60;
	for (int i = N - 1; i >= 0; --i) {
		H -= c[i] >> 32;
		d = std::max((long long)(int)c[i], d);
		ans = std::min(ans, N - i + (H > 0 ? (H + d - 1) / d : 0));
	}
	std::cout << ans << std::endl;
}
int main() {
	run();
	return 0;
}

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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  

int ans, k, cnt=0;
void f(vector<int>& curr, int index=0, int last_used=0, bool leading_zero = true)
{
    if(ans) return;
    if(index == 61)
    {
        cnt++;
        if(cnt == k+1)
        {
            for(int i=0;i<61;i++)
            {
                ans = ans*10 + curr[i];
            }
        }
        return;
    }
    int start = last_used -1;
    if(start < 0) start = 0;
    int end = min(last_used + 1, 9LL);
    int z = 0;
    if(leading_zero) end = 9;
    for(int i=start;i<=end;i++)
    {
        curr[index] = i;
        if(i) leading_zero = false;
        f(curr, index+1, i, leading_zero);
        //z += dp[index+1][i];
    }
   // dp[index+1][i] = z; 
}


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    cin >> k;
    vector<int> curr(61, 0);
    f(curr);
    cout << ans << "\n";
    return 0;
}



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

a = -1   # 10000
b = -1   # 5000
c = -1   # 1000

for i in range(n + 1):
    for j in range(n + 1 - i):
        k = n - i - j
        if y == 10000 * i + 5000 * j + 1000 * k:
            a = i
            b = j
            c = k

print("{} {} {}".format(a, b, c))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mod 1e9+7
#define cr7 ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long ll;
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
  
// Function to find gcd of array of 
// numbers 
int findGCD(int arr[], int n) 
{ 
    int result = arr[0]; 
    for (int i = 1; i < n; i++) 
        result = gcd(arr[i], result); 
  
    return result; 
} 
int main(){
	cr7
    int n;cin >> n;
    int sum=0;
    for(int i=1;i<=n;i++){
    	for(int j=1;j<=n;j++){
    		for(int k=1;k<=n;k++){
    			int arr[3];
    			arr[0]=i,arr[1]=j,arr[2]=k;
				sum+=findGCD(arr,3);
			}
		}
	}
	cout<<sum<<"\n";
    return 0;
}

Measured memory_bytes: 3640
// Mahesh Sharma
// Beauty is in the struggle!
#include<bits/stdc++.h>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <memory.h>
#include <cassert>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define ford(i, a, b, c)        for(int i=(a); i<(b); i+=(c))
#define fori(i, a, b)           ford(i,a,b,1)
#define rep(i, n)               fori(i,0,n)
#define ifor(i, a, b)           for(int i=(a); i>=(b); i--)
#define si(x)                   ((int)x.size())
#define SS                      ({int x;scanf("%d",&x);x;})
#define pb                      push_back
#define mp                      make_pair
#define all(a)                  a.begin(),a.end()
#define inf                     (int)1e9
#define linf                    (long long)1e18
#define V                       vector
#define S                       string
#define XX                      first
#define YY                      second
#define PVI(v)                  rep(i, si(v)) cout<<v[i]<<" "; puts("")
#define PPI(p)                  cout<<"("<<p.first<<", "<<p.second<<")\n"
#define PVPI(v)                 rep(i, si(v)) cout<<"("<<v[i].first<<", "<<v[i].second<<")"<<(i==si(v)-1?"":", ");puts("")
#define PA(arr1, arr2)          for(auto it = arr1; it != arr2; it++) cout<<*it<<" "; puts("");

typedef V<int> vi;
typedef V<S> vs;
typedef long long ll;
typedef pair<int,int> pii;
const int MOD7 = 1000000000+7;
const int MOD9 = 1000000000+9;
/* ################### Program Body starts here ################ */


int main() {
       int h = SS, a = SS;
        cout<<(h+a-1)/a<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <deque>
using namespace std;
#define MAXA 1001
#define MAXB 1001
#define MAXH 1000000001
#define MAXW 301
#define INF (1LL << 50)
#define MAXN 100001
#define MAXM 100001
#define MAXK 100002
#define MAXV 100001
#define MAXP 1000001
#define MOD 1000000007
#define EPS (1e-10)
typedef long long ll;

int N;
int a[MAXN];

bool check(int i, map<int, int> m){
    int b[MAXN];
    if(m[i] == 0) return false;
    m[i]--;
    b[0] = i;
    for(int i = 1;i < N;i++){
        if(b[i - 1] == 0){
            if(m[2] == 0) return false;
            m[2]--;
            b[i] = 2;
        }else if(b[i - 1] == 1){
            if(m[1] == 0){
                if(m[2] == 0) return false;
                m[2]--;
                b[i] = 2;
            }else{
                m[1]--;
                b[i] = 1;
            }
        }else{
            if(m[0] == 0){
                if(m[1] == 0){
                    if(m[2] == 0) return false;
                }else{
                    m[1]--;
                    b[i] = 1;
                }
            }else{
                m[0]--;
                b[i] = 0;
            }
        }
    }

    return true;
}

int main(){
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> a[i];
    }
    map<int, int> m;
    for(int i = 0;i < N;i++){
        if(a[i] % 2) m[0]++;
        else{
            if(a[i] % 4) m[1]++;
            else m[2]++;
        }
    }
    for(int i = 0;i < 3;i++){
        if(m.find(i) == m.end()){
            m[i] = 0;
        }
    }
    if(check(0, m) ){
        printf("Yes\n");
    }else if(check(1, m) || check(2, m)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 1024