akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 998244353
#define INF 98765431219876543
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

ll H, W;
vector<ll> f[501], e;
vector<string> ret;
void o(int y2, int x2, int y3, int x3) {
  int by = y2, bx = x2;
  bool flag = true;
  for (int i = y2; i <= y3; i++) {
    for (int j = x2; j <= x3; j++) {
      if (flag) {
        flag = false;
        continue;
      }
      ostringstream ss;
      ss << by << " " << bx << " " << i << " " << j;
      ret.pb(ss.str());
      by = i, bx = j;
    }
  }
}

int main() {
  cin >> H >> W;
  REP(i, H) {
    REP(j, W) {
      ll a;
      cin >> a;
      if (a % 2) {
        f[j].pb(i);
      }
    }
  }

  REP(i, W) {
    if (f[i].size() % 2 == 1) {
      o(f[i].back() + 1, i + 1, H, i + 1);
      e.pb(i);
      f[i].pop_back();
    }

    REP(j, f[i].size()) {
      if (j % 2 == 0) {
        o(f[i][j] + 1, i + 1, f[i][j + 1] + 1, i + 1);
      }
    }
  }

  if (e.size() % 2)
    e.pop_back();

  REP(i, e.size()) {
    if (i % 2)
      continue;
    o(H, e[i] + 1, H, e[i + 1] + 1);
  }

  cout << ret.size() << endl;
  for (auto &b : ret) {
    cout << b << endl;
  }
}

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

int main(){
    ll n;
    cin>>n;
    stack<char> s;
    while(n!=0){
        int rem=n%26;
        if(rem==0){s.push('z');n=n-26;}
        else {s.push('a'+rem-1);n=n-rem;}
        n=n/26;
    }
    while(!s.empty()){
        cout<<s.top();
        s.pop();
    }
    return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        int B = scan.nextInt();
        int K = scan.nextInt();
        int gcd = gcd(A, B);
        int n = 0;
        int answer = 0;
        for(int i = gcd; n < K; i-- ) {
            if (gcd % i == 0) {
                n += 1;
                answer = i;
            }
        }
        System.out.println(answer);
    }
    private static int gcd(int m, int n) {
        if (n == 0) {
            return m;
        }
        return gcd(n, m%n);
    }
}


Measured memory_bytes: 23636
#include<string>
#include<iostream>
#include<algorithm>

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

using namespace std;

