akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
from heapq import heappop, heappush

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def dijkstra(E, start):
    N_d = len(E)
    dist = [INF] * N_d
    dist[start] = 0
    q = [(0, start)]
    while q:
        dist_v, v = heappop(q)
        if dist[v] != dist_v:
            continue
        for u, dist_vu in E[v]:
            dist_u = dist_v + dist_vu
            if dist_u < dist[u]:
                dist[u] = dist_u
                heappush(q, (dist_u, u))
    return dist

N, M = MAP()
ab = [LIST() for _ in range(M)]

graph = [[] for _ in range(N)]

for a, b in ab:
	graph[a-1].append((b-1, 1))
	graph[b-1].append((a-1, 1))

ans = 0
for a, b in ab:
	E = deepcopy(graph)
	E[a-1].remove((b-1, 1))
	d = dijkstra(E, a-1)
	if d[b-1] == INF:
		ans += 1
print(ans)


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

int main() {
  string S, T;
  cin >> S >> T;
  vector<int> alpha1(26,-1), alpha2(26,-1);
  int length = S.length();
  string result = "Yes";
  for (int i = 0; i < length; i++) {
    int c1 = S.at(i)-'a', c2 = T.at(i)-'a';
    if (alpha1[c1] != -1 or alpha2[c2] != -1) {
      if (alpha1[c1] != c2 or alpha2[c2] != c1) {
        result = "No";
      }
    }
    alpha1[c1] = c2, alpha2[c2] = c1;
  }
  cout << result << endl;
  return 0;
}



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

long double a,b,c;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>a>>b>>c;
    
    
    long double left = (long double)a+(long double)b+(long double)(2*sqrt(a*b));
    long double right = (long double)c;
    if (left-right>=0.000000000000000000000000000) cout<<"No";
    else cout<<"Yes";
    
    
    




    return 0;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const long long  int INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"

void Main()
{
	ll N,X;
	ll result=1;
	string S;
	cin>>N>>X;
	VI A(N);
	REP(i, N) cin >> A[i];
	ll pos=0;
	REP(i,N){
		pos+=A[i];
		if(pos<=X)
			result++;
	}


	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


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

int n,pos;

vector<int> pre,in,post;

void rec(int l, int r)
{
    if(l>=r) return;
    int root=pre[pos++];
    int m=distance(in.begin(), find(in.begin(),in.end(),root));
    rec(l,m);
    rec(m+1,r);
    post.push_back(root);
}

void solve()
{
    pos=0;
    rec(0,pre.size());
    for(int i=0;i<n;i++){
        if(i) cout<<" ";
        cout<< post[i];
    }
    cout<<endl;
}

int main()
{
    int k;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>k;
        pre.push_back(k);
    }
    for(int i=0;i<n;i++){
        cin>>k;
        in.push_back(k);
    }
    solve();
    return 0;
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n, k; 
    cin >> n >> k;
    if(n%k == 0) cout << 0 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 384
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define fi first
#define se second
#define mkp make_pair    
#define mkt make_tuple
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vc vector<char> 
#define vll vector< pair<ll,ll> > 
#define mps map<string ,ll>
#define mpc map<char ,ll>
#define mpl map<ll, ll>
#define pr pair<ll,ll>
#define tpl tuple<ll,ll,ll>
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll t=1;
      
//	   cin>>t;
      

	      while(t--)
{
ll n;
/*
6
AC
TLE
AC
AC
WA
TLE*/
cin>>n;
string  s;
map <string ,ll> M;
fo(i,n)
{
	cin>>s;
	M[s]++;
}/*
AC x 3
WA x 1
TLE x 2
RE x 0
*/
cout<<"AC x "<<M["AC"];
ee;
cout<<"WA x "<<M["WA"];
ee;
cout<<"TLE x "<<M["TLE"];
ee;
cout<<"RE x "<<M["RE"];
ee;







}
return 0;
}














Measured memory_bytes: 3640
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <bitset>
#include <complex>
using namespace std;

const double EPS = 1e-9;
const double PI = 3.14159265359;

typedef complex<double> P;

