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

using pii = pair<int, int>;
using ll  = long long;
#define rep(i, j) for (int i = 0; i < (int)(j); i++)
#define repeat(i, j, k) for (int i = (j); i < (int)(k); i++)
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " : " << x << endl

template <class T>
bool set_min(T &a, const T &b) {
    return a > b ? a = b, true : false;
}
template <class T>
bool set_max(T &a, const T &b) {
    return a < b ? a = b, true : false;
}
// vector
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &a : v) is >> a;
    return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &t : v) os << "\t" << t;
    return os << endl;
}
// pair
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &v) {
    return os << "<" << v.first << ", " << v.second << ">";
}

const int INF = 1 << 30;
const ll INFL = 1LL << 60;



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

    int H, W; cin >> H >> W;
    vector<string> G(H); cin >> G;
    
    vector<vector<int>> dp(H + 1, vector<int>(W + 1, INF));
    dp[0][0] = G[0][0] == '#' ? 1 : 0;
    rep(y, H) {
      rep(x, W) {
	set_min(dp[y + 1][x], dp[y][x] + (y + 1 < H and G[y + 1][x] == '#' and G[y][x] == '.'));
	set_min(dp[y][x + 1], dp[y][x] + (x + 1 < W and G[y][x + 1] == '#' and G[y][x] == '.'));
      }
    }
    // debug(dp);
    cout << min(dp[H - 1][W], dp[H][W - 1]) << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    
    vector<string> s(n);
    for(int i=0;i<n;i++) cin>>s[i];
    
    sort(s.begin(), s.end());
    s.erase(unique(s.begin(),s.end()), s.end());
    
    
    cout<<s.size()<<endl;   
}


Measured memory_bytes: 9596
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

typedef pair<long long int,int> P; //cost,to

struct vec{
    vector<P> edge;
};

vector<vec> V;

long long int dfs(int i, int pre){
    if(V[i].edge.size()==1&&V[i].edge[0].second==pre) return 0;
    long long int maxiumum=0;
    int cost=0;
    for(auto& e:V[i].edge){
        if(e.second==pre){
            cost=e.first;
            continue;
        }
        maxiumum=max(maxiumum,dfs(e.second,i));
    }
    return cost+maxiumum;
}

