akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool solve(){
  string s;cin>>s;
  deque<char>deq;
  bool isReverse=false;
  rep(i,s.size()){
    deq.push_back(s[i]);
  }

  ll Q;cin>>Q;
  while (Q--)
  {
    ll x;cin>>x;
    if(x==1){
      isReverse=!isReverse;
    }else{
      ll f;cin>>f;
      char c;cin>>c;
      if(f==2){
        if(!isReverse)deq.push_back(c);
        else deq.push_front(c);
      }else{
        if(isReverse)deq.push_back(c);
        else deq.push_front(c);
      }
    }
  }
  
  if(isReverse)reverse(all(deq));
  for(auto&&i:deq)cout<<i;
  cout<<endl;
  return false;
}


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


Measured memory_bytes: 1104
def main():
    N = int(input())
    S = input()
    result = ""
    for i in S:
        ch = ord(i)
        if ch + N > 90:
            result += chr(ch - 90 + N + 64)
        else:
            result += chr(ch + N)

    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

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

    ll a, b, c, k; cin >> a >> b >> c >> k;
    ll ans = 0;
    if(k & 1) {
        ans = b - a;
    } else {
        ans = a - b;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
using namespace std;
int main(){
	int i,j=0,n;
	for(cin>>n;j<n;j++){
		string s;
		cin>>s;
		set<string> m;
		for(i=1;i<s.length();i++){
			string s1=s.substr(0,i),s2=s.substr(i),r1=s1,r2=s2;
			reverse(r1.begin(),r1.end());
			reverse(r2.begin(),r2.end());
			m.insert(s1+s2);
			m.insert(r1+s2);
			m.insert(s1+r2);
			m.insert(r1+r2);
			m.insert(s2+s1);
			m.insert(r2+s1);
			m.insert(s2+r1);
			m.insert(r2+r1);
		}
		cout<<m.size()<<endl;
	}
}

Measured memory_bytes: 1292
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T lcm(T x,T y){
    return x*y/GCD(x,y);
}


int main(){
    int n; cin >> n;
    map<int,int> mp;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        mp[a]++;
    }
    int m; cin >> m;
    int ans = 0;
    for(int i = 0; i < m; i++){
        int k; cin >> k;
        if (mp[k])ans++;
    }
    cout << ans << endl;
}
  




Measured memory_bytes: 10056
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  int a,b,c=0;
  cin>>a>>b;
  for(int i=1;i<=(b-a);i++){
    c+=i;
  }
  cout<<c-b<<endl;
}

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

int main(){
  int n; cin>>n;
  vector<int> num(n,0);
  string s; cin>>s;
  for(int i=1;i<n;i++){
    if(s[i]=='E')num[0]++;
  }
  for(int i=1;i<n;i++){
    num[i]=num[i-1];
    if(s[i]=='E') num[i]--;
    if(s[i-1]=='W') num[i]++;
  }
  sort(num.begin(),num.end());
  cout<<num[0]<<endl;
}

Measured memory_bytes: 2052
N = int(input())
A = []

for i in range(N) :
    a = int(input())
    A.append((a, i))

A.sort(key=lambda A : A[0], reverse=True)

for i in range(N) :
    if i == A[0][1] :
        print(A[1][0])
    else :
        print(A[0][0])


Measured memory_bytes: 33356
fn = lambda x : m+f >= x 
while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif fn(80):
        print("A")
    elif fn(65):
        print("B")
    elif fn(50):
        print("C")
    elif fn(30):
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")





Measured memory_bytes: 5592
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#include <string>
using namespace std;

//宣言
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//数値
#define MOD 1000000007
#define INF (1<<20)
const double EPS = 1e-10;
const double PI = acos(-1.0);

//操作
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define REP(i,n) FOR(i,0,n)
#define REPB(i,n) for(int i=n;i>=0;--i)
#define SORT(A) sort(A,A+sizeof(A)/sizeof(A[0]))
#define VSORT(A) sort(A.begin(),A.end())
#define EXIST(s,e) (s.find(e)!=s.end())
#define PB push_back
#define MP make_pair
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);

//DEBUG
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int c[500], s[500], f[500];

