akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  vector<int> h(n);
  int xt = 0;
  int yt = 0;
  int ht = 0;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> h[i];
    if (h[i] >= 1) {
      xt = x[i];
      yt = y[i];
      ht = h[i];
    }
  }

  for (int cx = 0; cx < 101; cx++) {
    for (int cy = 0; cy < 101; cy++) {
      const int H = max(ht + abs(xt - cx) + abs(yt - cy), 0);
      bool found = true;
      for (int i = 0; i < n; i++) {
        const int v = max(H - abs(x[i] - cx) - abs(y[i] - cy), 0);
        if (h[i] != v) {
          found = false;
          break;
        }
      }
      if (found) {
        cout << cx << " " << cy << " " << H << endl;
        return 0;
      }
    }
  }
  return 0;
}


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

int main() {
    string S;
    cin >> S;
    int cnt = 0, N = S.size();
    int ans[N] = {};
    rep(c, 2) {
        int cnt = 0;
        rep(i, N) {
            if (S[i] == 'R') {
                cnt++;
            } else {
                ans[i] += cnt / 2;
                ans[i-1] += (cnt + 1) / 2;
                cnt = 0;
            }
        }

        reverse(ans, ans + N);
        reverse(S.begin(), S.end());
        rep(j, N) S[j] = (S[j] == 'R' ? 'L' : 'R');
    }

    rep(i, N) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60;
const ll mod=1000003 ;

int main(){
  int h,w,k;
  cin >> h >> w >> k;
  char c[h][w];
  rep(i,h)rep(j,w)cin >> c[i][j];
  int a[h][w]={};
  bool flag[h]={};
  rep(i,h){
    int cnt=0;
    vector<int> pos;
    rep(j,w){
      if(c[i][j]=='#'){
        cnt++;
        pos.push_back(j);
      }
    }
    if(cnt>0){
      int kk=pos.size();
      rep(j,kk-1){
        REP(k,pos[j]+1,w){
          a[i][k]++;
        }
      }
    }else flag[i]=true;
  }
  int p[h][w]={};
  int num=0;
  rep(i,h){
    if(!flag[i]){
      rep(j,w){
        p[i][j]=a[i][j]+num+1;
      }
      num=p[i][w-1];
    }
  }
  rep(i,h){
    if(!flag[i]){
      int temp=i;
      while(temp>0 && flag[temp-1]){
        rep(j,w){
          p[temp-1][j]=p[temp][j];
        }
        flag[temp-1]=false;
        temp--;
      }
    }
  }
  for(int i=h-1;i>=0;i--){
    if(!flag[i]){
      int temp=i;
      while(temp+1<h && flag[temp+1]){
        rep(j,w){
          p[temp+1][j]=p[temp][j];
        }
        flag[temp+1]=false;
        temp++;
      }
    }
  }
  if(flag[h-1])rep(j,w)p[h-1][j]=p[h-2][j];
  rep(i,h){
    rep(j,w)cout << p[i][j] << ' ';
    cout << endl;
  }
return 0;}

Measured memory_bytes: 1536
#include <stdio.h>
long long a [100010];
int main (){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%lld",&a[i]);
int zero =0;
for(int i=0;i<n;i++)if(a[i]==0) zero ++;
if(zero >0){
// a[i] contains 0
printf("0\n");
return 0;
}
long long prod =1;
for(int i=0;i<n;i++){
if(a[i ] <=1000000000000000000/ prod ){
// This condition is equivalent to prod*a[i] <=10ˆ18
prod *=a[i];
}else{
printf("-1\n");
return 0;
}
}
printf("%lld\n",prod );
}

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


vector<int> seieve_Eras(int n){
    vector<int>a(n,1);vector<int>v;
    for(int i=2;i*i<=n;i++){
        if(a[i]==1){
            for(int j=i*i;j<n;j+=i)
                 a[j]=0;
        }
    }
    for(int i=2;i<n;i++)
    if(a[i]==1)
    v.push_back(i);
    return v;
}
struct listnode{
 int val;
 listnode*  next;};
 vector<int> func( vector<int> a,vector<int>l,int sum){
      vector<int>k,val;
       for(int i=0;i<l.size();i++)
           if(l[i]==0){
            k.push_back(i);
            val.push_back(a[i]);}
   if(sum<0)
   return a;
  else {
      sort(val.rbegin(),val.rend());
      for(int i=0;i<k.size();i++)
         a[k[i]]=val[i];}
         return a;

 }
 


int32_t main(){
 int m=1000000007;
    string s;
    cin>>s;
    string t;
    if(s[s.size()-1]=='s')
      t="es";
      else
      {
        t="s";
      }
      cout<<s<<t<<endl;
      
    
return 0;
}

Measured memory_bytes: 3632
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,c; cin>>n>>c;
    vector<vector<int>> data(30,vector<int>(100001,0));
    rep(i,n){
        int s,t,C; cin>>s>>t>>C;
        data[C-1][s-1]++;
        data[C-1][t-1]--;
    } 
    rep(i,30)rep(j,100000){
        if(data[i][j+1]==1){
            data[i][j+1]--;
            data[i][j]++;
        }
    }
    int ans=0;
    rep(i,30) ans+=data[i][0];
    rep(i,100000){
        int cnt=0;
        rep(j,30){
            data[j][i+1]+=data[j][i];
            cnt+=data[j][i+1];
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 12416
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <string>

using namespace std;

const int N = 100010;

int a[N], b[N];//砍，扔
int n, h, cnt, ma = -111111;

int main()
{
	cin >> n >> h;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i] >> b[i];
		ma = max(ma, a[i]);//记录砍伤害的最大值
	}
	
	sort(b + 1, b + n + 1);
	
	for(int i = n; i >= 1; i--)
		if(b[i] >= ma && h > 0)//把超过砍伤害值的刀全扔出去
		{
			cnt++;
			h -= b[i];
		}
	
	if(h > 0)//还有剩余血量就用ma继续砍
	{
		if(h % ma) cnt += h / ma + 1;
		else cnt += h / ma;
	}
	cout << cnt << endl;
	
	return 0;
}

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

typedef long long i64;
typedef i64 ll;


i64 bin[5010];
i64 MOD = 1e9 + 7;
ll inv_mod( ll a, ll m = MOD )
{
  ll b, x, u, q, abs_m, tmp; 

  abs_m = ( m < 0 ) ? -m : m;
  b = m; x = 1; u = 0; 
  while ( b > 0 ) {
    q = a / b; 
    tmp = u; u = x - q * u; x = tmp;
    tmp = b; b = a - q * b; a = tmp;
  }

  return ( x < 0 ) ? abs_m + x : x;
}

i64 mod(i64 num)
{
	return num % MOD;
}

i64 dp[5010][5010];

int n;
int m;
string s;

int main()
{
	cin >> n >> s;
	int m = s.length();

	int cou = n - m;

	bin[0] = 1;

	for(int i = 1;i <= 5000;i++)
	{
		bin[i] = mod(bin[i - 1] * 2);
	}

	dp[0][0] = 1;
	//n time"s
	for(int i = 1;i <= n;i++)
	{
		for(int j = 0;j <= n;j++)
		{
			if(j == 0)
			{
				dp[i][j] = mod(dp[i - 1][j] + dp[i - 1][j + 1]);
			}
			else
			{
				dp[i][j] = mod(dp[i - 1][j - 1] * 2 + dp[i - 1][j + 1]);
			}
			////cout << i << " " << j << "=" << dp[i][j] << endl;
		}
	}

	//cout << dp[n][m] << "/" << inv_mod(bin[m]) << endl;

	cout << mod(dp[n][m] * inv_mod(bin[m])) << endl;
}


Measured memory_bytes: 195968
// Oh boi here we go again
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;

#define all(s) s.begin(), s.end()
#define ok puts("ok")
#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define pi pair < int, int >
#define pii pair < int, pi >
#define next next123
#define left left123

const int N = 2e5 + 7;
const ll mod = 1e9 + 7;

ll c[N];
ll ans = 0;
int n;

ll binpow (ll v, ll pw){
    if (pw == 0)
        return 1LL;
    if (pw % 2 == 0){
        ll r1 = binpow(v, pw / 2);
        return (r1 * r1) % mod;
    }
    else
        return (v * binpow(v, pw - 1)) % mod;
}

main(){
    cin >> n;
    for (int i = 1; i <= n; i++){
        scanf("%lld", &c[i]);
    }
    sort(c + 1, c + n + 1);
    ll ans = 0;
    for (int i = 1; i < n; i++){
        ll x = n - i + 1;
        ans += (((((2LL * c[i]) % mod * binpow(2LL, 2LL * n - 2LL * x)) % mod * (((x - 1LL) * binpow(2LL, x - 2LL)) % mod + binpow(2LL, x - 1LL) - 1LL) % mod) % mod * binpow(2LL, x - 1LL)) % mod) % mod;
        while(ans < 0);
        ans %= mod;
        ans += (((2LL * c[i]) % mod * binpow(2LL, 2LL * n - 2LL * x)) % mod * binpow(2LL, x - 1LL)) % mod;
        while(ans < 0);
        ans %= mod;
    }
    ll x = 1LL;
    ans += (((2LL * c[n]) % mod * binpow(2LL, 2LL * n - 2LL * x)) % mod * binpow(2LL, x - 1LL)) % mod;
    ans %= mod;
    cout << ans;
}


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

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  int d = B / K;
  if (d * K >= A) {
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PI  3.14159265358979323846
#define M   1000000007
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }
    }
}
ll f(ll x,ll y)
{
    ll pro=1;
    for(ll i=x;i<=y;i++)
    {
        pro=((pro%M)*(i%M))%M;
    }
    return pro;
}
int main()
{
 ll n,R;
 cin>>n>>R;
 if(n>=10)
 {
     cout<<R;
 }
 else
 {
     ll p=100*(10-n);
     cout<<R+p;
 }

}












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

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