int main(){
    int n;
    while(cin>>n,n){
        V.clear();
        for(int i=0;i<n;i++)V.push_back(vec());
        int P[1000];
        int D[1000];
        for(int i=1;i<n;i++) cin>>P[i];
        for(int i=1;i<n;i++) cin>>D[i];
        for(int i=1;i<n;i++){
            int p=P[i]-1;
            V[i].edge.emplace_back(D[i],p);
            V[p].edge.emplace_back(D[i],i);
        }
        long long int ans=0;
        for(int i=1;i<n;i++) ans+=3*D[i];
        for(int i=0;i<n;i++){
            if(V[i].edge.size()==1) ans-=2*V[i].edge[0].first;
        }
        long long int longest=0;
        for(int i=0;i<n;i++){
            if(V[i].edge.size()==1)continue;
            longest=max(longest,dfs(i,-1));
        }
        ans-=longest;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3256
#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define FORD(i, a, b) for (int i=(a); i>(b); i--)
#define PPC(x) __builtin_popcountll(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define BACK(x) prev((x).end())
#define HASK(x, y) ((x).find(y) != (x).end())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;
 
const int maxN = 1 << 20;

void solve()
{
	int m, n;
	scanf ("%d%d", &m, &n);
	while (n--)
	{
		int a;
		scanf ("%d", &a);
		m -= a;
	}
	printf("%s\n", m <= 0 ? "Yes" : "No");
}
 
int main()
{
	int t = 1;
	//scanf ("%d", &t);
	FOR(tid, 1, t+1)
	{
		//printf("Case #%d: ", tid);
		solve();
	}
	return 0;
}





Measured memory_bytes: 3632
N, K = map(int, input().split())
D = list(map(int, input().split()))

d = set()
for i in range(K):
    d.add(str(D[i]))
# print(d)

for i in range(N, 100000):
    flag = True
    s = str(i)
    li = list(s)
    for nowletter in li:
        if nowletter in d:
            flag = False
    if flag:
        print(i)
        exit()



Measured memory_bytes: 9136
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

a=input()

if ord(a) in range(ord("a"),ord("z")+1):
    print("a")
else:
    print("A")


Measured memory_bytes: 72636
function main(input){
  input = input.split("\n");
  var n = parseInt(input[0].split(" ")[0]);
  var a = parseInt(input[0].split(" ")[1]);
  var b = parseInt(input[0].split(" ")[2]);

  console.log(n*a > b ? b : n*a);
}
 
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    ll x;
    cin >> x;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];
    sort(all(a));
    int c=0;
    rep(i,0,n) {
        if(x>=a[i]) {
            x-=a[i];
            ++c;
        }
    }
    if(c==n && x>0) --c;
    cout << c << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

// #define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
ll mod = (1000000007LL);
inline ll Mod(ll a, ll b){return (a%b);}
inline ll poww(ll a, ll b){ll res = 1;while (b > 0){if(b & 1) res = (res * a)%mod;a = (a * a)%mod;b >>= 1;}return res;}
ll gcd (ll a, ll b) { while (b) { a %= b,swap(a, b);}return a;}
void read(vector<int> &w, int n){w.resize(n);for(int i = 0; i < n; i++) cin>>w[i];}
void print(vector<int> &w){for(int i =0; i < sz(w); i++){if(i == sz(w) - 1) cout<<w[i]<<"\n";else cout<<w[i]<<" ";}}
int prodmod(vector<int> w);
int summod(vector<int> w);
///CUIDADO COM MAXN
#define N 300050

int n, m, q, k, v[N], ans;
pii w[N];
string s;

int32_t main(){
	ios::sync_with_stdio(false); cin.tie(0);
	char c;
	cin>>c;
	if('A'<=c and c<='Z') cout<<"A\n";
	else cout<<"a\n";
}
/*
    CUIDADO COM MAXN, MOD, OVERFLOW 
    >Colocar (>DEFINE INT LONG LONG<) no inicio do template
    >mod = (1e9 + 7), por padrao (NAO ESQUECER DE ALTERAR)
    >NAO ESQUECER DEFINE INT LONG LONG
    > N = 1 ? 
*/
int summod(vector<int> w){int curr=0;for(int i=0;i<sz(w); i++){curr = (curr+w[i])%mod;if(curr<0)curr+=mod;}return curr;}
int prodmod(vector<int> w){int curr = 1;
for(int i = 0; i < sz(w); i++){if(w[i] >= mod) w[i] %= mod;curr = (curr * w[i]) % mod;if(curr < 0) curr += mod;}return curr;}

Measured memory_bytes: 3596
#include<stdio.h>
#include<algorithm>
using namespace std;
int c[110000];
int z[110000];
int ret[110000];
pair<int,pair<int,int> >ev[210000];
int bit[110000];
int sum(int a,int b){
	if(a)return sum(0,b)-sum(0,a-1);
	int ret=0;
	for(;b>=0;b=(b&(b+1))-1)ret+=bit[b];
	return ret;
}
void add(int a,int b){
	for(;a<110000;a|=a+1)bit[a]+=b;
}
int L[110000];
int R[110000];
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",c+i);
		z[i]=c[i];
	}
	z[a]=-1000000000;
	z[a+1]=1000000000;
	std::sort(z,z+a+2);
	int b;scanf("%d",&b);
	for(int i=0;i<b;i++){
		int p,q,r;
		scanf("%d%d%d",&p,&q,&r);
		p--;q--;
		ev[i*2]=make_pair(p,make_pair(i,0));
		ev[i*2+1]=make_pair(q+1,make_pair(i,1));
		L[i]=min(c[p],c[q])-r;
		R[i]=max(c[p],c[q])+r;
	}
	std::sort(ev,ev+b*2);
	int now=0;
	for(int i=0;i<b*2;i++){
		int at=ev[i].first;
		int ind=ev[i].second.first;
		int type=ev[i].second.second;
		while(now<at){
			add(lower_bound(z,z+a+2,c[now])-z,1);
			now++;
		}
		if(type){
			ret[ind]+=sum(0,lower_bound(z,z+a+2,L[ind])-z-1);
			ret[ind]+=sum(upper_bound(z,z+a+2,R[ind])-z,a+1);
		}else{
			ret[ind]-=sum(0,lower_bound(z,z+a+2,L[ind])-z-1);
			ret[ind]-=sum(upper_bound(z,z+a+2,R[ind])-z,a+1);
		}
	}
	for(int i=0;i<b;i++)printf("%d\n",ret[i]);
}

Measured memory_bytes: 5876
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0xfff;
const ll maxs = 1000000000000000000;
bool cmp(int a, int b)
{
	return a > b;
}
ll gcd(ll a, ll b)
{
	return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll a[1000005];
int main()
{
	//ios::sync_with_stdio(false);
	ll a;
	long double b;
	cin >> a >> b;
	cout << (ll)(a * b) << endl;
}

Measured memory_bytes: 3728
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] head = br.readLine().split(" ");
    int h = Integer.parseInt(head[0]);
    int w = Integer.parseInt(head[1]);
    int m = Integer.parseInt(head[2]);

    int[] sum_h = new int[h];
    int[] sum_w = new int[w];
    int[][] bombs = new int[m][2];
    for(int i = 0; i < m; i++){
      String[] line = br.readLine().split(" ");
      bombs[i][0] = Integer.parseInt(line[0]) - 1;
      bombs[i][1] = Integer.parseInt(line[1]) - 1;
      sum_h[bombs[i][0]]++;
      sum_w[bombs[i][1]]++;
    }
    br.close();

    int max_sum_h = 0;
    int max_cnt_h = 0;
    for(int i = 0; i < h; i++){
      if(max_sum_h < sum_h[i]){
        max_sum_h = sum_h[i];
        max_cnt_h = 1;
      } else if(max_sum_h == sum_h[i]){
        max_cnt_h++;
      }
    }
    int max_sum_w = 0;
    int max_cnt_w = 0;
    for(int i = 0; i < w; i++){
      if(max_sum_w < sum_w[i]){
        max_sum_w = sum_w[i];
        max_cnt_w = 1;
      } else if(max_sum_w == sum_w[i]){
        max_cnt_w++;
      }
    }
    long max_bombs_pos_nominee = (long) max_cnt_h * max_cnt_w;
    for(int i = 0; i < m; i++){
      if(sum_h[bombs[i][0]] == max_sum_h && sum_w[bombs[i][1]] == max_sum_w){
        max_bombs_pos_nominee--;
      }
    }
    if(max_bombs_pos_nominee == 0){
      System.out.println(max_sum_h + max_sum_w - 1);
    } else {
      System.out.println(max_sum_h + max_sum_w);
    }
  }
}

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