int main() {
	int n;
	cin >> n;
	REP(i, n-1) cin >> c[i] >> s[i] >> f[i];
	REP(i, n) {
		int t=0;
		if(t!=n-1) t = s[i] + c[i];
		int p = i + 1;
		while(p<n-1){
			int m;
			if (t%f[p]) m = f[p] - t%f[p];
			else m = 0;
			t=max(s[p],t+m);
			t += c[p];
			p++;
		}
		cout << t << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){

  long long A, B, C, K;
  long long sum = 0;

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

  for(int i=0; i<K; i++){
    if(A>0){
      sum++; A--;
      continue;
    }
    if(B>0){
      B--;
      continue;
    }
    if(C>0){
      sum--; C--;
      continue;
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3636
from functools import lru_cache
 
N = int(input())
A = list(map(int, input().split()))
 
@lru_cache(None)
def f(l, r, xl, xr):
  if l+1 == r:
    return xl * A[l] + xr * A[r]
  tmp = float("inf")
  for m in range(l+1, r):
    v = f(l, m, xl, xl+xr) + f(m, r, xl+xr, xr) - (xl+xr) * A[m]
    tmp = min(tmp, v)
  return tmp
 
print(f(0, N-1, 1, 1))

Measured memory_bytes: 155524
#include <iostream>
#include <cstdio>

using namespace std;


int main()
{
    int h, w, a, b;
    scanf("%d%d%d%d", &h, &w, &a, &b);
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
            printf("%d", (int)((j < a) ^ (i < b)));
        printf("\n");
    }
}


Measured memory_bytes: 1280
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int n, k, x[110],ans=0;
	cin >> n >> k;
	for (int i = 1; i <= n;i++) {
		cin >> x[i];
	}
	for (int i = 1; i <= n;i++) {
		ans += min(2 * x[i], 2 * (k - x[i]));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    S = int(input())
    #|ac - bd| == S, a == 10 ** 9
    a = 10 ** 9
    c = (S - 1) // a + 1
    bd = a * c - S
    if bd == 0: b, d = 0, 0
    else:
        for i in range(1, bd):
            if i ** 2 > bd: break
            if bd % i == 0:
                b, d = i, bd // i
                break
    print(0, 0, a, b, d, c)

    return 0

if __name__ == "__main__":
    solve()

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

int main()
{
	string A,B,C;
	cin >> A >> B >> C;
	int a = A.size();
	int b = B.size();
	int c = C.size();
	if(A[a-1] == B[0] && B[b-1] == C[0]){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
lis = [[0,True]for _ in range(N)]
adj =[{}for _ in range(N)]
for i in range(N-1):
    i,j,w = map(int,input().split())
    i -= 1
    j -= 1
    w = w%2
    adj[i][j]=w
    adj[j][i]=w

lis[0][1] =False
tsugi =[0]
while len(tsugi)!=0:
    foo = []
    for i in tsugi:
        for j in adj[i].keys():
            if lis[j][1]:
                lis[j][0]=lis[i][0]+adj[i][j]
                foo.append(j)
            adj[j].pop(i)
        adj[i].clear()
    tsugi = foo

ans = [str(i[0]%2) for i in lis]
print("\n".join(ans))

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

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





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



string s,t;
int n,m;
bool ha[maxn];

ll ans=0;

map<char,vector<int>> mp;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>s>>t;
    n=s.length();
    m=t.length();
    for (int i=0; i<n; i++) {
	mp[s[i]].push_back(i);
    }

    for (char c: s) {
	ha[c-'a']=true;
    }
    for (char c: t) {
	if (!ha[c-'a']) out(-1);
    }

    int j=-1;

    for (int i=0; i<m; i++) {
	auto iter = upper_bound(mp[t[i]].begin(), mp[t[i]].end(), j);
	if (iter == mp[t[i]].end()) {
	    ans += n-j-1;
	    j = -1;
	    iter = upper_bound(mp[t[i]].begin(), mp[t[i]].end(), j);
	    assert(iter != mp[t[i]].end());
	}

	ans += *iter - j;

	//watch(ans);
	j = *iter;
    }

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


Measured memory_bytes: 1228
def judge(list, a, x, y)
  arr = Array.new(a.length,-1)
  list.each{ |i|
    arr[i] = 1
  }
  bool = true
  list.each{|i|
    a[i].times{|t|
      if (arr[x[i][t]-1] == -1 && y[i][t] == 1) || (arr[x[i][t]-1] == 1 && y[i][t] == 0)
        bool = false
      end
    }
  }
  bool
end

n = gets.to_i
a = []
x = Array.new(n).map{Array.new}
y = Array.new(n).map{Array.new}
n.times{|i|
  a[i] = gets.to_i
  a[i].times{|t|
    x[i][t], y[i][t] = gets.chomp.split(" ").map(&:to_i)
  }
}

bit = 2**n-1
ans = 0
for i in 0..bit
  list = []
  keta = 0
  num = 0
  while i > 0
    if i%2 == 1
      list.push(keta)
      num += 1
    end
    i = i / 2
    keta += 1
  end
  if judge(list, a, x, y)
    ans = num > ans ? num : ans
  end
end

puts ans

Measured memory_bytes: 2428
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char str[105];
    scanf("%s",str);
    int len=strlen(str);
    int flag=0;
    for(int i=1;i<=len;i++)
    {
        if(i%2==0)
        {
            if(str[i-1]!='L'&&str[i-1]!='U'&&str[i-1]!='D')
                flag=1;
        }
        else if(i%2==1)
        {
            if(str[i-1]!='R'&&str[i-1]!='U'&&str[i-1]!='D')
                flag=1;
        }
        if(flag==1)
            break;
    }
    if(flag==1)
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}


Measured memory_bytes: 384
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
#define chmax(x,y) (x = max(x, y))
void solve(); int main() { solve(); return 0; }

void solve() {
  string s; cin >> s;
  sort(s.begin(), s.end());
  if (s == "abc") cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main(){
	long long n, a, b;	cin >> n >> a >> b;
	if((b-a)%2 == 0){
		cout << (b-a)/2 << endl;
	}
	else{
		cout << min(a-1, n-b) + 1 + (b-a)/2 << endl;
	}
	return 0;
}

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

int main(){
    int n=0;
    cin >> n;
    int a[n] = {0};
    for(int i=1;i<=n;i++){
        cin >> a[i];
        }
   int b[n] = {0};
    for(int j=1;j<=n;j++){cin >> b[j];}
    int c[n-1]= {0};
    int d = n - 1;
    for(int i=1;i<=d;i++){cin >> c[i];}
    int ans=0;
    for(int i=1;i<=n;i++){
        int temp = b[a[i]];
        ans += temp;       
        if(a[i] == a[i-1] + 1){
            ans += c[a[i-1]];
        }
     //   cout << "for=" << i << endl;
     //   cout << ans <<endl;
        
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
char t[30][100];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)
			for(int j=0;j<6;j++)
				scanf("%s",t[i]+j);
		int ret=0;
		for(int i=0;i<a;i++){
			bool ok=true;
			char p[4];
			p[0]=t[i][1];
			p[1]=t[i][2];
			p[2]=t[i][4];
			p[3]=t[i][3];
			char q[4];
			for(int j=0;j<i;j++){
				if(t[i][0]==t[j][0]){
					q[0]=t[j][1];
					q[1]=t[j][2];
					q[2]=t[j][4];
					q[3]=t[j][3];
				}
				if(t[i][0]==t[j][1]){
					q[0]=t[j][5];
					q[1]=t[j][2];
					q[2]=t[j][0];
					q[3]=t[j][3];
				}
				if(t[i][0]==t[j][2]){
					q[0]=t[j][5];
					q[1]=t[j][4];
					q[2]=t[j][0];
					q[3]=t[j][1];
				}
				if(t[i][0]==t[j][3]){
					q[0]=t[j][5];
					q[1]=t[j][1];
					q[2]=t[j][0];
					q[3]=t[j][4];
				}
				if(t[i][0]==t[j][4]){
					q[0]=t[j][0];
					q[1]=t[j][2];
					q[2]=t[j][5];
					q[3]=t[j][3];
				}
				if(t[i][0]==t[j][5]){
					q[0]=t[j][4];
					q[1]=t[j][2];
					q[2]=t[j][1];
					q[3]=t[j][3];
				}
				for(int k=0;k<4;k++){
					bool OK=true;
					for(int l=0;l<4;l++){
						if(p[l]!=q[(k+l)%4])OK=false;
					}
					if(OK)ok=false;
				}
			}
			if(!ok)ret++;
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1032
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int Taka,Aoki;
void T()
{
	if(Taka & 1)
	{
		Taka--;
	}
	Aoki += Taka >> 1;
	Taka >>= 1;
}
void A()
{
	if(Aoki & 1)
	{
		Aoki--;
	}
	Taka += Aoki >> 1;
	Aoki >>= 1;
}
int main(int argc, char const *argv[])
{
	int k;
	cin>>Taka>>Aoki>>k;
	for(int i = 1;i <= k; ++i)
	{
		if(i & 1)
		{
			T();
		}
		else
		{
			A();
		}
	}
	cout<<Taka<<" "<<Aoki<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define dbg puts("bug bug bagum");
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(), _a.end()
#define EPS 1e-9
#define PI acos(-1.0)
#define MAX 200005
#define MOD 1000000007
#define INF (1 << 31)
#define nl '\n'
#define fast ios_base ::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define in_file freopen("input.txt", "r", stdin)
#define out_file freopen("output.txt", "w", stdout)
#define fr(i, b, e) for (int(i) = (b); (i) < (e); (i)++)
#define fr(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define ms0(x) memset((x), 0, sizeof((x)));
#define ms1(x) memset((x), -1, sizeof((x)));
#define pqmin(x) priority_queue<x, vector<x>, greater<x>>
#define pqmax(x) priority_queue<x>
#define sortd(x) sort(all(x), greater<int>())
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) __lcm(x, y)
#define fact(x) factorial(x)
#define sieve(x) normal_sieve(x)
#define bsieve(x) bitwise_sieve(x)
#define bprime(x) !Chk(x)
#define in_file freopen("input.txt", "r", stdin)
#define out_file freopen("output.txt", "w", stdout)
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef pair<int, int> pii;
typedef pair<int, pii> tii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
/* Function to check if x is power of 2*/
bool isPowerOfTwo(int x)
{
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x & (x - 1)));
}
///code starts from here.............................................
int main()
{
    fast;
    int k,x;
    cin>>k>>x;
    if(k*500>=x)cout<<"Yes"<<endl;
    else
    {
         cout<<"No"<<nl;
    }
    
    return 0;
}


Measured memory_bytes: 256
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}


int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int n = readInt(), k = readInt();
	cout << ((n % k) ? 1 : 0);
	return 0;
}

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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

#define ll long long
#define ull unsigned ll

void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(double *x){scanf("%lf",x);}
int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;}
template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);}
template <class T, class S, class U> void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);}
template <class T, class S, class U, class V> void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);}