int main(){
	const string Kan[]={
		"a","b","c","d","e","f","g","h","i","j","k","l","m",
		"n","o","p","q","r","s","t","u","v","w","x","y","z",
		"ld","mb","mp","nc","nd","ng","nt","nw","ps","qu","cw","ts"
	};

	int ans[38][38]={};

	int T; cin>>T; cin.ignore();
	while(T--){
		string s; getline(cin,s);
		int len=s.length(),pre=-1;
		rep(i,len){
			if(s[i]==' ') pre=-1;
			else{
				int j;
				for(j=37;;j--) if(s[i]==Kan[j][0] && (Kan[j].length()==1 || i<len-1 && s[i+1]==Kan[j][1])) break;
				if(~pre) ans[pre][j]++;
				pre=j;
				if(Kan[j].length()==2) i++;
			}
		}
	}

	rep(i,38){
		int j=max_element(ans[i],ans[i]+38)-ans[i];
		cout<<Kan[i]<<' '<<Kan[j]<<' '<<ans[i][j]<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

//Multi-column List
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int line = sc.nextInt();
			if(line==0)break;
			int col = sc.nextInt();
			int w = sc.nextInt();
			int space = sc.nextInt();
			String sp = "";
			while(sp.length()<space)sp+=".";
			sc.nextLine();
			boolean con = true;
			String s = "";
			while(con){
				if("".equals(s)){
					s = sc.nextLine();
					if("?".equals(s))break;
				}
				String[][] res = new String[col][line];
				for(int c=0;c<col;c++){
					for(int l=0;l<line;l++){
						res[c][l] = "";
						if(!con){
							while(res[c][l].length()<w)res[c][l]=res[c][l]+".";
							continue;
						}
						if("".equals(s)){
							s = sc.nextLine();
							if("?".equals(s)){
								con = false;
								s = "";
							}
						}
						int t = Math.min(s.length(), w);
						res[c][l] = s.substring(0, t);
						while(res[c][l].length()<w)res[c][l]=res[c][l]+".";
						s = s.substring(t, s.length());
					}
				}
				for(int l=0;l<line;l++){
					for(int c=0;c<col;c++){
						System.out.print(res[c][l]+(c==col-1?"\n":sp));
					}
				}
				System.out.println("#");
			}			
			System.out.println("?");
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
import java.util.*;

public class Main{
    public static void main(String args[])
    {
    	boolean ans=true;
        Scanner sc=new Scanner(System.in);     
        int size=sc.nextInt();
        int elements[]=new int[ size];
        for(int i=0;i<size;i++)
        {
        	elements[i]=sc.nextInt();
        	   	
        }
        Arrays.sort(elements);
        for(int j=size-1;j>0;j--)
        {
        if(elements[j]==elements[j-1])
        {
        	ans=false;
        	break;
        }
        }
        
        if(ans)
       System.out.println("YES");
        else
        {
        	System.out.println("NO");
        	
        
        }
        
        sc.close();
        
    }
    
}

Measured memory_bytes: 65708
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  int res;
  if(b == 100){
    res = a * 1000 + 100;
  }else if(b >= 10){
    res = a * 100 + b;
  }else{
    res = a * 10 + b;
  }
  bool flag = false;
  int i = 1;
  while(i * i <= res){
    if(i * i == res) flag = true;
    i++;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($N,$X) = explode(" ",trim(fgets(STDIN)));
$x = explode(" ",trim(fgets(STDIN)));
if ($X == 1) {
  printf("%d\n",$x[0]-$X);
  exit;
}
$f = $X;
foreach($x as $v) {
  $l[]=abs($f-$v);
  $f = $v;
}
printf("%d\n",array_reduce($l,'gcd'));

function gcd($a,$b) {
  if ($b == 0) return $a;
  return gcd($b,$a%$b);
}
function lcm($a,$b) {
  $l = gcd($a,$b);
  return $a / $l * $b;
}


Measured memory_bytes: 35420
n = int(input())
aka = [[0 for i in range(2*n)] for j in range(2*n)]
for i in range(n):
    a, b = map(int,input().split())
    aka[a][b] = 1
ao = [tuple(map(int,input().split())) for i in range(n)]
ao.sort()
ans = 0
for x , y in ao:
    flag = False
    for j in reversed(range(y)):
        if flag:
            break
        for i in reversed(range(x)):
            if aka[i][j] == 1:
                ans += 1
                aka[i][j] = 0
                flag = True
                break
print(ans)


Measured memory_bytes: 9440
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (H, W, N): (i64, i64, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };
    let (a, b): (Vec<i64>, Vec<i64>) = {
        let (mut a, mut b) = (vec![], vec![]);
        for _ in 0..N {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            a.push(iter.next().unwrap().parse().unwrap());
            b.push(iter.next().unwrap().parse().unwrap());
        }
        (a, b)
    };

    let p = (0..N)
        .map(|i| (a[i], b[i]))
        .collect::<std::collections::HashSet<_>>();
    let mut dp = vec![0; 10];
    for k in 0..N {
        let (y, x) = (a[k], b[k]);
        for u in std::cmp::max(1, y - 2)..(std::cmp::min(H - 2, y) + 1) {
            for l in std::cmp::max(1, x - 2)..(std::cmp::min(W - 2, x) + 1) {
                dp[(u..(u + 3))
                    .map(|i| (l..(l + 3)).filter(|&j| p.contains(&(i, j))).count())
                    .sum::<usize>()] += 1;
            }
        }
    }
    for i in 1..10 {
        dp[i] /= i as i64;
    }
    let ans = (0..10)
        .map(|i| {
            if i == 0 {
                ((H - 2) * (W - 2) - dp.iter().sum::<i64>()).to_string()
            } else {
                dp[i].to_string()
            }
        })
        .collect::<Vec<_>>()
        .join("\n");

    println!("{}", ans);
}


Measured memory_bytes: 12540
#include<bits/stdc++.h>
using namespace std;
#define pi 2*acos(0.0)
int main()
{
	long long int n;
	int m,x;
	long int sum = 0;
	scanf("%lld %d",&n,&m);
	while(m--)
	{
		cin>>x;
		sum+=x;
	}
	if(n-sum<0)printf("-1\n");
	else
		printf("%lld\n",(n-sum));

	return 0;
}

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

int main(){
	int a,b,c,d,i;

	cin>>a>>b>>c>>d;

	for(i=0;a>0 && c>0;i++){
		i%2 ? a-=d : c-=b;
	}

	cout<< (a<=0 ? "No" : "Yes") <<endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<limits>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define x first
#define y second

long double angle(pair<int,int> a, pair<int,int> b){
	static long double PI = acos(-1);
	long double inner_product = a.x*b.x + a.y*b.y, absa = sqrt(a.x*a.x + a.y*a.y), absb = sqrt(b.x*b.x + b.y*b.y);
	long double c = inner_product/(absa*absb);
	return fabs(acos(c)/PI)*180;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int n;
	vector<int>  per;
	vector<pair<long double, long double>> shop;
	long double ans = numeric_limits<long double>::max();
	
	cin>>n;
	
	shop.resize(n+1);
	per.resize(n+2);
	
	for(int i = 1; i <= n; per[i] = i, i++)
		cin>>shop[i].x>>shop[i].y;
	
	do{
		long double sum = 0;
		pair<long long, long long> nd, d = {1,0};
		
		for(int i = 0; i <= n; d = nd, i++){
			nd = make_pair(shop[per[i+1]].x - shop[per[i]].x, shop[per[i+1]].y - shop[per[i]].y);
			sum += angle(d,nd);
		}
		
		ans = min(ans, sum);
		
	} while(next_permutation(per.begin()+1, per.end()-1));
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 3360
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
int n, dp[200009], rb[200009], opt[(1 << 26) + 9]; string s;
int main() {
	cin >> s;
	n = s.size();
	for (int i = 0; i < 26; i++) rb[i] = (1 << i);
	int curbit = 0;
	for (int i = 1; i < 1 << 26; i++) opt[i] = inf;
	for (int i = 0; i < n; i++) {
		curbit ^= 1 << (s[i] - 97);
		dp[i + 1] = inf;
		for (int j = 0; j < 27; j++) {
			dp[i + 1] = min(dp[i + 1], opt[curbit ^ rb[j]] + 1);
		}
		opt[curbit] = min(opt[curbit], dp[i + 1]);
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 263556
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int h,w; cin >> h >> w;
  vector<string> a(h);
  rep(i,h) cin >> a[i];
  vector<vector<bool>> check(h,vector<bool>(w,true));
  
  rep(i,h){
    bool b = true;
    rep(j,w){
      if(a[i][j] == '#') b = false;
    }
    if(b){
      rep(k,w) check[i][k] = false;
    }
  }
  rep(j,w){
    bool b = true;
    rep(i,h){
      if(a[i][j] == '#') b = false;
    }
    if(b){
      rep(k,h) check[k][j] = false;
    }
  }
  
  rep(i,h){
    bool b = false;
    rep(k,w){
      if(check[i][k]) b = true;
    }
    if(b){
      rep(j,w){
        if(check[i][j]) cout << a[i][j];
      }
      cout << endl;
    }
  }
  
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  bool tf = false;
  string ans = "WA";
  if (s[0] == 'A') {
    if (find(s.begin(), s.end(), 'C')>=s.begin()+2 and find(s.begin(), s.end(), 'C') <= s.end()-2) {
      string temp(s);
      temp.erase(temp.begin()+0);
      temp.erase(find(temp.begin(), temp.end(), 'C'));
      string low(temp);
      transform(low.begin(), low.end(), low.begin(), ::tolower);
      if (temp == low) ans = "AC";
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
int AM[100][100];
int color[100], d[100], f[100], time;

void DFS();
void DFS_visit(int);

int main(){
  int i, j, u, k, v;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      AM[i][j] = 0;
    }
  }

  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j = 0 ; j < k ; j++){
      scanf("%d",&v);
      v--;
      AM[u][v] = 1;
    }
  }
  
  DFS();

  return 0;
}

void DFS(){
  int i;
  for(i = 0 ; i < n ; i++){
    color[i] = WHITE;
  }

  time = 0;

  for(i = 0 ; i < n ; i++){
    if(color[i] == WHITE) DFS_visit(i);
  }

  for(i = 0 ; i < n ; i++){
    printf("%d %d %d\n",i+1, d[i],f[i]);
  }
}

void DFS_visit(int x){
  int i;
  
  color[x] = GRAY;
  d[x] = ++time;
  for(i = 0 ; i < n ; i++){
    if(AM[x][i] ==  0) continue;
    if(color[i] == WHITE){
      DFS_visit(i);
    }
  }
  color[x] = BLACK;
  f[x] = ++time;
}



Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
const int MOD = 1e9+7;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

int dp[100010][2];

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    string S; cin >> S;
    dp[0][0]=1;
    rep(i,SZ(S)){
        if(S[i]=='0'){
            dp[i+1][0]=dp[i][0];
            dp[i+1][1]=(dp[i][1]*3)%MOD;
        } else {
            dp[i+1][1]=(dp[i][0]+dp[i][1])%MOD;
            (dp[i+1][0] += dp[i][0]*2%MOD) %=MOD;
            (dp[i+1][1] += dp[i][1]*2%MOD) %=MOD;
        }
    }

    cout << (dp[SZ(S)][0]+dp[SZ(S)][1])%MOD << endl;

}

Measured memory_bytes: 2000
#include <iostream>
#include <set>

int main() {
    int N;
    std::cin >> N;
    std::set<int> s;
    for (int i = 0; i < N; ++i) {
        int e;
        std::cin >> e;
        s.insert(e);
    }

    int Q;
    std::cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int k;
        std::cin >> k;
        std::cout << s.count(k) << std::endl;
    }
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a){cout<<((a)?"Yes":"No")<<endl;}
void YESNO(int a){cout<<((a)?"YES":"NO")<<endl;}
void AorB(int a,string b,string c){cout<<((a)?b:c)<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int n;
    cin>>n;
    cout<<180*(n-2)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>

#define MAX 1000

using namespace std;

bool isEmpty();
bool isFull();
void push(int x);
int pop();

int top = 0;
int S[MAX];

int main(void)
{
	int a, b;
	char s;
	while(scanf("%s", &s) != EOF){
		switch(s){
		case '+':
			a = pop();
			b = pop();
			push(a + b);
			break;
		case '-':
			b = pop();
			a = pop();
			push(a - b);
			break;
		case '*':
			a = pop();
			b = pop();
			push(a * b);
			break;
		default:
			push(atoi(&s));
			break;
		}
	}
	cout << pop() << endl;
	return 0;
}

bool isEmpty(){
	if(top) return false;
	else return true;
}

bool isFull(){
	if(top >= MAX - 1) return true;
	else return false;
}

void push(int x){
	if(isFull()) cout << "?????????????????????" << endl;
	++top;
	S[top] = x;
	
}

int pop(){
	if(isEmpty()) cout << "??¢??????????????????" << endl;
	--top;
	return S[top + 1];
}

Measured memory_bytes: 1168
n=int(input())

ans='Yes'
dt=0
cur=0
cur_t=0
dist=0
for i in range(n):
	t,x,y=map(int,input().split())
	dist=abs(cur-(x+y))
	cur=x+y
	dt=t-cur_t
	cur_t=t
	
	if dist>dt or dt%2!=(dist)%2:
		ans='No'
		break
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdint.h>

int
main(void)
{
	int i, j, k, n, m, l;
	int a[100][100] = {};
	int b[100][100] = {};
	int64_t c[100][100] = {};

	scanf("%d%d%d", &n, &m, &l);

	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++)
			scanf("%d", &a[i][j]);

	for (i = 0; i < m; i++)
		for (j = 0; j < l; j++)
			scanf("%d", &b[i][j]);

	for (i = 0; i < n; i++)
		for (j = 0; j < l; j++)
			for (k = 0; k < m; k++)
				c[i][j] += a[i][k] * b[k][j];

	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++)
			printf("%s%ld", j > 0 ? " " : "", c[i][j]);
		printf("\n");
	}

	return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int a,b; cin >> a>>b;
  int s = a+b;
  int m = a-b;
  int d = a*b;
  cout << max(s,max(m,d)) << endl;

  return 0;
}


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

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)