bool p(int n)
{
	string s;
	stringstream ss;
	bool flag=true;
	ss<<n;
	ss>>s;
	for(int i=0;i<s.length()/2;i++)
	{
		if(s[i]!=s[s.length()-1-i])flag=false;
	}
	if(flag)return true;
	else return false;
}

int main()
{	
	int a,b,sum=0;
	cin>>a>>b;
	for(int i=a;i<=b;i++)
	{
		if(p(i))sum++;
	}
	cout<<sum<<endl;
	return 0;	
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
//#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

  ll a,b;

  cin>>a>>b;

  //vector<ll> keta(40);
  ll ext[2][40];
  vector<ll> ans(40,0);
  
  ll aa=0;

  for( ll i = 0; b >> i > 0 ; i++){
    //cout << a % (1LL << i+2) << ',' << b % (1LL << i+2) << endl;
    ext[0][i]=a % (1LL << i+1);
    ext[1][i]=(b+1) % (1LL << i+1);
    //cout << ext[0][i] << ',' << ext[1][i] << endl;
    if( i==0 ){
      if(a==0){
        ans[i] = b/2 + b%2;
        ans[i] %= 2;
      }
      else{
        ans[i] = b/2 + b%2 - (a-1)/2 - (a-1)%2;
        ans[i] %= 2;
      }
      
    }
    else{
      //cout << max( ext[0][i]-(1LL << i) , 0LL ) << ',' << max( ext[1][i]-(1LL << i) , 0LL ) << endl;
      ans[i] = max( ext[1][i]-(1LL << i) , 0LL ) - max( ext[0][i]-(1LL << i) , 0LL );
      ans[i] %=2;
      ans[i] = abs(ans[i]);
    }
    //cout << ans[i] << endl;
    aa+= ans[i] << (i);
  }
  //cout << endl;

  cout << aa << endl;
    
  return 0;
}


