akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
vector<int> v;
int cnt[100010] = {};
int main(){
	string s;
	cin >> s;
	int i,n  = s.size();
	v.push_back(-1);
	for(i=1;i<n;i++){
		if(s[i - 1]=='R' && s[i]=='L'){
			v.push_back(i);
		}
	}
	int j = 0;
	for(i=0;i<n;i++){
		if(s[i]=='L'){
			if((i - v[j])&1){
				cnt[v[j] - 1]++;
			}else{
				cnt[v[j]]++;
			}
		}else{
			while(j<v.size() && v[j]<i){
				j++;
			}
			if((v[j] - i)&1){
				cnt[v[j] - 1]++;
			}else{
				cnt[v[j]]++;
			}
		}
	}
	for(i=0;i<n;i++){
		cout << cnt[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 1280
#include<iostream>

using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int t[200001];
int main(){
    int n,tt;
    cin>>n>>tt;
    rep(i,n){
        cin>>t[i];
    }
    int sum=0;
    FOR(i,1,n){
        sum+=min(tt,t[i]-t[i-1]);
    }
    cout<<sum+tt<<endl;
    return 0;
}

Measured memory_bytes: 1024
let quick_search str pat =
  let n_str = String.length str in
  let n_pat = String.length pat in
  let tbl = Array.init 256 (fun _ -> n_pat + 1) in
  String.iteri (fun i c -> tbl.(Char.code c) <- n_pat - i) pat;
  let i = ref 0 in
  try
    while !i < (n_str - n_pat) do
      let j = ref 0 in
      while String.get str (!i + !j) = String.get pat !j do
        if !j = (n_pat - 1) then raise Exit;
        incr j;
      done;
      i := !i + tbl.(Char.code (String.get str (!i + n_pat)));
    done;
    None
  with Exit -> Some !i

let () =
  let s = read_line () in
  let l = read_line () in
  match quick_search (s^s) l with
  | None -> Printf.printf "No\n"
  | Some _ -> Printf.printf "Yes\n"

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

#define PI 3.1415926535897932384626433832795
#define pii pair <int, int>
#define pb push_back
#define ll long long
#define ss second
#define ff first
#define N 100010

using namespace std;

int n, a;
multiset <int> S;

int main()
{
	cin >> n;
	
	for(int i = 1; i <= n; i++)
		cin >> a, S.insert(a);
	
	int mx = *S.rbegin();
	
	S.erase(S.find(mx));
	
	auto j = S.lower_bound(mx/2);
	int a = *j;
	if(a < mx/2)
		a = 1e9;
	
	j--;
	int b = *j;
	if(b > mx/2)
		b = 0;
	
	cout << mx << " " << (a-mx/2 > mx/2-b ? b : a);
}

Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
map<int,int>t;
int x,n,m;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		t[x]++;
	}
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&x);
		if(t[x]==0)
		{
			puts("NO");
			return 0;
		}
		t[x]--;
	}
	puts("YES");
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) cin >> A.at(i);
  int ans = A.at(0);
  
  for(int i = 1; i < N; i++){
    ans = gcd(ans, A.at(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 3736
#include<stdio.h>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=5010,P=1e9+7;
inline char gc(){
    static char buf[N],*s=buf,*t=buf;
    return s==t&&(t=(s=buf)+fread(buf,1,N,stdin),s==t)?EOF:*s++;
}
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
int n,m,k,f[N][N][2],g[N],ans;
inline void A(int&x,int y){(x+=y)%=P;}
int main(){
	//freopen("1.out","w",stdout);
	register int i,j;
	m=read();n=read();k=read();
	if(!m){puts("1");return 0;}
	m--;k--;
	f[1][0][0]=1;
	for(j=1;j<=k;j++){
		f[1][j][1]=1;
		if(j&&j%k==n%k&&(k-j)<=m&&(k-j)%k==m%k)A(ans,f[1][j][1]);
	}
	for(i=2;i<=n+m;i++){
		g[0]=f[i-1][0][0];
		for(j=1;j<=n;j++){
			g[j]=(g[j-1]+f[i-1][j][0])%P;
			A(g[j],f[i-1][j][1]);
		}
		for(j=0;j<=n;j++){
			f[i][j][0]=(f[i-1][j][0]+f[i-1][j][1])%P;
			if(j)f[i][j][1]=g[j-1];
			if(j>k)A(f[i][j][1],P-g[j-k-1]);
			if(j&&j%k==n%k&&(i*k-j)<=m&&(i*k-j)%k==m%k)A(ans,f[i][j][1]);
		}
	}printf("%d\n",ans);
	return 0;
}

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

int main(){
  int n,v;
  cin >> n;
  set<int> s;
  map<int,int> m0,m1;
  for(int i=0;i<n;i++){
    cin >> v;
    s.insert(v);
    if(i%2==0){
      if(m0.count(v)){
        m0.at(v)++;
      }else{
        m0[v]=1;
      }
    }else{
      if(m1.count(v)){
        m1.at(v)++;
      }else{
        m1[v]=1;
      }
    }
  }
  int64_t ans=0;
  if(s.size()==1){
    cout << n/2 << endl;
    return 0;
  }
  priority_queue<int> pq0,pq1;
  priority_queue<int,vector<int>,greater<int> > PQ;
  int n0,n1;
  pq0.push(-1);
  pq1.push(-1);
  for(auto p:m0){
    if(pq0.top()<p.second){
      n0=p.first;
    }
    pq0.push(p.second);
  }
  for(auto p:m1){
    if(pq1.top()<p.second){
      n1=p.first;
    }
    pq1.push(p.second);
  }
  int max0,max1;
  if(n0==n1){
    max0=pq0.top();
    max1=pq1.top();
    pq0.pop();
    pq1.pop();
    PQ.push(n/2-max0+n/2-pq1.top());
    PQ.push(n/2-max1+n/2-pq0.top());
    cout << PQ.top() << endl;
    return 0;
  }
  ans+=n/2-pq0.top();
  ans+=n/2-pq1.top();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10240
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()
    val m = n / 15

    println(800 * n - 200 * m)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()

fun println(value : Any) {
    pw.println(value)
}

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

#define endl '\n'

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

    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    
    double rate = -1e9;
    int ws = 0;
    int s = 0;
    for(int i = 0; ; i++) {
        if(a * i * 100 > f) break;
        for(int j = 0; ; j++) {
            int water = a * i + b * j;
            water *= 100;
            if(water > f) break;
            int msugar = water * e / 100;
            if(water + msugar > f) {
                int minus = water + msugar - f;
                msugar -= minus;
            }
            int fsugar = 0;
            for(int x = 0; ; x++) {
                if(c * x > msugar) break;
                for(int y = 0; ; y++) {
                    int sugar = c * x + d * y;
                    if(sugar > msugar) break;
                    fsugar = max(fsugar, sugar);
                }
            }

            double frate = 100.0 * fsugar / (water + fsugar);
            if(frate > rate) {
                rate = frate;
                s = fsugar;
                ws = fsugar + water;
            }
        }
    }
    cout << ws << " " << s;
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
const int MaxN = 2e5;
using namespace std;
map<int, int> vis;
int n, m;
int main() 
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++){
		int x;
		scanf("%d", &x);
		vis[x]++;
	}
	bool ok = 1;
	scanf("%d", &m);
	for (int i = 1; i <= m; i++) {
		int x;
		scanf("%d", &x);
		if(vis[x] < 1) ok = 0;
		else vis[x]--;
	}
	if(ok) puts("YES");
	else puts("NO");
}

Measured memory_bytes: 9600
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
	int W, H;
	int N;
	int state[16][16]; //マップの状態を表します. (0...ok 1...ng)
	int dp[16][16]; //その道に来る通り数.
	
	while (scanf("%d %d", &W, &H) && W != 0){
		scanf("%d", &N);
		
		memset(state, 0, sizeof(state));
		memset(dp, 0, sizeof(dp));
		
		for (int i = 0; i < N; i++){
			int x, y;
			scanf("%d %d", &x, &y);
			--x; --y;
			state[y][x] = 1;
		}
		
		dp[0][0] = 1;
		
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				if (state[i][j] == 1){
					continue;
				}
				if (i - 1 >= 0){
					dp[i][j] += dp[i - 1][j];
				}
				if (j - 1 >= 0){
					dp[i][j] += dp[i][j - 1];
				}
			}
		}
		
		printf("%d\n", dp[H - 1][W - 1]);
	}
	
	return (0);
}

