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

using namespace std;

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  int answer;

  answer = A * X + B * Y;
  answer =
      min(answer, X > Y ? 2 * Y * C + A * (X - Y) : 2 * X * C + B * (Y - X));
  answer = min(answer, 2 * max(X, Y) * C);

  cout << answer << endl;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val a = sc.nextInt()
  val b = sc.nextInt()

  println(a(a, b))
}

private fun a(a: Int, b: Int): String {
  if (0 < a && 0 < b) return "Positive"
  if (a <= 0 && 0 <= b) return "Zero"

  val size = b - a + 1
  if (size % 2 == 0) return "Positive"

  return "Negative"
}


Measured memory_bytes: 29472
#include <bits/stdc++.h>
#define ls (o << 1)
#define rs (o << 1 | 1)
#define mid ((L + R + 1) >> 1)
using namespace std;
const int MAXN = 200050;
const int mod = 998244353;
typedef long long LL;
int main() {
#ifdef TEST
	freopen("input.txt", "r", stdin);
#endif
	LL a, b;
	cin >> a >> b;
	LL L = 0, R = a + b;
	while (L < R) {
		if (b >= mid + mid && a + (b - mid - mid) / 2 >= mid) {
			L = mid;
		} else {
			R = mid - 1;
		}
	}
	cout << L << endl;
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

string s;

int64 ten(int64 x, int64 d) {
  REP(i, d) x *= 10;
  return x;
}

int64 stoi_my(string s) {
  int64 ret = 0;
  REP(i, s.size()) ret = ret*10 + s[i]-'0';
  return ret;
}

int64 score(int64 a) {
  int64 ss = stoi_my(s);
  return min(abs(ss-a), ten(1, s.size()) - abs(ss-a));
}

int main(void) {
  int64 N, M;
  cin >> N >> M;
  vector<int64> E(N+1, 0), rW(N+1, 0);
  REP(i, M) {
    string s;
    cin >> s;
    REP(j, s.size()) {
      if (s[j] == 'W') rW[j]++;
      else E[j]++;
    }
  }
  REP(i, N) E[i+1] += E[i];
  for (int64 i = N; i > 0; i--) rW[i-1] += rW[i];
  int64 res = -1, sum = rW[0];
  REP(i, N) {
    if (E[i]+rW[i+1] < sum) {
      res = i;
      sum = E[i]+rW[i+1];
    }
  }
  cout << res+1 << " " << res+2 << endl;
}


Measured memory_bytes: 3312
fn a() {
    input!{
        s: Chars
    }

    let mut ans = 0;
    let mut f = false;

    for i in 0..3 {
        if s[i] == 'R' {
            ans += 1;
            f = true;
        }
        else if f {
            break;
        }
    }
    println!("{}", ans);
}

use proconio::{input, marker::Chars};

fn main() {
    a();
}

Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int n;
double x[10],y[10];
double ans,ad=1;
bool book[10]; 
void dfs(int t,int step,double now) {
//	cout<<"t = "<<t<<" step = "<<step<<" now = "<<now<<'\n';
	if(step==n) {
		ans+=now;
		return;
	}
	for(int i=1;i<=n;i++) {
		if(step==0) {
			book[i]=1;
			dfs(i,step+1,0);
			book[i]=0;
			continue;
		}
		if(!book[i]) {
			book[i]=1;
			dfs(i,step+1,now+sqrt(pow(x[t]-x[i],2)+pow(y[t]-y[i],2)));
			book[i]=0;
		}
	}
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		cin>>x[i]>>y[i];
	dfs(0,0,0);
	for(int i=1;i<=n;i++)
		ad*=i;
	cout<<fixed<<setprecision(8)<<ans/ad;
	return 0;
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    ll Q;
    cin >> S >> Q;
    deque<char> answers;
    for (int i = 0; i < S.size(); i++)
    {
        answers.push_back(S.at(i));
    }
    bool isReverse = false;
    for (int i = 0; i < Q; i++)
    {
        ll type;
        cin >> type;
        if (type == 1)
        {
            isReverse = !isReverse;
        }
        else if (type == 2)
        {
            ll subType;
            cin >> subType;
            char c;
            cin >> c;
            //先頭に追加
            if (subType == 1)
            {
                if (isReverse)
                {
                    answers.push_back(c);
                }
                else
                {
                    answers.push_front(c);
                }
            }
            else if (subType == 2)
            {
                if (isReverse)
                {
                    answers.push_front(c);
                }
                else
                {
                    answers.push_back(c);
                }
            }
        }
    }
    while (!answers.empty())
    {
        if (isReverse)
        {
            cout << answers.back();
            answers.pop_back();
        }
        else
        {
            cout << answers.front();
            answers.pop_front();
        }
    }
    cout << endl;
    return 0;
}


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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll N;
	cin>>N;
	ll A[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<A[N-1]<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun May  3 01:08:25 JST 2020
 **/

const Int INF = 1e18;
signed main() {
    int n;
    std::cin >> n;
    std::vector<Int> a(n);
    REP(i, n) std::cin >> a[i];
    std::vector<std::vector<int>> g(n);
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        std::cin >> u >> v;
        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    std::vector<Int> dp(n, INF), ans(n);
    auto dfs = [&](auto f, int v, int prv) -> void {
        auto it = std::lower_bound(dp.begin(), dp.end(), a[v]);
        Int idx = it - dp.begin(), val = *it;
        *it = a[v];
        ans[v] = std::lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
        for (int s : g[v]) {
            if (s == prv) continue;
            f(f, s, v);
        }
        dp[idx] = val;
    };
    dfs(dfs, 0, -1);
    for (Int x : ans) std::cout << x << "\n";
}


Measured memory_bytes: 38720
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int m = Integer.parseInt(str[1]);

    int[] k = new int[m];
    ArrayList<ArrayList<Integer>> list = new ArrayList<>();
    for(int i = 0; i<m; i++) {
      list.add(new ArrayList<>());
   }
    
    for(int i = 0; i<m; i++) {
      str = in.readLine().split(" ");
      k[i] = Integer.parseInt(str[0]);
      for(int j = 1; j<=k[i]; j++) {
        list.get(i).add(Integer.parseInt(str[j]));
      }
    }
    
    int p[] = new int[m];
    str = in.readLine().split(" ");
    for(int i = 0; i<m; i++){
      p[i] = Integer.parseInt(str[i]);
    }
    
    List<String> com = conbination(Arrays.asList(""),n);
    
    int ans = 0;
    for(int i = 0; i<com.size(); i++) {
      String swit[] = com.get(i).split("");
      boolean flag = false;
      
      for(int j = 0; j<m; j++) {
        int count = 0;
        for(int l = 0; l <k[j]; l++) {
          if(swit[list.get(j).get(l) - 1].equals("1")) {
            count++;
          }
        }
        
        if(p[j] == 0) {
          if(count % 2 ==0) {
          } else {
             flag = true;
          }
        } else {
          if(count % 2 ==0) {
            flag = true;
          }
        }
        if(flag) {
          break;
        }
      }
      if(!flag)
        ans++;
    }
    System.out.println(ans);
  }
  
  public static List<String> conbination(List<String> binary, int count) {
    if(count <= 0)
      return binary;
    List<String> list = new ArrayList<String>(binary.size() *2);
    for(String s : binary) {
      list.add(s+0);
      list.add(s+1);
    }
    return conbination(list,count-1);
  } 
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;

ll divceil(ll x, ll y) {
    assert(y);
    return (x+y-1)/y;
}



ll go(ll k, ll n) {
    if (n==0) return 1;
    return k*go(k,n-1);
}

ll f(ll k, ll n) {
    ll res = 0;
    for (int i=1; i<=n; i++) {
	res += go(k,i);
    }
    return res;
}

vector<vector<int>> all;
vector<int> v;

void dfs(int rem, ll k) {
    if (rem==0) {
	all.push_back(v);
    } else {
	for (int x=1; x<=k; x++) {
	    v.push_back(x);
	    dfs(rem-1,k);
	    v.pop_back();
	}
    }
}

vector<int> brute(ll k, ll n) {
    for (int i=1; i<=n; i++) {
	dfs(i,k);
    }
    sort(all.begin(), all.end());
    ll len = all.size();
    int mid = (len-1)/2;
    return all[mid];
    /*
      for (int i=mid; i<=mid; i++) {
      for (int x: all[i]) {
      cout<<x<<" ";
      }
      if (mid==i) cout<<"***";
      cout<<endl;
      }
    */
}

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

    //watch(f(k,n));
    

    vector<int> ans;
    if (k%2==0) {
	ans.push_back(k/2);
	for (int i=1; i<n; i++) {
	    ans.push_back(k);
	}
    } else {
	ans.resize(n, (k+1)/2);
	ll iter = divceil(n-1,2);
	for (int i=0; i<iter; i++) {
	    ans.back()--;
	    if (ans.back()==0) {
		ans.pop_back();
	    } else {
		while ((int)ans.size() < n) {
		    ans.push_back(k);
		}
	    }
	}
	// cout<<"ans: ";
	// for (int x: ans) cout<<x<<" ";
	// cout<<endl;
    }

    if (false) {
	auto bru = brute(k,n);
	cout<<"bru: ";
	for (int x: bru) cout<<x<<" ";
	cout<<endl;
	assert(ans==bru);
    }

    
    for (int x: ans) cout<<x<<" ";
    cout<<endl;
    
    return 0;
}
/*
  For odd K
  Let X=(K+1)/2 
  Consider len N sequence of X,X,X...X.
  All non-trivial prefixes of this sequence map to themselves, so we need to "back up"
  our initial sequence by ceil((N-1)/2) indices because there are N-1 non-trivial prefixes
  of our sequence.
  1->3
  2->2
  3->3

  f(k,n) is 39
  1 
  1 1 
  1 1 1 
  1 1 2 
  1 1 3 
  1 2 
  1 2 1 
  1 2 2 
  1 2 3 
  1 3 
  1 3 1 
  1 3 2 
  1 3 3 
  2 
  2 1 
  2 1 1 
  2 1 2 
  2 1 3 
  2 2 (maps to self)
  2 2 1 ***
  2 2 2 
  2 2 3 
  2 3 
  2 3 1 
  2 3 2 
  2 3 3 
  3 
  3 1 
  3 1 1 
  3 1 2 
  3 1 3 
  3 2 
  3 2 1 
  3 2 2 
  3 2 3 
  3 3 
  3 3 1 
  3 3 2 
  3 3 3
*/


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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int H,W;
string a[550];
bool r[550][550],b[550][550];
signed main() {
  cin>>H>>W;
  for(int i=0;i<H;i++)cin>>a[i];
  for(int i=0;i<H;i++)r[i][0]=b[i][W-1]=true;
  for(int i=0;i<H;i++)for(int j=1;j<W-1;j++){
    r[i][j]=i%2==0;
    b[i][j]=i%2==1;
  }
  for(int i=0;i<H;i++)for(int j=1;j<W-1;j++){
    if(i%2==0)b[i][j]=a[i][j]=='#';
    else r[i][j]=a[i][j]=='#';
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++)cout<<(r[i][j]?'#':'.');
    cout<<endl;
  }
  cout<<endl;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++)cout<<(b[i][j]?'#':'.');
    cout<<endl;
  }
}