using namespace std;

//#define FILE_IO

typedef pair<int, int> pii;

int N;
vector<pii> edg[100005];
int d[100005];
deque<int> q;

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    for(int i = 0; i < N; i++)  d[i] = 1 << 30;

    d[1] = 1;
    q.push_front(1);
    while(!q.empty())
    {
        int x = q.front();
        q.pop_front();

        int y = (x * 10) % N;
        if(d[y] > d[x])
        {
            d[y] = d[x];
            q.push_front(y);
        }

        y = (x + 1) % N;
        if(d[y] > d[x] + 1)
        {
            d[y] = d[x] + 1;
            q.push_back(y);
        }
    }

    printf("%d\n", d[0]);

    return 0;
}


Measured memory_bytes: 3200
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint zyo[18];
int main()
{
	lint n;int out=0;cin>>n;
	zyo[0]=1;rep(i,17) zyo[i+1]=zyo[i]*10;
	rep(i,17) REP(j,1,10){
		if(n>=zyo[i]*j-1) out=max(out,i*9+j-1);
	}
	cout<<out<<endl;
}


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

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<char> VB;

#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()

const double eps=1e-5;
const long long INF=(LL)(1e9)*(LL)(1e9);

template<class T>
void chmin(T& a, const T& b)
{
	if(a>b)
		a=b;
}
template<class T>
void chmax(T& a, const T& b)
{
	if(a<b)
		a=b;
}

const LL pow(const LL p, const LL q)
{
	LL t=1;
	REP(i,q)
		t*=p;
	return t;
}


int a[128];
LL memo[128][2];
LL dfs(int n,int e)
{
	if(n==-1) return e;
	if(memo[n][e]!=-1) return memo[n][e];

	LL ret=0;
	for(int j=a[n]-1;j<=a[n]+1;j++)
	{
		if(j%2==0)
			ret+=dfs(n-1, 1);
		else
			ret+=dfs(n-1,e);
	}
	return memo[n][e]=ret;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin>>n;
	REP(i,n)
	cin>>a[i];

	REP(i,100)
	REP(j,2)
	memo[i][j]=-1;

	cout<<dfs(n-1,0)<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>

using namespace std;
typedef pair<int,int> P;
int n;
bool ng[51][51];
int edge[51][51][51];
int used[51];

bool check(int id,int iv){
    priority_queue<P> que;
    que.push(P(id,iv));
    memset(used,-1,sizeof(used));
    while(que.size()){
        P q=que.top();
        que.pop();
        if(used[q.second]>q.first)continue;
        used[q.second]=q.first;
        for(int i=0;i<n;i++){
            int nd=q.first;
            while(nd>=0){
                if(edge[nd][q.second][i]==1)break;
                else nd--;
            }
            if(nd==-1)continue;
            if(used[i]<nd){
                used[i]=nd;
                que.push(P(nd,i));
            }
        }
    }
    for(int i=0;i<n;i++){
        if(used[i]==-1){
            return false;
        }
    }
    return true;
}

int main(void){
    while(1){
        scanf("%d",&n);
        if(n==0)break;
        memset(ng,false,sizeof(ng));
        memset(edge,0,sizeof(edge));
        for(int i=0;i<n;i++){
            int d;
            scanf("%d",&d);
            for(int j=0;j<d;j++){
                int k;
                scanf("%d",&k);
                ng[k][i]=true;
            }
        }
        for(int i=0;i<=30;i++){
            for(int j=0;j<n;j++){
                for(int k=0;k<n;k++){
                    if(ng[i][j] && ng[i][k]){
                        edge[i][j][k]=1;
                        edge[i][k][j]=1;
                    }
                }
            }
        }
        int res=31;
        bool flag=false;
        for(int d=0;d<=30;d++){
            for(int i=0;i<n;i++){
                if(!flag){
                    if(check(d,i)){
                        res=d;
                        flag=true;
                    }
                }
            }
        }
        printf("%d\n",res<=30?res:-1);
    }
}

Measured memory_bytes: 1560
// Problem : N - Slimes
// Contest : Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_n
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pb push_back
#define maxm 1e18
#define minm -1e18
#define pr pair<ll,ll>
#define mod 1000000007
 
void solve()
{
	ll n,i,j,k,len,sum=0;
	cin>>n;
	vector<ll> a(n);
	ll dp[n][n],b[n][n];
	for(i=0;i<n;i++)
		cin>>a[i],sum+=a[i];
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
		{
			dp[i][j]=maxm;
			if(i==j)
				b[i][j]=dp[i][j]=a[i];
		}
	for(len=2;len<=n;len++)
	{
		for(i=0;i<n;i++)
		{
			j=i+len-1;
			if(j>=n)
				continue;
			b[i][j]=b[i][j-1]+b[j][j];
			for(k=i;k<j;k++)
			{
				dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+b[i][j]);
			}
		}
	}
	cout<<dp[0][n-1]-sum<<endl;
}
 
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
    	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 2816