Measured memory_bytes: 1028
#include <cstdio>
#include <algorithm>
using namespace std;
int s[400], l[400], p[400], w[400];
int dp[401];
/*
printf("Here\n");
*/

int main() {
	int n, m;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d %d %d", &s[i], &l[i], &p[i]);
	}
	scanf("%d", &m);
	for (int i = 0; i < m; i++) {
		scanf("%d", &w[i]);
	}
	for (int i = n-1; i >= 0; i--) {
		for (int j = 0; j < 400; j++) {
			for (int k = s[i]; k <= l[i]; k++) {
				if (j-k>=0) {
					dp[j] = max(dp[j], dp[j-k]+p[i]);
				}
			}
		}
	}
	bool sw = false;
	for (int i = 0; i < m; i++) {
		if (dp[w[i]]==0) {
			sw = true;
			break;
		}
	}
	if (sw) {
		printf("-1\n");
	} else {
		for (int i = 0; i < m; i++) {
			printf("%d\n", dp[w[i]]);
		}
	}
	return 0;
}


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

#define all(x) x.begin(),x.end()
#define pb(x) emplace_back(x)
#define forn(i,N) for(int i=0;i<N;i++)

using namespace std;
using ll=long long int;
using ld=long double;
using vi=vector<int>;
using vll=vector<ll>;
using vd=vector<double>;



int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

int N,K;
cin>>N>>K;
map<int,int> m;
vector<pair<int,int>> v;
forn(i,N) {
  int x;
  cin>>x;
  m[x]++;
}
if(m.size()<=K) {
  cout<<0<<endl;
  return 0;
}
for(auto& x: m) {
  v.push_back({x.first,x.second});
}
int cpy=m.size()-K,ans=0;
sort(all(v),[](auto i, auto j){return i.second<j.second;});
for(auto& x: v) {
  ans+=x.second;
  cpy--;
  if(cpy==0) {
    break;
  }
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 14692
# -*- coding: utf-8 -*-


def bubble_sort(n, a):
    cnt = 0
    flag = True
    while flag:
        flag = False
        for i in reversed(range(n)):
            if i is 0: break
            if a[i] < a[i - 1]:
                tmp = a[i]
                a[i] = a[i - 1]
                a[i - 1] = tmp
                flag = True
                cnt += 1
    return a, cnt


if __name__ == '__main__':
    n = int(input())
    a = [int(n) for n in input().split()]
    ans = bubble_sort(n, a)
    print(' '.join(map(str, ans[0])))
    print(ans[1])

Measured memory_bytes: 7680
#include<bits/stdc++.h>
#define int long long

using namespace std;

int dfs(int n)
{
    if (n == 1)
        return 1;
    else
        return 1 + 2 * dfs(n / 2);
}

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

    int n;
    cin >> n;
    cout << dfs(n) << '\n';

    return 0;
}