void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(double x, char c){printf("%.15f",x);mypc(c);}
void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);}
void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);}
template<class T> void writerLn(T x){writer(x,'\n');}
template<class T, class S> void writerLn(T x, S y){writer(x,' ');writer(y,'\n');}
template<class T, class S, class U> void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');}
template<class T> void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');}

char memarr[17000000]; void *mem = memarr;
#define MD 1000000007

int main(){
  int i;
  ll A[3];

  rep(i,3) reader(A+i);
  if(A[0]%2 && A[1]%2 && A[2]%2){
    sort(A, A+3);
    writerLn(A[0]*A[1]);
  } else {
    writerLn(0);
  }

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast","unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define F first
#define S second
#define MEM(a,b) memset(a,b,sizeof a)
#define Tie ios::sync_with_stdio(0),cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int n,k,a[101],dp[100100];

int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=1;i<=k;i++)
	{
		dp[i]=1;
		for(int j=0;j<n&&i-a[j]>=0;j++)
			dp[i]&=dp[i-a[j]];
		dp[i]^=1;
	}
	if(dp[k])
		cout <<"First\n";
	else
		cout <<"Second\n"; 
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (scanner.hasNext()) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int i = 0;
			int digit = 1;
			while (a + b >= digit) {
				i++;
				digit *= 10;
			}
			System.out.println(i);
		}
	}

}