Measured memory_bytes: 256
x,y = map(int,input().split())
ans = 10**10
for i in [[-1,1],[1,0]]:
    for j in [[-1,1],[1,0]]:
        if x*i[0] <= y*j[0]:
            ans = min(ans,y*j[0]-x*i[0]+i[1]+j[1])
print(ans)

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k - 1] += 'a' - 'A';
    cout << s << endl;
}

Measured memory_bytes: 892
import java.io.PrintWriter

//private val inp = java.io.File("in")
private val inp = System.`in`
private val reader = inp.bufferedReader()
private val wr = PrintWriter(System.out.bufferedWriter())

private fun readLn(): String = reader.readLine()
private fun readInt(): Int = readLn().toInt()
private fun readStrs(): List<String> = readLn().split(" ")
private fun readInts(): IntArray = readStrs().map { it.toInt() }.toIntArray()
private fun readChars(): CharArray = readStrs().map { it.single() }.toCharArray()
private fun readLongs(): LongArray = readLn().map { it.toLong() }.toLongArray()

fun main() {
    val (n, m) = readInts()
    val a = readInts()

    var sum = 0L;
    for (i in a) sum += i
    val r = n - sum

    println(if (r < 0) -1 else r)
}

Measured memory_bytes: 38552
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	d := nextInt()
	t := nextInt()
	s := nextInt()

	df := float64(d)
	tf := float64(t)
	sf := float64(s)

	// fmt.Fprintf(out, "%f\n", df/sf)

	if df/sf <= tf {
		fmt.Fprintf(out, "%s\n", "Yes")
	} else {
		fmt.Fprintf(out, "%s\n", "No")
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func quickSort(val []int) []int {
	if len(val) < 2 {
		return val
	}

	pivot := val[0]

	left := []int{}
	right := []int{}

	for _, v := range val[1:] {
		if pivot > v {
			left = append(left, v)
		} else {
			right = append(right, v)
		}
	}

	left = quickSort(left)
	right = quickSort(right)

	ret := append(left, pivot)
	ret = append(ret, right...)

	return ret
}


Measured memory_bytes: 1812
#include <iostream>
#define Q 100005
using namespace std;
typedef long long ll;
int n,q,u,t[Q],p[Q];
bool marked[Q];
char c[Q];
ll ans;

int find(int x){
  if(marked[x]) return x;
  return p[x]=find(p[x]);
}

int main(){
  while(1){
    cin>>n>>q;
    if(!n&&!q) break;
    for(int i=1;i<=n;i++) marked[i]=false;
    for(int i=2;i<=n;i++) cin>>u,p[i]=u;
    marked[1]=true;
    for(int i=0;i<q;i++){
      cin>>c[i]>>t[i];
      if(c[i]=='M'){
	if(marked[t[i]]) c[i]='E';
	marked[t[i]]=true;
      }
    }
    ans=0;
    for(int i=q-1;i>=0;i--){
      if(c[i]=='E') continue;
      if(c[i]=='M') marked[t[i]]=false;
      else ans+=find(t[i]);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2284
n = int(input())
city = []
nums = []
result = []

for i in range(n):
  s,p = input().split()
  p = int(p)
  city.append(s)
  nums.append(p)
  result.append([s,p,i+1])

for i in sorted(set(city)):
  for j in sorted(set(nums), reverse = True):
    for k in result:
      if k[0] == i and k[1] == j:
        print(k[2])

Measured memory_bytes: 9116
n = int(input())
s = ["" for _ in range(n)]
for i in range(n):
    s[i] = str(input())
    s[i] = s[i][0]

march = ["M","A","R","C","H"]
march_num = [0,0,0,0,0]

for i in range(len(s)):
    if s[i] in march:
        march_num[march.index(s[i])] += 1
ans = 0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            ans += (march_num[i]*march_num[j]*march_num[k])
print(ans)

Measured memory_bytes: 3984
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1)/ (y))
#define MOD 1000000007ULL

s64 W, H, x, y;


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

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

    double area = (double)(W * H) / 2.0;
    cout << setprecision(9) << area << " " << (((W == 2 * x) && (H == 2 * y)) ? 1 : 0) << "\n";

    return 0;
}



Measured memory_bytes: 256
#gcdは3.4.3だとfractionsにある
from fractions import gcd

from math import factorial as f

from math import ceil,floor,sqrt

from sys import exit

from copy import deepcopy
import numpy as np

import bisect
import re


ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))



