akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {

            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            //var p = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int Q = input[1];
            List<List<int>> G = new List<List<int>>();
            for(var i = 0; i < N; i++)
            {
                G.Add(new List<int>());
            }
            var g = new Graph();
            int[] p = new int[Q];
            int[] x = new int[Q];


            long[] ans = new long[N];
            bool[] seen = new bool[N];

            for (var i = 0; i < N - 1; i++)
            {
               
                var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
                G[ab[0] - 1].Add(ab[1] - 1);
                
            }
            
            for (var i = 0; i < N; i++)
            {
                ans[i] = 0;
                seen[i] = false;
            }

            for (var i = 0; i < Q; i++)
            {
                var px = Console.ReadLine().Split().Select(int.Parse).ToArray();
                p[i] = px[0];
                x[i] = px[1];

                ans[p[i] - 1] += x[i];
            }



            seen[0] = true;
            int pp = 0;

            g.Dfs(G, seen, 0, ans, pp);


            for(var i = 0; i < N; i++)
            {
                Console.WriteLine(ans[i]);
            }
            


            Console.Out.Flush();

        }
    }

    //010100

    public class Calculation
    {

    }

    public class Graph
    {
        public void Dfs(List<List<int>> graph, bool[] seen, int v,long[]ans,int p)
        {
            seen[v] = true;
            //初めて訪れたタイミングでここの処理
            
            if (v != 0) { ans[v] += ans[p]; }

            foreach (var next in graph[v])
            {
                if (seen[next] == true) { continue; }
                p = v;
                Dfs(graph, seen, next,ans,p);
                
            }
            //Console.WriteLine(v);//行き先がない状態になったらこの部分の処理

        }
    }
}