import java.util.*;
public class Main {
    public static int max(int a, int b){return (a > b ? a : b);}
    public static int min(int a, int b){return (a < b ? a : b);}
    public static int gcd(int a, int b){return (b > 0 ? gcd(b, a % b) : a);}
    public static int lcm(int a, int b){return a / gcd(a, b) * b;}
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int ans = N / 2 + N % 2;
        System.out.print(ans);
    }
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Train {
    class Class2 {
        

        static void Main(string[] args) {
            new Class2().solve();
        }
        void solve() { 
            int num_Instance = int.Parse(Console.ReadLine());
            
            for (int num = 0; num < num_Instance; num++) {
                string input = Console.ReadLine();
                List<string> data = new List<string>();
                data.Add(input.Substring(0,1));
                patrol(input , data);
                string result = "";
                for (int i = 0; i < data.Count; i++) {
                    result += data[i];
                }
                Console.WriteLine(result);
            }
        }

        void patrol(string data,List<string> order) {
            for (int i = 1; i < data.Length; i+=3) {
                string mark = data.Substring(i, 2);
                string car = data.Substring(i+2,1);
                if (mark == "->") {
                    if (!isInside(car,order)) {
                        order.Add(car);
                    }
                } else if (mark == "<-") {
                    if (!isInside(car, order)) {
                        order.Insert(0, car);
                    }
                }
            }
        }

        bool isInside(string car, List<string> order) {
            for (int i = 0; i < order.Count; i++) {
                if (car == order[i]) {
                    return true;
                }
            }
            return false;
        }
    }
}

Measured memory_bytes: 8976
import sys
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush

sys.setrecursionlimit(10**6)
INF = 10**20

def mint():
    return map(int,input().split())
def lint():
    return map(int,input().split())
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])

N = int(input())
S = input()
X = [0]*26
Y = [0]*26

for i in range(N):
    k = ord(S[i])-ord('a')
    Y[k] += 1

ans = 0
for i in range(N):
    k = ord(S[i])-ord('a')
    X[k] += 1
    Y[k] -= 1
    tmp = 0
    for j in range(26):
        if X[j]>0 and Y[j]>0:
            tmp += 1
    ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 69064
#include<map>
#include<set>
#include<ctime>
#include<cmath>
#include<queue>
#include<bitset>
#include<vector>
#include<cstdio>
#include<cctype>
#include<string>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define lc (x<<1)
#define rc (x<<1|1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define ll long long
#define pi pair<int,int>
using namespace std;
const int N=1e5+10,size=1<<20,mod=998244353;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	x=0; int f=1; char c=gc;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c))x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x<0) putchar('-'),x=-x;
	if(x>9) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {qw(x); putchar(' ');}
template<class o> void pr2(o x) {qw(x); puts("");}

//math
ll gcd(ll x,ll y) {return !x?y:gcd(y%x,x);}
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}
ll power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=c*a%mod;
		b /= 2; a=a*a%mod;
	}
	return c;
}


int T,n;

int main() {
	qr(n); n%=10;
	if(n==2||n==4||n==5||n==7||n==9) puts("hon");
	else if(n==3) puts("bon");
	else puts("pon");
	return 0;
}



Measured memory_bytes: 3640
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back

#define eb emplace_back
#define mod   1000000007
#define PI 2*acos(0.0)
#define all(r)(r).begin(),(r).end()
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define inf 1000000000000000000
#define N 2000
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};

int n,m, sx, sy, dx, dy;
ll dp[N][N];
int ck[N][N];

//=============================================ASIFAZAD==============================================//


int32_t main()
{
    io;
    int h, w, m;
    cin>>h>>w>>m;
    vi col(h+5), row(w+5);
    map<pii, bool> bomb;
    for(int i = 0;i < m; i++)
    {
        int u, v;
        cin>>u>>v;
        col[u]++;
        row[v]++;
        bomb[{u, v}] = 1;
    }
    int ma1 = -1, ma2 = -1;
    vi f, s;
    for(auto x: col)
        ma1 = max(ma1, x);
    for(auto x: row)
        ma2 = max(ma2, x);
    for(int i = 0; i<= h; i++)
    {
        if(col[i] == ma1)
            f.pb(i);
    }
    for(int i = 0; i<= w; i++)
    {
        if(row[i] == ma2)
            s.pb(i);
    }
    ll ans = ma1 + ma2 - 1;
    if(f.size()*s.size() > 300000)
        ans++;
    else
    {
        bool ck = 0;
        for(auto x: f)
        {
            if(ck)
                break;
            for(auto y: s)
            {
                if(!bomb[{x, y}])
                {
                    ck = 1;
                    break;
                }
            }
        }
        if(ck)
            ans++;
    }

    cout<<ans;
    return 0;
}

Measured memory_bytes: 28500
#include<stdio.h>
int main(){
  int n;
  int a,b,i,j;

  scanf("%d",&n);
  
  int A[n];
  
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(j=0;j<n;j++){
    if(j>0)printf(" ");
    printf("%d",A[j]);
  }
  printf("\n");
  
  for(i=1;i<n;i++){
    a=A[i];
    b=i-1;
    while(b>=0&&A[b]>a){
      A[b+1]=A[b];
      b--;
    }
    A[b+1]=a;
    for(j=0;j<n;j++){
      if(j>0)printf(" ");
      printf("%d",A[j]);
    }
    printf("\n");
  }

  return 0;
}



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

#define jaldi ios_base::sync_with_stdio(false)
#define fr(i,j,n) for(i=j;i<n;i++)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%ld",&x)
#define sll(x) scanf("%lld",&x)
#define sc(x) scanf("%c",&x)
#define ss(x) scanf("%s",x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%ld",x)
#define pll(x) printf("%lld",x)
#define pc(x) printf("%c",x)
#define ps(x) printf("%s",x)
#define vi vector<int> 
#define vl vector<long> 
#define vll vector<long long>
#define vc vector<char>  
#define vs vector<string>
#define vvi vector<vector<int>> 
#define vvll vector<vector<long long>> 
#define F first
#define S second
#define ll long long
#define pb push_back
#define ppii pair<int,int> 
#define ppll pair<long long,long long>
#define ppcc pair<char,char>
#define ppss pair<string,string> 
#define vpll vector<pair<long long,long long>>
#define PI 3.1415926535897932384626
#define precision(x) cout<<fixed<<setprecision(x) 
#define mod 998244353