//      *   *  *****  *   *  *   *
//     *   *  *      **  *  *   *
//    *****  *****  * * *  *   *
//   *   *      *  *  **  *   *
//  *   *  *****  *   *   ***

//      ***** ***** *   * *     ***** *   * ***** *****
//        *  *   * *   * *       *   **  *   *   *   *
//       *  *   * ***** *       *   * * *   *   *****
//   *  *  *   *   *   *       *   *  **   *   *
//  ****  *****   *   ***** ***** *   *   *   *


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

int main(void){
	int m,n;

	while(cin>>m>>n && (m||n)){
		vector<int> v;
		for(int i=1;i<=m;i++) v.push_back(i);
		int now = 0;
		for(int i=1;i<=n;i++,now=(now+1)%v.size()){
			stringstream ss;
			if(i % 3 == 0) ss<<"Fizz";
			if(i % 5 == 0) ss<<"Buzz";
			if(ss.str() == "") ss<<i;
			string s1 = ss.str();

			string s2;
			cin>>s2;

			if(s1 != s2 && v.size() > 1){
				v.erase(v.begin() + now);
				now--;
			}
		}

		cout<<v[0];
		for(int i=1;i<v.size();i++) cout<<" "<<v[i];
		cout<<endl;
	}

	return 0;
}

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

using namespace std;

#define REP(i, a, b) for ( int i = (a), _end_ = (b); i <= _end_; ++ i )
#define mem(a) memset ( (a), 0, sizeof ( a ) )
#define str(a) strlen ( a )
typedef long long LL;
template<class T> int maxx(T a, T b) { return a > b ? a : b; }
template<class T> int minn(T a, T b) { return a < b ? a : b; }
template<class T> int abss(T a) { return a > 0 ? a : -a; }
#define max maxx
#define min minn
#define abs abss
#define int long long
const int maxn = 10000010;

const int Mod1 = 983 ;
const int Mod2 = 991 ;
const int Mod3 = 997;
const int Mod = 40000000;

int n, p1[maxn], p2[maxn], p3[maxn], f1[maxn << 2], f2[maxn << 2], f3[maxn << 2];
int a[4][maxn], tot;
char s[maxn];

signed main()
{
    scanf("%lld", &n); scanf("%s", s + 1);
    p1[0] = p2[0] = p3[0] = 1; REP(i, 1, n) p1[i] = (p1[i - 1] * Mod1) % Mod, p2[i] = (p2[i - 1] * Mod2) % Mod, p3[i] = (p3[i - 1] * Mod3) % Mod;
    for ( int len = n / 2; len >= 1; -- len )
    {
        REP(i, 1, tot) f1[a[1][i]] = f2[a[2][i]] = f3[a[3][i]] = 0;
        tot = 0;
        int Hash1 = 0, Hash2 = 0, Hash3 = 0, Hash4 = 0, Hash5 = 0, Hash6 = 0;;
        REP(i, 1, len)
        {
            Hash1 = ((Hash1 * Mod1) + s[i]) % Mod;
            Hash2 = ((Hash2 * Mod2) + s[i]) % Mod;
            Hash5 = ((Hash5 * Mod3) + s[i]) % Mod;
        }
        f1[Hash1] = 1; f2[Hash2] = 1; f3[Hash5] = 1;
        ++ tot; a[1][tot] = Hash1; a[2][tot] = Hash2; a[3][tot] = Hash5;
        REP(i, len + 1, len + len)
        {
            Hash3 = ((Hash3 * Mod1) + s[i]) % Mod;
            Hash4 = ((Hash4 * Mod2) + s[i]) % Mod;
            Hash6 = ((Hash6 * Mod3) + s[i]) % Mod;
        }
        if ( f1[Hash3] == 1 && f2[Hash4] == 1 && f3[Hash6] == 1 ) { printf("%lld\n", len); return 0; }
        REP(i, len + 2, n - len + 1)
        {
            int j = i - len;
            Hash1 = (Hash1 - s[j - 1] * p1[len - 1]) * Mod1 + s[i - 1];
            Hash1 = ((Hash1 % Mod) + Mod) % Mod;
            Hash2 = (Hash2 - s[j - 1] * p2[len - 1]) * Mod2 + s[i - 1];
            Hash2 = ((Hash2 % Mod) + Mod) % Mod;
            Hash5 = (Hash5 - s[j - 1] * p3[len - 1]) * Mod3 + s[i - 1];
            Hash5 = ((Hash5 % Mod) + Mod) % Mod;
            f1[Hash1] = 1; f2[Hash2] = 1; f3[Hash5] = 1;
            ++ tot; a[1][tot] = Hash1; a[2][tot] = Hash2; a[3][tot] = Hash5;
            Hash3 = (Hash3 - s[i - 1] * p1[len - 1]) * Mod1 + s[i + len - 1];
            Hash3 = ((Hash3 % Mod) + Mod) % Mod;
            Hash4 = (Hash4 - s[i - 1] * p2[len - 1]) * Mod2 + s[i + len - 1];
            Hash4 = ((Hash4 % Mod) + Mod) % Mod;
            Hash6 = (Hash6 - s[i - 1] * p3[len - 1]) * Mod3 + s[i + len - 1];
            Hash6 = ((Hash6 % Mod) + Mod) % Mod;
            if ( f1[Hash3] == 1 && f2[Hash4] == 1 && f3[Hash6] == 1 ) { printf("%lld\n", len); return 0; }
        }
    }
    puts("0");
	return 0;
}


Measured memory_bytes: 952704
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
//freopen("","r",stdin);
//freopen("","w",stdout);
int main(){
    int n,r;
    cin >> n >> r;
    int aux = 10 - n;
    if(aux < 0)
        cout << r << '\n';
    else
        cout << aux * 100 + r << '\n';
    return 0;
}