int main(){
	int m, n;

	while(cin >> n >> m, m+n){
		vector<int> v(n+1);
		int pos = 0;
		for(int i = 0; i < n-1; i++){
			for(int j = 0; j < m; j++){
				pos=pos%n+1;
				while(v[pos] != 0){
					pos=pos%n+1;
				}
			}
			v[pos] = 1;
		}
		for(int i = 1; i < n+1; i++){
			if(!v[i]){
				cout << i << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
int main(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double ans = 360.0*((max(h*5+(m/60.0)*5.0,m)-min(h*5+(m/60.0)*5.0,m))/60.0);
    double pi = DegreeToRadian(ans);
    double c = a*a + b*b - 2*a*b*cos(pi);
    c = sqrt(c);
    printf("%.15lf",c);
    return 0;
}

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

const int N = 1010;

int n, m, row, col;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m >> row >> col;
	for (int i = 0; i < n; i++, cout << '\n')
		for (int j = 0; j < m; j++)
			cout << ((i >= col) ^ (j >= row));
}


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

int main()
{
  string a;
  cin >> a;
  
  int i = 0;
  if(a[0] == '1') ++i;
  if(a[1] == '1') ++i;
  if(a[2] == '1') ++i;
  cout << i << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_mutiset tree<int,null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(ll i=vv;i<n;i++)
#define FORR(i,n,vv) for(ll i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define INF 1000000000000000000ll
#define PRECISE cout.precision(18);
#define all(v) v.begin(),v.end()
#define BS(v,n) binary_search(all(v),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(all(v),greater <ll>())
#define uni(v) v.resize(unique(all(v))-v.begin())
#define F first
#define S second
#define GET(i,p) get<p>(i)

/////////


int main(){

	#ifndef ONLINE_JUDGE
    // for getting input from input.txt	
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif	

    FAST
//	PRECISE

ll x;
cin>>x;
if(x>=30)cout<<"Yes";
else cout<<"No";

return 0;
 }



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI 3.1415926535897
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int N;
string W[110];


bool solve(){
	rep(i, 0, N)
		rep(j, 0, N)
			if(i != j && W[i] == W[j]) return false;
	rep(i, 0, N-1)
		if(W[i].back() != W[i+1][0]) return false;
	return true;
}


signed main(){
	cin >> N;
	rep(i, 0, N) cin >> W[i];

	if(solve()) Yes;
	else No;

	return 0;
}


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

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

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

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	string s; cin >> s;
	int cur = s.size() - 1;
	while (cur >= 4) {
		bool found(false);
		for (int i = 0; i < 4; ++i) if (st[i].size() <= cur + 1) {
			if (s.substr(cur - st[i].size() + 1, st[i].size()) == st[i]) {
				cur -= st[i].size();
				found = true; break;
			}
		}
		if (!found) break;
	}
	puts(cur < 0 ? "YES" : "NO");

	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(){
   long n,k,a;

   scanf("%ld",&k);
   a=7;
   for (n=1;a%k>0 && n<=k;n++)
      a=(a*10+7)%k;
   if (n<=k) printf("%ld\n",n);
   else      puts("-1");
   return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
 
int n;
long long dp[402][402];
long long sum[402][402];
long long a[402];
 
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	
	memset(dp,0x7f,sizeof dp);
	
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j++){
			sum[i][j] = sum[i][j-1] + a[j];
		}
	}
	
	for(int j=1;j<=n;j++){
		dp[j][j] = 0;
		for(int i=j-1;i>0;i--){
			for(int k=i+1;k<=j;k++){
				dp[i][j] = min(dp[i][j], dp[i][k-1]+dp[k][j]);
			}
			dp[i][j] += sum[i][j];
		}
	}
	
	cout<<dp[1][n];
	
	return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];

  vector<vector<Int> > G(30);
  for(Int i=0;i<n;i++){
    Int k=a[i],x=0;
    while(~k&1) k>>=1,x++;
    G[x].emplace_back(k>>1);
  }
  
  Int ans=0;
  for(Int i=0;i<30;i++){
    vector<Int> v=G[i];
    sort(v.rbegin(),v.rend());
    map<Int, queue<Int> > mq;
    Int m=v.size();
    for(Int j=0;j<m;j++) mq[v[j]].emplace(j);
    vector<Int> used(m,0);
    for(Int j=0;j<m;j++){
      if(used[j]) continue;
      Int d=1;
      while(v[j]>=d) d<<=1;
      d--;
      assert((d&v[j])==v[j]);
      Int y=d^v[j];
      if(!mq.count(y)||mq[y].empty()) continue;
      Int z=mq[y].front();mq[y].pop();
      while((used[z]||z==j)&&!mq[y].empty()){
        z=mq[y].front();mq[y].pop();
      }
      if(used[z]||z==j) continue;
      used[j]=1;
      used[z]=1;
      ans++;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}


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

struct Edge {
  int from, to, id, color = 0;
  Edge() {}
  Edge(int f, int t) : color(0), from(f), to(t) {}
  Edge(int f, int t, int id) : from(f), to(t), id(id) {}
  friend bool operator < (const Edge& lhs, const Edge& rhs) { return lhs.color < rhs.color; };
  friend bool operator > (const Edge& lhs, const Edge& rhs) { return rhs < lhs; };
  friend bool operator <= (const Edge& lhs, const Edge& rhs) { return !(lhs > rhs); };
  friend bool operator >= (const Edge& lhs, const Edge& rhs) { return !(lhs < rhs); };
};

typedef vector<vector<Edge>> Graph;

int color[100010];
int ans[100010];
int n;

int bfs(Graph& g) {
  int k = 1;
  queue<int> q;
  for (int i = 0; i < n; ++i) {
    color[i] = -1;
  }
  color[0] = 0;
  q.push(0);
  while (!q.empty()) { 
    int from = q.front(); q.pop();
    int c = 1;
    for (Edge& e: g[from]) {
      if (color[e.to] != -1) continue;
      if (c == color[from]) ++c;
      // cerr << c << " " << from << " " << e.to << endl;
      color[e.to] = c++;
      ans[e.id] = color[e.to];
      e.color = c;
      k = max(k, color[e.to]);
      q.push(e.to);
    }
  }
  return k;
}

int main() {
  cin >> n;
  Graph g(n);
  for (int i = 0; i < n-1; ++i) {
    int a, b;
    cin >> a >> b;
    --a;--b;
    g[a].emplace_back(a, b, i);
    g[b].emplace_back(b, a, i);
  }
  int k = bfs(g);
  cout << k << endl;
  for (int i = 0; i < n-1; ++i) {
    cout << ans[i] << endl;
  }
}



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

int ans;
int hi;

bool fnc(ll n)
{
    int chk[10] = {};

    while (n) {
        int rem = n % 10;
        chk[rem] = 1;
        n /= 10;
    }

    if (chk[3] && chk[5] && chk[7]) return true;

    return false;
}

void dfs(ll n)
{
    if (n > hi) return;

    if (fnc(n)) ans++;

    dfs(n*10 + 3);
    dfs(n*10 + 5);
    dfs(n*10 + 7);
}

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

    dfs(0);

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int w[10],k[10];
	int wmax[3]={0,0,0};
	int kmax[3]={0,0,0};
	int i,n;
	for(i=0;i<10;i++){
		scanf("%d",&w[i]);
	}
	for(i=0;i<10;i++){
		scanf("%d",&k[i]);
	}
	for(i=0;i<10;i++){
		if(w[i]>wmax[0])wmax[0]=w[i];
	}
	for(i=0;i<10;i++){
		if(w[i]>wmax[1]&&w[i]<wmax[0])wmax[1]=w[i];
	}
	for(i=0;i<10;i++){
		if(w[i]>wmax[2]&&w[i]<wmax[0]&&w[i]<wmax[1])wmax[2]=w[i];
	}
	for(i=0;i<10;i++){
		if(k[i]>kmax[0])kmax[0]=k[i];
	}
	for(i=0;i<10;i++){
		if(k[i]>kmax[1]&&k[i]<kmax[0])kmax[1]=k[i];
	}
	for(i=0;i<10;i++){
		if(k[i]>kmax[2]&&k[i]<kmax[0]&&k[i]<kmax[1])kmax[2]=k[i];
	}
	printf("%d %d\n",wmax[0]+wmax[1]+wmax[2],kmax[0]+kmax[1]+kmax[2]);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
const ll INF = ll(1e9);
const int N = 1e5 + 5;
const ll mod = 1000000007 ;
using namespace std;


int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);


	ll tc = 1;

	// cin >> tc;


	while (tc--) {

		ll n, i, j, r, x, y;

		cin >> n;



		ll rem = n % 10;
		n = rem;
		if (n == 3) {
			cout << "bon" << endl;
		}

		else if (n == 2 or n == 4 or n == 5 or n == 7 or n == 9) {
			cout << "hon" << endl;
		}

		else cout << "pon" << endl;






	}

}

Measured memory_bytes: 3644
#include <iostream>
#include <stdio.h>
using namespace std;

void swap(long long int *a, long long int*b) {
	long long int x;
	x = *a;
	*a = *b;
	*b = x;
}

int GetGCD(long long int a, long long int b) {
	if (b > a) { swap(&a, &b); }
	while (a%b != 0) {
		a = a%b;
		swap(&a, &b);
	}
	return b;
}

int main() {
	long long int a, b, GCD, LCM;
	while (cin >> a>> b) {
		GCD = GetGCD(a, b);
		LCM = a*b / GCD;
		cout << GCD << " " << LCM << endl;
	}
}

Measured memory_bytes: 1156
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int main()
{
    int n,m,a[200005],b[200005];
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    scanf("%d",&m);
    for(int i=0;i<m;i++)
        scanf("%d",&b[i]);
    if(n<m)
        {
            printf("NO\n");return 0;
        }
    sort(a,a+n);
    sort(b,b+m);
    int j=n-1;
    for(int i=m-1;i>=0;i--)
    {
        int t=1,g=0;
        while(b[i-1]==b[i])
        {
            t++;i--;
        }
        while(a[j]>b[i])
            j--;
        if(j-t+1<0||a[j-t]<b[i-1])
        {
            printf("NO\n");return 0;
        }
        if(a[j-t+1]!=b[i])
        {
            printf("NO\n");return 0;
        }
        j-=t;
    }
    printf("YES\n");
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vl vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, ans = 100000000000000;
  std::cin >> n;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ans = min(ans, i + n/i);
    }
  }
  std::cout << ans - 2 << '\n';
  return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a  =sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    int e = sc.nextInt();
    int ans = 0;
    if(a == 0) ans = 1;
    else if(b == 0) ans = 2;
    else if(c == 0) ans = 3;
    else if(d == 0) ans = 4;
    else ans = 5;
    System.out.println(ans);
    sc.close();
  }
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &e: a) cin >> e;
    
    vector<int> loc(n+1);
    set<int> s;
    for (int i = 0; i < n; ++i) {
        s.insert(i);
        loc[a[i]] = i;
    }
    s.insert(-1);
    s.insert(n);
    
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        auto it = s.find(loc[i]);
        auto lo = prev(it), hi = next(it);
        if (*lo != -1) {
            ans += (ll)i * (*lo - *prev(lo)) * (*hi - *it);
        }
        if (*hi != n) {
            ans += (ll)i * (*it - *lo) * (*next(hi) - *hi);
        }
        s.erase(it);
    }
    
    cout << ans << endl;
        
    
    return 0;
}