Measured memory_bytes: 1536
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string w;
	int m, h, i, k, s;

	while( true )
	{
		cin >> w;
		if(w == "-")
			break;

		k = 0;
		s = w.size();

		cin >> m;
		for(i = 0; i < m; ++i){
			cin >> h;
			k += h;
		}

		for(i = 0; i < s; ++i)
			cout << w[(i+k)%s];
	
		cout << "\n";
	}

	return 0;
}

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

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

    int ans = 999999;
    int size = static_cast<int>(S.size() - T.size());
    int t_size = static_cast<int>(T.size());
    for(int i = 0; i <= size; i++) {
        string s = S.substr(i, t_size);

        int count = 0;
        rep(j, 0, t_size){
            if(s[j] != T[j])
            ++count;
        }
        ans = min(count, ans);
    }

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


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define _READ freopen("input.txt", "r", stdin);
#define _FAST                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
int32_t main()
{
    int n,m;
    cin>>n;
     m=(n+1)/2;
    cout<<fixed<<setprecision(15)<<((double)m/n);
    return 0;
}

Measured memory_bytes: 3776
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

int main()
{
	int N, K;
	cin >> N >> K;

	vector<int> A(N);

	int i;
	//rep(i, N) cin >> A[i];

	int ans = ceil((double)(N - 1) / (double)(K - 1));

	cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
long long x[100000], v[100000], cw1[100000], cw2[100000], ccw1[100000], ccw2[100000];
 
int main() {
	int n;
	long long c, tot, mx = 0;
 
	scanf("%d %lld", &n, &c);
 
	for (int i = 0;i < n;++i)
		scanf("%lld %lld", &x[i], &v[i]);
 
	tot = v[0];
	cw1[0] = max((long long)0, v[0] - x[0]);
	cw2[0] = max((long long)0, v[0] - x[0] * 2);
 
	mx = cw1[0];
 
	for (int i = 1;i < n;++i) {
		tot += v[i];
		cw1[i] = max(cw1[i - 1], tot - x[i]);
		cw2[i] = max(cw2[i - 1], tot - x[i] * 2);
 
		mx = max(mx, cw1[i]);
	}
 
	tot = v[n - 1];
	ccw1[n - 1] = max((long long)0, v[n - 1] - (c - x[n - 1]));
	ccw2[n - 1] = max((long long)0, v[n - 1] - (c - x[n - 1]) * 2);
 
	mx = max(mx, ccw1[n - 1]);
	if (n > 1) {
		mx = max(mx, ccw1[n - 1] + cw2[n - 2]);
		mx = max(mx, ccw2[n - 1] + cw1[n - 2]);
	}
 
	for (int i = n - 2;i >= 0;--i) {
		tot += v[i];
		ccw1[i] = max(ccw1[i + 1], tot - (c - x[i]));
		ccw2[i] = max(ccw2[i + 1], tot - (c - x[i]) * 2);
 
		mx = max(mx, ccw1[i]);
 
		if (i > 0) {
			mx = max(mx, ccw1[i] + cw2[i - 1]);
			mx = max(mx, ccw2[i] + cw1[i - 1]);
		}
	}
 
	printf("%lld", mx);
 
	return 0;
}

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

int main(void){
  int count=0;
  while(1){
  cin >> count;
  if(count == 0) break;
  else{
    int maxkan,maxkyori=-1,kan=0,kyori1=0,kyori2=0;
    for(int i=0;i<count;i++){
      cin >> kan >> kyori1 >> kyori2;
       if(maxkyori < kyori1+kyori2){
         maxkan = kan;
         maxkyori = kyori1+kyori2;
       }
    }
    cout << maxkan << " " << maxkyori << endl;
   } 
  }
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>

using namespace std;

int main(){
  int H, W;
  char a[110][110];

  cin >> H >> W;
  for(int y = 0; y < H; y++){
    for(int x = 0; x < W; x++){
      cin >> a[y][x];
    }
  }

  for(int i = 0; i < W+2; i++) cout << "#";
  cout << endl;

  for(int y = 0; y < H; y++){
    cout << "#";
    for(int x = 0; x < W; x++){
      cout << a[y][x];
    }
    cout << "#" << endl;
  }

  for(int i = 0; i < W+2; i++) cout << "#";
  cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int main(){
    int N;
    double C, K;
    cin >> N >> C >> K;
    vector<double> T(N, 0);
    FOR(i, 0, N) cin >> T[i];

    sort(T.begin(), T.end());
    int ans = 0;
    //先頭の人
    double t = T[0];
    int people = 0;
    bool last = false;
    FOR(i, 0, N){
        //バス出発
        if(t + K < T[i]){
            ans++;
            people = 1;
            t = T[i];
        }
        //乗れた
        else{
            people++;
            //バスで最後の乗客だった
            if(people==C){
                ans++;
                people = 0;
                if(i+1==N) last = true;
                t = T[i+1];
            }
        }
    }
    if(!last) ans++;
    cout << ans << endl;
}

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

using namespace std;

#define endl '\n'

typedef long long ll;

const int maxn = 3000 + 5;

int dp[maxn][maxn];
int n, m;

string a, b, ans;

int lcs;

void generate(int x, int y){
	
	if(x >= n || y >= m)
		return;
	
	if(dp[x + 1][y + 1] >= dp[x][y + 1] && dp[x + 1][y + 1] >= dp[x + 1][y] && a[x] == b[y]){
		ans += a[x];
		generate(x + 1, y + 1);	
		return;
	}
	
	if(dp[x][y + 1] >= dp[x + 1][y])
		generate(x, y + 1);
	else
		generate(x + 1, y);
}

int solve(int i, int j){
	if(i >= n || j >= m)
		return 0;
	if(dp[i][j] != -1)
		return dp[i][j];
	int ans = max(solve(i + 1, j), solve(i, j + 1));
	if(a[i] == b[j])
		ans = max(ans, solve(i + 1, j + 1) + 1);
	return dp[i][j] = ans;
}

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

	cin >> a >> b;
	n = (int)a.size(), m = (int)b.size();
	
	memset(dp, -1, sizeof(dp));
	lcs = solve(0, 0);
	
	for(int i = 0; i < maxn; i++)
		for(int j = 0; j < maxn; j++)
			if(dp[i][j] == -1)
				dp[i][j] = 0;
	
	generate(0, 0);
	
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

#define endl "\n"
#define F first
#define S second
#define B begin()
#define E end()
#define PB push_back
#define int long long

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;

const int maxn = 1e5;
const int OO = 1e18;

int32_t main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin >> n;
	n = n%10;
	
	if(n==3)
	{cout << "bon";
	}
	else if(n==0 or n==1 or n==8 or n==6)
	cout  << "pon";
	else 
	cout << "hon";
	
	
	return 0;
}


Measured memory_bytes: 3612
def main():
  N, M = map(int,input().split())
  sc = list(list(input().split()) for _ in range(M))

  li = [""] * N

  for i in range(M):
    j = li[int(sc[i][0]) - 1]
    if j == "": li[int(sc[i][0]) - 1] = sc[i][1]
    elif j != sc[i][1]: return -1

  for i in range(N):
    if i == 0:
      if li[0] == "0" and N != 1: return -1
      if li[0] == "":
        if N == 1: li[0] = "0"
        else: li[0] = "1"
    elif li[i] == "": li[i] = "0"

  return "".join(li)

print(main())

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

#define FOR(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

using ll = long long;

int main() {
  string s; cin >> s;
  ll ans = 1;
  FOR(i,1,s.size()) if (s[i] != '9') { ans--; break;}
  ans += (s[0] - '0' - 1) + (s.size()-1)*9;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{

 int r , d , x ;
 cin>> r >> d >> x ;
 int res = r*x-d ;
 cout<< res << endl ;
 for (int i=0 ; i<9 ; i++ ){
    res=res*r-d ;
    cout<< res << endl ;
 }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>


#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#include <stdio.h>
#include <vector> 
#include <map> 
#include <algorithm>
#include <functional>


#include<iostream>
using namespace std;
int main()
{
	int a;
	cin >> a;

	int aa[] = {
		1, 10, 100, 1000, 10000, 100000,
	};

	int tt = 0;

	if (a >= 9) {
		tt += 9;

		if (a >= 999) {
			tt += 900;

			if (a >= 99999) {
				tt += 90000;
			} else {
				tt += std::max(0, a - 9999);
			}

		} else {
			tt += std::max(0, a - 99);
		}

	} else {
		tt = a;
	}


	


	cout << tt << endl;
	return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**5)

def solve(n, x):
  if n == 0:
    if x > 0:
      return 1
    else:
      return 0
  else:
    ans = 0
    burger_prev = 2**(n+1)-3
    pate_prev = 2**n-1
    if x > 1:
      if x < burger_prev+1:
        ans += solve(n-1 ,x-1)
      else:
        ans += pate_prev
        if x > burger_prev+1:
          ans += 1
          if x > burger_prev*2+2:
            ans += pate_prev
          else:
            ans += solve(n-1, x-2-burger_prev)
    return ans

N, X = map(int, input().split())
print(solve(N, X))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()


//library mod int
template <int mod>
struct modint{
    ll x;

    //constructor
    modint(ll x=0): x((x%mod+mod)%mod){}

    //unary operator
    modint operator-() const { return modint(mod-x);}
    modint inv() const { return this->pow(mod-2);}
    
    //compound assignment
    modint& operator+=(const modint& a){
        if((x+=a.x)>=mod) x-=mod;
        return *this;
    }
    modint& operator-=(const modint& a){
        if((x-=a.x)<0) x+=mod;
        return *this;
    }
    modint& operator*=(const modint& a){
        (x*=a.x)%=mod;
        return *this;
    }
    modint& operator/=(const modint& a){
        return *this *= a.inv();
    }

    //arithmetic
    // なぜmodintの後ろに＆を書いたり書かなかったりしてるかの理解ができていない
    //おそらく＆をつけるとポインタで参照しているのでもとの値を書き換えることができる
    //＆をつけないとコピーを作ってからそれに対して計算するので、もとの値は変更されない
    modint operator-(const modint& a) const {return modint (*this) -= a ; }
    modint operator+(const modint& a) const {return modint (*this) += a ; }
    modint operator*(const modint& a) const {return modint (*this) *= a ; }
    modint operator/(const modint& a) const {return modint (*this) /= a ; }
    //n should not be smaller than 0.
    modint pow(ll n) const{
        auto x=modint(1);
        auto m=*this;
        while(n>0){
            if(n&1) x*=m;
            n>>=1;
            m*=m;
        }
        return x;
    }

    //compare
    bool operator==(const modint& a) const {return x==a.x ; }
    bool operator!=(const modint& a) const {return x!=a.x ; }

    //I/O
    friend istream& operator>>(istream& is, modint& a ) noexcept {return is >> a.x ; }
    friend ostream& operator<<(ostream& os, const modint& a ) noexcept {return os << a.x ; }
};

//modの調整
constexpr int mod = 1e9 + 7;
using mint = modint<mod>;

//////////////////////////////////////////////////////////////////////
//combination
//コンビネーション計算で代入できる値は3e6で設定している
vector<mint> mintcombvector;
int startmintcomb(int n){
    mintcombvector.push_back(0);
    mintcombvector.push_back(1);
    rep(i,n) mintcombvector.push_back(mintcombvector[i+1]*(i+2));
    return 0;
}
mint comb(mint a, mint b){
    if(a.x<b.x || a.x<=0 || b.x<0) return mint(0);
    if(b.x==0) return mint(1);
    if(a==b) return mint(1);
    return mintcombvector[a.x]*(mintcombvector[b.x].inv())*(mintcombvector[a.x-b.x].inv());
}
//combinationを使いたいときは　startmintcomb(n=代入したい数の最大値); を始めに打つこと


int main(){
    startmintcomb(3e6);
    int x,y;
    cin>>x>>y;
    if((x+y)%3!=0){
        cout<<0<<endl;
        return 0;
    }
    int z=(x+y)/3;
    mint a=x-z, b=y-z;
    cout<<comb((a+b),b)<<endl;
    return 0;
}

Measured memory_bytes: 35172
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
const int INF = 1e9 + 7;
int main(){
    int n, k, q;  cin>>n>>k>>q;
    vi v(n+1,k-q);
    for(int i = 0; i < q; i++){
        int t; cin>>t;
        v[t]++;
    }
    for(int i = 1; i <= n; i++){
        if(v[i]>0) cout<<"Yes\n";
        else cout<<"No\n";
    }
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main()
{
	string S,T,U;
	int A,B;
	cin>>S>>T;
	cin>>A>>B;
	cin>>U;
	if(U == S) A--;
	if(U == T) B--;
	cout<<A<<" "<<B<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}


  int main(){
    lint A,B;
    lint ans=0;
    cin>>A>>B;
    lint x[60];
    rep(i,60){
        x[i]=0;
    }
    lint f=log2(A)+1;
    lint g=log2(B)+1;
    rep(i,g){
        lint j=(B+1)/(lint)pow(2,i+1);
        x[i]+=j*(lint)pow(2,i);
        lint b=(B+1)-j*pow(2,i+1);
        x[i]+=max((lint)0,b-(lint)pow(2,i));
    }

        rep(i,f){
        lint j=A/(lint)pow(2,i+1);
        x[i]-=j*(lint)pow(2,i);
        lint b=A-j*pow(2,i+1);
        x[i]-=max((lint)0,b-(lint)pow(2,i));
    }
    rep(i,60){
        if(x[i]%2==1)ans+=(lint)pow(2,i);
            }
            cout<<ans;
     }
  

Measured memory_bytes: 384
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,C;
	while(cin>>N>>M>>C) {
		VI A(M),B(M); ll ans=0;
REP(i, M) cin>>B[i];
REP(j, N) {
ll v=C;
REP(i, M){
cin>>A[i];
v+=A[i]*B[i];
}
if(v>0)ans++;
}
cout<<ans<<endl;
		
		
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
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=1e9+7 ;
#define SIZE_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))

unsigned GetDigit(unsigned num){
    return std::to_string(num).length();
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    int count;
    int j = 1;
    cin >> N;
    int sum;
    int n = N;
    while(N){
    count = N % 10;
    sum = sum + count;
    N = N / 10;
    }

    if(n % sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int main(int argc, char const* argv[])
{
    int H, W;
    cin >> H >> W;

    vector<pair<int,int>> black;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            char A;
            cin >> A;
            if (A == '#') {
                black.push_back({i,j});
            }
        }
    }

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

    vector<vector<int>> d(H, vector<int>(W, -1));
    for (auto itr : black) {
        d[itr.first][itr.second] = 0;
    }

    int ans = 0;
    for (int i = 0; i < (int)black.size(); i++) {
        int x = black[i].first, y = black[i].second;
        for (int j = 0; j < 4; j++) {
            int gx = x + dx[j], gy = y + dy[j];
            if (0 <= gx && gx < H && 0 <= gy && gy < W && d[gx][gy] == -1) {
                d[gx][gy] = d[x][y] + 1;
                ans = max(ans, d[gx][gy]);
                black.push_back({gx,gy});
            }
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 14444
#include <iostream>
#include <cassert>
#include <vector>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <fstream>
#include <string>
#include <sstream>
#include <iterator>
#include <map>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <limits>
#include <typeinfo>
 
#include <stdio.h>
#include <string.h>
 
 
using namespace std;
 
int main(int argc, char* argv[])
{
	int N,M;
	int a[50],b[50];
	int road[50];
 
	cin >> N >> M;

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

	memset(road,0,sizeof(road));

	for(int i=0;i<M;i++){
		road[a[i]-1]+=1;
		road[b[i]-1]+=1;
	}

	for(int i=0;i<N;i++){
		cout << road[i] << endl;
	}
 
	return 0;
}


Measured memory_bytes: 256
A,B = map(int, raw_input().split())

result = False
Amin = int(round(A * 12.5)) 
Amax = int(round((A+1) * 12.5)-1)
Bmin = B * 10
Bmax = (B+1) * 10 - 1


for i in range(Amin,Amax+1):
    for j in range(Bmin,Bmax+1):
        if(i == j):
            print(i)
            result = True
            break

    if(result):

        break



if(result==False):
    print(-1)        
       
    


Measured memory_bytes: 2568
#include <stdio.h>
using namespace std;
const int mod = 1000000007;
const int maxn = 234567;
int mul(long long a, long long b){
	return a * b % mod;
}
int xp(int a, int b){
	int r = 1;
	for(; b; b >>= 1, a = mul(a, a)) if(b&1) r = mul(r, a);
	return r;
}
int p[maxn], q[maxn];
int fat[maxn], ifat[maxn], p2[maxn];
int ncr(int n, int r){
	if(r > n) return 0;
	return mul(fat[n], mul(ifat[r], ifat[n - r]));
}
void pre(){
	fat[0] = 1;
	for(int i = 1; i < maxn; i++) fat[i] = mul(i, fat[i - 1]);
	ifat[maxn - 1] = xp(fat[maxn - 1], mod - 2);
	for(int i = maxn - 2; i >= 0; i--) ifat[i] = mul((i + 1), ifat[i + 1]);
	p2[0] = 1;
	for(int i = 1; i < maxn; i++) p2[i] = mul((mod + 1)/2, p2[i - 1]);
}
int main(){
	pre();
	int B, W; scanf("%d %d", &B, &W);
	for(int i = 1; i <= W + B; p[i] %= mod, i++) p[i] = p[i - 1] + mul(p2[i], ncr(i - 1, B - 1));
	for(int i = 1; i <= W + B; q[i] %= mod, i++) q[i] = q[i - 1] + mul(p2[i], ncr(i - 1, W - 1));
	for(int i = 0; i < W + B; i++){
		int num = 1 + mod - p[i] + q[i];
		if(num >= mod) num -= mod;
		printf("%d\n", mul(num, (mod + 1)/2));
	}
	return 0;
}


Measured memory_bytes: 6528
#include<iostream>
using namespace std;
int main()
{
     long long n,k,x,y,l;
     cin>>n>>k>>x>>y;
     if(n>=k)
     {
         cout<<((k*x)+((n-k)*y))<<endl;
     }
     else
     {
         cout<<((n*x))<<endl;
     }
     return 0;
}

Measured memory_bytes: 3640
defmodule Main do
  def main do
    n =
      IO.read(:line)
      |> String.trim
      |> String.to_integer

    ans =
      1 .. n + 1
      |> Enum.reduce(0, fn (i, acc) ->
        y = div(n, i)
        acc + div(y * (y + 1) * i, 2)
      end)


    IO.puts(ans)
  end
end


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

int main()
{
 int N;
 cin >> N;
 int a,b,c,d;
 a = N / 1000;
 b = (N - a*1000)/100;
 c =  (N - a*1000 - b*100)/10;
 d = N - a*1000 - b*100 - c *10;
 int count = 0;
 if(a == 2) count++; 
 if(b == 2) count++; 
 if(c == 2) count++; 
 if(d == 2) count++; 
 cout << count;
 return 0;
}


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int n;cin >> n;
    ll x[15],y[15],p[15];
    for (int i = 0;i < n;++i) cin >> x[i] >> y[i] >> p[i];
    vector<vector<ll>> mnx(1<<n,vector<ll>(n)),mny(1<<n,vector<ll>(n));
    vector<ll> dp(1<<n,1e18);
    for (int s = 0;s < (1<<n);++s) {
        for (int i = 0;i < n;++i) {
            mnx[s][i] = abs(x[i]);
            for (int j = 0;j < n;++j) if ((s>>j)&1) mnx[s][i] = min(mnx[s][i],abs(x[i]-x[j]));
        }
    }
    for (int s = 0;s < (1<<n);++s) {
        for (int i = 0;i < n;++i) {
            mny[s][i] = abs(y[i]);
            for (int j = 0;j < n;++j) if ((s>>j)&1) mny[s][i] = min(mny[s][i],abs(y[i]-y[j]));
        }
    }
    vector<ll> ans(n+1,1e18);
    int t = 1;
    for (int i = 0;i < n;++i) t *= 3;
    for (int s = 0;s < t;++s) {
        int ss = s,bitx = 0,bity = 0,cnt = 0;
        for (int i = 0;i < n;++i) {
            if (ss%3 == 1) bitx += (1<<i),cnt++;
            else if (ss%3 == 2) bity += (1<<i),cnt++;
            ss /= 3;
        }
        ll sum = 0;
        for (int i = 0;i < n;++i) sum += min(mnx[bitx][i],mny[bity][i])*p[i];
        ans[cnt] = min(ans[cnt],sum);
    }
    for (int i = 0;i < n+1;++i) cout << ans[i] << newl;
}

Measured memory_bytes: 13164
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll max(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
double max(double a, double b) {

	if (a > b)return a;
	else return b;

}
//a??¨b?????§?????????

ll min(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//a??¨b????°??????????

ll avd_i(ll a, ll b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//a??¨b???????????¶??????

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//p????´???°,a???b??????p??§?????£?????????

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//p????´???°,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//?????§??¬?´???°

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//????°???¬?????°

int main() {
	
	const string S[4] = { "S","H","C","D" };

	int n;
	bool check[4][13];

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {

			check[i][j] = false;

		}
	}

	cin >> n;
	for (int i = 0; i < n; i++) {

		char c;
		int num;

		cin >> c >> num;

		switch (c) {

		case 'S':
			check[0][num - 1] = true;
			break;
		case 'H':
			check[1][num - 1] = true;
			break;
		case 'C':
			check[2][num - 1] = true;
			break;
		case 'D':
			check[3][num - 1] = true;
			break;

		}

	}

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {

			if (!check[i][j])cout << S[i] << " " << j + 1 << endl;

		}
	}

	return 0;
}

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

const int mod = 1e9+7;

int main() 
{
	int n, k;
	scanf("%d%d", &n, &k);
	int dp[100005];
	int a[103];
	memset(dp, 0, sizeof(dp));
	dp[0] = 1;
	for(int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		vector<int> prefix(k+1, 0);
		vector<int> tmp(k+2, 0);
		for(int j = k; j >= 0; j--) {
			tmp[j+1] += dp[j];
			if(tmp[j+1] >= mod) tmp[j+1] -= mod;
			tmp[min(k, j+x)+1] += (-1)*dp[j];
			tmp[min(k, j+x)+1] %= mod;
			if(tmp[min(k, j+x)+1] < 0) tmp[min(k, j+x)+1] += mod;
		}
		for(int j = 1; j <= k; j++) {
			prefix[j] = prefix[j-1] + tmp[j];
			// printf("___tmp[j]___ : %d\n", tmp[j]);
			if(prefix[j] >= mod) prefix[j] -= mod;
		}
		for(int j = 0; j <= k; j++) {
			dp[j] += prefix[j];
			// printf("___prefix[j]___ : %d\n", prefix[j]);
			// printf("___dp[%d]___ : %d\n", i, dp[j]);
			if(dp[j] >= mod) dp[j] -= mod;
		}
	}
	if(dp[k] < 0) dp[k] += mod;
	printf("%d\n", dp[k]%mod);
}

Measured memory_bytes: 4460
#include <stdio.h>
void MRoy(){
    long long a,b;
    scanf("%lld%lld",&a,&b);
    if((a+b)&1) printf("IMPOSSIBLE\n");
    else printf("%lld\n",(a+b)/2);
    return;
}
int main(){
    MRoy();
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define LL long long
#define mp make_pair
#define next tipa_next
#define hash tipa_hash
#define ll long long
const int INF = 1000LL*1000*1000;
const int base = 1000 * 1000 * 1000;
LL n , sum;
LL a[200005];
LL c[200005];
LL f[200005];
LL g[200005];
LL zapas[200005];
int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        c[i] = a[i];
    }
    LL ans = INF * (LL) INF;
    LL cur = 0;
    for(int i = 1; i < n; i++)
    {
        LL d = a[i];
        while(d * 4 <= a[i - 1])
        {
            d *= 4;
            zapas[i]++;
        }
    }
    f[0] = 0;
    f[1] = 1;
    vector<int> zapasy;
    for(int i = 1; i < n; i++)
    {
        f[i + 1] = f[i] + 1;
        if(a[i] <= a[i - 1])
        {
            while(zapas[i])
            {
                zapasy.PB(i);
                zapas[i]--;
            }
        }
        else
        {
            while(a[i] > a[i - 1])
            {
                a[i - 1] *= 4;
                if(zapasy.size())
                {
                    f[i + 1] += 2 * (i - zapasy.back());
                    zapasy.pop_back();
                }
                else
                {
                    f[i + 1] += 2 * i;
                }
            }
        }
    }
    zapasy.clear();
    for(int i = 0; i < n; i++)
        a[i] = c[i];
    reverse(a , a + n);
    
    for(int i = 1; i < n; i++)
    {
        LL d = a[i];
        while(d * 4 <= a[i - 1])
        {
            d *= 4;
            zapas[i]++;
        }
    }
    for(int i = 1; i < n; i++)
    {
        g[i + 1] = g[i];
        if(a[i] <= a[i - 1])
        {
            while(zapas[i])
            {
                zapasy.PB(i);
                zapas[i]--;
            }
        }
        else
        {
            while(a[i] > a[i - 1])
            {
                a[i - 1] *= 4;
                if(zapasy.size())
                {
                    g[i + 1] += 2 * (i - zapasy.back());
                    zapasy.pop_back();
                }
                else
                {
                    g[i + 1] += 2 * i;
                }
            }
        }
    }
    // for(int i = 0; i <= n; i++)
    // {
    //     cout << f[i] << " ";
    // }
    // cout << endl;
    // for(int i = 0; i <= n; i++)
    // {
    //     cout << g[i] << " ";
    // }
    // cout << endl;
  
    for(int i = 0; i <= n; i++)
        ans = min(ans , f[i] + g[n - i]);
    cout << ans;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll H, W;
    cin >> H >> W;
    vector<string> grid(H);
    rep(i, H) cin >> grid[i];
    vector<vector<ll>> L(H + 1, vector<ll>(W + 1, 0));
    vector<vector<ll>> R(H + 1, vector<ll>(W + 1, 0));
    vector<vector<ll>> U(H + 1, vector<ll>(W + 1, 0));
    vector<vector<ll>> D(H + 1, vector<ll>(W + 1, 0));

    rep(i, H) {
        rep(j, W) {
            if (grid[i][j] == '.') {
                R[i][j + 1] += R[i][j] + 1;
            } else {
                R[i][j + 1] = 0;
            }
        }
        rrep(j, W - 1, 0) {
            if (grid[i][j] == '.') {
                L[i][j] += L[i][j + 1] + 1;
            } else {
                L[i][j] = 0;
            }
        }
    }
    rep(j, W) {
        rep(i, H) {
            if (grid[i][j] == '.') {
                U[i + 1][j] += U[i][j] + 1;
            } else {
                U[i + 1][j] = 0;
            }
        }
        rrep(i, H - 1, 0) {
            if (grid[i][j] == '.') {
                D[i][j] += D[i + 1][j] + 1;
            } else {
                D[i][j] = 0;
            }
        }
    }
    ll ans = 0;
    rep(i, H) {
        rep(j, W) {
            if (grid[i][j] == '#')continue;
            ll cnt = R[i][j] + L[i][j + 1] + U[i][j] + D[i + 1][j] + 1;
            ans = max(ans, cnt);
        }
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 130048
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>

using namespace std;

#define REP(i,a,b) for((i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) REP(i,0,n)
// BEGIN CUT HERE
#define foreach(itr,c) for(typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
// END CUT HERE

int main(){
  int i;
  vector<int> in(5);

  rep(i,5) cin >> in[i];
  sort(in.begin(), in.end(), greater<int>());
  rep(i,4) cout << in[i] << " ";
  cout << in[4] << endl;

  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<utility>

using namespace std;

int main(){

	int ans=0;
	int ans2=0;
	int n,m;
	cin>>n>>m;
	int p[m];
	string s[m];
	vector<pair<int,int> > v(n);
	for(int i=0;i<m;i++){
		cin>>p[i]>>s[i];
	}

	for(int i=0;i<m;i++){
		if(s[i]=="WA")v[p[i]-1].first++;
		else if(s[i]=="AC"){
			if(v[p[i]-1].second==0){
				ans+=v[p[i]-1].first;
				ans2+=1;
				v[p[i]-1].second=1;
			}
		}
	}


	cout<<ans2<<" "<<ans;

	cout<<endl;

	return 0;
}


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

int main()
{
    string s;
    int l, i, f;

    cin >> s;

    l = s.length();

    for(i = 0; i < l; i++){
        if(i % 2 == 0){
            if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D'){
                f = 1;
            }
            else{
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D'){
                f = 1;
            }
            else{
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256