//AB^2=AC^2+BC^2-2*AC*BC*COSC

signed main(){
    int A,B,C,K;

    int sum=0;

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

    while(K!=0&&A!=0){
        K--;
        A--;
        sum++;
    }
    while(K!=0&&B!=0){
        K--;
        B--;
    }
    while(K!=0&&C!=0){
        K--;
        C--;
        sum--;
    }
    cout<<sum<<endl;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

int main()
{
    ll n;
    cin>>n;
    ll ma=0;
    ll ans=0;
    rep(i,n){
        ll a,b;
        cin>>a>>b;
        if(a>ma){
            ans=a+b;
            ma=a;
        }
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 3604
<?php
fscanf(STDIN, "%d%d", $H, $W);
for($y = 0; $y < $H; $y++){
    fscanf(STDIN, "%s", $str);
    for($x = 0; $x < $W; $x++){
        $map[$y][$x] = $str[$x];
        if($map[$y][$x] == "#"){
            $list[] = [$y,$x];
        }
    }
}
$count = 0;
while($list){
    $nextList = [];
    foreach($list as list($y, $x)){
        if($x > 0){
            if($map[$y][$x-1] == "."){
                $map[$y][$x-1] = "#";
                $nextList[] = [$y, $x-1];
            }
        }
        if($y > 0){
            if($map[$y-1][$x] == "."){
                $map[$y-1][$x] = "#";
                $nextList[] = [$y-1, $x];
            }
        }
        if($x < $W-1){
            if($map[$y][$x+1] == "."){
                $map[$y][$x+1] = "#";
                $nextList[] = [$y, $x+1];
            }
        }
        if($y < $H-1){
            if($map[$y+1][$x] == "."){
                $map[$y+1][$x] = "#";
                $nextList[] = [$y+1, $x];
            }
        }
    }
    $list = $nextList;
    if($list)$count++;
}
echo $count;


Measured memory_bytes: 473576
#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    vector<int> vec(n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &vec[i]);
    }
    vector<int>::iterator itr, last = unique(vec.begin(), vec.end());

    printf("%d", vec[0]);
    for (itr = vec.begin() + 1; itr != last; itr++)
    {
        printf(" %d", *itr);
    }
    printf("\n");
    return 0;
}



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

struct Vertex{
		int parent;
		int depth;
		int sibling;
		int height;
	};

void treeMake(int vertex,int depth,vector< vector<int> > &T, vector<Vertex> &V){
	if(depth==0){
		V[vertex].parent=-1;
		V[vertex].sibling=-1;
	}
	V[vertex].depth=depth;
	if(T[vertex][0]==-1&&T[vertex][1]==-1){
		return ;
	}
	int i;
	
	if(T[vertex][0]!=-1){
	V[T[vertex][0]].parent=vertex;
	V[T[vertex][0]].sibling=T[vertex][1];
	treeMake(T[vertex][0],depth+1,T,V);
	}
	
	if(T[vertex][1]!=-1) {
	V[T[vertex][1]].parent=vertex;
	V[T[vertex][1]].sibling=T[vertex][0];
	treeMake(T[vertex][1],depth+1,T,V);
	}
	/*for(i=0;i<T[vertex].size();i++){
		V[T[vertex][i]].parent=vertex;
		treeMake(T[vertex][i],depth+1,T,V);
		
	}*/
}

int main(){
	int n,i,j,k,d,e;
	cin >> n;
	
	vector< vector<int> > T(n);
	vector<int> check(n,0); 
	
	for (i=0;i<n;i++){
		cin >> k ;
		for (j=0;j<2;j++){
			cin >> e;
			T[k].push_back(e);
			if(e!=-1) check[e]=1;
		}
	}
	
	int r;
	for (i=0;i<n;i++){
		if(check[i]==0){
			r=i;
			break;
		}
	}
	
	vector<Vertex> V(n);
	
	treeMake(r,0,T,V);
	
	//height????¨????
	for (i=0;i<n;i++){
		if(T[i][0]==-1&&T[i][1]==-1){
			int j=i;
			int count=0;
			V[j].height=count;
			while(1){
				j=V[j].parent;
				count++;
				if(j==-1) break;
				if( V[j].height<count ){
					V[j].height=count;
				}
			}
		}
	}
	
	for (i=0;i<n;i++){
		cout << "node "<<i<<": parent = "<< V[i].parent <<", sibling = " << V[i].sibling << ", degree = ";
		if(T[i][0]==-1&&T[i][1]==-1){
			cout <<0 ;
		}else if(T[i][0]==-1||T[i][1]==-1){
			cout <<1;
		}else{
			cout <<2;
		}
		cout <<", depth = "<<V[i].depth<<", height = " << V[i].height;
		if(V[i].parent==-1){
			cout << ", root";
		}else if(T[i][0]==-1&&T[i][1]==-1){
			cout << ", leaf";
		}else{
			cout << ", internal node";
		}
		cout <<endl;
	}
	return 0;
}

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

using namespace std;

# define REP(i, a, b) for(int i = a; i <= b; ++ i)
# define CLR(i, a) memset(i, a, sizeof(i))
# define REPD(i, a, b) for(int i = a; i >= b; -- i)

typedef long long LL;

const int N = (1 << 16) + 5, B = 16, MOD = 1e9 + 7;

# define gc getchar
inline int rd() {
	char ch = gc(); int ret = 0, sgn = 1;
	while(ch < '0' || ch > '9') { 
		if(ch == '-') sgn = -1;
		ch = gc();
	}
	while(ch >= '0' && ch <= '9') 
		ret = ret * 10 + ch - '0', ch = gc();
	return ret * sgn;
}

int f[B + 2][N], a[B + 2], m, n;
int fac[N], invfac[N];
inline int binom(int x, int y) {
	if(x < y) return 0;
	return (LL)fac[x] * invfac[y] % MOD * (LL)invfac[x - y] % MOD;
}

inline int pow_(int x, int k) {
	int ret = 1;
	for(; k; k >>= 1, x = (LL)x * x % MOD)
		if(k & 1) ret = (LL)ret * x % MOD;
	return ret;
}

inline void inc(int &x, int y) { x = (x + y) % MOD; }
int pw[B + 2];
int S;

int main() {
	n = rd(), m = rd();
	S = (1 << n) - 1;
	REP(i, 1, m) a[i] = rd();
	fac[0] = invfac[0] = pw[0] = 1;
	REP(i, 1, B) pw[i] = pw[i - 1] << 1;
	REP(i, 1, S) fac[i] = (LL)fac[i - 1] * i % MOD;
	invfac[S] = pow_(fac[S], MOD - 2);
	REPD(i, S - 1, 1) invfac[i] = (LL)invfac[i + 1] * (i + 1) % MOD;

	sort(a + 1, a + m + 1, [](const int x, const int y) {
		return x > y;
	});

	// f[i][S] -> f[i + 1][S ^ (1 << j - 1)] * binom(lft, cur) * fac[cur]
	f[0][0] = 1;
	REP(i, 0, m - 1) {
		REP(s, 0, S) {
			inc(f[i + 1][s], f[i][s]);
			for(int g = ~s, j = g & -g; g; g -= j, j = g & -g) {
				if(pw[n] - s - a[i + 1] < j - 1) break;
				inc(f[i + 1][s ^ j], (LL)f[i][s] * 
					binom(pw[n] - a[i + 1] - s, j - 1)
					% MOD * (LL)fac[j] % MOD);
			}
		}
	}

	int ans = 0;
	REP(s, 0, S) {
		int op = __builtin_popcount(s) & 1 ? -1 : 1;
		// cout << f[m][s] << " " << fac[pw[n] - 1 - s] << " " << s <<endl;
		int hh = (LL)f[m][s] * fac[pw[n] - 1 - s] % MOD;
		inc(ans, ((LL)op * hh + MOD) % MOD);
	}

	printf("%lld\n", (LL)ans * pw[n] % MOD);

	return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

ll fastPow(ll x, ll n)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

ll modDiv(ll a, ll b)
{
    return a * fastPow(b, MOD - 2) % MOD;
}

ll gcd(ll a, ll b)
{
    if (a < b)
        ll c = a, a = b, b = c;

    return a % b == 0 ? b : gcd(b, a % b);
}

vector<int> prime(int n)
{
    vector<bool> num;
    vector<int> p;

    for (int i = 0; i <= n + 10; i++)
        num.push_back(true);

    FOR(i, 2, n)
    {
        if (!num[i])
            continue;

        p.push_back(i);

        for (int j = i * 2; j <= n; j += i)
        {
            num[j] = false;
        }
    }

    return p;
}

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

    auto p = prime(1123456);

    int n;
    ll a[11234];

    static int mp[1123456];
    memset(mp, 0, sizeof(mp));

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

        ll b = a[i];

        for (ll j : p)
        {
            if (j * j > b)
                break;

            if (b % j)
                continue;

            int cnt = 0;
            while (b % j == 0)
            {
                b /= j;
                cnt++;
            }
            if (cnt)
                mp[j] = max(mp[j], cnt);
        }

        mp[b] = max(mp[b], 1);
    }

    ll al = 1;

    for (int i = 2; i < 1000001; i++)
    {
        if (mp[i] == 0)
            continue;

        (al *= fastPow(i, mp[i])) %= MOD;
    }

    ll res = 0;
    REP(i, n)
    {
        res += modDiv(al, a[i]);
        res %= MOD;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 5228
// Aizu Vol-10 1051: Citation Format
// 2017.8.18 bal4u@uu

#include <stdio.h>

int main()
{
	int n;
	int i, f, last, s, p;

	while (scanf("%d", &n) && n) {
		scanf("%d", &s), last = s, f = 1;
		for (i = 1; ; i++) {
			if (i < n) {
				scanf("%d", &p);
				if (p == last + 1) { last++; continue; }
			}
			if (f) f = 0;
			else putchar(' ');
			if (last == s) printf("%d", s);
			else printf("%d-%d", s, last);
			if (i >= n) { putchar('\n'); break; }
			s = last = p;
		}
	}
	return 0;
}

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

int main() {
  int N; cin >> N;
  string S; cin >> S;
  vector<long long> cnt(3, 0);
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'R') cnt.at(0)++;
    else if (S.at(i) == 'G') cnt.at(1)++;
    else cnt.at(2)++;
  }
  long long ans = cnt.at(0) * cnt.at(1) * cnt.at(2);
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      if (S.at(i) == S.at(j)) continue;
      int k = 2*j - i;
      if (k >= N) continue;
      if (S.at(k) != S.at(i) && S.at(k) != S.at(j)) ans--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3584
n,m=map(int,input().split())
X=[]
for i in range(m):
    a,b=map(int,input().split())
    X.append([a,b])
X.sort(key=lambda x:x[1])
x=0
ans=0
for i in range(m):
    if X[i][0]<=x:
        continue
    else:
        x=X[i][1]-1
        ans+=1
print(ans)

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

using namespace std;

int main(){
   long n,a;

   cin >> n >> a;
  
  vector<long> x(n);
  long y=a;
  for(int i=0;i<n;i++) {
    cin >> x[i];
    y=max(y,x[i]);
    x[i]-=a;
  }
  
 long dp[n+1][2*n*y+1];
  
  for(int i=0;i<2*n*y+1;i++) dp[0][i]=0;
  dp[0][n*y]=1;
  
  for(int j=1;j<n+1;j++){
   for(int t=0;t<2*n*y+1;t++){
  if(0<=t-x[j-1]&&t-x[j-1]<=2*n*y) dp[j][t]=dp[j-1][t]+dp[j-1][t-x[j-1]];
  else  dp[j][t]=dp[j-1][t];
   }
  }
  
  cout << dp[n][n*y]-1 << endl;
  
}
    

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int[]x = new int[5];
			 x[0] = scan.nextInt();
			 x[1] = scan.nextInt();
			 x[2] = scan.nextInt();
			 x[3] = scan.nextInt();
			 x[4] = scan.nextInt();
			 
			
			
			for(int i = 0;i<5;i++) {
				if(x[i]==0) {
					System.out.println(i+1);
					System.exit(0);
				}
			}
			
		}
		
		
	}
		

}