def main():
    kisuu = ['R','U','D']
    guusuu = ['L','U','D']
    flag = True
    
    s = input()
    for e,i in enumerate(s):
        if not e % 2:
            if not i in kisuu:
                flag = False
        else:
            if not i in guusuu:
                flag = False
    if flag:
        print('Yes')
    else:
        print('No')




main()


Measured memory_bytes: 13540
#include<bits/stdc++.h>
using namespace std;
long long dp[101][100001];
int n;
long long funs(int w[],int v[],int s,int wt){
   if(s==-1 || wt==0) return 0; 
   if(dp[s][wt]!=-1) return dp[s][wt];
   if(w[s]<=wt){
         return dp[s][wt]=max(funs(w,v,s-1,wt-w[s])+v[s],funs(w,v,s-1,wt));
   }
   return dp[s][wt]=funs(w,v,s-1,wt);
      
}
int main(){
  int i,j,wt;
  memset(dp,-1,sizeof(dp));
  cin>>n>>wt;
  int w[n],v[n];
  for(i=0;i<n;i++){
    cin>>w[i]>>v[i];
  }
  long long ans=funs(w,v,n-1,wt);
  cout<<ans;
  
 
}

Measured memory_bytes: 82384
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> iP;
typedef pair< LL, LL > LP;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 300005;

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );
            if( i * i != n ) ret.pb( n / i );

        }
    }
    sort( all( ret ) );
    return ret;
}

LL dp[105][100005];

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

        int N, W;
        cin >> N >> W;
        vector< LP > v(N + 1);
        for( int i = 1; i <= N; ++i ) {
                cin >> v[i].F >> v[i].S;

        }

        for( int i = 0; i <= N; ++i ) {
                for( int j = 1; j < 100005; ++j ) {
                        dp[i][j] = LINF;

                }
        }

        for( int i = 1; i <= N; ++i ) {
                for( int j = 1; j < 100005; ++j ) {
                        if( j < v[i].S ) {
                                dp[i][j] = dp[i - 1][j];

                        } else {

                                if( j == v[i].S ) {
                                        dp[i][j] = v[i].F;

                                } else {
                                        dp[i][j] = min(dp[i][j], dp[i - 1][j]);
                                        if( dp[i - 1][j - v[i].S] == LINF ) continue;
                                        else dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i].S] + v[i].F);

                                }
                                dp[i][j] = min(dp[i][j], dp[i - 1][j]);
                        }
                }
        }

        LL res = 0;
        for( int i = 1; i < 100005; ++i ) {
                if( dp[N][i] <= W ) {
                        res = i;

                }
        }

        /*
        for( int i = 1; i <= N; ++i ) {
                for( int j = 1; j <= 30; ++j ) {
                        cout << dp[i][j] << " ";

                }
                cout << endl;
        }*/

        cout << res << endl;
    return 0;
}



Measured memory_bytes: 80256
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int GCD(int x,int y){
    int r=x%y;
    while(r>0){
        x=y;
        y=r;
        r=x%y;
    }
    return y;
}