Measured memory_bytes: 26424
/* トランプのカードをソートするプログラム
   4つの絵柄(S,H,C,D)と1-9までの数字を組み合わせた36枚の
   カードを使う。

   N枚のカードを昇順に並び替える。
   その際、バブルソートと選択ソートのアルゴリズム2つを使う。
   更にそれらのソートの出力が安定的であるかどうか出力する。

   入力：
   一行目にカードの枚数N
   二行目に絵柄と数字与えられる。隣り合うカードはひとつの空白が与えられる。

   出力：
   一行目にバブルソートの結果
   二行目に出力が安定であるかどうか出力(Stable か Not stable)
   三行目に選択ソートの結果
   四行目に出力が安定的であるかどうか出力
*/

#include <stdio.h>
#include <stdbool.h> 

//カードの型
struct card {
   char suit;
   int  num;
};

//安定的であるかどうかの判定
bool isStable(struct card* in, struct card* out, int n)
{
   for (int i = 0; i < n; i++)
      for (int j = i+1; j < n; j++)
         for (int a = 0; a < n; a++)
            for (int b = a+1; b < n; b++)
               //入力されているカードの数字が同じ場合 かつ
               //出力においてそのカードの数字の要素が昇順でない場合
               if (in[i].num == in[j].num && in[i].suit == out[b].suit && in[i].num == out[b].num
                   &&  in[j].suit == out[a].suit && in[j].num == out[a].num)
                  return false;

   return true;
}