Measured memory_bytes: 5760
import sys
str_in = ""
for e in sys.stdin:
    str_in += e
str_in_lower = str_in.lower()
print("a : " + str(str_in_lower.count("a")))
print("b : " + str(str_in_lower.count("b")))
print("c : " + str(str_in_lower.count("c")))
print("d : " + str(str_in_lower.count("d")))
print("e : " + str(str_in_lower.count("e")))
print("f : " + str(str_in_lower.count("f")))
print("g : " + str(str_in_lower.count("g")))
print("h : " + str(str_in_lower.count("h")))
print("i : " + str(str_in_lower.count("i")))
print("j : " + str(str_in_lower.count("j")))
print("k : " + str(str_in_lower.count("k")))
print("l : " + str(str_in_lower.count("l")))
print("m : " + str(str_in_lower.count("m")))
print("n : " + str(str_in_lower.count("n")))
print("o : " + str(str_in_lower.count("o")))
print("p : " + str(str_in_lower.count("p")))
print("q : " + str(str_in_lower.count("q")))
print("r : " + str(str_in_lower.count("r")))
print("s : " + str(str_in_lower.count("s")))
print("t : " + str(str_in_lower.count("t")))
print("u : " + str(str_in_lower.count("u")))
print("v : " + str(str_in_lower.count("v")))
print("w : " + str(str_in_lower.count("w")))
print("x : " + str(str_in_lower.count("x")))
print("y : " + str(str_in_lower.count("y")))
print("z : " + str(str_in_lower.count("z")))



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

