akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <string.h>
#include <stdlib.h>

using namespace std;
// vector push_back push front top empty pop make_pair long long insert begin end  
typedef long long ll;
typedef vector<int> vi;
typedef vector<pair <int,int> > vpi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define B begin()
#define RB rbegin()
#define E end()
#define RE rend()
#define Z size()
#define REP(i,a,b) for (int i = a; i < b; i++)
#define L length()
#define show(a) cerr << " *** " << a << endl;
#define show1(a) cerr << " /// " << a << endl;
#define valid(a,b,c) (a >= b && a < c ? 1 : 0)
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int mod = (int)1e9 + 7;
void ads(ll &a, ll b){a += b;if (a >= mod)a -= mod;}
void mis(ll &a, ll b){a -= b;if (a >= mod)a -= mod; if (a < 0)a += mod;}
ll gcd(ll a, ll b) {return (b==0? a:gcd(b,a%b));}
ll egcd(ll a, ll b, ll & x, ll & y) {if (a == 0){x = 0;y = 1;return b;}ll x1, y1;ll d = egcd(b % a, a, x1, y1);x = y1 - (b / a) * x1;y = x1;return d;}
ll mbinp(ll a, ll b){a %= mod;if (b == 0)return 1;ll ans = mbinp(a, b/2);ll tmp = (ans * ans) % mod;if (b % 2)return ((tmp * a) % mod);return ((tmp) % mod);}
ll binp(ll a, ll b){if (b == 0)return 1;ll ans = binp(a, b/2);ll tmp = (ans * ans);if (b % 2)return ((tmp * a));return ((tmp));}
int n;

vector <vll> id;

vector <vll> mult(vector <vll> a, vector <vll> b)
{
	vector <vll> out(n,vll(n,0));
	REP(i,0,n)
	{
		REP(j,0,n)
		{
			REP(x,0,n)
			{
				out[i][j] += (a[i][x] * b[x][j])%mod;
				out[i][j] %= mod;
			}
		}
	}
	return out;
}

vector <vll> bb(vector <vll>a, ll k)
{
	if (k == 0)
		return id;
	vector <vll> res = bb(a, k/2);
	if (k&1)
		return (mult(mult(res,res),a));
	return (mult(res,res));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll k;
	cin >> n >> k;
	id.resize(n);
	REP(i,0,n)
		REP(j,0,n)
		{
			if (i == j)
				id[i].PB(1);
			else
				id[i].PB(0);
		}
	ll out = 0;
	vector <vll> inp(n);
	REP(i,0,n)
	{
		REP(j,0,n)
		{
			int x;cin >>x;inp[i].PB(x);
		}
	}
	vector <vll> res = bb(inp,k);
	REP(i,0,n)
	{
		REP(j,0,n)
			ads(out,res[i][j]);
	}
	cout << out;
}


Measured memory_bytes: 1792
#include<stdio.h>

int getRightIndex( int top, int front )
{
	int right=0;
	int i;
    int label[][5]={{ 5, 3, 2, 4, 5 },
						    { 1, 3, 6, 4, 1 },
						    { 1, 5, 6, 2, 1 },
						    { 1, 2, 6, 5, 1 },
						    { 1, 4, 6, 3, 1 },
						    { 2, 3, 5, 4, 2 }};

	for( i=0; i<4; i++ ) {
		if( top == (label[front][i]-1) ) {
			right=label[front][i+1];
			break;
		}
	}
	right--;
	return right;
}

int main( void ) 
{
	int dice[7];
	int i,j;
    int q;    
    int front,top;
	

	for( i=0; i<6; i++ ) {
    	scanf( "%d", &dice[i] );
    }
    scanf( "%d", &q );

	for( i=0; i<q; i++ ) {
    	scanf( "%d%d", &top, &front );
    	
    	for( j=0; j<6; j++ ) {
    		if( dice[j] == top ) {
    			top = j;
    		}
     		if( dice[j] == front ) {
    			front = j;
    		}
    	}
    	printf( "%d\n", dice[ getRightIndex( top, front )] );
    }
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a,b;
	cin>>a>>b;
	if(b==1){
		cout<<0<<endl;
	}else{
		cout<<a-b<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public int calcGCD(int a_in, int b_in) {
		int a, b;
		if (a_in == b_in) { return a_in;
		} else if (a_in < b_in) { a = b_in; b = a_in;
		} else { a = a_in; b = b_in; }

		int r = a % b;
		if (r == 0) { return b;
		} else { return calcGCD(b, r); }
	}

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

		while (sc.hasNext()) {
			int a = sc.nextInt(), b = sc.nextInt();
			int gcd = m.calcGCD(a, b);
			System.out.println(gcd+" "+(a/gcd*b));
		}

	}
}

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