int x_d[8] = {-1,1,0,0,-1,-1,1,1};
int y_d[8] = {0,0,-1,1,-1,1,-1,1};

ll power(ll b,ll e)
{
    if(b==0)
        return 0;
    
    ll r=1;
    while(e>0)
    {
        if(e%2)
            r=(r*b)%mod;
        b=(b*b)%mod;
        e/=2;
    }
    return r;
}

int main()
{
    jaldi;
    precision(20);
    
    ll n,m,ans=0,x;
    cin>>n>>m;

    ll i;
    fr(i,0,m)
    {
        cin>>x;
        ans+=x;
    }
    if(ans>n)
        cout<<-1<<endl;
    else
        cout<<n-ans<<endl;

    // cout<<2*n*PI<<endl;

    return 0;
}

Measured memory_bytes: 3620
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Ord 

main :: IO ()
main = readLn >>= print . solve

solve :: Int -> Int
solve = generate 1
    where
        generate i p
            | p == 4 || p == 2 || p == 1 =  i + 3
            | odd p = generate (i + 1) $ 3 * p + 1
            | otherwise = generate (i + 1) $ p `div` 2 

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 508
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

#define TRACE(x) std::cout << #x << " = " << x << "\n"
#define _ << " _ " <<

using namespace std;

using u64 = uint64_t;

vector<u64> reduce(vector<u64> mat, int m = 62) {
  int n = mat.size();

  vector<u64> ret;
  int r = 0;
  for (int i = 0; i < m; ++i) {
    int k = -1;
    for (int j = r; j < n; ++j) {
      if ((mat[j] >> i) & 1) {
        k = j;
        break;
      }
    }
    if (k == -1) continue;

    swap(mat[k], mat[r]);

    for (int l = 0; l < n; ++l) {
      if (l != r && ((mat[l] >> i) & 1)) {
        mat[l] ^= mat[r];
      }
    }
    ret.push_back(mat[r]);
    r++;
  }
  return ret;
}

bool solve(vector<u64>& A, string S) {
  int N = A.size();

  vector<u64> T;
  for (int i = N - 1; i >= 0; --i) {
    if (S[i] == '1') {
      T.push_back(A[i]);
      if (reduce(T).size() == T.size()) return false;
      T.pop_back();
    } else {
      T.push_back(A[i]);
      T = reduce(T);
    }
  }
  return true;
}

int main() {
  std::ios_base::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    int N;
    cin >> N;
    vector<u64> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];

    string S;
    cin >> S;

    bool ret = solve(A, S);
    cout << (ret ? '0' : '1') << '\n';
  }

  return 0;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

char str[200005];

void solve()
{
    int n, a, b, c, d;
    scanf("%d%d%d%d%d%s", &n, &a, &b, &c, &d, str); a--; b--; c--; d--;
    int i;
    if (c > d) {
        for (i = a + 1; i < b; i++) {
            if (str[i] == '#' && str[i - 1] == '#') {
                printf("No\n"); return;
            }
        }
        for (i = d + 1; i < c; i++) {
            if (str[i] == '#' && str[i - 1] == '#') {
                printf("No\n"); return;
            }
        }
        int bad = 1;
        for (i = b; i <= d; i++) {
            if (str[i+1] == '.' && str[i]=='.' &&  str[i - 1] == '.') {
                bad = 0;
            }
        }
        if (bad) {
            printf("No\n"); return;
        }
    }
    else {
        for (i = a + 1; i < c; i++) {
            if (str[i] == '#' && str[i - 1] == '#') {
                printf("No\n"); return;
            }
        }
        for (i = b + 1; i < d; i++) {
            if (str[i] == '#' && str[i - 1] == '#') {
                printf("No\n"); return;
            }
        }
    }
    printf("Yes\n");
    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 384
N = int(input())
ans = 1
for A in input().split():
    A = int(A)
    if ans == -1 and A == 0:
        ans = 0
        break
    elif ans == -1:
        continue
    else:
        ans *= A
        if ans > 10**18:
            ans = -1
print(ans)


Measured memory_bytes: 84020
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef vector<P> vp;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}
bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
    
int main(){
    int N; cin >> N;
    vvi as(2, vi(N, 0));
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < N; j ++) {
            cin >> as[i][j];
        }
    }
    
    ll ret = 0;
    for(int i = 0; i < N; i++){
        ll tmp = 0;
        for(int j = 0; j < N; j++){
            if(j <= i){
                tmp += as[0][j];
                if(j == i) tmp += as[1][j];
            }
            else tmp += as[1][j];
        }
        ret = max(ret, tmp);
    }
    cout << ret << endstr;
    return 0;
}


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

int main() {
  int D;
  cin >> D;
  vector<int> c(26);
  rep(i,26) cin >> c[i];
  vector<vector<int>> s(D,vector<int>(26,0));
  rep(i,D)rep(j,26) cin >> s[i][j];
  vector<int> t(D);
  rep(i,D) cin >> t[i];
  vector<int> v(D,0);
  vector<int> last(26,0);
  
  rep(d,D) {
    int m = 0;
    last[t[d]-1]=d+1;
    rep(j,26) m += c[j]*(d+1-last[j]);
    if(d==0) v[d] = s[d][t[d]-1] - m;
    else v[d] = v[d-1] + s[d][t[d]-1] - m;
  }
  rep(i,D) cout << v[i] << endl;
  
  return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	if(n%2!=0) cout << 2*n << endl;
	else cout << n << endl;
	return 0;
}