Measured memory_bytes: 64948
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int a[2*m],b[n+1];
  for(int i=0;i<=n;i++){
    b[i]=0;
  }
  for(int i=0;i<2*m;i++){
    cin >> a[i];
    b[a[i]]++;
  }
  for(int i=1;i<=n;i++){
    cout << b[i] << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top=0, s[100];

void push(int x){
	s[top]=x;
	top++;
}

int pop(){
	top--;
	return s[top];
}

int main(void){
	int x, a, b;
	char s[100];
	
int i=0;
	while( scanf(" %s", s) != EOF ){
		
		if ( s[0] == '+' ){
			a = pop();
            b = pop();
            push(a + b);
		//	printf("i%d a + b%d\n", i, a + b);
			
		} 
		else if ( s[0] == '-' ){
			a = pop();
            b = pop();
            push(b-a);
			
		//	printf("i%d a - b%d\n", i, a - b);
			
		}
		else if ( s[0] == '*' ){
			a = pop();
            b = pop();
            push(a * b);
		//	printf("i%d a * b%d\n", i, a * b);
			
		}
		else {
			x = atoi(s);
			push(x);
		//	printf("i%d x%d\n", i, x);
			
		}
		i++;
	}
	
	printf("%d\n", pop());

  return 0;
}



Measured memory_bytes: 2032
n=int(input())
a = map(int, input().split())
q = int(input())
r = {}
s = 0
for i in a:
    s += i
    if i in r:
        r[i] += 1
    else:
        r[i] = 1

for i in range(q):
    b,c = map(int, input().split())
    if b in r:
        if c in r:
            r[c] += r[b]
        else:
            r[c] = r[b]
        s = s + r[b] * (c-b)
        r[b] = 0
    print(s)


Measured memory_bytes: 21904
import java.util.Scanner;

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


		String str;
		int[][] score = new int[3][100];
		int n = 0;
		int rank = 1;
		int j, v, w;
		int ans;
		
		while(true){
			str = scan.next();
			if(str.equals("0,0"))break;
			String[] num = str.split(",", 0);
			score[0][n] = Integer.parseInt(num[0]);
			score[1][n] = Integer.parseInt(num[1]);
			n++;
		}
		for(int i  = 1; i <= n - 1; i++){
			w = score[0][i];
			v = score[1][i];
			j = i - 1;
			while(j >= 0 && score[1][j] < v){
				score[1][j + 1] = score[1][j];
				score[0][j + 1] = score[0][j];
				j--;
			}
			score[1][j + 1] = v;
			score[0][j + 1] = w;
		}
		for(int i = 0; i < n; i++){
			score[2][i] = rank;
			if(n < 99){
				if(score[1][i]  > score[1][i + 1])rank++;
			}
		}
		
		while(scan.hasNextInt()){
			ans = scan.nextInt();
			for(int i = 0; i < n; i++){
				if(ans == score[0][i]){
					System.out.println(score[2][i]);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 25936
a, b, c, k = list(map(int, input().split()))
res = min(a, k)
f = True
k -= min(a, k)
if k == 0:
    print(res)
    f = False
k -= min(b, k)
if k == 0 and f:
    print(res)
    f = False
res -= min(c, k)
if f:
    print(res)


Measured memory_bytes: 9184
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef struct d{ll n,r,l;}d;
const ll INF=100000000000000000;
d T[1000001];
int N,gp=1;

void pre(int n)
{
	if(n==-1)return;
	printf(" %d",T[n].n);
	if(T[n].l!=-1)pre(T[n].l);
	if(T[n].r!=-1)pre(T[n].r);
	return;
}

void ino(int n)
{
	if(n==-1)return;
	if(T[n].l!=-1)ino(T[n].l);
	printf(" %d",T[n].n);
	if(T[n].r!=-1)ino(T[n].r);
	return;
}

void ins(int p,int np=0)
{
	if(T[np].n==INF)T[np].n=p;
	else
	{
		if(T[np].n>p)
		{
			if(T[np].l==-1)
				T[np].l=gp++;
			ins(p,T[np].l);
		}
		else
		{
			if(T[np].r==-1)
				T[np].r=gp++;
			ins(p,T[np].r);
		}
	}
}

void p()
{
	ino(0);puts("");
	pre(0);puts("");
}

bool f(int p,int np=0)
{
	if(T[np].n==p)return 1;
	if(T[np].r!=-1&&T[np].n<p)
		return f(p,T[np].r);
	if(T[np].l!=-1&&T[np].n>p)
		return f(p,T[np].l);
	return 0;
}

int main()
{
	for(int i=0;i<1000001;i++)
	{
		T[i].n=INF;
		T[i].r=T[i].l=-1;
	}
	scanf("%d\n",&N);
	for(int i=0;i<N;i++)
	{
		char s[20];
		int a;
		scanf("%s%d\n",s,&a);
		if(s[0]=='i')
			ins(a);
		else if(s[0]=='f')
			puts(f(a)?"yes":"no");
		else
			p();
	}
}

Measured memory_bytes: 24640
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

const int COUNT = 6;

#define size_array(x) ((sizeof(x)) / (sizeof(x[0])

class Dice
{
private:
	int num[6];

public:
	Dice();
	void play_dice(string);
	void play(int, int, int, int);
	void print_() {printf("%d\n", num[0]);}
};

Dice::Dice()
{
	for (int i = 0; i < COUNT; ++i)
	{
		cin >> num[i];
		
	}
}


void Dice::play_dice(string s)
{
	if(s == "E") {play(0, 2, 5, 3); }
		
	if(s == "N") {play(0, 4, 5, 1); }
		
	if(s == "S") {play(0, 1, 5, 4); }
	
	if(s == "W") {play(0, 3, 5, 2); }
}

void Dice::play(int a, int b, int c, int d)
{
	int temp;
	temp = num[d]; num[d] = num[c]; num[c] = num[b]; num[b] = num[a]; num[a] = temp;
}


int main(int argc, char const *argv[])
{
	Dice c;
	string cmd;
	cin >> cmd;
	for (int i = 0; i < (int)cmd.size(); ++i)
	{
		c.play_dice(cmd.substr(i, 1));
	}
	c.print_();
	return 0;
}

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

int main() {
	int n, l;
	cin >> n >> l;
	vector<string> s(n);
	
	for(int i = 0; i < n; i++){
		cin >> s.at(i);
	}
	
	sort(s.begin(), s.end());
	string a;
	for(int i = 0; i < n; i++){
		a += s.at(i);
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim (lld)1e9+7
#define MAX2 (int)2e5+9
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const lld mod=lim;

lld power(lld x, lld y, lld p)  
{   lld res = 1;     x = x % p; if (x == 0) return 0;  
  
    while (y > 0)  
    { if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;   }  
    return res;  } 


int extend_gcd(int a, int b, int& x, int& y) {
    if (b == 0) { x = 1;y = 0;return a;}
    int x1, y1;
    int d = extend_gcd(b, a % b, x1, y1);
    x = y1; y = x1 - y1 * (a / b);return d;	}

int rowNum[]={-1,0,0,1};
int colNum[]={0,-1,1,0};

int main()
{
	fastio
    int x,n;
    cin>>x>>n;

    int ans=x,ans1=x;

    std::vector<int> v(n);

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

    sort(v.begin(), v.end());

   
        while(binary_search(v.begin(), v.end(),ans))
        {
            ans++;
        }
   
        while(binary_search(v.begin(), v.end(),ans1))
        {
            ans1--;
        }
  

    if(abs(ans-x)>=abs(ans1-x))
        cout<<ans1<<endl;

    else
        cout<<ans<<endl;

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
typedef long long ll;
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define Fd(i,a,b) for(ll i=a;i>=b;i--)
using namespace std;
const int N=(1e5)+5;

struct cok
{
	int x;
	int y;
	int t;
};

cok A[N];
bool cmp(cok a,cok b);

 int main()
 {
	int n;
	scanf("%d",&n);

	F(i,1,n)
	{
		scanf("%d%d%d",&A[i].t,&A[i].x,&A[i].y);
	}
	sort(A+1,A+1+n,cmp);

	int X,Y,T;
	X=0;
	Y=0;
	T=0;

	F(i,1,n)
	{
		if((abs(X-A[i].x)+abs(Y-A[i].y)>A[i].t-T)||(abs(X-A[i].x)+abs(Y-A[i].y))%2!=(A[i].t-T)%2)
		{	
			printf("No\n");
			return 0;
		}

		X=A[i].x;
		Y=A[i].y;
		T=A[i].t;
	}

	printf("Yes\n");
	return 0;
 }
////////
 bool cmp(cok a,cok b)
 {
	return a.t<b.t;
 }


Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>
int main(void)
{
	char S[1001];
	int n=0,w=0,s=0,e=0,a=0,i;
	scanf("%s",S);
	for(i=0; i<strlen(S); i++){
		if(S[i]=='N')n=1;
		if(S[i]=='W')w=1;
		if(S[i]=='S')s=1;
		if(S[i]=='E')e=1;
		if(n==1 && w==1 && s==1 && e==1)break;
	}
	if(n==1 && s==0)a=1;
	if(s==1 && n==0)a=1;
	if(w==1 && e==0)a=1;
	if(e==1 && w==0)a=1;
	if(a==1)puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 128
N = int(input())
X = [int(i) for i in input().split()]

a = min(X)
b = max(X)

s = 10**6
for i in range(a, b+1):
    t = 0
    for j in range(N):
        t += (X[j] - i)**2
    if t < s:
        s = t

print(s)

Measured memory_bytes: 9040
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
int main() {
	cin >> H >> W;
	vll A(H, vl(W, 0));
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
	vector<tuple<ll, ll, ll, ll>> Ans;
	for (i = 0; i < H; i++) {
		for (j = 0; j < W-1; j++) {
			if (A[i][j] % 2 == 1) {
				A[i][j]--;
				A[i][j + 1]++;
				ans++;
				Ans.push_back(make_tuple(i + 1, j + 1, i + 1, j + 2));
			}
		}
	}
	for (i = 0; i < H-1; i++) {
		if (A[i][W-1] % 2 == 1) {
			A[i][W-1]--;
			A[i+1][W-1]++;
			ans++;
			Ans.push_back(make_tuple(i + 1, W, i + 2, W));
		}
	}
	cout << Ans.size() << endl;
	for (i = 0; i < Ans.size(); i++) {
		cout << get<0>(Ans[i]) << " " <<get<1>(Ans[i]) << " " << get<2>(Ans[i]) << " " << get<3>(Ans[i]) << endl;
	}
}

Measured memory_bytes: 8432
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cstdio>

#include<string>

using namespace std;

int main(){
    string s,t;
    getline(cin,s);
    getline(cin,t);
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s<t){
        puts("Yes");
    }
    else{
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt();
        P[] ps = new P[n];
        for (int i = 0; i < n; i++) {
            int t = sc.nextInt() - 1;
            int d = sc.nextInt();
            ps[i] = new P(t, d);
        }

        Arrays.sort(ps);

        long ans = 0;
        long cur = 0;
        boolean[] used = new boolean[n];
        LinkedList<Integer> pops = new LinkedList<>();
        long cnt = 0;

        for (int i = 0; i < k; i++) {
            ans += ps[i].d;
            cur += ps[i].d;
            if (used[ps[i].t]) {
                pops.addFirst(ps[i].d);
            } else {
                cnt++;
                used[ps[i].t] = true;
            }
        }

        ans += cnt * cnt;

        for (int i = k; i < n && !pops.isEmpty(); i++) {
            if (!used[ps[i].t]) {
                cur -= pops.removeFirst();
                cur += ps[i].d;
                cnt++;
                ans = Math.max(ans, cur + cnt * cnt);
                used[ps[i].t] = true;
            }
        }
        System.out.println(ans);
    }

    class P implements Comparable<P> {
        int t, d;
        public P(int t, int d) {
            this.t = t;
            this.d = d;
        }

        @Override
        public int compareTo(P o) {
            return o.d - d;
        }

        @Override
        public String toString() {
            return String.format("{t: %d, d: %d}", t, d);
        }
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }


    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 92388
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		if (a % 2 == 0 || b % 2 == 0)

			System.out.println("No");
		else

			System.out.println("Yes");

	}
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int h,w,i=0,j,c=0;
    char a;
    string s[100],m="a";
    cin >> h >> w;
    for(i=1;i<h+1;i++)
    {
        cin >> s[i];
        s[i]=m+s[i]+m;
    }
    s[0]=string(w+3, 'x');
    s[h+1]=string(w+3,'x');
    for(i=1;i<h+1;i++)
    {
        for(j=1;j<w+1;j++)
        {
            if(s[i].at(j)=='#')
            {
                continue;
            }
            if(s[i-1].at(j-1)=='#')
            {
                c++;
            }
            if(s[i-1].at(j)=='#')
            {
                c++;
            }
            if(s[i-1].at(j+1)=='#')
            {
                c++;
            }
            if(s[i].at(j-1)=='#')
            {
                c++;
            }
            if(s[i].at(j+1)=='#')
            {
                c++;
            }
            if(s[i+1].at(j-1)=='#')
            {
                c++;
            }
            if(s[i+1].at(j)=='#')
            {
                c++;
            }
            if(s[i+1].at(j+1)=='#')
            {
                c++;
            }
            a=c + '0';
            s[i].at(j)=a;
            c=0;
        }
    }
    for(i=1;i<h+1;i++)
    {
        cout << s[i].substr(1,w) << endl;
    }
    
    return 0;

}


Measured memory_bytes: 3632
def main():
    n,m,x = map(int, input().split())
    c = [None]*n
    a = [None]*n
    
    for i in range(n):
        line = list(map(int, input().split()))
        c[i] = line[0]
        a[i] = line[1:]
    
    costs = []
    
    def func(i, points, cost, x):
        if i == n:
            if all([point >= x for point in points]):
                costs.append(cost)
            else:
                return None
        
        if all([point >= x for point in points]):
            costs.append(cost)
            return None
        
        func(i+1, points, cost, x)
        func(i+1, [points[j] +a[i][j] for j in range(m)], cost+c[i], x)
    
    func(0, [0]*m, 0, x)
    
    if len(costs) == 0:
        return -1
    
    return min(costs)

print(main())

Measured memory_bytes: 9260
#include <iostream>

using namespace std;

int main(){
    int n; cin >> n;
    int count = 0;

    for(int i = 1; i <= n; i++){
        int k = 1;
        for(int j = 10; i/j != 0; j *= 10)k++;
        if(k % 2 == 1)count++;
    }
    cout << count << endl;
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename T> struct BIT {
    int S;
    vector<T> v;

    BIT<T>(int _S) {
        S = _S;
        v.resize(S+1);
    }

    void update(int i, T k) {
        for(i++; i <= S; i += i&-i)
            v[i] = v[i] + k;
    }

    T read(int i) {
        T sum = 0;
        for(i++; i; i -= i&-i)
            sum = sum + v[i];
        return sum;
    }

    T read(int l, int r) {
        return read(r) - read(l-1);
    }

    /*
     * Returns in O(logS) the first index i such that read(i) >= sum.
     * Returns S if no such i exists.
     * Requires that read(i) is non-decreasing in i.
     */
    int lower_bound(T sum) {
        T res = 0;
        int inx = 0;
        for (int i = 31 - __builtin_clz(S); i >= 0; i--) {
            if ((inx + (1 << i) <= S) && res + v[inx + (1 << i)] < sum) {
                inx += 1 << i;
                res += v[inx];
            }
        }
        return inx;
    }
};

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

    int N;
    cin >> N;
    ll tot = N * 1ll * (N + 1) / 2;

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

    vi vals = a;
    sort(all(vals));
    vals.erase(unique(all(vals)), vals.end());

    int lo = 1, hi = vals.size() - 1, ans = 0;
    while (lo <= hi) {
        int mi = (lo + hi) / 2;

        ll pos = 0;
        BIT<int> ct(2 * N + 1);
        ct.update(N + 0, 1);

        int bal = 0;
        for (int v : a) {
            if (v >= vals[mi]) bal++;
            else bal--;

            pos += ct.read(N + bal);
            ct.update(N + bal, 1);
        }

        if (2 * pos >= tot) {
            ans = mi;
            lo = mi + 1;
        } else hi = mi - 1;
    }

    cout << vals[ans] << endl;

    return 0;
}



Measured memory_bytes: 1804
class UnionFind():
    def __init__(self, n):
        self.par = [-1 for i in range(n)]

    def root(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x])  # contraction
            return self.par[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            if self.par[x] > self.par[y]:  # merge technique
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x

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

    def size(self, x):
        return -self.par[self.root(x)]


n, m, k = map(int, input().split())
n_friends = [0] * n
uf = UnionFind(n)
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1

    uf.unite(a, b)
    n_friends[a] += 1
    n_friends[b] += 1

ans = [uf.size(i) - 1 - n_friends[i] for i in range(n)]

for _ in range(k):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    if uf.same(c, d):
        ans[c] -= 1
        ans[d] -= 1

print(*ans)


Measured memory_bytes: 14200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a, b;
    int cnt = 0;
    cin >> a >> b;
    for (int i=a; i<=b; i++) {
        if (to_string(i)[0] == to_string(i)[4]
        && to_string(i)[1] == to_string(i)[3]) cnt++;
    }
    cout << cnt << endl;
}

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

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

    
    if(a>b)
      swap(a,b);
      
    
    if(b>c)
      swap(b,c);
    
  
    if(a >b)
    swap(a,b);

    cout <<a << ' ' << b << ' ' << c << endl;
  
}


Measured memory_bytes: 3064
#include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define all(c) (c).begin(), (c).end()
#define dump(a) cerr << #a << "=" << (a) << endl

using namespace std;

int main() {
	int N,A,B,C,X;
	int Y;
	vector<int> ys;
	int check_cnt;
	int ii;
	
	while(cin >> N >> A >> B >> C >> X) 
	{
		if (N==0 && A==0 && B==0 && C==0 && X==0) { break; }
		ii=0;
		ys.clear();
		rep(i,N) {
			cin >> Y;
			ys.push_back(Y);
		}
		rep(i,10001) {
			if (ys.empty()) { break; }
			else if (X == ys.front()) {
				ys.erase(ys.begin());
				ii=i;
			}
			X = (A * X + B) % C;
		}
		if (ys.empty()) {
			cout << ii << endl;
		}
		else { cout << -1 << endl; }
	}


	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
   char sum[1000];
int main()
{

    int a,b,cou,t;
    while(cin>>a>>b)
    {
        sprintf(sum,"%d",a+b);
        printf("%d\n",strlen(sum));


    }

    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

#define UNION_FIND_MAX (1000*1000)

int uf_table[UNION_FIND_MAX];

void uf_init(void) {
	int i;
	for(i=0;i<UNION_FIND_MAX;i++)uf_table[i]=0;
}

void uf_merge(int a,int b) {
	int next;
	while(uf_table[a]>0) {
		next=uf_table[a]-1;
		if(uf_table[next]>0)uf_table[a]=uf_table[next];
		a=next;
	}
	while(uf_table[b]>0) {
		next=uf_table[b]-1;
		if(uf_table[next]>0)uf_table[b]=uf_table[next];
		b=next;
	}
	if(a!=b)uf_table[a]=b+1;
}

int uf_issame(int a,int b) {
	int next;
	while(uf_table[a]>0) {
		next=uf_table[a]-1;
		if(uf_table[next]>0)uf_table[a]=uf_table[next];
		a=next;
	}
	while(uf_table[b]>0) {
		next=uf_table[b]-1;
		if(uf_table[next]>0)uf_table[b]=uf_table[next];
		b=next;
	}
	return a==b;
}

void uf_merge_2d(int ax,int ay,int bx,int by) {
	uf_merge(ay*1000+ax,by*1000+bx);
}

int uf_issame_2d(int ax,int ay,int bx,int by) {
	return uf_issame(ay*1000+ax,by*1000+bx);
}

int width,height;
char map[1000][1004];

int main(void) {
	int fb_x=-1,fb_y=-1;
	int x,y,i;
	int eigyo_zikan;
	int kaiho_x[1000];
	int kaiho_y[1000];
	scanf("%d%d",&width,&height);
	for(y=0;y<height;y++) {
		scanf("%s",map[y]);
		if(fb_x<0) {
			for(x=0;x<width;x++) {
				if(map[y][x]=='t') {
					fb_x=x;fb_y=y;break;
				}
			}
		}
	}
	for(y=0;y<height;y++) {
		for(x=0;x<width;x++) {
			if(map[y][x]=='#')continue;
			if(x>0 && map[y][x-1]!='#')uf_merge_2d(x,y,x-1,y);
			if(y>0 && map[y-1][x]!='#')uf_merge_2d(x,y,x,y-1);
		}
	}
	scanf("%d",&eigyo_zikan);
	for(i=0;i<eigyo_zikan;i++)scanf("%d%d",&kaiho_x[i],&kaiho_y[i]);
	if(uf_issame_2d(0,0,fb_x,fb_y)) {
		puts("0");
	} else {
		for(i=0;i<eigyo_zikan;i++) {
			x=kaiho_x[i];y=kaiho_y[i];
			if(map[y][x]=='#') {
				map[y][x]='.';
				if(x>0 && map[y][x-1]!='#')uf_merge_2d(x,y,x-1,y);
				if(y>0 && map[y-1][x]!='#')uf_merge_2d(x,y,x,y-1);
				if(x+1<width && map[y][x+1]!='#')uf_merge_2d(x,y,x+1,y);
				if(y+1<height && map[y+1][x]!='#')uf_merge_2d(x,y,x,y+1);
			}
			if(uf_issame_2d(0,0,fb_x,fb_y))break;
		}
		printf("%d\n",i<eigyo_zikan?i+1:-1);
	}
	return 0;
}

Measured memory_bytes: 4944
#include <iostream>

using namespace std;

int kaijo(int n)
{
	int sum = 1;
	while (n >= 1)
	{
		sum *= n;
		n--;
	}
	return (sum);
}

int main()
{
	int N;
	cin >> N;
	int i = 0;
	int P[N];
	int Q[N];
	while (i < N)
		cin >> P[i++];
	i = 0;
	while (i < N)
		cin >> Q[i++];
	int ans1 = 1,ans2 =1;
	int j,p,q;
	i = 0;
	while (i < N)
	{
		j = 0;
		p = 0;
		q = 0;
		while (j < i)
		{
			if (P[j] < P[i])
				p++;
			if (Q[j] < Q[i])
				q++;
			j++;
		}
		ans1 += kaijo(N - (i + 1)) * (P[i] - 1 - p);
		ans2 += kaijo(N - (i + 1)) * (Q[i] - 1 - q);
		i++;
	}
	printf("%d", abs(ans1-ans2));
	return 0;
}

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

int main()
{
    int W, H, x, y, r;

    cin >> W >> H >> x >> y >> r;

    if( x >= r && y >= r)                   // x,yがr以下ならはみ出る
        if( x + r <= W && y + r <= H )      // x+rがwこえたらはみ出る yも同様
        {
            cout << "Yes" << endl;
            return 0;
        }
    
    cout << "No" << endl;
        
    return 0;
}


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

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

  vector<int> blackLeft(N + 1);
  vector<int> whiteRight(N + 1);

  int black = 0;
  for (int i = 0; i <= N; i++) {
    blackLeft[i] = black;
    //cout << black << endl;

    if (i < N && S[i] == '#') {
      black++;
    }
  }
  int white = 0;
  for (int i = N; i >= 0; i--) {
    if (i < N && S[i] == '.') {
      white++;
    }
    whiteRight[i] = white;
  }

  int min = N;
  for (int i = 0; i <= N; i++) {
    int n = blackLeft[i] + whiteRight[i];
    if (min > n) {
      min = n;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 2172
n,m = map(int, input().split())

kl = []
sl = []
for _ in range(m):
    line = list(map(int, input().split()))
    k = line[0]
    s = line[1:]
    kl.append(k)
    sl.append(s)
p = list(map(int, input().split()))

res = 0

for i in range(2**n):
    s = []
    for j in range(n):
        if i>>j&1==1:
            s.append(j+1)
    flag = True
    for mi in range(m):
        cnt = 0
        for si in s:
            if si in sl[mi]:
                cnt += 1
        if cnt%2!=p[mi]:
            flag = False
        if not flag:
            break
    if flag:
        res += 1

print(res)


Measured memory_bytes: 3064
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N, M;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    vector<pii> seg[309];
    
    cin>>N>>M;
    rep(i,M){
        int l,r,x; cin>>l>>r>>x;
        seg[r].push_back({l,x});
    }
    
    int dp[309][309][309]={};
    dp[0][0][0]=1;
    ll ret=0;
    rep(i,N+1){
        rep(j,N+1){
            rep(k,N+1){
                int m = max(i,max(j,k));
                
                for(pii p:seg[m]){
                    int r=m;
                    int l=p.first;
                    int x=p.second;
                    
                    int cnt=0;
                    if(l<=i&&i<=r) cnt++;
                    if(l<=j&&j<=r) cnt++;
                    if(l<=k&&k<=r) cnt++;
                    if(cnt!=x) dp[i][j][k]=0;
                }
                
                if(m==N){
                    ret = (ret+dp[i][j][k])%MOD;
                    continue;
                }
                
                int num=dp[i][j][k];
                dp[m+1][j][k] = (dp[m+1][j][k]+num)%MOD;
                dp[i][m+1][k] = (dp[i][m+1][k]+num)%MOD;
                dp[i][j][m+1] = (dp[i][j][m+1]+num)%MOD;
            }
        }
    }
    cout1(ret);
}

Measured memory_bytes: 115584
//2016.7.21 「ナップザック問題」 Sae.I
#include<iostream>
using namespace std;


int main(){

	//入力
	int N;			//品物の種類
	int W;			//ナップザックの容量
	cin >> N >> W;

	int DP[N+1][W+1]; 	//メモ化テーブル

	int v[1000];		//各品物の価値
	int w[1000];		//各品物の重さ

	for(int i=0;i<N;i++)
		cin >> v[i] >> w[i];

	for(int j=0;j<=W;j++)
		DP[0][j] =0;
	

	for(int i=1;i<=N;i++)
		for(int j=0;j<=W;j++)

			if(j<w[i-1])
				DP[i][j]=DP[i-1][j];

			else{
				if(DP[i-1][j]>DP[i][j-w[i-1]]+v[i-1])
					DP[i][j]=DP[i-1][j];
				else
					DP[i][j]=DP[i][j-w[i-1]]+v[i-1];
				
			}



	cout << DP[N][W] << endl;
	return 0;
}

Measured memory_bytes: 5112
#include <iostream>
#include<cstdio>
#include<algorithm> 
#include<cstring>
using namespace std;

//#pragma warning(disable:4996)

struct res
{
	char ch[21];
	int s = -1;
	int i = -1;
};

res r[101];

bool comp(res& r1, res& r2)
{
	int c = strcmp(r1.ch, r2.ch);
	if (c < 0)return true;
	if (c > 0)return false;
	return r1.s > r2.s;
}

int n;
int main()
{
	//cin >> n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
	{
		scanf("%s", r[i].ch);
		scanf("%d", &r[i].s);
		r[i].i = i;
	}
	sort(&r[1], &r[n]+1, comp);

	for (int i = 1; i <=n; ++i)
		printf("%d\n", r[i].i);

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<string>
#include<utility>
#include<iomanip>
#include<bitset>
#include<math.h>
using namespace std;


int main(){

	string s[] = {"Sunny","Cloudy","Rainy","Sunny"};

    string in;
    cin >> in;

    for (int i = 0; i < 3; i++)
    {
        if(in == s[i]){
            cout << s[i+1] << endl;
            break;
        }
    }
    

	return 0;
}


Measured memory_bytes: 256
N=int(input())
ac=0
wa=0
tle=0
re=0

for _ in range(N):
    s=input()
    if s=='AC':
        ac+=1
    elif s=='WA':
        wa+=1
    elif s=='TLE':
        tle+=1
    else:
        re+=1

print('AC'+' x '+str(ac))
print('WA'+' x '+str(wa))
print('TLE'+' x '+str(tle))
print('RE'+' x '+str(re))


Measured memory_bytes: 74696
N, T = map(int,input().split())
t = list(map(int, input().split()))

t.append(t[-1] + T)

ans = 0
for i in range(len(t) - 1):
    if t[i+1] - t[i] >= T:
        ans += T
    else:
        ans += t[i+1] - t[i]
print(ans)


Measured memory_bytes: 25200
#include <bits/stdc++.h>
using namespace std;
static const int MOD = 1000000000+7;

int main() {
  unsigned long long x;
  cin >> x;
  unsigned long long money=100;

  long long ans = 0;
  while (money < x) {
    ans++;
    money += money * 0.01;
    // cout << money << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include <algorithm>  
using namespace std;
int main(){
	int A,B,K,c,a[100],i,j=0;
	cin >> A >> B >> K;
	c=__gcd(A,B);
	for(i=1;i<=c;i++){
		if(c%i==0)
		{
			a[j]=i;
			j++;
		}
	}
	cout << a[j-K] << "\n";
	
}

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

using namespace std;
const int maxn=1e5+5;

vector< vector<int> > ady(maxn);
int mk[maxn];

int cont=0;

void dfs(int node)
{
    mk[node]=1;

    for(int i=0; i< ady[node].size(); i++)
    {
        if(!mk[ady[node][i]])
        {
            dfs(ady[node][i]);
        }
    }
}

int main()
{
    int n,m;
    cin>>n>>m;

    for(int i=0;i<m;i++)
    {
        int a,b;cin>>a>>b;

        ady[a].push_back(b);
        ady[b].push_back(a);
    }

    for(int i=1;i<=n;i++)
    {
        if(!mk[i])
        {
            dfs(i);
            cont++;
        }
    }
    cout<<cont-1<<'\n';
}


Measured memory_bytes: 9940
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <boost/xpressive/xpressive.hpp>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;
using namespace boost;

int main() {
  string S;
  cin >> S;

  S.pop_back();
  xpressive::smatch m;
  const xpressive::sregex re = xpressive::sregex::compile("^([a-z]+)\\1");
  xpressive::regex_search(S, m, re);
  cout << m.str().length() << endl;
  return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <iomanip>

using namespace std;

int main(){
    int W, H, x, y;
    cin >> W >> H >> x >> y;
    cout << fixed << setprecision(15);
    cout << (double)W * H / 2.0 << " " << (W == x + x && H == y + y) << endl;
    return 0;
}

Measured memory_bytes: 256
fun main() {
    val (n, a, b) = readLine()!!.split(" ").map(String::toInt)
    val s = readLine()!!

    var aC = 0
    var bC = 0
    for (c in s) {
        when (c) {
            'a' -> {
                if (aC + bC < a + b) {
                    aC++
                    println("Yes")
                } else {
                    println("No")
                }
            }
            'b' -> {
                if (aC + bC < a + b && bC < b) {
                    bC++
                    println("Yes")
                } else {
                    println("No")
                }
            }
            else -> {
                println("No")
            }
        }
    }
}

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

using namespace std;

#define MAX_N 16
#define INF 1e9

int N,a[MAX_N][MAX_N+1];
int dp[MAX_N][1<<MAX_N];

int solve(int v,int S){
  if(S == (1<<N)-1){
    return dp[v][S] = 0;
  }
  if(dp[v][S] >= 0){
    return dp[v][S];
  }
  int res = INF;
  for(int i = 0 ; i < N ; i++){
    if(S >> i & 1){ continue; }
    res = min(res,solve(i,S|(1<<i))+a[i][0]);
    for(int j = 0 ; j < N ; j++){
      if(S >> j & 1){
        res = min(res,solve(i,S|(1<<i))+a[i][j+1]);
      }
    }
  }
  return dp[v][S] = res;
}

int main(){
  while(cin >> N,N){
    for(int i = 0 ; i < N ; i++){
      for(int j = 0 ; j < N+1 ; j++){
        cin >> a[i][j];
      }
    }
    memset(dp,-1,sizeof(dp));
    int res = INF;
    for(int i = 0 ; i < N ; i++){
      res = min(res,solve(i,1<<i)+a[i][0]);
    }
    cout << res << endl;
  }
  return 0;
}

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

int a[200001];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>a[i];
	long long int sum=0,ans=0;
	map<long long int,int> M;
	M[0]++;
	for(int i=1;i<=n;i++){
		sum+=a[i];
		if(M.count(sum))	ans+=M[sum];
		M[sum]++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 13568
n,d = map(int, input().split())
x = []
y = []
for i in range(n):
    temp_x, temp_y =map(int, input().split())
    x.append(temp_x)
    y.append(temp_y)

cnt = 0
for i in range(n):
    if (x[i]**2 + y[i]**2) <= d**2:
        cnt += 1
print(cnt)

Measured memory_bytes: 24912
#include <bits/stdc++.h>
 
using namespace std;
 
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
 
typedef long long tint;

const int INF = 1e6;
const long double PI = acos(-1);
 
int main() {
	int a, b, c, d, e; cin >> a >> b >> c >> d >> e;
	int mini = 10000;
	vector<int> n = {a, b, c, d, e};
	do{
		int tmp = n[0];
		forsn(i, 1, n.size()){
			int res = tmp%10;
			if(res == 0) res = 10;
			tmp = tmp+(10-res);
			tmp+=n[i]; 
		}
		mini = min(mini, tmp);
	}while(next_permutation(all(n)));
	cout << mini << endl;
}


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

int main() {
    long long N;
    long long M;
    cin >> N >> M;
    long long tot[N + M];
    for (long long i = 0; i < N; ++i) {
        tot[i] = 0;
    }
    for (long long i = N; i < (N + M); ++i) {
        tot[i] = 1;
    }
    long long good_pairs = 0;
    for (long long i = 0; i < (N + M); ++i) {
        for (long long j = i + 1; j < (N + M); ++j) {
             if ((tot[i] + tot[j]) % 2 == 0) {
                 good_pairs += 1;
             }
        }
    }
    cout << good_pairs << endl;
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){ 
    int n;
    string S,T;
    cin >> n;
    cin >> S >> T;
    string NEW = "";
    for(int i = 0; i < n; i++){
        NEW += S.substr(i,1) + T.substr(i,1);
    }
    cout << NEW << endl;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
	
	#define 	ll 						long long int
	#define 	REP(i,a,b)				for(i=a;i<=b;i++)
	#define 	REPr(i,b,a)				for(i=b;i>=a;i--)
	#define 	pb 						push_back
    #define 	mp 						make_pair
    #define 	f  						first
   	#define 	s  						second
   	#define 	umap(type1,type2)		unordered_map<type1,type2>

int mod = pow(10,9)+7;

void solve(){
	int x;	cin>>x;
	if(x>=30)	cout<<"Yes"<<endl;
	else	cout<<"No"<<endl;
}

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

	/***************************

		FuCk RATINGS I am in love with EXPERIENCE.

	***************************/

	int t;	t=1;
	while(t--)	solve();
}

int main(){
	pb_18();
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
  int n;
  scanf("%d", &n);
  switch(n%10){
  case 0:
    printf("pon\n");
    break;
  case 1:
    printf("pon\n");
    break;
  case 2:
    printf("hon\n");
    break;
  case 3:
    printf("bon\n");
    break;
  case 4:
    printf("hon\n");
    break;
  case 5:
    printf("hon\n");
    break;
  case 6:
    printf("pon\n");
    break;
  case 7:
    printf("hon\n");
    break;
  case 8:
    printf("pon\n");
    break;
  case 9:
    printf("hon\n");
    break;
  }
  return 0;
}


Measured memory_bytes: 1664
n,k = map(int,input().split())
a = list(map(int,input().split()))
l = []

for i in range(n):
    count = 0
    for j in range(i,n):
        count += a[j]
        l.append(count)

ans = 0
for i in range(44,-1,-1):
    x = 1<<i
    check = ans+x
    count = 0
    for j in l:
        if (check&j) == check:
            count += 1
    if count >= k:
        ans += x
print(ans)


Measured memory_bytes: 123792
import java.util.*;

class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int c = 0;
        int m = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n / i; j++) {
                m = n - (j * i);
                if (m == 0) {
                    continue;
                }
                c++;
            }
        }
        System.out.println(c);
    }
}


Measured memory_bytes: 35708
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll N, K; cin >> N >> K;
	map<ll, ll> mp;
	for (int i = 0; i < N; i++) {
		ll a, b; cin >> a >> b;
		mp[a] += b;
	}

	ll cnt = 0;
	for(auto x:mp) {
		cnt += x.second;
		if (cnt >= K) {
			cout << x.first << endl;
			break;
		}
	}
}


Measured memory_bytes: 7552
import math

A, B, H, M = list(map(int, input().split()))

# 分針
m_d = 360 * (M / 60)
# 時針
h_d = 360 * (((60 * H) + M) / (60 * 12))

x = abs(m_d - h_d)
y = 360 - x
C_d = min(x, y)

C = A ** 2 + B ** 2 - (2 * A * B * math.cos(math.radians(C_d)))
ans = math.sqrt(C)
print(ans)

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

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

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

typedef long long  ll;

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

int main() {
        ll N,M;
        cin>>N>>M;
        if(N==1 && M==1)cout<<1<<endl;
        else if(N==1)cout<<M-2<<endl;
        else if(M==1)cout<<N-2<<endl;
        else cout<<(N-2)*(M-2)<<endl;



    return 0;
}

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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<long long> a(n);

  int ans = 0;
  for(int i = 0; i < n; ++i){
    cin >> a[i];
    if(a[i] % 2 == 0){
      ans++;
    }
  }
  if(ans == n){
    cout << "second\n";
  }else{
    cout << "first\n";
  }

  return 0;
}


Measured memory_bytes: 1024
N=int(input())
num=0
for j in range(1,N+1,2):
    cnt=0
    for i in range(1,j+1):
#        print(i)
#        print(j)
        if j%i==0 :
            cnt=cnt+1
    if cnt==8 :
#        print(cnt)
        num+=1
    cnt=0
#    print("---")
print(num)

Measured memory_bytes: 3060
#include <stdio.h>



int main(void){
    int unko[101]={};
    int N;
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        int kari;
        scanf("%d",&kari);
        unko[kari]++;
    }
    int ans=0;
    for(int i=1;i<=100;i++)if(unko[i]!=0)ans++;
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int x, y;
string s;
int dpX[2][20005], dpY[2][20005]; //原点は10000
vector<int> X, Y;

int main(void) {
    cin >> s >> x >> y;
    x += 10000; y += 10000;
    X.pb(0); Y.pb(0);

    bool xx = true;
    int i = 0;
    while (i<sz(s)) {
        int c = 0;
        while (s[i]=='F' && i<sz(s)) {
            c++; i++;
        }
        if (xx) X.pb(c);
        else Y.pb(c);
        xx = !xx;
        i++;
    }

    //x座標が目的にたどり着けるか
    dpX[1][X[1]+10000] = 1; 
    for (int i=2; i<sz(X); i++) {
        int dx = X[i];
        for (int j=0; j<=20000; j++) {
            if (j-dx>=0) dpX[(i%2)][j] |= dpX[(i-1)%2][j-dx];
            if (j+dx<=20000) dpX[(i%2)][j] |= dpX[(i-1)%2][j+dx];
        }
        for (int j=0; j<=20000; j++) dpX[(i-1)%2][j] = 0;
    }

    //Y軸がたどり着けるか
    dpY[0][10000] = 1;
    for (int i=1; i<sz(Y); i++) {
        int dy = Y[i];
        for (int j=0; j<=20000; j++) {
            if (j-dy>=0) dpY[(i%2)][j] |= dpY[(i-1)%2][j-dy];
            if (j+dy<=20000) dpY[(i%2)][j] |= dpY[(i-1)%2][j+dy];
        }
        for (int j=0; j<=20000; j++) dpY[(i-1)%2][j] = 0;
    }

    if (dpX[(sz(X)-1)%2][x] && dpY[(sz(Y)-1)%2][y]) puts("Yes");
    else puts("No");

	return 0;
}


Measured memory_bytes: 640