int main() {
    int N, out=1;
    cin >> N;
    vector<int> d(N);
    for (int i=0; i<N; i++) cin >> d.at(i);
    sort(d.begin(), d.end());
    int ue = d.at(N-1);
    for (int i=2; i<N+1; i++){
        if (ue>d.at(N-i)){
            out += 1;
            ue = d.at(N-i);
        }
    }
    cout << out << endl;
    return 0;
}


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

#define  _   int v, int tl, int tr, int l, int r
#define tm  (tl+tr >> 1)
#define sol v+v,tl,tm,l,r
#define sag v+v+1,tm+1,tr,l,r

#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef pair< int , int > pp;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;

int A[N],n,i,x,mn,mx,mni,mxi;

signed main(){
    cin >> n;
    for(i=1;i<=n;i++){
        cin >> x;
        A[i] = x;
        if(mn > A[i]){ mn=A[i]; mni = i; }
        if(mx < A[i]){ mx=A[i]; mxi = i; }
    }
    if(mx == 0 && mn == 0){
        cout << "0\n";
        return 0;
    }
    if(mx > -mn){
        cout << n+n << endl;
        cout << mxi << " " << mxi << endl;
        cout << mxi << " " << 1 << endl;
        for(i=1;i<n;i++){
            cout << i << " " << i+1 << endl;
            cout << i << " " << i+1 << endl;
        }
    }
    else{
        cout << n+n << endl;
        cout << mni << " " << mni << endl;
        cout << mni << " " << n << endl;
        for(i=n; i>1 ;i--){
            cout << i << " " << i-1 << endl;
            cout << i << " " << i-1 << endl;    
        }
    }
    
    return 0;
}

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