Measured memory_bytes: 256
k = gets.to_i
a = gets.split.map(&:to_i)
min = 2
max = 2

while (ai = a.pop) && min > 0
  #p [max,min,ai]
  if max < ai || (max/ai == min/ai && min % ai != 0 )
    min = -1
  else
  max = (max/ai+1) * ai - 1
  min = (min/(ai.to_f)).ceil * ai
  end
end
if min == -1
  puts -1
else
  print "#{min} #{max}"
end


Measured memory_bytes: 8580
#include<bits/stdc++.h>
#define mp make_pair
#define pr pair<ll,ll>
#define MAX 1000000
using namespace std;
typedef long long int ll;
#define mod 998244353
void sync(){
ios_base::sync_with_stdio;
cin.tie(NULL);
cout.tie(NULL);
}
/*
bitset<MAX> prime;
void sieve()
{ 
prime.set();
  	prime[0]=0;
  	prime[1]=0;
    for (ll p=2; p*p<=MAX; p++) 
    { 
        if (prime[p] == 1) 
        { 
            for (ll i=p*p; i<=MAX; i += p) 
                prime[i] = 0; 
        } 
    } 
} 
bool comp(vector<ll> a,vector<ll> b)
{
	if(a[0]>b[0])
	return true;
	else if(a[0]<b[0])
	return false;
	else{
		if(a[4]>b[4])
		return true;
		else return false;
	}
}
long long power(long long a,long long b){			//(a^b)%mod
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
long long fact[200005],fact_inv[200005];			//n<=2*10^5+4
void pre(){
    fact[0]=1;
    fact_inv[0]=1;
    for(long long i=1;i<200005;i++){
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
        fact_inv[i]=power(fact[i],mod-2);
    }
}
long long ncr(long long n,long long r){
    if(n<0)return 1;
    if(n<r){return 0;}
    if(n==r||r==0){return 1;}
    return (((fact[n]*fact_inv[n-r])%mod)*fact_inv[r])%mod;
    //return x; 
}
 ll exponentiation(ll base,ll exp) //fast modulo exponentiation
{ 
    if (exp == 0) 
        return 1; 
  
    if (exp == 1) 
        return base % mod; 
  
    ll t = exponentiation(base, exp / 2); 
    t = (t * t) % mod; 
    if (exp % 2 == 0) 
        return t; 
  
    else
        return ((base % mod) * t) % mod; 
} 
*/
int main(){
	sync();
	ll t;
	t=1;
	while(t--){
		ll n;
		cin>>n;
		ll a[n];
		for(ll i=0;i<n;i++)cin>>a[i];
		map<ll,ll> ck;
		for(ll i=0;i<n;i++)ck[a[i]]++;
		ll tot=0;
		for(auto i=ck.begin();i!=ck.end();i++){
			ll p=i->second;
			tot=tot+p*(p-1)/2;
		}
		ll ans=0;
		for(ll i=0;i<n;i++){
			ans=0;
			ans=tot;
			ll p=ck[a[i]];
			ans-=p*(p-1)/2;
			p--;
			if(p>1)ans+=p*(p-1)/2;
			cout<<ans<<endl;
		}
		
	}
}