//バブルソート
void Bubble(struct card* p, int n)
{
   struct card tmp;

   for (int i = 0; i < n; i++) {
      for (int j = n-1; j >= i+1; j--) {
         //隣り合うカードが昇順でない場合に、並び替える
         if (p[j].num < p[j-1].num) {
            tmp = p[j];
            p[j] = p[j-1];
            p[j-1] = tmp;
         }
      }
   }

   return;
}

//選択ソート
void Selection(struct card* p, int n)
{
   int minj;
   struct card tmp;

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

      for (int j = i ; j < n; j++) {
         //最小値の要素を更新
         if (p[j].num < p[minj].num)
            minj = j;
      }
      tmp = p[i];
      p[i] = p[minj];
      p[minj] = tmp;
   }

   return;
}

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

   struct card card[n];

   //改行文字を読み飛ばし
   getchar();

   //入力設定
   for (int i = 0; i < n; i++) {
      scanf("%c%d", &card[i].suit, &card[i].num);

      //スペース読み飛ばし
      getchar();
   }

   bool isstable;

   struct card bubble[n];
   struct card selection[n];

   //入力されたカードをそれぞれソートする入力値へ設定
   for (int i = 0; i < n; i++) {
      bubble[i] = card[i];
      selection[i] = card[i];
   }

   //バブルソートの実行
   Bubble(bubble, n);

   //安定的かどうかの判定
   isstable = isStable(card, bubble, n);

   //出力
   for (int i = 0; i < n; i++) {
      printf("%c%d", bubble[i].suit, bubble[i].num);
      if (i == n-1)
         printf("\n");
      else 
         printf(" ");
   }
   if (isstable == false)
      printf("Not stable\n");
   else if (isstable == true)
      printf("Stable\n");

   //選択ソートの実行
   Selection(selection, n);
   isstable = isStable(card, selection, n);

   //出力
   for (int i = 0; i < n; i++) {
      printf("%c%d", selection[i].suit, selection[i].num);
      if (i == n-1)
         printf("\n");
      else 
         printf(" ");
   }
   if (isstable == false)
      printf("Not stable\n");
   else if (isstable == true)
      printf("Stable\n");

   return 0;
}


Measured memory_bytes: 2128
def solve():
    N = int(input())
    t_i, x_i, y_i = 0, 0, 0
    for i in range(N):
        t_j, x_j, y_j = map(int, input().split())
        dt = t_j - t_i
        dxy = x_j - x_i + y_j - y_i
        if (dxy < -dt) | (dxy > dt):
            return "No"
        if ((t_i - t_j) % 2) != (dxy % 2):
            return "No"
        t_i, x_i, y_i = t_j, x_j, y_j
    return "Yes"
print(solve())

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		static void Main()
		{
			string s = Console.ReadLine();
			var counts = new int[26];
			int n = s.Length;
			for (int i = 0; i < n; i++) {
				counts[s[i] - 'a']++;
			}

			for (int i = 0; i < 26; i++) {
				if (counts[i] > 1) {
					Console.WriteLine("no");
					return;
				}
			}

			Console.WriteLine("yes");
		}
	}
}

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

using namespace std;

long long func(string s){
    
    if(s[0] != '['){
        return stoi(s) / 2 + 1;
    }

    int depth = 0;
    int begin = 0;
    vector<long long> cnt;
    for(int i = 0; i < (int)s.size(); i++){
        char c = s[i];
        if(c == '['){
            if(depth == 0){
                begin = i;
            }
            depth++;
        }
        else if(c == ']'){
            depth--;
            if(depth == 0){
                long long temp = func(s.substr(begin + 1, i - begin - 1));
                cnt.push_back(temp);
            }
        }
    }

    int win = (int)cnt.size() / 2 + 1;
    sort(cnt.begin(), cnt.end());
    
    long long ret = 0;
    for(int i = 0; i < win; i++){
        ret += cnt[i];
    }

    return ret;
}

void solve(){
    string s;
    cin >> s;

    long long ans = func(s);
    cout << ans << endl;
}

int main(){

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

    return 0;
}


Measured memory_bytes: 3240
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cassert>
using namespace std;

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

	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	
	int best = 1e9;
	for (int x = -100; x <= 100; x++) {
		int tmp = 0;
		for (int i = 0; i < n; i++) tmp += (x - a[i]) * (x - a[i]);
		best = min(best, tmp);
	}
	
	cout << best << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<list>