using namespace std;

inline long long read(){
   long long w=1,s=0;
   char ch=getchar();
   while(ch<'0'||ch>'9') {if (ch=='-') w=-1;ch=getchar();} 
   while(ch>='0'&&ch<='9')  s=s*10+ch-'0',ch=getchar();
   return s*w;
}


int main(){
    int n=read();
    if (n%2==1) cout<<((n-1)/2+1)*(n-1)/2;
    else cout<<n*n/4;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
int gcd(int a,int b){return b?gcd(b,a%b):a;}    //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

int main(){
    int a,b,c,x;
    int count = 0;
    cin >> a >> b >> c >> x;
    rep(i,a+1){
        rep(j,b+1){
            rep(k,c+1){
                if(500*i+j*100+k*50==x){
                    count++;
                }
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll
#define endl '\n'

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 998244353;

ll modpow(ll x, ll y){
    ll r = 1, a = x % MOD;
    while(y > 0){
        if((y&1) == 1) r = (r*a) % MOD;
        a = (a*a) % MOD;
        y /= 2;
    }
    return r;
}
int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    while(cin >> n){
        int x;
        cin >> x;
        map<int, ll> mp, c;
        REP(i, n - 1) {
            int y;
            cin >> y;
            c[y] ++;
        }
        if (x != 0 || c[0] != 0) {
            cout << 0 << endl;
        } else {
            c[0] = 1;
            mp[0] = 1;
            for(auto it : c) {
                int x = it.first;
                if (x != 0) {
                    mp[x] = mp[x - 1] * modpow(c[x - 1], c[x]) % MOD;
                }
            }
            cout << mp.rbegin()->second << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 12800
n = int(input())
A = []
B = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()
if n%2 == 0:
    x = A[n//2-1]+A[n//2]
    y = B[n//2-1]+B[n//2]
    ans = y-x+1
else:
    x = A[n//2]
    y = B[n//2]
    ans = y-x+1
print(ans)


Measured memory_bytes: 104476
n = int(input())
D = {}
cnt = 0
for _ in range(n):
    a = int(input())
    if a not in D:
        D[a] = 1
    else:
        D[a] += 1
for i in D:
    if D[i] % 2 != 0:
        cnt += 1
print(cnt)


Measured memory_bytes: 15076
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int cnt = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				for (int k = 1; k <= n; k++) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 23892
#include <string>
#include <iostream>
using namespace std;
int main()
{
  string s;
  cin >> s;
  int now = 1;
  for (auto c : s)
  {
    if (now && c == 'L') {puts("No"); return 0;}
    if (!now && c == 'R') {puts("No"); return 0;}
    now = now ^ 1;
  }
  puts("Yes");
  return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }
    map<int, int> mp;
    rep(i, n) mp[a[i]]++;
    int cnt = 0;
    for (auto p : mp) {
        if (p.second == 1) ++cnt;
    }
    if (cnt == 0) {
        cout << 0 << endl;
        return 0;
    }
    for (auto p : mp) {
        if (p.second == 0) continue;
        int s = p.first;
        for (int i=2; i*s<=1000000; ++i) {
            if (mp[i*s] == 1) mp[i*s] = 0;
        }
    }
    int cnt2 = 0;
    for (auto p : mp) {
        if (p.second == 1) ++cnt2;
    }
    cout << cnt2 << endl;
    return 0;
}


Measured memory_bytes: 50992
import * as fs from 'fs';

const input = fs.readFileSync("/dev/stdin", "utf8").split("\n");
const s = input[0] as string;
const t = input[1] as string;
var l = t.length;
for (var i = 0; i <= s.length - t.length; i++) {
    var l0 = 0;
    for (var j = 0; j < t.length; j++) {
        if (s[i + j] != t[j]) {
            l0++;
            if (l < l0) break;
        }
    }
    if (l0 < l) l = l0;
    if (l == 0) break;
}
console.log(l);


Measured memory_bytes: 32264
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
long long num,sol=0;


int main(){

cin>>num;
vector<pair<long long,long long> > vett(num);
for(long long i=0;i<num;i++){
	cin>>vett[i].first;
	vett[i].second=i;
}
vector<pair<long long,long long> > temp=vett;
sort(temp.begin(),temp.end());

for(long long i=0;i<num;i++){
	if(i%2!=temp[i].second%2){
		sol++;
	}
}

cout<<sol/2<<endl;
return 0;
}

Measured memory_bytes: 3328
let () = 
	let s = Array.make 13 false in
	let h = Array.make 13 false in
	let c = Array.make 13 false in
	let d = Array.make 13 false in
	let n = read_int () in
	for i = 1 to n do 
		let (a, j) = Scanf.scanf "%c %d\n" (fun x y -> (x, y - 1)) in
		match a with
			| 'S' -> s.(j) <- true
		    | 'H' -> h.(j) <- true
		    | 'C' -> c.(j) <- true
		    | 'D' -> d.(j) <- true
	        | _   -> ()
	done;
	let f c = 
		Array.iteri (fun i v -> if not v then Printf.printf "%c %d\n" c (i + 1) else ()); in
	f 'S' s;
	f 'H' h;
	f 'C' c;
	f 'D' d;
;;


Measured memory_bytes: 2408
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
a_list = list(map(int, input().split()))
sum_a = sum(a_list)
count = 0

for a in a_list:
    if a < sum_a / (4 * m):
        continue
    else:
        count += 1

if count >= m:
    print("Yes")
else:
    print("No")


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

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

    if (a <= 0 && b >= 0) {
        puts("Zero");
        return 0;
    }

    if (a > 0) {
        puts("Positive");
        return 0;
    }

    ll cnt = b - a + 1;
    if (cnt & 1) {
        puts("Negative");
    } else {
        puts("Positive");
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> vec;
    vector<int> c_vec;
    rep(i,n) {
        int p;
        cin >> p;
        vec.push_back(p);
        c_vec.push_back(p);
    }
    sort(all(c_vec));
    int cnt = 0;
    
    for(int i=0;i<vec.size();i++){
        if (vec[i] != c_vec[i]) cnt += 1;
    }

    if (cnt<=2) cout << "YES" << endl;
    else cout << "NO" << endl;
     
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt(), M = sc.nextInt();
        int[] H = new int [N];
        for (int i=0; i<N; i++) {
        	H[i] = sc.nextInt();
        }
        int[] array = new int [N];
        for (int i=0; i<M; i++) {
            int a = sc.nextInt()-1, b = sc.nextInt()-1;
            array[a] = Math.max(array[a],H[b]);
            array[b] = Math.max(array[b],H[a]);
        }
        int ans = 0;
        for (int i=0; i<N; i++) {
            ans += (H[i] > array[i])?1: 0;
        }
      sc.close();
        System.out.println(ans);
	}
}

Measured memory_bytes: 60620
import java.util.*;

public class Main {

	static Main obj = new Main();
	static int vertex;
	static int edge;
	static int source;
	static int[] cost;
	static ArrayList<Edge>[] graph;

	@SuppressWarnings("unchecked")
	public static void init() {
		Scanner sc = new Scanner(System.in);

		vertex = sc.nextInt();
		edge = sc.nextInt();

		source = sc.nextInt();

		cost = new int[vertex];

		graph = new ArrayList[vertex];
		for (int i = 0; i < vertex; i++) {
			cost[i] = 1 << 30;
			graph[i] = new ArrayList<Edge>();
		}

		for (int i = 0; i < edge; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();

			graph[a].add(obj.new Edge(a, b, c));
		}
	}

	public static void dijk(int start) {

		HashSet<Integer> visited = new HashSet<>();
		PriorityQueue<Edge> pq = new PriorityQueue<>();

		cost[source] = 0;
		pq.add(obj.new Edge(start, start, 0));

		while (!pq.isEmpty()) {
			Edge e = pq.poll();
			if (visited.contains(e.to)) {
				continue;
			}
			visited.add(e.to);
			cost[e.to] = e.cost;

			for (Edge f : graph[e.to]) {
				pq.offer(obj.new Edge(f.from, f.to, f.cost + e.cost));
			}

		}
		for (int e : cost) {
			if (e != 1 << 30) {
				System.out.println(e);
			} else {
				System.out.println("INF");
			}
		}
	}

	public static void main(String[] args) {

		init();
		dijk(source);

	}

	private class Edge implements Comparable<Edge> {

		int from;
		int to;
		int cost;

		public Edge(int a, int b, int c) {
			from = a;
			to = b;
			cost = c;
		}

		@Override
		public int compareTo(Edge other) {

			return cost - other.cost;
		}

	}

}



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

int main(void){
    int N=0,max=0;
    cin >> N;
    vector<int> value(N);
    vector<int> price(N);
    for(int i=0;i<N;i++)cin >> value[i];
    for(int i=0;i<N;i++)cin >> price[i];
    for(int i=0;i<N;i++){
        int data=value[i]-price[i];
        if(data>0)max+=data;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define maxn 300005
#define ll long long
 
int n,m,k;
int a[maxn];
 
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    cout<<a[n/2+1]-a[n/2];
    return 0;
}

Measured memory_bytes: 640
h,w= map(int,input().split())
tb = [input() for _ in range(h)]
st = [[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
    for j in range(w):
        if i==0 and j==0:st[i][j]= (1 if tb[i][j]=='#' else 0)
        else:
            tr=td=999999999
            if i!=0:
                td=st[i-1][j]+(1 if (tb[i-1][j]=='.' and tb[i][j]=='#') else 0)
            if j!=0:
                tr=st[i][j-1]+(1 if (tb[i][j-1]=='.' and tb[i][j]=='#') else 0)
            st[i][j]=min(td,tr)
print(st[h-1][w-1])

Measured memory_bytes: 9116
#include <iostream>

const int MAX_HW = 100;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

void solve();

void dfs(int x, int y, char c);

int H, W;
char field[MAX_HW][MAX_HW] = {0};
int ans = 0;

int main(){
    while(true){
        ans = 0;
        std::cin >> H >> W;
        if(H + W == 0)
            break;
        for(int i = 0; i < H; ++i){
            for(int j = 0; j < W; ++j){
                std::cin >> field[j][i];
            }
        }
        solve();
        std::cout << ans << std::endl;
    }
}

void solve(){
    for(int i = 0; i < W; ++i){
        for(int j = 0; j < H; ++j){
            if(field[i][j] != '.'){
                ++ans;
                dfs(i, j, field[i][j]);
            }
        }
    }
}

void dfs(int x, int y, char c){
    field[x][y] = '.';

    for(int i = 0; i < 4; ++i){
        int nx = x + dx[i], ny = y + dy[i];
        if(nx >= 0 && ny >= 0 && nx < W && ny < H && field[nx][ny] == c)
            dfs(nx, ny, c);
    }
}

Measured memory_bytes: 3844
s = list(input())
t = list(input())

ans = 1000
sub = 0
flag = False
for i in range(len(s)):
    if s[i] != t[sub]:
        sub = 0
        continue
    else:
        if sub == len(t) - 1:
            print(0)
            flag = True
            break
        sub += 1

if not flag:
    for i in range(len(s) - len(t) + 1):
        sub = 0
        an = 0
        for j in range(len(t)):
            if s[i + j] != t[sub]:
                an += 1
            sub += 1 
        ans = min(an, ans)

    print(ans)

Measured memory_bytes: 9100
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int n,step=0,x=0;
    cin>>n;
    while(x!=360)
    {
        step++;
        x=x+n;
        if(x>360)
        {
            x = x -360;
        }
    }
    cout<<step;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main(void) {

  int A;
  int B;
  int C;
  int K;

  cin >> A;
  cin >> B;
  cin >> C;
  cin >> K;

  if(K-A<=0) {
    cout << K << endl;
    return 0;
  }
  else
    K -= A;

  if(K-B<=0){
    cout << A << endl;
    return 0;
  }
  else
    K -= B;

  if(K-C<=0){
    cout << A-K << endl;
    return 0;
  }
  else
    cout << A-C << endl;
    
  
  return 0;
}


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

int main() {
  int N,K,sum,i;
  cin>>N>>K;
  sum=1;
  for(i=0;i<N;i++){
    if(sum>K)sum+=K;
    else sum*=2;
  }
  cout<<sum<<endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int n,q;
set <pii> d;
set <pii> :: iterator itr;
int ans[300000];
pair < int , pii > block [300000];
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>q;
    for(int i=1;i<=n;i++){
        int s,t,x;
        cin>>s>>t>>x;
        t--;
        block [i] = mp (x , mp (max(0,s-x),max(0,t-x)) );
    }
    sort(block+1,block+1+n);

    for(int i=1;i<=q;i++){
        int st; cin>>st;
        d.insert( mp (st,i) );
    }

    for(int i=1;i<=n;i++){
        int x,s,t;
        x = block[i].fi;
        s = block[i].sf;
        t = block[i].ss;

        itr = d.lower_bound(mp(s,-1));
        while(itr != d.end()){
            pii p = *itr;
            int val,idx;
            val = p.fi;
            idx = p.se;

            if(val<s){itr++;}
            else if(val>t){break;}
            else{
                ans[idx]=x;
                d.erase(itr++);
            }
        }
    }

    for(int i=1;i<=q;i++){
        if(ans[i]==NULL)cout<<-1<<newl;
        else cout<<ans[i]<<newl;
    }



}


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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    char b;
    cin1(b);
    if (b == 'A')
        cout <<'T' << endl;
    if (b == 'T')
        cout <<'A' << endl;
    if (b == 'C')
        cout <<'G' << endl;
    if (b == 'G')
        cout <<'C' << endl;
}


Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
int N, K;
int A[200005];

bool f(int x) {
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] == 0) {
            if (x >= 0) cnt += N - 1;
            else cnt += 0;
            continue;
        }

        int tmp = x / A[i];
        if (tmp * A[i] > x) {
            if ((tmp + 1) * A[i] <= x) tmp++;
            else tmp--;
        }

        if (A[i] < 0) {
            int ret = (A + N) - lower_bound(A, A + N, tmp);
            if (A[i] >= tmp) ret--;
            cnt += ret;
        } else {
            // tmp以下をさがす
            int ret = upper_bound(A, A + N, tmp) - A;
            if (A[i] <= tmp) ret--;
            cnt += ret;
        }
    }

    return (cnt / 2) >= K;
}

signed main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) cin >> A[i];
    sort(A, A + N);

    int lb = -1e18 - 5;
    int ub = 1e18 + 5;

    while (ub - lb > 1) {
        int mid = (ub + lb) / 2;
        if (f(mid)) {
            ub = mid;
        } else {
            lb = mid;
        }
    }

    cout << ub << endl;

    return 0;
}

Measured memory_bytes: 1792
// abc118_a
// #include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main(void) {
	int A, B;
	cin >> A >> B;
	if (A == 1) {
		cout << A + B << endl;
		return 0;
	}
	if (B % A == 0) {
		cout << A + B << endl;
	}
	else {
		cout << B - A << endl;
	}

	return 0;
}

Measured memory_bytes: 256
/**
 * Created by hiramekun at 20:58 on 2020-04-19.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n, m;
    cin >> n >> m;
    vl a(m);
    cin >> a;

    ll tmp = n - accumulate(all(a), 0LL);
    cout << (tmp < 0 ? -1 : tmp) << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 3708
import math
n,h = map(int,input().split())
a = []
b = []
for i in range(n):
  x,y = map(int, input().split())
  a += [x]
  b += [y]
amax = max(a)
ans = 0
b.sort(reverse=True)
for x in b:
  if x >= amax:
    ans += 1
    h -= x
  if h <= 0:
    print(ans)
    exit()
 
if h % amax == 0:
  print(ans + h//amax)
else:
  print(ans + h//amax + 1)

Measured memory_bytes: 11328
def main():
    N, M, K  = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    a, b = [0], [0]
    for i in range(N):
        a.append(a[i] + A[i])
    for i in range(M):
        b.append(b[i] + B[i])
    bs = M
    ans = 0
    for i in range(N + 1):
        if a[i] > K:
            break
        for j in range(bs, -1, -1):
            if b[j] + a[i] <= K:
                bs = j
                break
        ans = max(ans, i + bs)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 47552
#include <iostream>
#define mxn 100010
using namespace std;

int ar[mxn], dp[mxn];

// iterative

int main() {
    int n; cin >> n;
    fill(dp, dp+mxn, -1);
    for(int i=1; i<=n; ++i) cin >> ar[i];
    
    dp[1] = 0, dp[2] = abs(ar[1]-ar[2]);

    for(int i=3; i<=n; ++i)
        dp[i] = min(dp[i-1] + abs(ar[i] - ar[i-1]),
                    dp[i-2] + abs(ar[i] - ar[i-2]));
    cout << dp[n];
    return 0;
}

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


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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    set<int> s(ALL(a));
    if (a.size() == s.size()) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 13456
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int N, M;

const ll mod = 1e9 + 7;

int factorial(int n) {
	int res = 1;
	rep(i, 1, n + 1) {
		res = ((i % mod) * (res % mod)) % mod;
	}
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> M;
	if(N != M && N - M != 1 && M - N != 1) {
		cout << 0 << endl;
		return 0;
	}
	int n = factorial(N);
	int m = factorial(M);
	if(N == M) {
		ll res = (((n % mod) * (m % mod) % mod) * 2) % mod;
		cout << res << endl;
		return 0;
	} else {
		ll res = ((n % mod) * (m % mod) % mod) % mod;
		cout << res << endl;
		return 0;
	}	


}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf
# @pysnooper.snoop()
#import pysnooper # debug

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect

def solve(a, b, c, k):
    if k < a:
        return k
    if k < a + b:
        return a
    get_c = k - (a + b)
    return a - get_c

if __name__ == '__main__':
    a, b, c, k = list(map(int, input().split()))
    ans = solve(a, b, c, k)
    #print('ans') # debug
    print(ans)

    #print('\33[32m' + 'end' + '\033[0m') # debug


Measured memory_bytes: 68524
import sys
import itertools
sys.setrecursionlimit(10**6)

INF = 10**10


def main(input, print):
    n, m, x = map(int, input().split())
    table = [[] for _ in range(n)]
    for i in range(n):
        table[i] = list(map(int, input().split()))
    ans = INF
    for i in range(1, n+1):
        p = itertools.combinations(range(n), i)
        for pj in p:
            t = 0
            mt = [0] * m
            for k in range(len(pj)):
                t += table[pj[k]][0]
                for l in range(m):
                    mt[l] += table[pj[k]][l+1]
            is_ok = True
            for l in range(m):
                if mt[l] < x:
                    is_ok = False
            if is_ok:
                ans = min(ans, t)
    if ans == INF:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main(sys.stdin.readline, print)


Measured memory_bytes: 74132
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    a = list(map(int, input().split()))
    b = sorted(a)
    c = [0] + sorted(b)
    c = list(accumulate(c))
    a.sort(reverse=True)
    
    # mid以上の和をm個作れるならTrue
    def check(mid):
        total = 0
        for i in a:
            total += n - bisect_left(b, mid-i)
            if total >= m:
                return True
        return False

    l = 0
    r = 2*(10**5)+10
    # 最終的なlがm個以上作れる最小値
    while r - l > 1:
        mid = (l+r) // 2
        if check(mid):
            l = mid
        else:
            r = mid
    res = 0
    for i in a:
        d = bisect_left(b, r-i)
        if d == n:
            continue
        res += i * (n-d) + c[-1] - c[d]
        m -= n - d

    print(res + l*m)

if __name__ == '__main__':
    main()

Measured memory_bytes: 58384
def examC(inf):
    N = I()
    F = [LI() for _ in range(N)]
    P = [LI() for _ in range(N)]
    loop = 2**10
    ans = -inf
    for i in range(1,loop):
        cur = [0]*N
        for j in range(10):
            if (i>>j)&1==1:
                for k in range(N):
                    if F[k][j]==1:
                        cur[k]+=1
        ansC =0
        for j in range(N):
            ansC += P[j][cur[j]]
        ans = max(ans,ansC)
    print(ans)


import sys,copy,bisect,itertools
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC(inf)


Measured memory_bytes: 3568
#include <stdio.h>
int main(){
	int n,k,q,a;
	scanf("%d%d%d",&n,&k,&q);
	int c[n+5];
	for (int i=0;i<n;i++){
		c[i]=k;
	}
	for(int i=0;i<q;i++){
		scanf("%d",&a);
		c[a-1]+=1;
	}
	for (int i=0;i<n;i++){
		if(c[i]-q>0){
			printf("Yes\n");}
		else{
			printf("No\n");
		}
	}
	return 0;
}


Measured memory_bytes: 896
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np

def main():
	N = int(input())
	
	ans = lcm(2, N)
	
	print(ans)
	
def gcd(a, b):
	if a > b:
		a, b = b, a
		
	while a > 0:
		a, b = b % a, a
	return b
	
def lcm(a, b):
	g = gcd(a, b)
	return a // g * b
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 13992
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <cmath>

using namespace std;

typedef long long ll;



int main()
{
    
    int a, b, c;
    cin >> a >> b >> c;
    if (a < b)
        swap(a, b);
    if (a < c)
        swap(a, c);
    cout << 10 * a + b + c;
    return 0;
}
















Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define push_back pb
#define make_pair mp
using ll =  long long;
const int INF = 0x3f3f3f3f;
const int MAX_N = 2e5+10;
int N;
string s[MAX_N];

map<map<int,int>,int> ans;
map<int,int> tmp;

void solve()
{
	for(int i=0;i<N;++i){
		tmp.clear();
		for(auto c : s[i]) tmp[c]++;
		ans[tmp]++;
	}
	long long cnt = 0;
	for(const auto& p : ans){
		if(p.second > 1) cnt += ((ll)p.second * ((ll)p.second - 1)) / 2;
	}
	cout << cnt << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N;
	for(int i=0;i<N;++i)cin >> s[i];
	solve();
	return 0;
}

Measured memory_bytes: 55424
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	char c;
	vector< vector<int> > data(n, vector<int>(m));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> c;
			if (c == 'c') {
				data[i][j] = 0;
			} else {
				data[i][j] = -1;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = m-1; j >= 0; j--) {
			if (data[i][j] == -1) {
				for (int k = 1; j-k >= 0; k++) {
					if (data[i][j-k] == 0) {
						data[i][j] = k;
						break;
					}
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (j != 0) {
				cout << ' ' << data[i][j];
			} else {
				cout << data[i][j];
			}
		}
		cout << endl;
	}
	return 0;
}

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

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		String s = sc.next();
		String s1=s.substring(k-1,k).toLowerCase();
		System.out.println(s.substring(0,k-1)+s1+s.substring(k));
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,x,y,i;
  cin>>n>>m>>x;
  for(i=1;i<=m;i++){
    cin>>y;
    if(x<y) break;
  }
  cout<<min(i-1,m-i+1)<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  string A,B;
  cin>>A>>B;
  
  if(A.size() != B.size())
  {
    A = to_string(A.size());
    B = to_string(B.size());
  }

  
  if(A>B)
  {
    cout<<"GREATER"<<endl;
  }
  else if(A < B)
  {
    cout<<"LESS"<<endl;
  }
  else
  {
    cout<<"EQUAL"<<endl;
  }
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Console;

namespace c {
static class Extensions {
   public static int ToInt(this string str) {
      return int.Parse(str);
   }

   public static int[] readIntArr() {
      return ReadLine().Split(' ').Select(int.Parse).ToArray();
   }
}

class Program {
   public static void Main(string[] args) {
      var s = ReadLine();

      // 先頭が'0'の場合
      int count1 = 0;
      for (int i = 0; i < s.Length; i++) {
         if (i % 2 == 0) {
            if (s[i] == '1') count1++;
         } else {
            if (s[i] == '0') count1++;
         }
      }

      int count2 = 0;
      for (int i = 0; i < s.Length; i++) {
         if (i % 2 == 0) {
            if (s[i] == '0') count2++;
         } else {
            if (s[i] == '1') count2++;
         }
      }

      WriteLine(Math.Min(count1, count2));
   }
}

}


Measured memory_bytes: 13280
#include<iostream>
using namespace std;
typedef long long int LL;
const LL MAX=(LL)1<<60;
LL x[200005];
LL t[200005];
int main(){
	LL n,m;
	LL a,b,c;
	LL i,j,k;
	LL s=(LL)1<<60;
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>x[i];
		if(i==0)t[i]=x[i];
		else t[i]=t[i-1]+x[i];
	}
	for(i=1;i<=n;i++){
		a=m*(i+n);
		for(j=n-1,k=0;j>=0;j-=i,k++){
			if(k==0)a+=t[j]*(LL)5;
			else if(k>1)a+=t[j]*(LL)2;
			if(a>MAX)break;
		}
		if(s>a)s=a;
	}
	cout<<s<<endl;
	return 0;
}
		


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using Pdi = pair<double, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

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

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    if(N % 10 == 3) Out("bon");
    else if(N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) Out("pon");
    else Out("hon");

    return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>


using namespace std;
#define INF 0x3f3f3f3f3f
#define ll long long
#define pr(x) (cerr << #x << ' ' << x << ' ')
#define prln(x) (cerr << #x << ' ' << x << endl)
const int maxn = 160;
int a[maxn], b[maxn], c[maxn], d[maxn];
bool used[maxn];
int girl[maxn], line[maxn][maxn];
int n;

bool dfs(int x) {
	for (int j = 1; j <= n; ++j) {
		if (line[x][j] == 1 && !used[j]) {
			used[j] = 1;

			if (girl[j] == 0 || dfs(girl[j])) {
				girl[j] = x;
				return true;
			}
		}
	}

	return false;
}





int main()
{
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
	#endif // LOCAL

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

	for (int i = 1; i <= n; ++i) {
		cin >> c[i] >> d[i];
	}

	memset(line, 0, sizeof(line));

	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			if (a[i] < c[j] && b[i] < d[j]) {
				line[i][j] = 1;
			}
		}
	}

	memset(girl, 0, sizeof(girl));
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		memset(used, 0, sizeof(used));
		if (dfs(i)) ans++;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        res = L[i] + L[j]
        num = bisect.bisect_left(L, res) - (j+1)
        ans += num
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>

#define MAX_N 1000001
#define INF 1000000007
using namespace std;

vector<int> G[MAX_N];
int n,k;
queue<int> q;
long long res = k;
long long tmp;
void solve()
{
    int pre = -1;
    int now; 
    int depth;
    res = k;
    q.push(1);q.push(0);q.push(pre);
    while(!q.empty()){
        now = q.front();q.pop();
        depth = q.front();q.pop();
        pre = q.front();q.pop();
        tmp = 0;
        for(auto &e: G[now]){
            if(e==pre)continue;
            tmp +=1;
            q.push(e);
            q.push(depth+1);
            q.push(now); 
        }
        if(depth==0){
            for(int i = 1;i<=tmp;i++){
                res *= max(0,k-i);
                res %= INF;
            }
        }
        if(depth>0){
            for(int i = 1;i<=tmp;i++){
                res *= max(0,k-1-i);
                res %= INF;
            }
        }
    }
    cout<<res%INF<<endl;
}

int main()
{
    cin>>n>>k;
    int a,b;
    for(int i = 0;i<n-1;i++){
        cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a); 
    }
    solve();
    return 0;
}


Measured memory_bytes: 28408
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.numeric;

void main() {
    const tmp = readln.split.to!(long[]);
    const N = tmp[0], M = tmp[1], C = tmp[2];
    const bs = readln.split.to!(long[]);
    N.iota.map!(_ => readln.split.to!(long[]).dotProduct(bs) + C > 0 ? 1 : 0).sum.writeln;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, T;
ll A[100010];
ll minA[100010], diffA[100010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> T;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  minA[0] = A[0];
  diffA[0] = 0;
  for (int i = 1; i < N; i++) {
    minA[i] = min(minA[i - 1], A[i]);
    diffA[i] = A[i] - minA[i];
  }
  ll tmp = *max_element(diffA, diffA + N);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += diffA[i] == tmp;
  }
  cout << ans << endl;


  return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a;
    string s;
    cin >> a;
    cin >> s;
    if(a>=3200)
        cout << s;
    else
        cout << "red";
}


Measured memory_bytes: 256