Measured memory_bytes: 11008
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
int main() {
    int n,r;
    cin >> n >> r;
    if(n < 10){
        int ans = 100 * (10 - n);
        ans += r;
        cout << ans << endl;
    }else{
        cout << r << endl;
    }
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
s = list(input())

result = []
cnt = 0
cnt_b = 0
limit = a + b

for student in s:
    if student == "c":
        result.append("No")
    elif (student == "a") & (cnt < limit):
        result.append("Yes")
        cnt += 1
    elif (student == "b") & (cnt < limit) & (cnt_b < b):
        result.append("Yes")
        cnt += 1
        cnt_b += 1
    else:
        result.append("No")
print("\n".join(result))

Measured memory_bytes: 11344
#include <stdio.h>
#include <math.h>

int isPrime(int);

int main(void){

    int i, a, n, c=0, x;

    scanf("%d", &n);

    for(i=0; i<n; i++){
        scanf("%d", &x);
        if(isPrime(x) == 1) c++;
        else continue;
    }

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

    return 0;
}

int isPrime(int x){

    int i;

    if(x==2) return 1;
    if((x<2) || (x%2==0)) return 0;

    i = 3;
    while(i <= sqrt(x)){
        if(x%i==0) return 0;
        i += 2;
    }

    return 1;
}

Measured memory_bytes: 596
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    A, B, C, D, E, F = map(int, input().split())

    best = 0
    ans = (0, 0)
    for a in range(F // (100 * A) + 1):
        for b in range(F // (100 * B) + 1):
            if a == 0 and b == 0:
                continue
            for c in range(F // C + 1):
                w = 100 * (a * A + b * B)
                d = min((F - w - c * C), E * w // 100 - c * C) // D
                if d < 0:
                    continue
                s = c * C + d * D
                if best <= ((100 * s) / (w + s)):
                    best = (100 * s) / (w + s)
                    ans = (w + s, s)

    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define push_back

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,j,count=0;
    cin>>n;
    ll inf=1000015;
    vector<ll> v(n),ma(inf,0);
    for(i=0;i<n;i++)
    {
        cin>>v[i];
        ma[v[i]]++;
    }
    //sort(v.begin(),v.end());
    ll maxi=*max_element(v.begin(),v.end());
    //cout<<maxi;
    for(i=0;i<n;i++)
    {
        if(ma[v[i]])
        {
            for(j=2*v[i];j<=maxi+5;j+=v[i])
            {
                ma[j]=10;
            }
           // cout<<v[i]<<" ";
        }
    }
    for(i=0;i<n;i++)
    {
        if(ma[v[i]]<=1)
        count++;
    }
    cout<<count;
   
    return 0;
}

Measured memory_bytes: 12704
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i <= n; i++)
typedef unsigned long ul;
typedef pair<ul, ul> P;

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

    // 後ろから解くかわりにすべての文字列を「左右反転」する
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i)
        reverse(divide[i].begin(), divide[i].end());

    // 端から切っていく
    bool can = true;
    for (int i = 0; i < S.size();)
    {
        bool can2 = false; // 4 個の文字列たちどれかで divide できるか
        for (int j = 0; j < 4; ++j)
        {
            string d = divide[j];
            if (S.substr(i, d.size()) == d)
            { // d で divide できるか
                can2 = true;
                i += d.size(); // divide できたら i を進める
            }
        }
        if (!can2)
        { // divide できなかったら
            can = false;
            break;
        }
    }

    if (can)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std;
typedef pair<ll,ll> lp;
const int inf=0x3f3f3f3f;
void A() {
    char c;
    cin>>c;
    if(c<='z'&&c>='a') cout<<'a'<<endl;
    else cout<<'A'<<endl;
}
void B() {
    int n,k;
    cin>>n>>k;
    vector<int> a(n,0);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    int res=0;
    for(int i=0;i<k;i++) res+=a[i];
    cout<<res<<endl;
}
void C() {
    ll n;
    cin>>n;
    string s;
    while(n>0){
        s+=((n-1)%26+'a');
        n/=26;
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
}
void D() {
    ll n;
    cin>>n;
    unordered_map<ll,ll> cnt;
    ll sum=0;
    for(int i=0;i<n;i++) {
        ll a;
        cin>>a;
        sum+=a;
        cnt[a]++;
    }
    ll q;
    cin>>q;
    for(int i=0;i<q;i++){
        ll b,c;
        cin>>b>>c;
        if(!cnt.count(b)){
            cout<<sum<<endl;
            continue;
        }
        sum+=(c-b)*cnt[b];
        cnt[c]+=cnt[b];
        cnt.erase(b);
        cout<<sum<<endl;
    }
}
void E(){

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


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


int main() {
  int n, cnt=0;
  cin >> n;
  for(int i=1;i<=n;i++) {
    int a;
    cin >> a;
    if(i%2==1 && a%2==1) cnt++;
  }
  cout << cnt << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
const int MOD = 1e9+7;
const int maxn = 200010;
int n, a[maxn];
string s;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t = 1;
    //cin >> t;
    while(t--)
    {
        cin >> s;
        if(s=="RRR") cout << 3 << "\n";
        else if(s.substr(0, 2)=="RR" or s.substr(1, 2)=="RR") cout << 2 << "\n";
        else if(s[0]=='R' or s[1]=='R' or s[2]=='R') cout << 1 << "\n";
        else cout << 0 << "\n";
    }
}


Measured memory_bytes: 3652
import sys
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

N = int(input())
A = [int(x) for x in input().split()]

AS = [[a,idx+1] for idx,a in enumerate(A)]
AS.sort()

for a in AS:
	print(a[1], end=" ")

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

int main() {
  string S;
  cin >> S;
  if (S == "hi" || S == "hihi" || S == "hihihi" 
      || S == "hihihihi" || S == "hihihihihi") {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
loop do
    r, n = gets.split.map(&:to_i)
    break if r == 0 && n == 0
    b = n.times.map{gets.split.map(&:to_i)}
    h = Array.new(41,0)
    b.each do |xl,xr,ht|
        (xl+20).upto(xr+19) do |x|
            h[x] = [ht,h[x]].max
        end
    end
    ans = Float::INFINITY
    (-r+20).upto(r+19) do |xl|
        xr = xl + 1
        dl = 20 - xl
        dr = 20 - xr
        ret1 = r - Math.sqrt(r * r - dl * dl) + h[xl]
        ans = ret1 if ret1 < ans
        ret2 = r - Math.sqrt(r * r - dr * dr) + h[xl]
        ans = ret2 if ret2 < ans
    end
    puts sprintf('%.4f',ans)
end

Measured memory_bytes: 6164
import java.util.*;
import java.io.*;
import java.lang.*;
// ArrayList<Integer>[] arr=new ArrayList[n];
public class Main{	
public static void main(String[] args) throws FileNotFoundException, IOException{
        Scanner s = new Scanner(System.in);
         StringBuilder sb=new StringBuilder();
         BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
         int n=s.nextInt(),w=s.nextInt();
        int[][] arr=new int[n+1][2];
        long[][] dp=new long[100001][101];
        
        for(int i=1;i<100001;i++){
            Arrays.fill(dp[i],(long)1e13); 
        }
       // dp[0][0]=0;
        //dp[i][j] hold- minimum wt needed to get i values given j objects
        for(int i=1;i<=n;i++){
            arr[i][0]=s.nextInt(); arr[i][1]=s.nextInt();
        }

        for(int i=1;i<100001;i++){
            for(int j=1;j<=n;j++){
                if(arr[j][1]<=i){
                    dp[i][j]=Math.min(dp[i][j-1],arr[j][0]+dp[i-arr[j][1]][j-1]);
                }
                else{
                    dp[i][j]=dp[i][j-1];
                }
                //else{dp[j]=(long)1e13;}
            }
        }
        int res=0;
        for(int i=1;i<100001;i++){
            if(dp[i][n]<=w){res=i;}
        }       
        System.out.println(res);
    }
}

Measured memory_bytes: 129620
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

// N以下の素数を全て求める
set<long> get_primes(long N) {
  vector<bool> nums(N + 1, true);
  nums[0] = false;
  nums[1] = false;
  long i = 2;
  while (true) {
    while (i < nums.size() and not nums[i]) i++;
    if (i == nums.size()) break;
    for (long j = i * 2; j < nums.size(); j += i) nums[j] = false;
    i++;
  }
  set<long> ret;
  rep (i, nums.size()) if (nums[i]) ret.insert(i);
  return ret;
}

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

  auto primes = get_primes(55555);

  vector<long> ans;
  for (auto it: primes) if (it % 5 == 1) ans.push_back(it);

  bool flag = false;
  rep (i, N) {
    if (flag) cout << " ";
    flag = true;
    cout << ans[i];
  }
  cout << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#define int long long
using namespace std;
int test[51];
signed main() {
    int n;
    while (cin >> n) {
        cout << "3C";
        if (n % 39 == 0) {
            cout << 39 << endl;
        }
        else if (n % 39 <= 9) {
            cout << 0 << n % 39 << endl;
        }
        else {
            cout << n % 39 << endl;
        }
    }
}


Measured memory_bytes: 3084
while true
  n = gets.to_i
  break if n == 0
  a,b = 0,0
  n.times do
    ca,cb = gets.split.map{|s|s.to_i}
    ca == cb ? (a+=ca;b+=cb) : (ca>cb ? a += ca+cb : b += ca+cb)
  end
  puts"#{a} #{b}"
end

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

int min2nd(int a, int b, int c) {
  return
    ((a>b)?
      ((b>c)?
        b:
        ((a>c)?c:a)):
      ((a>c)?
        a:
        ((b>c)?c:b)));
}

int main() {
  int n, p[20], count=0;
  cin >> n;
  for(int i=0; i<n; ++i) cin >> p[i];
  for(int i=1; i<n-1; ++i)
    if(min2nd(p[i-1],p[i],p[i+1])==p[i])
      count++;
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
if __name__ == "__main__":
    a, b = list(map(int, (input().split(' '))))
    buf_ls = []
    buf = 0
    buf2 = b - a
    for i in range(0, 1000):
        buf += i+1
        buf_ls.append(buf)
        if buf2 == (i+1):
            print(buf_ls[i] - b)
            sys.exit()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int INF = 1e8;
struct edge{ int to,cap,rev; };
vector<edge> G[5000];
bool used[5000];

void init_edge(){
  for(int i=0;i<5000;i++){
    G[i].clear();
  }
}

void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,(int)G[to].size()});
  G[to].push_back((edge){from,0,(int)G[from].size()-1});
}

int dfs(int v,int t,int f){
  if(v==t)return f;
  used[v]=true;
  for(int i=0;i<(int)G[v].size();i++){
    edge &e=G[v][i];
    if(!used[e.to]&&e.cap>0){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
        e.cap-=d;
        G[e.to][e.rev].cap+=d;
        return d;
      }
    }
  }
  return 0;
}
int max_flow(int s,int t){
  if(s==t)return INF;
  
  int flow=0;
  while(1){
    memset(used,0,sizeof(used));
    int f=dfs(s,t,INF);
    if(f==0)break;
    flow+=f;
  }

  return flow;
}


int N,M;
char c[100][100];
int di[]={-1,0,1,0};
int dj[]={0,1,0,-1};

int calc(int y,int x){
  return y*M+x;
}

void make_graph(){
  init_edge();  
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      int flg=1;
      if( i==0 && j== 0)flg=2;
      if( i==0 && j==M-1)flg=2;
      if( i==N-1 && j==0)flg=2;
      if( i==N-1 && j==M-1)flg=2;
      add_edge( calc(i,j) , calc(i,j) + N*M , flg);
      
      for(int dir=0;dir<4;dir++){
        int ni=i+di[dir];
        int nj=j+dj[dir];
        if(ni<0 || nj<0 || ni>=N || nj>=M)continue;
        if(c[ni][nj]=='#')continue;
        if(c[i][j]=='#')continue;
        
        add_edge( calc(i,j)+N*M , calc(ni,nj) , 1);
      }
    }
  }
}

int main(){
  while(1){
    cin>>N>>M;
    if(N==0&&M==0)break;
    
    for(int i=0;i<N;i++){
      for(int j=0;j<M;j++){
        cin>>c[i][j];
      }
    }

    make_graph();
    if( max_flow( calc(0,0) , calc(N-1,M-1)+N*M ) < 2){
      cout<<"NO"<<endl;
      continue;
    }


    
    make_graph();
    if( max_flow( calc(0,M-1) , calc(N-1,0)+N*M ) < 2){
      cout<<"NO"<<endl;
      continue;
    }

    cout<<"YES"<<endl;
  }

  return 0;
}

Measured memory_bytes: 4092