Measured memory_bytes: 35892
#!/usr/bin/env python3



# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    # Failed to predict input format

    r,D,x2001 = list(map(int,input().split()))

    x = x2001
    for i in range(10):
        x = r*x - D
        print(x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstring>
#define int long long
#define N 100002
using namespace std;
int n,i,a[N],c[N*2],sum[N],l,r,mid,ans;
int lowbit(int x)
{
	return x&(-x);
}
void modify(int x,int y)
{
	for(int i=x;i<=N+n;i+=lowbit(i)) c[i]+=y;
}
int ask(int x)
{
	int ans=0;
	for(int i=x;i>=N-n;i-=lowbit(i)) ans+=c[i];
	return ans;
}
bool check(int x)
{
	int ans=0;
	memset(c,0,sizeof(c));
	for(int i=1;i<=n;i++){
		if(a[i]<x) sum[i]=sum[i-1]-1;
		else sum[i]=sum[i-1]+1;
	}
	for(int i=0;i<=n;i++){
		ans+=ask(sum[i]+N);
		modify(sum[i]+N,1);
	}
	if(ans>=n*(n+1)/4) return 1;
	return 0;
}
signed main()
{
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
		r=max(r,a[i]);
	}
	while(l<=r){
		mid=(l+r)/2;
		if(check(mid)){
			ans=mid;
			l=mid+1;
		}
		else r=mid-1;
	}
	cout<<ans<<endl;
	return 0;
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll k;
  cin >> k;
  
  ll res = 0;
  for (int i = 1; i <= k; i++) {
    res = (res * 10 + 7) % k;
    if (res == 0) {
      cout << i << '\n';
      return 0;
    }
  }
  
  cout << -1 << '\n';
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
vector<vector<tuple<ll,ll,ll>>> g;
vector<pair<ll,ll>> ex;
ll INF = ll(1e18)+5;
ll N,M,S;
using P =pair<ll,ll>;

vector<vector<P>> graph;


int main() {
   
    cin >> N >>M >>S;
    const ll maxCoin = N*50+1;
    graph.resize(N*maxCoin);
    for(int i=0;i<M;i++){
        ll u,v,a,b;
        cin >> u >> v >> a >>b;
        --u;--v;
        for(int j=a;j<maxCoin;j++){
            graph[u+ j*N].emplace_back((j-a)*N+v,b);
            graph[v+ j*N].emplace_back((j-a)*N+u,b);
        }
    }
    for(int i=0;i<N;i++){
        ll c,d;
        cin >> c >>d;
        for(int j=0;j<maxCoin;j++){
            graph[i+j*N].emplace_back(i+min((j+c),maxCoin-1)*N,d);
        }
    }
    priority_queue<P,vector<P>,greater<P>> pq;
    pq.push(P(0,min(maxCoin-1,S)*N));
    vector<ll> d(N*maxCoin,INF);
    d[min(maxCoin-1,S)*N] =0;
    while(!pq.empty()){
        P p = pq.top();pq.pop();
        // cerr <<"pos=" << p.second << " and" << p.second%N << endl;
        ll v =p.second;
        if(d[v] < p.first){
            continue;
        }
        for(int i=0;i<graph[v].size();i++){
            P e = graph[v][i];
            if(d[e.first] > d[v]+ e.second){
                d[e.first] = d[v] + e.second;
                pq.push(P(d[e.first],e.first));
            }
        }
    }
    for(int i=1;i<N;i++){
        ll ans = INF;
        for(int j=0;j<maxCoin;j++){
            ans = min(ans,d[i+j*N]);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 23748
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var oneList = new HashSet<int>();
            var nList = new HashSet<int>();

            for (var i = 0; i < NM[1]; i++)
            {
                var tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (tmp[0] == 1) oneList.Add(tmp[1]);
                if (tmp[1] == NM[0]) nList.Add(tmp[0]);
            }

            var isOk = oneList.Any(z => nList.Contains(z));
            Console.WriteLine(isOk ? "POSSIBLE" : "IMPOSSIBLE");
        }
    }
}


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

int main() {
  	int n,m;
  cin >> n >> m;
    vector<int> road(n);
    int a,b;
    rep(i,m){
        cin >> a >> b;
        road.at(a-1)++;
        road.at(b-1)++;
    }
    rep(i,n) cout << road.at(i) << "\n";
    
  
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x,y,a;
    while(1){
        cin>>x>>y;
        if(x==0 && y==0)break;
        if(x>y){
            a=x;
            x=y;
            y=a;
        }
        cout<<x<<" "<<y<<endl;
    }
}


Measured memory_bytes: 3092
def main():
    N, Ma, Mb = map(int, input().split())
    a = [0] * N
    b = [0] * N
    c = [0] * N
    for i in range(N):
        a[i], b[i], c[i] = map(int, input().split())

    dp = [[[float('inf')] * (405) for _ in range(405)] for _ in range(N + 5)]    
    dp[0][0][0] = 0

    for i in range(N):
        for j in range(401):
            for k in range(401):
                if dp[i][j][k] == float('inf'):
                    continue
                dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k])
                dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k] + c[i])

    ans = float('inf')
    for i in range(1,401):
        for j in range(1,401):
            if Ma * j == Mb * i:
                ans = min(ans, dp[N][i][j])

    if ans == float('inf'):
        print(-1)
    else:
        print(ans)
    