int main(){
    int n;
    scanf("%d",&n);
    vector<int> a(n+1,0);
    int i;
    scanf("%d",&a[1]);
    int ans=a[1];
    for(i=2;i<=n;i++){
        scanf("%d",&a[i]);
        ans=GCD(ans,a[i]);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <map>
#include <string>
#include <math.h>
using namespace std;


int main() {

    string s,t;
    cin >> s >> t;
    int a,b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(u==s){
        a--;
    }else if(u==t){
        b--;
    }

    cout << a << " " << b <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int n;
    cin >> n;
    vector<pii> arr(n);

    int a;
    rep(i,n){
        cin >> a;
        arr[i] = make_pair(i,a);
    }

    sort(arr.begin(),arr.end(),[](const pii &a, const pii &b){
        return a.second < b.second;
    });

    rep(i,n){
        cout << arr[i].first+1 << " ";
    }
    cout << endl;


    return 0;
}

Measured memory_bytes: 1664
import bisect
import collections
import functools
import heapq
import math
from collections import deque
from collections import defaultdict
MOD = 10**9+7

N,M = map(int,(input().split()))
lines = [[] for _ in range(N+1)]
for i in range(M):
    a,b = map(int,(input().split()))
    lines[a].append(b)
    lines[b].append(a)

stack = deque()
stack.append((1,1))
not_visit = [True]*(N+1)
ans = [0]*(N+1)
while stack:
    now = stack.popleft()
    if not_visit[now[0]]:
        not_visit[now[0]] = False
        ans[now[0]] = now[1]
        for room in lines[now[0]]:
            if not_visit[room]:
                stack.append((room,now[0]))

flag = 0
for i in not_visit[1:]:
    if i:
        flag = 1
        break

if flag == 1:
    print("No")
else:
    print("Yes")
    for i in ans[2:]:
        print(i)

Measured memory_bytes: 104460
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;

char func(int code){
	switch(code){
	case 11:return 'a';
	case 12:return 'b';
	case 13:return 'c';
	case 14:return 'd';
	case 15:return 'e';
	case 21:return 'f';
	case 22:return 'g';
	case 23:return 'h';
	case 24:return 'i';
	case 25:return 'j';
	case 31:return 'k';
	case 32:return 'l';
	case 33:return 'm';
	case 34:return 'n';
	case 35:return 'o';
	case 41:return 'p';
	case 42:return 'q';
	case 43:return 'r';
	case 44:return 's';
	case 45:return 't';
	case 51:return 'u';
	case 52:return 'v';
	case 53:return 'w';
	case 54:return 'x';
	case 55:return 'y';
	case 61:return 'z';
	case 62:return '.';
	case 63:return '?';
	case 64:return '!';
	case 65:return ' ';
	default:return '*';
	}
}


int main(){

	char buf[201],result[101],tmp;
	int p;
	bool NA_FLG;

	while(scanf("%s",buf)!=EOF){
		p = 0;
		NA_FLG = false;

		for(int i=0; buf[i] != '\0';){
			if(buf[i+1] != '\0'){
				tmp = func(10*(buf[i]-'0')+(buf[i+1])-'0');
				if(tmp == '*'){
					NA_FLG = true;
					break;
				}
				result[p++] = tmp;
				result[p] = '\0';
				i += 2;
			}else{
				NA_FLG = true;
				i++;
			}
		}

		if(NA_FLG)printf("NA\n");
		else{
			printf("%s\n",result);
		}
	}

    return 0;
}

Measured memory_bytes: 2544
def main():
  from collections import deque
  s,*c=open(0)
  h,w=map(int,s.split())
  f=[-1]*h*w
  q=deque()
  a,p=q.append,q.popleft
  for i,c in enumerate(''.join(t[:w]for t in c)):
    if c=='#':
      a(i)
      f[i]=0
  while q:
    i=p()
    v=f[i]+1
    j,k,l,m,u=i+w,i-w,i+1,i-1,i%w
    if h*w>j and f[j]<0:
      a(j)
      f[j]=v
    if k>=0 and f[k]<0:
      a(k)
      f[k]=v
    if w>u+1and f[l]<0:
      a(l)
      f[l]=v
    if u and f[m]<0:
      a(m)
      f[m]=v
  print(v-1)
if __name__=='__main__':
  main()

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

int main(){
  ll n,p;
  cin>>n>>p;
  ll ans=1;
  for(ll i=2;i*i<=p;i++){
    if(p%i==0){
      int x=0;
      while(p%i==0){
        p/=i;
        x++;
      }
      if(x>=n){
        ans*=pow(i,x/n);
      }
    }
  }
  if(p>1){
    if(n==1){
      ans*=p;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4116
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
bool data[5001][5001];
bool isOK(int x,int y){
  return x >= 0 && x < 5001 && y >= 0 && y < 5001 && data[x][y];
}
int main(){
  int n;
  int x[3000], y[3000];
  while(scanf("%d", &n) , n){
    memset( data,false,sizeof(data));
    for(int i = 0 ; i < n ; i++ ){
      scanf("%d %d",&x[i],&y[i]);
      data[x[i]][y[i]] = true;
    }
    int ret = 0;
    for(int i = 0 ; i < n ; i++ ){
      for(int j = 0 ; j < i ; j++ ){
        int xx = x[j] - x[i];
        int yy = y[j] - y[i];
        if(isOK(x[i] + yy,y[i] - xx) & isOK(x[j] + yy,y[j] - xx))
          ret = max( ret, xx * xx + yy * yy);
      }
    }
    printf("%d\n",ret);
  }
}

Measured memory_bytes: 25480
import sys

sys.setrecursionlimit(300000)


def I(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())


def LMI(): return list(map(int, sys.stdin.readline().split()))


def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))


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

from string import ascii_lowercase

N = I()
ans = ''
for i in range(1, 99):
    if N <= 26 ** i:
        N -= 1
        for j in range(i):
            ans += chr(ord('a') + N % 26)
            N //= 26
        break
    else:
        N -= 26 ** i
print(ans[::-1])


Measured memory_bytes: 71952
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int x; cin >> x;
  cout << (x^1);
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <complex>
#define repi(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) repi(i, 0, n)
#define endl "\n"
#define ing long long
using namespace std;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    //  cin.tie(0);
    //ios::sync_with_stdio(false);

    while(true){
        vector<pair<int,pair<int,int>>> c;
        vector<int> ans;
        int n, w, d, h;
        int p, s, num = 0;

        cin>>n>>w>>d;

        if(!n && !w && !d) break;

        c.push_back(make_pair(-1,make_pair(w,d)));

        for(int i = 0; i < n; i++){
            sort(c.begin(), c.end());
            pair<int,int> p1, p2;
            cin>>p>>s;
            
            p--;
            w = c[p].second.first;
            h = c[p].second.second;


            //   if(h == 0 || w == 0) cout<<"9804375043 "<<endl;
            //else
                s %= (h*2+w*2);

            num = s;
            
            if(s <= w){
                p1 = make_pair(num, h);
                p2 = make_pair(w-num,h);
            } else if(w <= s && s <= w+h){
                num -= w;
                // p1 = make_pair(num, h);
                //p2 = make_pair(w-num,h);
                
                p1 = make_pair(w, num);
                p2 = make_pair(w,h-num);
            } else if( w+h <= s && s <= w*2+h){
                num -= w+h;
                // p1 = make_pair(w, num);
                // p2 = make_pair(w,h-num);
                p1 = make_pair(num, h);
                p2 = make_pair(w-num,h);
                
            } else {
                num -= w*2+h;
                p1 = make_pair(w, num);
                p2 = make_pair(w,h-num);
                }
             if(p1.first*p1.second > p2.first*p2.second) swap(p1,p2);

             c.erase(c.begin()+p);
            c.push_back(make_pair(i,p1));
            c.push_back(make_pair(i,make_pair(p2.first,p2.second)));
        }

        for(int i = 0; i < c.size(); i++){
            ans.push_back(c[i].second.first*c[i].second.second);
            //cout<<c[i].first<<" "<<c[i].second<<endl;
        }
        
        sort(ans.begin(), ans.end());
        for(int i = 0; i < ans.size(); i++){
            if(i) cout<<" ";
            cout<<ans[i];
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3164
M,D = map(int,input().split())
count =0

for m in range(1,M+1):
    for d in range(21,D+1):
        d_10 = d//10
        d_1 = d%10
        if d_1 >1:
            if m == d_10 * d_1:
                count += 1
print(count)

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

int main(){
	
	int n;
	cin >> n;
	double p[n+1];
	for(int i=1;i<=n;i++) cin >> p[i];

	double dp[n+1][n+1];
	// dp[i][j] ---> prob. of i heads till jth toss

	for(int i=1;i<=n;i++) dp[i][0] = 0;
	dp[0][0] = 1;
	for(int j=1;j<=n;j++){
		dp[0][j] = (1.0-p[j]) * dp[0][j-1];
	}
	
	for(int j=1;j<=n;j++){
		for(int i=1;i<=n;i++){
			double head = p[j]*dp[i-1][j-1];
			double tail = (1.0-p[j]) * dp[i][j-1];
			dp[i][j] = head + tail;
		}
	}

	double ans=0.0;
	for(int i=0;i<=n;i++){
		if(i > n-i) ans += dp[i][n];
	}
	// cout << "dp:" << endl;
	// for(int i=0;i<=n;i++){
	// 	for(int j=0;j<=n;j++) cout << fixed << setprecision(4) << dp[i][j] << " ";
	// 		cout << endl;
	// } cout << endl;

	cout << fixed << setprecision(10) << ans << endl;

	return 0;
}

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

vector<int> X[505];

int main() {
    
    int N, M, Q;
    cin >> N >> M >> Q;
    
    while(M--)
    {
        int L, R;
        cin >> L >> R;
        X[L].push_back(R);
    }
    
    for(int i=1; i<=N; i++)
        sort(X[i].begin(), X[i].end());
    
    while(Q--)
    {
        int L, R;
        cin >> L >> R;
        
        int ans = 0;
        
        for(int i=L; i<=R; i++)
            ans += upper_bound(X[i].begin(), X[i].end(), R) - X[i].begin();
        
        cout << ans << "\n";
    }
    
    return 0;
}


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

using namespace std;

int main(void) {
  int n;
  cin >> n;

  int sn = 0;
  int tmp = n;
  for(int i = 1000000000; i > 0; i /= 10) {
    sn += n / i;
    n -= (n / i) * i;
  }
  if(tmp % sn == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;
public class Main {

        public static void main(String[] args) throws java.io.IOException{
            Scanner scan = new Scanner(System.in);
            int n=scan.nextInt();
            while(n!=0){
            	BigInteger bi1 = new BigInteger(scan.next());
            	BigInteger bi2 = new BigInteger(scan.next());
            	BigInteger ans =bi1.add(bi2);
            	if(ans.toString().length()<=80)
            	System.out.println(ans);
            	else System.out.println("overflow");
            	n--;
            }
        }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int N = 1000 + 5;
 
int main()
{
	int z;
	for(int i = 1; i <= 5; i++){
		int x;
		cin >> x;
		if(x == 0)
			z = i;
	}
	cout << z << endl;
    return 0; 
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<ll>;
const ll mod = 998244353ll;
int k, n;
vector<string> a;
bool cc;
bool check(string& s) {
	int c;
	for(auto &i : a) {
		c = 0;
		for(int j = 0; j < n; j++)
			c += s[j] != i[j];
		if(c&&c!=2)
			return false;
//		if(cc==false&&c==0)
//			return false;
	}
	return true;
}

int main() {
	ios::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	ll a, b;
	cin >> a >> b;
	ll g = __gcd(a, b);
	ll ans = 1;
	for(ll i = 2; i*i <= g; i++) {
		if(g%i) continue;
		ans++;
		while(g%i == 0) g/=i;
	}
	if(g > 1) ans++;
	cout << ans;
}


Measured memory_bytes: 384
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	cout<<c/a*b<<endl;
	rt0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll D, N;
    cin >> D >> N;
    string s;
    for(ll i = 0; i < D; i++) s += "00";
    cout << (N == 100 ? 101 : N) << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int isintersecter(double x1,double y1,double x2,double y2,double px,double py,
		  double qx,double qy){
  if(((py-y1)*(x1-x2)-(y1-y2)*(px-x1))*((qy-y1)*(x1-x2)-(y1-y2)*(qx-x1)) < 0)return 1;
  else return 0;
}
int main(){
  double x1,y1,x2,y2,x3,y3,xp,xy;
  while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>xy)
    {
      if(isintersecter(x1,y1,x2,y2,x3,y3,xp,xy) || 
	 isintersecter(x2,y2,x3,y3,x1,y1,xp,xy) || 
	 isintersecter(x1,y1,x3,y3,x2,y2,xp,xy) )cout << "NO" << endl;
      else cout << "YES" << endl;
    }
}

Measured memory_bytes: 1212
N=int(input())
a=list(map(int,input().split()))
mod = 10**9+7
ruiseki = 0
total=sum(a)
ans = 0
for i in range(N-1):
    ruiseki += a[i]
    ans += a[i] * (total- ruiseki) % mod

print(ans % mod)


Measured memory_bytes: 31512
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define PI 3.1415926535897932384626
#define mod 1000000007
#define fo(i,n) for(i=0;i<n;i++)
#define endl "\n"
#define mset(m,v) memset(m,v,sizeof(m))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
typedef vector<int>	vi;
#define FAST_IO  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

void solve()
{
	int n;
	cin >> n;
  if(n==0)
	cout <<  1;
 else 
   cout << 0;
}

int32_t main()
{
	FAST_IO;
	int t=1;//cin>>t;
	for(int i=1;i<=t;i++){	solve();}
	return 0;
}

Measured memory_bytes: 3648
fun main(args: Array<String>) {
  val (N, K) = readLine()!!.split(" ").map { it.toInt() }
  val A = readLine()!!.split(" ").map { it.toInt() }
  println((N - 1) / (K - 1) + (if ((N - 1) % (K - 1) > 0) 1 else 0))
}


Measured memory_bytes: 47976
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,VI(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n, m, k, x, y , z = 0, h, ans=0, w, sum = 0, Max = -1, Min = 1e9+1;
  string u= "";
  bool ok=true;
  cin >> n;
  VI a(n); rep(i,n) cin >> a[i];
  deque<int> deq;
  if(n%2==0){
    rep(i,n){
      if(i%2==0){
        deq.push_back(a[i]);
      }
      else{
        deq.push_front(a[i]);
      }
    }
  }
  else{
    rep(i,n){
      if(i%2!=0){
        deq.push_back(a[i]);
      }
      else{
        deq.push_front(a[i]);
      }
    }
  }
  for_each(deq.begin(), deq.end(), [](int x) {
    cout << x << " ";
  });
  
  return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    char in[500];
    int ans_max=0,ans_long=0;
    string s_max,s_long;
    map<string,int> mm;
    
    while(EOF!=scanf("%s",in)){
        
        string S = in;
        
        if((int)S.size() > ans_long){
            s_long = S;
            ans_long = (int)S.size();
        }
        
        mm[S]++;
    }
    
    for(map<string,int>::iterator it = mm.begin();it!=mm.end();it++){
        if( (it->second) > ans_max ){
            ans_max = it->second;
            s_max = it->first;
        }
    }
    
    cout << s_max <<  " " << s_long << endl;
    
    return 0;
}


Measured memory_bytes: 3112
import sys
input = sys.stdin.readline
n = int(input())
t,x,y = 0,0,0
for i in range(n):
    t_,x_,y_ = map(int,input().split())
    X = abs(x_ - x)
    Y = abs(y_ - y)
    T = t_ - t
    if ( X + Y > T ) or (T % 2 != ( X + Y ) % 2):
        print("No")
        exit()
    t = t_
    x = x_
    y = y_
print("Yes") 

Measured memory_bytes: 3064
#include <stdio.h>

int main ()
{
    int A, B;
    int Ad, S, M;

    scanf("%d %d", &A, &B);

    Ad = A + B;
    S = A - B;
    M = A * B;

    if (Ad > S && Ad > M)
    {
        printf("%d\n", Ad);
    }
    else if (S > Ad && S > M)
    {
        printf("%d\n", S);
    }
    else if (M > Ad && M > S)
    {
        printf("%d\n", M);
    }
    else
    {
        printf("%d\n", A);
    }

    return 0;
}


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

int main() {
int n;
cin >> n;
int num = n%10;
	switch (num) {
		case 1:
			cout << "pon";
			break;
		case 2:
			cout << "hon";
			break;
		case 3:
			cout << "bon";
			break;
               case 4:
			cout << "hon";
			break;
               case 5:
			cout << "hon";
			break;
              case 6:
			cout << "pon";
			break;
             case 7:
			cout << "hon";
			break;
            case 8:
			cout << "pon";
			break;
            case 9:
			cout << "hon";
			break;
            case 0:
			cout << "pon";
			break;
	}
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
int compare(string a, string b) {
	int i;
	for (i = 0; i < a[i] != '\0'; i++) {
		if (b[i] == '\0')
			return -1;
		else if (a[i] < b[i])
			return 1;
		else if (a[i] > b[i])
			return -1;
	}
	if (b[i] != '\0')
		return 1;
	else
		return 0;
}
int main() {
	int n, i, c[111],p[111],j,k,t;
	char s[111][111],mins[111];
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> s[i] >> p[i];
		c[i] = 0;
	}
	for (i = 0; i < n; i++) {
		for (k = 0; k < 100; k++)
			mins[k] = 'z';
		for (j = 0; j < n; j++) {
			if (c[j] == 0) {
				if (compare(mins, s[j]) == -1) {
					t = j;
					for (k = 0; s[j][k] != '\0'; k++)
						mins[k] = s[j][k];
					mins[k] = '\0';
				}
				else if (compare(mins, s[j]) == 0) {
					if (p[t] < p[j]) {
						t = j;
						for (k = 0; s[j][k] != '\0'; k++)
							mins[k] = s[j][k];
						mins[k] = '\0';
					}
				}
			}
		}
		c[t] = i + 1;
	}
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			if (c[j] == i + 1)
				cout << j + 1 << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include<math.h>
using namespace std;

int main()
{
    int a , h , m , s;
    a = h = m = s = 0;

    cin >> a;
    int  i =a;
    while(i>=3600){
        i -= 3600;
        h +=1;
    }
    while (i>=60) {
        i -= 60;
        m +=1;
    }
    s = i;

    cout << h << ":" << m << ":" << s << endl;
}

Measured memory_bytes: 1168
#include <iostream>
#include <cstring>
#include <cstdlib>

/*
問題文
シカのAtCoDeerくんは二つの正整数 
a, b  を見つけました。 
a と b をこの順につなげて読んだものが平方数かどうか判定してください。

制約
1 ≤ a, b ≤ 100
a, b  は整数

入力
入力は以下の形式で標準入力から与えられる。
a b

出力
a と b をこの順につなげて読んだものが平方数なら Yes を、 そうでないなら No を出力せよ。

*/

int main()
{
    char sa[7], sb[4];
    int n = 0;
    std::cin >> sa >> sb;
    std::strcat(sa, sb);
    n = atoi(sa) ;

    for (int i = 0; i < 1000; ++i)
    {
        if ( i * i == n)
        {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    std::cout << "No" << std::endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
     
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
 
            String s = sc.next();

            StringBuilder sb = new StringBuilder();
            for(int i = 0; i < s.length(); i++){
                String subS = s.substring(i, i + 1);
                if(subS.equals("B")){
                    if(sb.length() != 0){
                        sb.setLength(sb.length() - 1);
                    }
                }else{
                    sb.append(subS);
                }
            }

            System.out.println(sb.toString());
 
        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000000)
#define MOD (1000000007)
#define MAX (110)

/////////////////////////////////////////////////////////

int BS(vector<ll> v, ll left, ll right, ll key){
  ll mid = (left + right) / 2;
  if(v[mid] <= key) left = mid;
  else right = mid;
  if(right - left == 1) return left;
  return BS(v, left, right, key);
}

void chmin(ll &a, ll b) {if(a > b) a = b;}

void Main() {
  ll A, B, Q; cin >> A >> B >> Q;
  vector<ll> s(A), t(B), x(Q);
  rep(i, 0, A) cin >> s[i];
  rep(i, 0, B) cin >> t[i];
  rep(i, 0, Q) cin >> x[i];

  rep(i, 0, Q){
    ll res = INF;
    ll key = x[i];
    ll sl, sr, tl, tr;
    sr = upper_bound(all(s), key) - s.begin();
    sl = sr - 1;
    tr = upper_bound(all(t), key) - t.begin();
    tl = tr - 1;
    if(sl >= 0 && tl >= 0) chmin(res, min(abs(key - s[sl]), abs(key - t[tl])) + abs(s[sl] - t[tl]));
    if(sl >= 0 && tr <  B) chmin(res, min(abs(key - s[sl]), abs(key - t[tr])) + abs(s[sl] - t[tr]));
    if(sr <  A && tl >= 0) chmin(res, min(abs(key - s[sr]), abs(key - t[tl])) + abs(s[sr] - t[tl]));
    if(sr <  A && tr <  B) chmin(res, min(abs(key - s[sr]), abs(key - t[tr])) + abs(s[sr] - t[tr]));
    cout << res << endl;
  }
}

/////////////////////////////////////////////////////////

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

  Main();
}


Measured memory_bytes: 3712
N = str(input())
L = [int(x) for x in list(N)]

if L[0] + L[1] + L[2] + L[3] == 7:
    print('{}+{}+{}+{}=7'.format(L[0], L[1], L[2], L[3]))
elif L[0] + L[1] + L[2] - L[3] == 7:
    print('{}+{}+{}-{}=7'.format(L[0], L[1], L[2], L[3]))
elif L[0] + L[1] - L[2] + L[3] == 7:
    print('{}+{}-{}+{}=7'.format(L[0], L[1], L[2], L[3]))
elif L[0] - L[1] + L[2] + L[3] == 7:
    print('{}-{}+{}+{}=7'.format(L[0], L[1], L[2], L[3]))
elif L[0] + L[1] - L[2] - L[3] == 7:
    print('{}+{}-{}-{}=7'.format(L[0], L[1], L[2], L[3]))
elif L[0] - L[1] + L[2] - L[3] == 7:
    print('{}-{}+{}-{}=7'.format(L[0], L[1], L[2], L[3]))
elif L[0] - L[1] - L[2] + L[3] == 7:
    print('{}-{}-{}+{}=7'.format(L[0], L[1], L[2], L[3]))
elif L[0] - L[1] - L[2] - L[3] == 7:
    print('{}-{}-{}-{}=7'.format(L[0], L[1], L[2], L[3]))

Measured memory_bytes: 3064