Measured memory_bytes: 256
import bisect

N, M, K = list(map(int, input().split(" ")))
A = list(map(int, input().split(" ")))
B = list(map(int, input().split(" ")))

asum = [0]
for a in A:
    asum.append(asum[-1] + a)

bsum = [0]
for b in B:
    bsum.append(bsum[-1] + b)

ans = 0
for i, a in enumerate(asum):
    btime = K - a
    if btime < 0:
        break
    bindex = bisect.bisect_right(bsum, btime)
    ans = max(ans, i + (bindex-1))

print(ans)


Measured memory_bytes: 47608
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
double n,m,a,b,c,d,x,y,z;
string s,t;
//

signed main() {
  RAPID;
  IN2(n,a);
  while(n>=500) n-=500;
  Yes(n<=a);
}

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

int main() {
    int N, h, t = -1, c = 0;
    cin >> N;
    for (; N > 0; N--) {
        cin >> h;
        if (h >= t) {
            c++;
            t = h;
        }
    }

    cout << c << endl;
    return 0;

}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, M int
	var ss = map[string]int{}
	var s, t string

	fmt.Scan(&N)

	for i := 0; i < N; i++ {
		fmt.Scan(&s)
		ss[s]++
	}

	fmt.Scan(&M)
	for i := 0; i < M; i++ {
		fmt.Scan(&t)
		ss[t]--
	}

	max := 0
	for _, score := range ss {
		if max < score {
			max = score
		}
	}

	fmt.Println(max)
}


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

int main() {
  int N;
  cin >> N;
  vector<int64_t> L(N + 1);
  L.at(0) = 2;
  L.at(1) = 1;
  for (int i = 2; i <= N; i++) {
    L.at(i) = L.at(i-1) + L.at(i-2);
  }
  cout << L.at(N) << endl;
}

Measured memory_bytes: 256
// i hope i get better                                                           
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int sz=1e2+9;
string s;
bool ok;