#include<algorithm>
using namespace std;

int main(void) {
	int q, x;
	char com[20];
	scanf("%d", &q);

	list<int> v;

	for (int i = 0;i <= q - 1;i++) {
		scanf("%s", com);
		if (com[0] == 'i') {
			scanf("%d", &x);
			v.push_front(x);
		}
		else if (com[6] == 'L'){
			v.pop_back();
		}
		else if (com[6] == 'F') {
			v.pop_front();
		}
		else if (com[0] == 'd') {
			scanf("%d", &x);
			for (list<int>::iterator it = v.begin();it != v.end();it++) {
				if (*it == x) {
					v.erase(it);
					break;
				}
			}
		}
	}

	int i = 0;
	for (list<int>::iterator it = v.begin();it != v.end();it++) {
		if (i++ > 0)printf(" ");
		printf("%d", *it);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 33916
A = [0,0,0]
N,A[0],A[1],A[2] = map(int,input().split())
L = [int(input()) for _ in range(N)]
#print(L)

ans = 10 ** 9
for i in range(4**N):
  G = [[] for _ in range(4)]
  for j in range(N):
    G[(i//(4**j))%4].append(L[j])
  #print(G)
  mp = 0
  for j in range(3):
    if len(G[j]) == 0:
      mp = 10 ** 9
      break
    mp += (len(G[j])-1)*10
    mp += abs(sum(G[j])-A[j])
  ans = min(ans,mp)
print(ans)

Measured memory_bytes: 44252
#include <bits/stdc++.h>
//#include <cstdio>
//#include <algorithm>
//#include <cmath>
//#include <cstring>
//#include <iostream>
using namespace std;
typedef long long ll;
const int maxx=2e5+100;
const int INF=1e9;
const int MOD=1e9+7;
char s[maxx];
 
int main()
{
    scanf("%s",s);
    for(int i=0; i<strlen(s); i++){
        if(i%2==0)
            cout<<s[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 384
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#define cout(s) cout<<s<<endl 
using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if ((b - a) == (c - b))
		cout("YES");
	else 
		cout("NO");
	return 0;
}


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

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

  vector<int> t(N), x(N), y(N);
  rep(i, N) cin >> t[i] >> x[i] >> y[i];

  bool ok = true;

  int ct = 0, cx = 0, cy = 0;
  rep(i, N) {
    int dd = abs(x[i] - cx) + abs(y[i] - cy);
    int dt = t[i] - ct;
    ct = t[i], cx = x[i], cy = y[i];
    if (dd <= dt && dt % 2 == dd % 2)
      continue;
    ok = false;
    break;
  }

  if (ok)
    puts("Yes");
  else
    puts("No");
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;

void solve() {
    LL a, b, c;
    cin >> a >> b >> c;
    LL k;
    cin >> k;
    if (k <= a + b) cout << min(a, k) << endl;
    else cout << a - (k - a - b);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // int t;cin >> t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int main(){
	int N,A,res=1;
	map<int,int> mp;
	cin>>N;
	rep(i,N){
		cin>>A;
		mp[A]++;
		if(mp[A]>2 || A>=N || mp[0]>1)res=0;
	}
	rep(i,N/2)res=(res*2)%1000000007;
	cout<<res<<endl;
}


Measured memory_bytes: 3328
N, K, Q = map(int, input().split())
A = []
for i in range(Q):
  A.append(int(input()))
  
P = [K-Q for i in range(N)]

for i in A:
  P[i-1] += 1
  
for i in P:
  if i > 0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 11776
n,k=map(int,input().split())
x = list(map(int,input().split()))
t = 1
s = n
f=0
while t:
    for i in range(k):
        f = 0
        if str(x[i]) in str(s):
            break
        elif i == k -1:t = 0
    s+=1
print(s-1)
    

Measured memory_bytes: 3060
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> a;
  tools::read(a, N);

  const auto max_it = std::max_element(a.begin(), a.end());
  const auto min_it = std::min_element(a.begin(), a.end());
  const i64 max_index = std::distance(a.begin(), max_it) + 1;
  const i64 min_index = std::distance(a.begin(), min_it) + 1;
  if (*max_it >= 0 && std::abs(*min_it) <= std::abs(*max_it)) {
    std::cout << 2 * N - 1 << std::endl;
    std::cout << max_index << ' ' << N << std::endl;
    std::cout << max_index << ' ' << N << std::endl;
    std::cout << N << ' ' << N << std::endl;
    for (i64 i = 2; i <= N - 1; ++i) {
      std::cout << N << ' ' << i << std::endl;
      std::cout << N << ' ' << N << std::endl;
    }
  } else {
    std::cout << 2 * N - 1 << std::endl;
    std::cout << min_index << ' ' << 1 << std::endl;
    std::cout << min_index << ' ' << 1 << std::endl;
    std::cout << 1 << ' ' << 1 << std::endl;
    for (i64 i = N - 1; i >= 2; --i) {
      std::cout << 1 << ' ' << i << std::endl;
      std::cout << 1 << ' ' << 1 << std::endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
N = gets.chomp.to_i
s = []
t = []

N.times do
  _s, _t = gets.chomp.split(" ")
  s << _s
  t << _t.to_i
end

X = gets.chomp

idx = s.index(X)

if t[idx+1..-1].empty? then
  puts "0"
  exit
end
puts t[idx+1..-1].inject(:+)

Measured memory_bytes: 1788
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def Z_algorithm(s):
        n = len(s)
        z = [0]*n
        z[0] = n
        c = 1
        for i in range(1,n):
            if i+z[i-c] < c+z[c]:
                z[i] = z[i-c]
            else:
                j = max(0,c+z[c]-i)
                while i+j < n and s[j] == s[i+j]:
                    j += 1
                z[i] = j
                c = i
        return z
    n = I()
    s = input()
    ans = 0
    for i in range(n):
        z = Z_algorithm(s[i:])
        for j in range(i,n):
            l = min(j-i,z[j-i])
            if ans < l:
                ans = l
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 49116
var N;
function c753(s) {
    if ((s - 0) > N) return 0;

    var f = new Array(8);
    f[7] = f[5] = f[3] = false;
    for (var n = 0; n < s.length; n++) { f[s.charAt(n) - 0] = true; }
    var count = (f[7] && f[5] && f[3]) ? 1 : 0;
    for (var c of ['7', '5', '3']) { count += c753(s + c); }
    return count;
}
function Main(input) {
    N = input.split("\n")[0] - 0;
    var count = c753("");
    console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100001
int par[MAX_N];
int size[MAX_N];
int id[MAX_N];
bool flg=false;

void init(){
  for(int i=0;i<MAX_N;i++){
    par[i]=i;
    size[i]=1;
    id[i]=-1;
  }
}

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

void unite(int a,int b){
  a=find(a);
  b=find(b);
  if(a==b)return;
  if(size[a]>size[b])swap(a,b);
  par[a]=b;
  size[b]+=size[a];
  
  if(id[a]!=-1&&id[b]!=-1&&id[a]!=id[b])flg=true;
  
  if(id[a]!=-1){
    id[b]=id[a];
  }
}

int N,M,K;
int main(){
  init();
  
  scanf("%d %d %d",&N,&M,&K);
  for(int k=1;k<=K;k++){
    int type,x,y;
    scanf("%d %d %d",&type,&x,&y);
    if(type==1){
      unite(x,y);
    }else if(type==2){
      x=find(x);
      if(id[x]!=-1&&id[x]!=y)flg=true;
      id[x]=y;
    }
    if(flg){
      cout<<k<<endl;
      break;
    }
  }
  if(!flg){
    cout<<0<<endl;
  }
  return 0;
}

Measured memory_bytes: 4368
#include <bits/stdc++.h>  
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define REP(i, a, n, op) for(int i=a; i<(int)(n); i ## op ## op)
#define cout(val) cout << val << endl

using namespace std;  

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

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

# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<command-line>" 2
# 1 "<stdin>"

using namespace std;

# 1 "../Algo/NumberTheory/eratosthenes.h" 1
class Eratosthenes {
public:
    Eratosthenes(int n): mx(n+1) {
        primes.reserve(mx);
        firstDiv.assign(mx, -1);
        firstDiv[1] = 1;
        vector<bool> ps(mx, true);
        for (int p = 2; p < mx; p++) {
            if (!ps[p]) {
                continue;
            }
            primes.push_back(p);

            for (int d = p; d < mx; d += p) {
                ps[d] = false;
                if (firstDiv[d] == -1) {
                    firstDiv[d] = p;
                }
            }
        }
    }

    vector<int> primeFactorizeFlat(int k) {
        auto gr = primeFactorize(k);
        vector<int> res;
        for (auto pr: gr) {
            int p = pr.first;
            for (int c = 0; c < pr.second; c++) {
                res.push_back(p);
            }
        }
        return res;
    }

    vector<pair<int, int>> primeFactorize(int k) {
        assert(k < mx);
        vector<pair<int, int>> res;
        int cur = k;
        while (cur > 1) {
            int p = firstDiv[cur];
            int cnt = 0;
            while (cur % p == 0) {
                cnt++;
                cur /= p;
            }
            res.push_back({p, cnt});
        }
        return res;
    }

    vector<int> allDivs(int k) {
        auto primeFact = primeFactorize(k);
        vector<int> res = {1};
        for (auto pr: primeFact) {
            int sz = res.size();
            int mul = 1;
            for (int c = 0; c < pr.second; c++) {
                mul *= pr.first;
                for (int i = 0; i < sz; i++) {
                    res.push_back(res[i] * mul);
                }
            }
        }
        sort(res.begin(), res.end());
        return res;
    }


    int mobius(int k) {
        auto ps = primeFactorize(k);
        for (auto pr: ps) {
            if (pr.second > 1) {
                return 0;
            }
        }
        return ps.size() % 2 == 0 ? 1 : -1;
    }

    vector<int> allPrimes() {
        return primes;
    }

private:
    int mx;
    vector<int> firstDiv;
    vector<int> primes;
};
# 5 "<stdin>" 2

const int MX = 1e6 + 9;
Eratosthenes eth(MX);

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> cnt(MX, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    int ans = 0;
    for (int v: a) {
        cnt[v]--;
        bool ok = true;
        for (int d: eth.allDivs(v)) {
            if (cnt[d] > 0) {
                ok = false;
            }
        }
        if (ok) {
            ans++;
        }
        cnt[v]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 12156
n, *L = map(int, open(0).read().split())

dp = [0] * n

dp[0] = 0
dp[1] = abs(L[1] - L[0])

for i in range(2, n):
    dp[i] = min(dp[i - 1] + abs(L[i] - L[i - 1]), dp[i - 2] + abs(L[i] - L[i - 2]))
    

print(dp[-1])


Measured memory_bytes: 13876
#pragma region 宣言部分
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;
 
#pragma endregion
 
 
 
int main(){
    ll n;
    cin >> n;
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }
    ll m = n;
    vector <ll> sosuu;
    //cout << "!" << endl;
    for(ll i = 2;i*i <= n;i++){
        ll cnt = 0;
        while(m%i == 0){
            m /= i;
            cnt++;
        }
        if(cnt != 0)
            sosuu.pb(cnt);
    }
    ll res = 0;
    if(m > 1)
        res++;

    
    for(int i = 0;i < sosuu.size();i++){    
        
        //cout << i << " " << num[i] << endl;
        int r = 1;
        while(sosuu[i] >= 0){
            sosuu[i] -= r;
            r++;
        }
            //cout << r-2 << endl;
            res += (r-2);
        
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3648
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {

            long[] arr = cin.ReadLongArray(4);
            var A = arr[0];
            var B = arr[1];
            var C = arr[2];
            var D = arr[3];
            var sum = B - A + 1;
            var multipleOfC = (B / C) - ((A - 1) / C);
            var multipleOfD = (B / D) - ((A - 1) / D);
            var multipleOfLcmCD = (B / Lcm(C,D)) - ((A - 1) / Lcm(C,D));
            var answer = sum - (multipleOfC + multipleOfD - multipleOfLcmCD);
            Console.WriteLine(answer);
            
            
        }

        //最小公倍数
        public long Lcm(long a, long b)
        {
            return a * b / Gcd(a, b);
        }

        // ユークリッドの互除法 
        public long Gcd(long a, long b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }

    }
    

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    //int t=100;

         //while(t--){
    vector<ll>v,v1;
    for(int i=0;i<3;i++)
    {
        int x;
        cin>>x;
        v.push_back(x);
        v1.push_back(x);
    }
    ll k;
    cin>>k;
    ll c=0;
    for(int i=1;i<=k;i++)
    {
        if(v[2]<=v[1])
            v[2]=v[2]*2;
        else if(v[2]<=v[0])
            v[2]=v[2]*2;
        else if(v[1]<=v[0])
            v[1]=v[1]*2;
      /* for(int i=0;i<3;i++)
            cout<<v[i]<<" ";
        cout<<endl;*/
                if(v[0]<v[1]&&v[1]<v[2]){
                    c=1;
                break;
                }
    }
    if(c==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3620