if __name__ == "__main__":
    main()

Measured memory_bytes: 125832
N=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(N):
    s = input()
    if s == 'AC':
        ac+=1
    elif s=='WA':
        wa+=1
    elif s=='TLE':
        tle+=1
    elif s=='RE':
        re+=1
    
print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d,N;
    a = 1,c=0,d=0;
    cin >> N;
    vector<int> v(N);
    for(int i=0;i<N;i++){
        cin >> b;
        v[i] = b;
    }
    for(int i=0;i<N;i++){
         if (a==2){
            cout << c << endl;
            d = 1;
            break;
        }
        a=v[a-1];
        c++;
    }
    if(d==0){
        cout << -1 << endl;
    }
}

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

int dp[41][501][501];
int inf = 1e6;

int main(){
    int n, ma, mb;
    cin >> n >> ma >> mb;

    vector<int> a(n), b(n), c(n);
    for(int i=0; i<n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }

    // init dp table
    for(int i=0; i<41; i++){
        for(int j=0; j<501; j++){
            for(int k=0; k<501; k++){
                dp[i][j][k] = inf;
            }
        }
    }
    dp[0][0][0] = 0;

    for(int i=0; i<n; i++){
        for(int f=0; f<401; f++){
            for(int s=0; s<401; s++){
                if(dp[i][f][s] == inf) continue;
                dp[i+1][f][s] = min(dp[i+1][f][s], dp[i][f][s]);
                dp[i+1][f + a[i]][s + b[i]] = min(dp[i+1][f + a[i]][s + b[i]], dp[i][f][s] + c[i]);
            }
        }
    }

    
    int ans = inf;
    for(int i=1; i<401; i++){
        for(int j=1; j<401; j++){
            if(ma*j == mb*i) ans = min(ans, dp[n][i][j]);
        }
    }
    if(ans == inf) ans = -1;

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

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

int main() {
  int N;
  cin >> N;
  N %= 10;
  if(N == 0||N == 1||N == 6||N == 8) cout << "pon" << endl;
  else if(N == 3) cout << "bon" << endl;
  else cout << "hon" << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
int main(){
int a,b,c=0,d,e;
while(c==0){
scanf("%d %d\n",&a,&b);
if(a==0 && b==0){
break;
}
else{
for(d=0;d<a;d++){
for(e=0;e<b;e++){
if(d==0 || d==a-1){
printf("#");
}
else{
if(e==0 || e==b-1){
printf("#");
}
else{
printf(".");
}
}
}
printf("\n");
}
printf("\n");
}
}
return 0;
}


Measured memory_bytes: 2136
#include<iostream>
using namespace std;
int N;
int memo[2<<17];
string X;
int d[2];
int pw[2][2<<17];
main()
{
	cin>>N>>X;
	for(int i=1;i<2<<17;i++)
	{
		memo[i]=memo[i%__builtin_popcount(i)]+1;
	}
	int pc=0;
	for(int i=0;i<N;i++)pc+=X[i]=='1';
	for(int i=0;i<2;i++)
	{
		int now=i?pc+1:pc-1;
		if(now<=0)
		{
			d[i]=0;
			continue;
		}
		else
		{
			int cur=0;
			pw[i][0]=1;
			for(int j=0;j<N;j++)
			{
				cur=(cur*2+X[j]-'0')%now;
				pw[i][j+1]=pw[i][j]*2%now;
			}
			d[i]=cur;
		}
	}
	for(int i=0;i<N;i++)
	{
		if(X[i]=='0')
		{
			cout<<memo[(d[1]+pw[1][N-i-1])%(pc+1)]+1<<endl;
		}
		else
		{
			if(pc==1)
			{
				cout<<0<<endl;
			}
			else
			{
				cout<<memo[((d[0]-pw[0][N-i-1])%(pc-1)+pc-1)%(pc-1)]+1<<endl;
			}
		}
	}
}


Measured memory_bytes: 6272
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>

using namespace std;
#define int long  long int
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int X;
	cin >> X;
	int num = X - 1;
	int cnt = 0;
	while (1)
	{
		cnt = 0;
		num++;
		for (int i = 2; i <= num/2; i++)
		{
			if (num % i != 0)
			{
				cnt++;
			}
		}
		if (cnt == num/2 - 2 + 1)break;
	}
	cout << num;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
template<class T> inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

//a^n mod を計算する関数
long long modpow(long long a,long long n,long long mod) {
    long long res = 1;
    while(n > 0) {
        if(n % 2 == 1) {
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//a^(-1) mod すなわちaの逆元を返す関数
long long modinv(long long a,long long mod) {
    return modpow(a,mod-2,mod);
}

//最大公約数をを返す関数
long long gcd (long long a,long long b) {
    if(a % b == 0) {
        return b;
    }else {
        return (gcd(b,a%b));
    }
}

const long long INF = 1LL << 60;
const long long P = 1000000007;

//nCkを求める関数
long long conbi (long long n,long long k) {
    long long res = 1;
    long long inv;
    for(long long i = n-k+1; i <= n; i++) {
        res *= i;
        res %= P;
    }
    for(long long i = 1; i <= k; i++) {
        inv = modinv(i,P);
        res *= inv;
        res %= P;
    }
    return res;
}

int main() {
    char s[4];
    scanf("%s", &s);
    int a,b,c,d;
    a = s[0]-'0';
    b = s[1]-'0';
    c = s[2]-'0';
    d = s[3]-'0';
    int sum = a+b+c+d;
    if(sum - 2*d == 7) {
        cout << a << "+" << b << "+" << c << "-" << d << "=7";
    }else if(sum - 2*c - 2*d == 7) {
        cout << a << "+" << b << "-" << c << "-" << d << "=7";
    }else if(sum - 2*b - 2*c - 2*d == 7) {
        cout << a << "-" << b << "-" << c << "-" << d << "=7";
    }else if(sum - 2*b == 7) {
        cout << a << "-" << b << "+" << c << "+" << d << "=7";
    }else if(sum - 2*c == 7) {
        cout << a << "+" << b << "-" << c << "+" << d << "=7";
    }else if(sum - 2*b - 2*d == 7) {
        cout << a << "-" << b << "+" << c << "-" << d << "=7";
    }else if(sum - 2*b - 2*c == 7) {
        cout << a << "-" << b << "-" << c << "+" << d << "=7";
    }else {
        cout << a << "+" << b << "+" << c << "+" << d << "=7";
    }
    return 0;
}



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

ll n ; int ans ;

void dfs(ll x, int a,int b ,int c){
  if(x>n) return ;
  if(a&&b&&c) ans++ ;
  dfs(10*x+3,1,b,c) ;
  dfs(10*x+5,a,1,c) ;
  dfs(10*x+7,a,b,1) ;
} 

int main() {
  cin >> n ;
  dfs(0,0,0,0);
  cout << ans << endl;
}
  

Measured memory_bytes: 256
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int main() {
    ll n;
    ll p[51];
    ll s[51];
    
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> p[i];
        s[i] = p[i];
    }
    sort(s,s+n);
    
    ll dif = 0;
    
    for (int i = 0; i < n; i++) {
        if(s[i] != p[i]){
            dif++;
        }
    }
    if(dif<=2){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }
}


Measured memory_bytes: 384
n = int(input())
mod = 1000000007

a, b, c = (1, 1, 1)
for i in range(n):
    a = a * 10 % mod
    b = b * 9 % mod
    c = c * 8 % mod

ans = (a + c - 2 * b) % mod
print(ans)


Measured memory_bytes: 9108
#include<stdio.h>
#include<string.h>
int main(void)
{
	char c[4],c1[4],cnt,k,k1,cnt1,i;
	scanf("%s %s",c,c1);
	k=strlen(c);
	k1=strlen(c1);
	cnt=0; cnt1=0;
	for(i=3;i>=0;i--){
		if(c[cnt]==c1[i]){
			cnt++; cnt1++;
		}
	}
	if(cnt1==3) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
import Data.List
import Control.Applicative

func (x:xs) Nothing Nothing = (x,x) : (func xs (Just x) (Just x))
func (x:xs) (Just mx) (Just mn) = (mx',mn') : (func xs (Just mx') (Just mn'))
  where
    mx' = max x mx
    mn' = min x mn
func [] _ _ = []

main :: IO ()
main = do
  [n,t] <- return . map (read::String->Int) . words =<< getLine
  a <- return . map (read::String->Int) . words =<< getLine

  let dat = reverse $ func (reverse a) Nothing Nothing
  let dat2 = zipWith (\x (a,b) -> a-x) (init a) (tail dat)
  let max' = maximum dat2

  print $ length $ filter (==max') dat2
  


Measured memory_bytes: 93564
#include <stdio.h>

int main(void)
{
	int n, m, a[100][100], b[100][1], c[100][1], count_1, count_2;

	scanf("%d %d", &n, &m);

	for (count_1 = 0; count_1 < n; count_1++)
	{
		for (count_2 = 0; count_2 < m; count_2++)
		{
			scanf("%d", &a[count_1][count_2]);
		}
	}

	for (count_1 = 0; count_1 < m; count_1++)
	{
		scanf("%d", &b[count_1][0]);
	}

	for (count_1 = 0; count_1 < n; count_1++)
	{
		for (c[count_1][0] = 0, count_2 = 0; count_2 < m; count_2++)
		{
			c[count_1][0] = c[count_1][0] + (a[count_1][count_2] * b[count_2][0]);
		}
	}

	for (count_1 = 0; count_1 < n; count_1++)
	{
		printf("%d\n", c[count_1][0]);
	}

	return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int w,h,n,x[2000],y[2000];
int main(){
    scanf("%d%d%d",&w,&h,&n);
    REP(i,n)
        scanf("%d%d",x + i,y + i);

    int sum = 0;
    FOR(i,1,n){
        if((x[i] - x[i - 1]) * (y[i] - y[i - 1]) > 0){
            int a = abs(x[i] - x[i - 1]);
            int b = abs(y[i] - y[i - 1]);
            sum += max(a,b);
        }else{
            sum += abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
        }
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 3220
import numpy as np
N=int(input())
a=[0]*N
b=[0]*N
s=0
for i in range(N):
    a[i], b[i] = map(int, input().split())
for i in range(N):
  for j in range(N):
    vec=[a[i]-a[j], b[i]-b[j]]
    s+=np.linalg.norm(vec)
print(s/N)


Measured memory_bytes: 12424
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class COneQuadrillionAndOneDalmatians {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;

        string res;
        while (N > 0) {
            N--;
            res += N % 26 + 'a';
            N /= 26;
        }
        reverse(res.begin(), res.end());
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    COneQuadrillionAndOneDalmatians solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3648