int main(){
	cin>>s;
	for(auto u:s){
		if(u=='7') ok=1;
	}
	if(ok) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

vector<int> uf, usz;
int nc;

void init(int n){
  vector<int> uf_(n);
  vector<int> usz_(n, 1);
  uf = uf_;
  usz = usz_;
  nc = n;

  for(int i = 0; i < uf.size(); i++){
    uf[i] = i;
  }
}

int find(int a){
  return (uf[a] == a) ? a : uf[a] = find(uf[a]);
}

void union_(int a, int b){
  a = find(a);
  b = find(b);

  if(a != b){
    if(usz[a] >= usz[b]){
      swap(a, b);
    }
    uf[a] = b;
    usz[b] += usz[a];
    nc--;
  }
}

int check(int a, int b){
  return (find(a) == find(b)) ? 1 : 0;
}

int get_size(int a){
  return usz[find(a)];
}


int main() {
  ll n,m;
  cin>>n>>m;
  init(n);
  vector<ll> v;
  rep(i,0,n){
    ll a;
    cin>>a;
    a--;
    v.pb(a);
  }
  rep(i,0,m){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    union_(v[a],v[b]);
  }
  ll ans = 0;
  rep(i,0,n){
    if(check(i,v[i])==1)ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2544
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
typedef long long ll;
const int MYINF = 1e9+7;
typedef int bool;
const bool true = 1;
const bool false = 0;

int A[500010];
int L[250010];
int R[250010];
int n, count;

bool cmp(int a, int b) {
	count++;
	return a <= b;
}

void merge(int left, int mid, int right) {
	int i, j, k, ni, nj;
	ni = mid - left;
	nj = right - mid;
	for (i = 0; i < ni; i++) {
		L[i] = A[left+i];
	}
	L[i] = MYINF;
	for (i = 0; i < nj; i++) {
		R[i] = A[mid+i];
	}
	R[i] = MYINF;
	for (i = 0, j = 0, k = left; k < right; k++) {
		if (cmp(L[i], R[j])) A[k] = L[i++];
		else A[k] = R[j++];
	}
}

void merge_sort(int left, int right) {
	int m;
	if (left + 1 == right) return;
	m = (left + right) / 2;
	merge_sort(left, m);
	merge_sort(m, right);
	merge(left, m, right);
}

int main(int argc, char **argv)
{
	int i;
	const char *sp;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	merge_sort(0, n);
	for (i = 0, sp = ""; i < n; i++) {
		printf("%s%d", sp, A[i]);
		sp = " ";
	}
	printf("\n%d\n", count);
	return 0;
}

Measured memory_bytes: 4500
import java.util.*;
public class Main {
	static boolean isIn(int a, int b, int w) {
		if(a <= b && b <= a + w) {
			return true;
		}
		else if(b <= a && a <= b + w) {
			return true;
		}
		return false;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int move = 0;
		if(!isIn(a, b, w)){
			if(a <= b) move = b - a - w;
			else move = a - b - w;
		}
		System.out.println(move);
	}
	

}


Measured memory_bytes: 21844
#include<cstdio>
#include<iostream>
using namespace std;
long long a,b,c,ans;
int maxn(int a,int b,int c)
	{
		if(a>=b&&a>=c) return a;
		if(b>=a&&b>=c) return b;
		if(c>=a&&c>=a) return c;
	}
int main()
	{
		cin>>a>>b;
		ans=maxn(a*b,a+b,a-b);
		cout<<ans<<endl;
		return 0;
	}

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

using namespace std ;

const int N=110;

int dp[N][N];

int main()

{

    int n;

    cin>>n;

    for (int i=0;i<=9;i++) dp[1][i]=1;

    for (int i=2;i<=10;i++)

        for (int j=0;j<=9;j++)

            dp[i][j]=dp[i-1][j]+dp[i-1][j-1]+dp[i-1][j+1];

    int l=0,r=0,flag=0;

    for (int i=1;i<=10;i++) 

	{

        for (int j=1;j<=9;j++) 

		{

            if(n<=dp[i][j])

			{

                l=i,r=j,flag=1;

                break;

            }

            n-=dp[i][j];

        }

        if(flag==1)break;

    }

    l--;

    queue<int> ans;

    ans.push(r);

    while(l!=0)

	{

        if(n<=dp[l][r-1])

		{

            r--;

            ans.push(r);

        }

		else

		{

            n-=dp[l][r-1];

            if(n<=dp[l][r]) ans.push(r);

			else

			{

                n-=dp[l][r];

                r++;

                ans.push(r);

            }

        }

        l--;

    }

    while(!ans.empty()) cout<<ans.front(),ans.pop();

    return 0 ;

}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>

 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;

int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
 
//    auto start = chrono::steady_clock::now();
  
//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n); readint(k);
        vector<int> a;
        forr(i,0,n)  {
            readint(kk); a.push_back(kk);
        }

        forr(i,k,n-k) {
            if (a[i]>a[i-k]) {
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        }

    }
 
//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;

    return 0;
}

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

#define Debug(x) x
typedef int regular_int;
// #define int ll
typedef long long ll;

int P[300000];


regular_int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(12) << fixed;

	int N, K;
	cin >> N >> K;
	for(int i = 0; i < N; ++i) {
		cin >> P[i];
	}
	int pos =  - 1;
	set<int > val;
	for(int i = 0; i < K; ++i) {
		val.insert(P[i]);
		if(i > 0 && P[i] < P[i - 1]) {
			pos = i;
		}
	}
	bool sum = pos < 0;
	int res = pos >= 0;
	bool active = *val.begin() != P[0];

	for(int i = K; i < N; ++i) {
		val.erase(P[i - K]);
		val.insert(P[i]);

		if(P[i] < P[i - 1]) {
			pos = i;
		}

		if(pos <= i - K + 1) {
			sum = true;
			active = false;
		} else {
			if(active || *(--val.end()) != P[i]) {
     //           cout << "i: " << i << endl;
				++res;
			}

		}
		active = *val.begin() != P[i - K + 1];

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


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

int main() {
    vector<string> v(3);
    cin >> v[0] >> v[1] >> v[2];
    cout << v[0][0] << v[1][1] << v[2][2] << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

type day struct {
	happinuess map[int]int
}

func NewDay() *day {
	d := &day{}
	d.happinuess = make(map[int]int)
	return d
}

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N+1)
	B := make([]int, N+1)
	C := make([]int, N+1)
	days := make([]*day, N+1)
	for i := 1; i <= N; i++ {
		days[i] = NewDay()
	}
	var a, b, c int
	for i := 1; i < N+1; i++ {
		fmt.Scan(&a, &b, &c)
		A[i] = a
		B[i] = b
		C[i] = c
	}
	days[1].happinuess[0] = A[1]
	days[1].happinuess[1] = B[1]
	days[1].happinuess[2] = C[1]
	for i := 2; i <= N; i++ {
		days[i].happinuess[0] = getMax(days[i-1].happinuess[1]+A[i], days[i-1].happinuess[2]+A[i])
		days[i].happinuess[1] = getMax(days[i-1].happinuess[0]+B[i], days[i-1].happinuess[2]+B[i])
		days[i].happinuess[2] = getMax(days[i-1].happinuess[0]+C[i], days[i-1].happinuess[1]+C[i])
	}
	fmt.Println(getMax(days[N].happinuess[0], days[N].happinuess[1], days[N].happinuess[2]))

}

func getMax(happines ...int) int {
	max := 0
	for _, h := range happines {
		if max < h {
			max = h
		}
	}
	return max
}


Measured memory_bytes: 25088
#include<cstdio>
#include<algorithm>
const int N = 2e5+5;
long long a[N];
long long b[N];
long long sum[N];
long long cnt[N];

int getId(long long u,int n){
    int l = 1, r = n;
    int res = -1;
    while(l<=r){
        int m = (l+r)/2;
        //最大的等于u的weizhi
        if(b[m]<=u){
            res = m;
            l = m+1;
        }
        else r = m-1;
    }
    return res;
}

int main(){
    int n; long long k;
    scanf("%d%lld",&n,&k);
    for(int i = 1; i <= n; i++){ 
        scanf("%lld",&a[i]);
        a[i]--;
    }
    sum[0] = 0;
    for(int i = 1; i <= n; i++){
        sum[i] = (sum[i-1] + a[i])%k;
        b[i] = sum[i];
    }
    //for(int i = 1; i <= n; i++) printf("sum[%d] = %lld\n",i,sum[i]);
    std::sort(b+1,b+1+n);
    //枚举i为右端点
    long long ans = 0;
    for(int i = 1; i <= n; i++){
        if(sum[i]==0 && i<k) ans++;
        int last = i-k;
        if(last>=1) cnt[getId(sum[last],n)]--;
        int u = getId(sum[i],n);
        ans += (long long)cnt[u];
        cnt[u] += 1;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
#define N 10005
#define rank raljfds
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P2;
 
class UF{
public:
  int V;
  vector<int> par, rank, mil;
  UF(){}
  UF(int V):V(V),par(V),rank(V,0),mil(V,-1){for(int i=0;i<V;i++) par[i]=i;}
 
  int find(int x){
    assert(x<V);
    if(par[x]==x) return x;
    return par[x]=find(par[x]);
  }
   
  void unite(int x,int y){
    x=find(x), y=find(y);
    if(x==y)return;
    
    if(mil[x]!=-1) mil[y]=mil[x];
    if(mil[y]!=-1) mil[x]=mil[y];
    
    if(rank[x]<rank[y]){
      par[x]=y;
    }
    else{
      par[y]=x;
      if(rank[x]<rank[y]) rank[x]++;
    }
  }
   
  bool same(int x,int y){return find(x)==find(y);}
   
  void add_mil(int num){
    mil[num]=num;
  }
   
  int get_mil(int x){
    return mil[find(x)];
  }
};
 
int n,t,k;
vector<P2> G;
UF uf;
 
int solve(){
   
  uf=UF(n);
   
  int milnum;
   
  for(int i=0;i<t;i++){
 
    cin>>milnum;
     
    uf.add_mil(milnum-1);
  }
   
  vector<int> ans;
   
  for(int idx=0;idx<G.size();idx++){
     
    int cost=G[idx].first;
    int A=G[idx].second.first;
    int B=G[idx].second.second;
    
    if(!(uf.get_mil(A)!=-1&&uf.get_mil(B)!=-1)) uf.unite(A,B);
    else ans.push_back(cost);
    
  }
 
  sort(ans.begin(),ans.end());
 
  int res=0;
  //  if(ans.size()<k) while(1);
  for(int i=0;i<k;i++) res+=ans[i];
   
  return res;
}
 
int main(){
 
  int T=1;
   
  while(1){
 
    cin>>n>>t>>k;
    if(!n&&!t&&!k) break;
 
    int a,b,cost;
     
    for(int i=0;i<n-1;i++){
       
      cin>>a>>b>>cost;
       
      a--, b--;
 
      G.push_back(P2(cost,P(a,b)));
    }
     
    sort(G.begin(),G.end(),greater<P2>());
     
    cout<<"Case "<<T<<": ";
     
    cout<<solve()<<endl;
 
    G.clear();
     
    T++;
  }
   
  return 0;
}

Measured memory_bytes: 3340
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int n;
int a;
int c;
int main()
{
	cin>>n;
	rep(i,n)
	{
		cin>>a;
		if(a%2==1)c++;
	}
	if(c%2==1)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x;
	cin>>n;
	int a[n+1];
	memset(a,0,sizeof(a));
	for(int i=1;i<n;i++)
	{
		cin>>x;
		a[x]++;
	}
	for(int i=1;i<=n;i++)
		cout<<a[i]<<endl;
    return 0;
}
	

Measured memory_bytes: 4404
import sys
n, a, b, c, d = map(int, input().split())
s = input()
if any(s[i]==s[i+1]=="#" for i in range(a-1, c-2)) or any(s[i]==s[i+1]=="#" for i in range(b-1, d-2)):
    print("No")
elif c<d:
    print("Yes")
else:
    for i in range(b-1, d):
        if s[i-1]==s[i]==s[i+1]==".":
            print("Yes")
            sys.exit()
    print("No")


Measured memory_bytes: 3572
// https://atcoder.jp/contests/abc167/tasks/abc167_d

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();
void solve2();

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

  try {
    solve2();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N, K;
  cin >> N >> K;

  VL as(N);
  rep(i, N) cin >> as[i];
  rep(i, N) as[i]--;

  ll loop_i = -1;
  ll loop_length = -1;

  {
    VL visited_step(N, -1);
    ll cur = 0;

    rep(step, N + 1) {
      if (visited_step[cur] == -1) {
        visited_step[cur] = step;
        cur = as[cur];
        continue;
      }

      loop_i = cur;
      loop_length = step - visited_step[cur];
      break;
    }
  }

  ll cur = 0;
  ll rest = K;

  while (rest > 0) {
    if (cur != loop_i) {
      cur = as[cur];
      --rest;
      continue;
    }

    rest %= loop_length;
    if (rest == 0) break;

    cur = as[cur];
    --rest;

    continue;
  }

  cout << cur + 1 << "\n";
}

void solve2() {
  ll N, K;
  cin >> N >> K;

  VL as(N);
  rep(i, N) cin >> as[i];
  rep(i, N) as[i]--;

  ll cur = 0;

  while (K > 0) {
    if (K & 1) cur = as[cur];
    VL nas(N);
    rep(i, N) nas[i] = as[as[i]];
    swap(as, nas);
    K >>= 1;
  }

  cout << cur + 1 << "\n";
}


Measured memory_bytes: 6312
#include<bits/stdc++.h>
using namespace std;
#define LL long long 
LL read(){
	LL x = 0,f = 0;char ch = getchar();
	while(!isdigit(ch)) {if(ch=='-')f=1;ch=getchar();}
	while(isdigit(ch)) {x=x*10+ch-'0';ch=getchar();}
	return f?-x:x;
}
const int N = 2e5+100; 
const int mod = 1000000007;
LL n,pre[N],a[N];
int main()
{
	n = read();
	for(int i = 1;i <= n;i++){
		a[i] = read();
		pre[i] = pre[i-1]+a[i];
		pre[i] %= mod;
	}
	LL ans = 0;
	for(LL i = 1;i < n;i++){
		(ans+=(a[i]*(pre[n]-pre[i])%mod)%mod)%=mod;
	}
	cout << (ans%mod+mod)%mod << endl;
	return 0;
}

Measured memory_bytes: 6752
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define chmax(a,b) a=max(a,b);
#define chmin(a,b) a=min(a,b);
#define N 310
namespace beta{
    string a,b; ll n;
    ll f[N][N],g[N][N];
    void initg(){
	for(int i=0;i<=n;i++)g[i][0]=g[0][i]=0;
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++){
	    g[i][j]=g[i-1][j-1]+(a[i-1]==b[j-1]);
	}
    }
    ll main(string aa,string bb){a=aa,b=bb;n=a.size();
	initg();
	for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)f[i][j]=1e17;
	f[n][n]=0;
	for(int i=n;i>=0;i--)for(int j=n;j>=0;j--){
	    if(j>0)chmin(f[i][j-1],f[i][j]+g[i][j]);
	    if(i>0)chmin(f[i-1][j],f[i][j]+g[i][j]);
	}
	return f[0][0];
    }
};
ll h,w;
string s[N];
int main(){
    cin>>h>>w;
    for(int i=0;i<w;i++)s[i]="";
    for(int i=0;i<h;i++)for(int j=0;j<w;j++){
	char z;cin>>z;
	s[j].push_back(z);
    }
    ll ans=0;
    for(int i=1;i<w;i++){
	ans+=beta::main(s[i-1],s[i]);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(int argc, char const *argv[])
{
    ll n;
    cin>>n;
    string ans="";
    char a[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    while(n)
    {
        n--;
        ans+=(char)('a'+n%26);
        n/=26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3620
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    aa = [LI() for _ in range(n)]
    def f(a,b):
        return (pow(a[0]-b[0],2) + pow(a[1]-b[1],2))**0.5

    s = 0
    c = 0
    for a in itertools.permutations(aa, n):
        c += 1
        t = 0
        for i in range(n-1):
            t += f(a[i],a[i+1])
        s += t

    return s / c


print(main())




Measured memory_bytes: 5464
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}

int main(){
    ll N;
    string S;
    cin >> N;
    ll a = N%10;
    if(a == 3){
        S = "bon";
    }else if(a==2||a==4||a==5||a==7||a==9){
        S = "hon";
    }else{
        S = "pon";
    }
    cout << S << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,p=0;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  	cin>>a[i];
  for(int i=0;i<n-1;i++)
  {
    int s=0;
    for(int j=i+1;j<n;j++)
    {
      s+=a[j];
    }
    p+=s*a[i];
  }
  cout<<p;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.Integer.parseInt;

/**
 * Related Products
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		line = br.readLine();

		int N, F;
		N = parseInt(line.substring(0, line.indexOf(' ')));
		F = parseInt(line.substring(line.indexOf(' ') + 1));

		Map<String, Integer> itemsByName = new TreeMap<>();
		Map<Integer, String> itemsById = new TreeMap<>();
		List<String[]> infos = new ArrayList<>();

		for (int i = 0; i < N; i++) {
			words = br.readLine().split(" ");
			for (int j = 1; j < words.length; j++) {
				itemsByName.putIfAbsent(words[j], 0);
			}
			Arrays.sort(words);
			infos.add(words);
		}

		{
			int i = 0;
			for (String item : itemsByName.keySet()) {
				itemsByName.replace(item, i);
				itemsById.put(i, item);
				i++;
			}
		}

		int[][] rels = new int[itemsByName.size()][itemsByName.size()];

		for (String[] info : infos) {
			for (int i = 1; i < info.length; i++) {
				for (int j = i + 1; j < info.length; j++) {
					int _i, _j;
					_i = itemsByName.get(info[i]);
					_j = itemsByName.get(info[j]);
					rels[_i][_j]++;
				}
			}
		}

		//solve
		List<String> results = new ArrayList<>();

		for (int i = 0; i < rels.length; i++) {
			for (int j = 0; j < rels.length; j++) {
				if (rels[i][j] >= F) {
					results.add(itemsById.get(i) + " " + itemsById.get(j));
				}
			}
		}

		System.out.println(results.size());

		if (results.size() != 0) {
			for (String result : results) {
				System.out.println(result);
			}
		}

	} // end main
}

Measured memory_bytes: 36100
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

struct Info{
	Info(){
		id = distance = num = 0;
	}
	Info(int arg_id,double arg_distance,int arg_num){
		id = arg_id;
		distance = arg_distance;
		num = arg_num;
	}

	double distance;
	int id,num;
};

int main(){

	int POW[16] = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768};
	int N,next_state;
	Info info[15];

	double sum;

	scanf("%d",&N);

	double** dp = new double*[N];
	int** pre = new int*[N];
	for(int i = 0; i < N; i++){
		dp[i] = new double[POW[N]];
		pre[i] = new int[POW[N]];
		for(int k = 0; k < POW[N];k++){
			dp[i][k] = DBL_MAX;
			pre[i][k] = -1;
		}
	}


	for(int i = 0; i < N; i++){
		scanf("%d %lf %d",&info[i].id,&info[i].distance,&info[i].num);
	}

	if(N == 1){
		printf("0\n");
		return 0;
	}


	for(int i = 0; i < N; i++){
		dp[i][POW[i]] = 0.0;
	}

	for(int state = 0; state <= POW[N]-2; state++){
		for(int kura = 0; kura < N; kura++){
			if(dp[kura][state] == DBL_MAX)continue;

			sum = 0;
			for(int a = 0; a < N; a++){
				if(state & (1 << a)){
					sum += info[a].num;
				}
			}

			for(int a = 0; a < N; a++){
				if(state & (1 << a)){
					//Do nothing
				}else{
					next_state = state + POW[a];
					if(dp[a][next_state] > dp[kura][state] + fabs(info[a].distance-info[kura].distance)*((7.0+2.0*sum)/200.0)){
						dp[a][next_state] = dp[kura][state] + fabs(info[a].distance-info[kura].distance)*((7.0+2.0*sum)/200.0);
						pre[a][next_state] = 100000*kura+state;
					}
				}
			}
		}
	}

	double minimum = DBL_MAX;
	int id;

	for(int i = 0; i < N; i++){
		if(minimum > dp[i][POW[N]-1]){
			minimum = dp[i][POW[N]-1];
			id = i;
		}
	}

	stack<int> S;

	S.push(info[id].id);
	int pre_kura = pre[id][POW[N]-1]/100000,pre_state = pre[id][POW[N]-1]%100000;

	while(true){
		S.push(info[pre_kura].id);
		id = pre_kura;
		if(pre[pre_kura][pre_state] == -1)break;
		pre_kura = pre[id][pre_state]/100000;
		pre_state = pre[id][pre_state]%100000;
	}

	printf("%d",S.top());
	S.pop();

	while(!S.empty()){
		printf(" %d",S.top());
		S.pop();
	}

	printf("\n");

	return 0;
}

Measured memory_bytes: 8556
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TOPSIC2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] SW = Console.ReadLine().Split(' ');
            int S = int.Parse(SW[0]);
            int W = int.Parse(SW[1]);

            if (W >= S)
            {
                Console.WriteLine("unsafe");
            }
            else
            {
                Console.WriteLine("safe");
            }

        }
    }
}


Measured memory_bytes: 17696
from bisect import bisect_left,bisect_right
import string 

dic = {c:[] for c in string.ascii_lowercase}

n = int(input())
s = list(input())
q = int(input())

for i,c in enumerate(s,start=1):
  dic[c].append(i)
  
for i in range(q):
  p,l,r = map(str,input().split())
  if p =='1':
    j = int(l)
    if r == s[j-1]:
      continue
    c = s[j-1]    
    dic[c].pop(bisect_left(dic[c],j))
    dic[r].insert(bisect_left(dic[r],j),j)
    s[j-1] = r
  else:
    ans = 0
    l = int(l)
    r = int(r)
    for c in string.ascii_lowercase:
      pl = bisect_left(dic[c],l)
      if pl < len(dic[c]):
        if dic[c][pl] <= r:
          ans += 1
    print(ans)


Measured memory_bytes: 29068
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <queue>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
void Traveling() {
	int N;
	cin >> N;
	int pt = 0,px = 0, py = 0;

	for (size_t i = 0; i < N; i++)
	{
		int t, x, y;
		cin >> t >> x >> y;
		int it = t - pt;
		int ix = abs(x - px);
		int iy = abs(y - py);
		if (it - ix - iy < 0) {
			cout << "No" << endl;
			return;
		}
		else if((it - ix - iy) % 2 != 0){
			cout << "No" << endl;
			return;
		}
		pt = t;
		px = x;
		py = y;
	}
	cout << "Yes" << endl;
}
int main() {
	Traveling();
	return 0;
}

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

string T[] = {"dream", "dreamer", "erase", "eraser"};
	
bool huga(string &S){
	// cout<<S<<endl;
	int size = S.size();
	if(size <= 4) return false;
	if(size == 5 || size == 6 || size == 7){
		for(int i = 0; i < 4; i++){
			if(T[i] == S)return true;
		}
	} else {
		string temp;
		bool ans = false;
		for(int i = 0; i < 5; i++){
			temp += S[i];
		}
		if(temp == T[0]){
			S.erase(S.begin(), S.begin()+5);
			if(huga(S))return true;
			if(S[0] == 'e'){
				S.erase(S.begin(), S.begin()+2);
				if(huga(S))return true;
			}				
		} else if(temp == T[2]){
			S.erase(S.begin(), S.begin()+5);
			if(huga(S))return true;
			if(S[0] == 'r'){
				S.erase(S.begin(), S.begin()+1);
				if(huga(S))return true;
			}	
		}
	}
	return false;
}
signed main(){
	string S;
	bool ans = false;
	
	
	cin>>S;
	
	cout<<(huga(S)?"YES":"NO")<<endl;
	
	return 0;
}

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

void change(string &str,int n){
    if(str[n-1]=='P'){
        str[n]='D';
    } else if(str[n+1]=='?' || str[n+1]=='D'){
        str[n]='P';
    } else {
        str[n]='D';
    }
}

int main(){
    string t;
    cin>>t;
    int answer=0;
    for(int i=0;i<t.length();i++){
        if(t[i]=='?'){
            change(t,i);
        }
    }
    for(int i=0;i<t.length();i++){
        cout<< t[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3376
#include<stdio.h>

int bfs(int,int,int);
void push(int);
int pop(void);
int empty(void);

int n,que[1000000],graph[101][101],head=0,tail=0,vst[101],count[101];

int main(void){
  int r,k,t,p,s,d,v,i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d %d",&r,&k);

    for(j=0;j<k;j++){
      scanf("%d",&t);
      graph[r][t]=1;
    }
  }
  
  scanf("%d",&p);

  for(i=0;i<p;i++){
    scanf("%d %d %d",&s,&d,&v);

    if(bfs(s,d,v)<=v && bfs(s,d,v)>0) printf("%d\n",bfs(s,d,v));
    else printf("NA\n");
  }

  return 0;
}

int bfs(int s,int d,int v){
  int u,i,j;

  for(i=0;i<=n;i++)vst[i]=count[i]=0;
  
  count[s]=1;
  push(s);
  vst[s]=1;

  while(!empty()){
    u=pop();

    for(i=1;i<=n;i++){
      if(!vst[i] && graph[u][i]){
	push(i);
	vst[i]=1;
	count[i]=count[u]+1;
      }
    }
  }

  return count[d];
}

void push(int a){
  que[tail++]=a;
}

int pop(void){
  int res=que[head++];
  return res;
}

int empty(void){
  return tail==head?1:0;
}

Measured memory_bytes: 1096