using namespace std;

int main() {
    int N, K; cin >> N >> K;
    int R, S, P; cin >> R >> S >> P;
    string T; cin >> T;
    string Q = "";

    int ans = 0;
    for (int i = 0; i < T.size(); ++i) {
        if (T[i] == 'r') {
            if (i >= K && Q[i - K] == 'p') {
                if (T[i + K] == 's') {
                    Q.append(1, 's');
                } else {
                    Q.append(1, 'r');
                }
            } else {
                Q.append(1, 'p');
                ans += P;
            }
        } else if (T[i] == 's') {
            if (i >= K && Q[i - K] == 'r') {
                if (T[i + K] == 'p') {
                    Q.append(1, 'p');
                } else {
                    Q.append(1, 's');
                }
            } else {
                Q.append(1, 'r');
                ans += R;
            }
        } else if (T[i] == 'p') {
            if (i >= K && Q[i - K] == 's') {
                if (T[i + K] == 'r') {
                    Q.append(1, 'r');
                } else {
                    Q.append(1, 'p');
                }
            } else {
                Q.append(1, 's');
                ans += S;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
const ll INF = 100000000000000000;

int main(){
    string s;
    cin>>s;
    string day[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    rep(i,0,6){
        if(s==day[i]){
            cout<<7-i<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int r[6][4]={
    {0,1,5,4},
    {0,3,5,2},
    {0,2,5,3},
    {0,4,5,1},
    {1,2,4,3},
    {1,3,4,2}
  };
  char W[6][7]={"North","East","West","South","Right","Left"};
  int n,s,i,j,k,t;
  char w[7];
  while(1){
    scanf("%d",&n);
    if(!n)break;
    int D[]={1,2,3,4,5,6};
    s=1;
    for(i=0;i<n;i++){
      scanf("%s",w);
      for(j=0;j<7;j++){
	if(strcmp(W[j],w)==0)break;
      }
      t=D[r[j][0]];
      for(k=0;k<3;k++)D[r[j][k]]=D[r[j][k+1]];
      D[r[j][3]]=t;
      s+=D[0];
      /*printf(" %d\n",D[2]);
      printf("%d%d%d%d\n",D[0],D[1],D[5],D[4]);
      printf(" %d\n",D[3]);*/
    }
    printf("%d\n",s);
  }
  return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

int main(void){
    int n;cin>>n;
    map<int,int> v;
    rep(i,n){
        int p;cin>>p;
        if(v.find(p)==v.end())v[p]=0;
        v[p]++;
    }
    int ans=0;
    for(auto p : v){
        if(p.second>p.first){
            ans+=p.second-p.first;
        }
        if(p.second<p.first){
            ans+=p.second;
        }
    }
    cout<<ans;
}



Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B;
    cin >> A >> B;
    cout << (A-1)*(B-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define YES "YES"
#define Yes "Yes"
#define NO "NO"
#define No "No"
#define YESNO OUT(three(solve(),YES,NO))
#define YesNo OUT(three(solve(),Yes,No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b-1,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB emplace_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int long long
#define zero 0LL
#define pb PB
using namespace std;
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef long double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
int dx[] = { 0,1,0,-1,1,1,-1,-1,0 }, dy[] = { 1,0,-1,0,1,-1,1,-1,0 };
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 1010;
const int SIZE3 = 188;
const int SIZE = SIZE1;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
LL solve(){
	int n;
	cin >> n;
	REP(i,n){
		LL ans=0,y,m,d;
		cin >> y >> m >> d;
		while(true){
			//cout << y <<" " << m <<" " << d << endl;
			
			if((y%3)?(d==m%2+19):(d==20)){
				d=0;
				m++;
			}
			if(m==11){
				m=1;
				y++;
			}
			if(y==1000){
				break;
			}
			ans++;
			d++;
		}	
		cout << ans+1 << endl;
	}
	return 0;
}
signed main(){

	solve();

}


Measured memory_bytes: 3084
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 4000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
bool vis[10];
bool judge(int x){
    while(x){
        int temp=x%10;
        if(vis[temp])
            return false;
        x/=10;
    }
    return true;
}
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
 
    memset(vis,false,sizeof(vis));
    for(int i=1; i<=k; i++){
        int x;
        scanf("%d",&x);
        vis[x]=true;
    }
 
    for(int i=n; ; i++){
        if(judge(i)){
            printf("%d\n",i);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	int A, B; cin >> A >> B;
	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0)cout << "Possible" << "\n";
	else cout << "Impossible" << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define N 100010
int n,num,m,h[N],vis[N];
struct node{int to,next;}mp[N<<1];
vector<int>ans;
inline void ins(int x,int y){
	mp[++num].to=y;mp[num].next=h[x];h[x]=num;
	mp[++num].to=x;mp[num].next=h[y];h[y]=num;
}
void dfs(int x,int rt){
	for(int i=h[x];i;i=mp[i].next){
		int y=mp[i].to;if(y==rt || vis[y]) continue;
		vis[y]=1;ans.push_back(y);dfs(y,rt);return;
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i){
		int x,y;scanf("%d%d",&x,&y);
		ins(x,y);
	}
	dfs(1,1);
	reverse(ans.begin(),ans.end());
	dfs(mp[h[1]].to,mp[h[1]].to);
	printf("%d\n",ans.size());
	for(int i=0;i<ans.size();++i) printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 6264
import java.util.Scanner;

public class Main {
	public static void main(String[] arg) {
		boolean[] notPrime = new boolean[50001];
		notPrime[0] = true;
		notPrime[1] = true;
		int primeCount = 50000 - 1;
		for (int i = 4; i <= 50000; i += 2) {
			if (!notPrime[i]) {
				notPrime[i] = true;
				primeCount--;
			}
			if (!notPrime[i - 1]) {
				for (int j = (i - 1) * 2; j <= 50000; j += i - 1) {
					if (!notPrime[j]) {
						notPrime[j] = true;
						primeCount--;
					}
				}
			}
		}
		int[] primes = new int[primeCount];
		int index = 0;
		for (int i = 0; i <= 50000; i++) {
			if (!notPrime[i]) {
				primes[index++] = i;
			}
		}
		int[] gbc = new int[50001];
		for (int i = 0; i < primes.length; i++) {
			for (int j = i; j < primes.length; j++) {
				int val = primes[i] + primes[j];
				if (val > 50000) {
					break;
				}
				gbc[val]++;
			}
		}

		Scanner in = new Scanner(System.in);
		while (in.hasNext()) {
			int n = in.nextInt();
			if (n != 0) {
				System.out.println(gbc[n]);
			}
		}

	}
}

Measured memory_bytes: 32964
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
using static Atcoder.IO;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var N = RInt;
            var a = RSInt;

            long ans = 0;
            for (int i = 0; i < N; i++)
            {
                if (i == 0) continue;
                if (a[i - 1] > a[i])
                {
                    ans += a[i - 1] - a[i];
                    a[i] = a[i - 1];
                }
            }
            WriteLine(ans);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 47060
a, b, x = map(int, input().split())

# print(a)
# print(b)
# print(x)

# count = 0
# for i in range(a, b + 1):
#     # print(i)
    
#     if i % x == 0:
#         count += 1
        
# print(count)

def f(n):
    if n == -1:
        return 0
    else:
        return (n // x) + 1

# print(int((a -1) / x) + 1)
# print(int(b / x))

# print(f(b))
# print(f(a - 1))
print(f(b) - f(a - 1))



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    speed();
    int N, M; cin >> N >> M;
    int L[M], R[M];
    rep(i, 0, M) cin >> L[i] >> R[i];
    int Start = L[0], End = R[0];
    rep(i, 0, M) {
        if (L[i] > Start) Start = L[i];
        if (R[i] < End) End = R[i];
    }
    int ans = max(0, (End - Start + 1));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mino "frequency"
#define ll long long
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define matrix vector<vector<ll>>
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define Down(i,a,b) for(int i=a; i>=b; i--)
#define FOR_(i,a,b) for(int i=a; i<b; i++)
#define turbo ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oo 1e9

const int N = 1e5 + 5;

using namespace std;

typedef pair<int,int> pii;


int n;
ll kq[N];
struct ii
{
    int val, pos;
};
ii a[N];

bool cmp(ii A, ii B)
{
    return A.val > B.val || (A.val == B.val && A.pos < B.pos);
}

void nhap()
{
    cin >> n;
    FOR(i,1,n)
    {
        cin >> a[i].val;
        a[i].pos = i;
    }
    sort(a+1,a+n+1,cmp);
}

void xuli()
{
    //FOR(i,1,n) cout << a[i].val << ' ' << a[i].pos << endl;
    a[n+1].val = 0;
    int mi = a[1].pos;
    FOR(i,2,n+1)
    {
        kq[mi] += 1ll * (i - 1) * (a[i-1].val - a[i].val);
        mi = min(mi, a[i].pos);
    }
    FOR(i,1,n) cout << kq[i] << endl;
}

int main()
{
    //freopen(mino".inp","r",stdin);
    //freopen(mino".out","w",stdout);
    turbo
    nhap();
    xuli();
}


Measured memory_bytes: 2688
#include <cstdio>
#include <utility>
#include <cctype>
#include <cmath>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

template<int N>
struct sieve {
	bool s[N];
	int v[N], l = -1;
	sieve() : s(), v() {
		s[2] = true;
		for (int i = 3; i < N; i += 2)
			s[i] = true;
		for (int i = 9; i < N; i += 6)
			s[i] = false;
		for (int i = 6, e = sqrt(N); i <= e; i += 6) {
			for (int j : {i - 1, i + 1})
				if (s[j])
					for (int k = j * j; k < N; k += j)
						s[k] = false;
		}
		for (int i = 2; i < N; i++)
			if (s[i])
				v[++l] = i;;
	}
};

int main() {
	sieve<32769> S;
	for (int n; (n = in);) {
		int c {};
		for (int i {}; S.v[i] <= n / 2; i++)
			if(S.s[n - S.v[i]])
				c++;
		outl(c);
	}
}


Measured memory_bytes: 2776
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
struct Coordinate {
	int x, y;
};

int main() {
	std::cin.sync_with_stdio(false);
	int h, w, n; std::cin >> h >> w >> n;
	std::vector<std::vector<Coordinate>> floor(h, std::vector<Coordinate>(w));
	for (auto& line : floor) for (auto& coordinate : line) std::cin >> coordinate.y >> coordinate.x;
	std::vector<std::vector<std::vector<Coordinate>>> step{ floor };
	for (auto i = 1; i < h * w; i <<= 1) {
		std::vector<std::vector<Coordinate>> new_floor(h, std::vector<Coordinate>(w));
		const auto& back = step.back();
		for (auto y = 0; y < h; ++y) for (auto x = 0; x < w; ++x) {
			auto next = back[y][x];
			new_floor[y][x] = back[next.y][next.x];
		}
		step.push_back(new_floor);
	}
	std::vector<Coordinate> dancers(n); for (auto& dancer : dancers) std::cin >> dancer.y >> dancer.x;
	std::vector<std::vector<int>> exists(h, std::vector<int>(w, -1));
	bool has_collision = false;
	for (const auto& dancer : dancers) {
		auto current_pos = step.back()[dancer.y][dancer.x];
		if (exists[current_pos.y][current_pos.x] != -1) {
			has_collision = true;
			break;
		}
		else {
			exists[current_pos.y][current_pos.x] = h * w + 1;
		}
	}
	if (!has_collision) {
		std::cout << -1 << '\n';
		return 0;
	}
	int min = 0;
	int max = h * w;
	while (min < max) {
		auto mid = (min + max) / 2;
		has_collision = false;
		for (auto dancer : dancers) {
			for (auto i = 0; i < step.size(); ++i) {
				if ((mid & (1 << i)) != 0) {
					dancer = step[i][dancer.y][dancer.x];
				}
			}
			if (exists[dancer.y][dancer.x] == mid) {
				has_collision = true;
				break;
			}
			else {
				exists[dancer.y][dancer.x] = mid;
			}
		}
		if (has_collision) max = mid;
		else min = mid + 1;
	}
	std::cout << max << '\n';
}


Measured memory_bytes: 45392
#include <string>
#include <iostream>
 
using namespace std;
 
int main()
{
    string name; int a, b;
 
    for (int i = 0; i < 9; i++)
    {
        cin >> name >> a >> b;
 
        cout << name << ' ' << a + b << ' ' << a * 200 + b * 300 << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define int long long
#define maxn 10005
#define maxc 105
using namespace std;

const int mod = 1e9 + 7;

//     len   sum  last
int dp[maxn][maxc][10] = {};
string s;
int n, k;


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> s >> k;
    reverse(begin(s), end(s));
    n = s.size(); s = "@" + s;
    for(int i = 0; i < 10; i++) {
        dp[1][i % k][i] = 1;
    }
    for(int len = 2; len <= n; len++) {
        for(int sum = 0; sum < k; sum++) {
            for(int last = 0; last < 10; last++) {
                int prev = (sum - last + 10 * k) % k;
                for(int i = 0; i < 10; i++)
                    dp[len][sum][last] += dp[len - 1][prev][i];
                dp[len][sum][last] %= mod;
            }
        }
    }
    int ans = 0, cnt = 0;
    for(int i = n; i > 0; i--) {
        for(int j = 0; j < (s[i] - '0'); j++) {
            int prev = (k - cnt + 10000000LL * k) % k;
            ans += dp[i][prev][j];
        }
        ans %= mod;
        cnt += s[i] - '0';
    }
    ans = (ans - 1 + mod) % mod;
    if(cnt % k == 0) ans = (ans + 1) % mod;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 85708
from collections import deque
A = deque(list(input()+'A'))
B = deque(list(input()+'B'))
C = deque(list(input()+'C'))

x = A.popleft()
while(True):
    if x == 'a':
        x = A.popleft()
    elif x == 'b':
        x = B.popleft()
    elif x == 'c':
        x = C.popleft()
    else:
        break

print(x)

Measured memory_bytes: 3316