akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<string>

using namespace std;

int main()
{
	stack<int> S;
	string s;
	int a, b;
	while (cin >> s)
	{
		if (s[0] == '+')
		{
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(a + b);
		}
		else if (s[0] == '-')
		{
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(b - a);
		}
		else if (s[0] == '*')
		{
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(a * b);
		}
		else
		{
			S.push(atoi(s.c_str()));
		}
	}
	cout << S.top() << endl;
	return 0;
}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
 int x,a;
  cin>>x>>a;
  if(x<a){
    cout<<0<<endl;}
  else{
    cout<<10<<endl;}
 
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

#if N % 2 == 0:
#    for i in range(1, N, 2):
#        if A.count(i) != 2:
#            print(0)
#            exit()
#    print(int((2 ** (N/2)) % (10*9 + 7)))
#else:
#    for j in range(0, N, 2):
#        if j == 0:
#            if int(A.count(j)) != 1:
#                print(0)
#                exit()
#        else:
#            if A.count(j) != 2:
#                print(0)
#                exit() 
#    print(int(2 ** ((N-1)/2) % (10*9 + 7)))

# 全探索でやると間に合わなかったので正しい場合の和の値を求めてそれを配列の和と比較する

K = N if N % 2 == 0 else N + 1
S = N // 2
if sum(A) == K * S:
    ans = 2 ** S % (10 ** 9 + 7)
else:
    ans = 0

print(ans)

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

int main() {
  int n;
  cin >> n;
  vector<vector<P>> v(n, vector<P>());
  rep(i, n) {
    int a;
    cin >> a;
    rep(j, a) {
      int x, y;
      cin >> x >> y;
      --x;
      v[i].push_back({x, y});
    }
  }

  int ans = 0;
  rep(s, 1 << n) {
    vector<int> d(n);
    rep(i, n) { d[i] = s >> i & 1; }

    bool ok = true;
    rep(i, n) {
      if (d[i] == 0) continue;
      for (auto p : v[i]) {
        int x = p.first, y = p.second;
        // if (d[i] == 0) y = (y + 1) % 2;
        if (d[x] != y) {
          // if (d[i] == 0) y = (y + 1) % 2;
          ok = false;
          break;
        }
      }
    }

    if (!ok) continue;
    int now = 0;
    rep(i, n) now += d[i];
    ans = max(ans, now);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<cstdio>
using namespace std;

const int maxn = 1e5 + 1;
const int SIZE = 26;
int n, m, cnt[maxn][26][26];
string s[maxn];

struct TrieNode
{
	struct TrieNode *children[SIZE];
    int f[SIZE], isEnd;
};

struct TrieNode *getNode(void)
{
	struct TrieNode *pNode = new TrieNode;
	pNode->isEnd = 0;
	for (int i = 0; i < SIZE; i++)
    {
        pNode->children[i] = NULL;
        pNode->f[i] = 0;
    }
	return pNode;
}

void Insert(struct TrieNode *root, string key)
{
	struct TrieNode *parent = root;
	for (int i = 0; i < (int) key.size(); i++)
	{
		int id = key[i] - 'a';
		if (!parent->children[id])
            parent->children[id] = getNode();
        parent->f[id]++;
		parent = parent->children[id];
	}
	parent->isEnd++;
}

void search(struct TrieNode *root, string key, int k)
{
	struct TrieNode *parent = root;
	for (int i = 0; i < (int) key.size(); i++)
	{
		int id = key[i] - 'a';
        for (int j = 'a' - 'a'; j <= 'z' - 'a'; j++)
        if (parent->children[j] && j != id)
            cnt[k][id][j] += parent->f[j];
        cnt[k][id][id] += parent->isEnd;
		parent = parent->children[id];
	}
}

struct TrieNode *root = getNode();
void Input()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> s[i], Insert(root, s[i]);
}

void Solve()
{
    memset(cnt, 0, sizeof(cnt));
	for (int i = 1; i <= n; i++)
        search(root, s[i], i);

    int q; cin >> q;
    while (q--)
    {
        int k; cin >> k;
        string p; cin >> p;
        int res = 1;
        for (int i = 0; i < (int) p.size(); i++)
        {
            for (int j = i; j < (int) p.size(); j++)
                res += cnt[k][p[j] - 'a'][p[i] - 'a'];
        }
        cout << res << '\n';
    }
}

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

    //freopen("test.inp" , "r" , stdin);
    //freopen("test.out" , "w" , stdout);

    Input();
    Solve();
}


Measured memory_bytes: 397332
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int n;
    string s;
    cin >> n >> s;

    int ret = 0;
    while(--n >= 0){
        string t;
        cin >> t;
        bool ok = false;
        for(unsigned i=0; i<t.size(); ++i){
            for(unsigned j=1; j<t.size(); ++j){
                string x;
                for(unsigned k=i; k<t.size(); k+=j){
                    x += t[k];
                    if(x == s)
                        ok = true;
                }
            }
        }
        if(ok)
            ++ ret;
    }

    cout << ret << endl;

    return 0;
}

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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
const int N = 2e5+5;

int n , m , s , t;
vector<int> adj[N];

int bfs()
{
    queue< pair<int,int> > q;
    int d[n+2][4];
    for(int i=1; i<=n; i++)
    {
        d[i][0]=1e8 , d[i][1] =1e8 , d[i][2] = 1e8;
    }
    q.push({s , 0});
    d[s][0] = 0;

    while(q.size())
    {
        int node = q.front().f , mod = q.front().s;
        q.pop();

        for(auto ch : adj[node])
        {
            int m = (mod+1)%3;
            if (d[ch][m] == 1e8)
            {
                d[ch][m] = d[node][mod]+1;
                q.push({ch,m});
            }
        }
    }

    if (d[t][0] == 1e8) return -1;
    else return d[t][0]/3;
}

int main()
{

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n >> m;
    for(int i=1; i<=m; i++)
    {
        int x,y;
        cin >> x >> y;
        adj[x].push_back(y);
    }

    cin >> s >> t;
    cout << bfs() << '\n';
//
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5;

int N, K, A[MAXN+10];
ll dp[MAXN+10];

int main()
{
    int i, j;

    scanf("%d%d", &N, &K);
    for(i=1; i<=N; i++) scanf("%d", &A[i]);

    for(i=2; i<=N; i++)
    {
        dp[i]=1e18;
        for(j=max(1, i-K); j<i; j++) dp[i]=min(dp[i], dp[j]+abs(A[i]-A[j]));
    }
    printf("%lld", dp[N]);
}


Measured memory_bytes: 1408
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sn = new Scanner(System.in);
		int N = sn.nextInt();
		int total = 0;
		int count = 0;
		for(int i = 0; i < N; ++i){
			total += i+1;
			count++;
			if(total >= N) break;
		}
		int rm = total - N;
		for(int i = 0; i < count; ++i){
			if(i+1 != rm)
				System.out.println(i+1);
		}
	}
}


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

int main(){
	int a, b, count = 1, total;

	while(cin >> a >> b){
		total = a + b;
		while(total/10 != 0){
			total /= 10;
			count++;
		}
		cout << count << endl;
		count = 1;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> a(N+1);
    a[0] = -2;
    for( int i = 1; i < N+1; ++i ){
        cin >> a[i];
        if( a[i] == 2 ) a[0] = -1;
    }


    int ans = 0, p = 1, b = 1;
    for( int i = 0; i < N+1; ++i ){
        p = a[b];
        b = p;
        ++ans;
        if( b == 2 ){
            cout << ans << endl;
            return 0;
        }
    }


    cout << -1 << endl;


    return 0;
}


Measured memory_bytes: 640
def _main(x1, x2, x3, x4, x5):
    if x1 == 0:
        print(1)
    elif x2 == 0:
        print(2)
    elif x3 == 0:
        print(3)
    elif x4 == 0:
        print(4)
    elif x5 == 0:
        print(5)


_main(*map(int, input().split()))


Measured memory_bytes: 9168
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#define FOR(i,a,n) for (int i = a; i < n; i++)

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const ull num = 1e18;

int main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n; cin >> n;
	bool flag = 0;
	double a = 0;
	ull res = 1;
	FOR(i, 0, n)
	{
		ull b; cin >> b;
		if (!b) flag = 1;
		a += log10(b);
		res *= b;
	}
	if (flag)
	{
		cout << 0;
	}
	else if (a > 18 || res > num) cout << -1;
	else cout << res;
	
	return 0;
}

Measured memory_bytes: 3528
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
#define len length
#define ret0 return 0
#define ret return 

#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)

#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>

// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;

#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)1e5+5

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

    ll n;
    cin>>n;
    ll a[n];
    loop(i,0,n){
        cin>>a[i];
    }
    ll x =0;
    loop(i,0,n) x=x^a[i];
    if(x==0){
        print("Yes");
    }
    else print("No");
        
    
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
    int n;
    cin>>n;
    vector<long long> a;
    map<long long,long long> nums;
    int firstdup;
    int seconddup;
    rep(i,n+1){
        long long tmp;
        cin>>tmp;
        a.push_back(tmp);
        if(nums.count(tmp)){
            firstdup=nums[tmp];
            seconddup=i;
        }else{
            nums[tmp]=i;
        }
    }
    COMinit();

//    cout << firstdup<<":"<<seconddup << endl;
    int x,z;
    x=firstdup;
    z=n-seconddup;
    long long ans=0;
    rep2(i,1,n+2){
        ans=(COM(n+1,i)-COM(x+z,i-1))%MOD;
        if(ans<0){
            ans=ans+MOD;
        }
//        cout << x << ":" << y << ":" << z<<endl;
        cout << ans << endl;
    }

    return 0;
}

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

namespace Atc_0035
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            var Ps = Console.ReadLine().Split(' ').Select(int.Parse).ToList<int>();

            Ps.Sort();

            int a = Ps[(Ps.Count) / 2 - 1];

            int b = Ps[(Ps.Count) / 2];

            Console.WriteLine(b - a);

        }
    }
}


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

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

    sort(a, a + 3);
    if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
using System; using System.Text; using System.Collections.Generic; using System.Linq; using E = System.Linq.Enumerable; class Program { static int[] L; static void Main(string[] args) {
    int N =　int.Parse(Console.ReadLine());
    var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
    var B = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
    var C = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
    
    Array.Sort(A);
    Array.Sort(B);
    Array.Sort(C);
    
    long ans = 0;
    for(long j = 0;j<N;j++){
      ans += LowerBound(A,B[j])*(N-LowerBound(C,B[j]+1));
    }
    Console.WriteLine(ans);
  }
     
     
     public static long LowerBound(long[] a,long v) {
         var l = 0;
         var r = a.Length - 1;
         while (l <= r) {
             var mid = l + (r - l) / 2;
             if (a[mid] < v) l = mid + 1;
             else r = mid - 1;
             }
             return l;
         }
             
     }


Measured memory_bytes: 43756
N = int(input())
data = list(map(int, input().split()))
count = 0

for i in range(N):
    min = i
    for j in range(i, N):
        if data[j] < data[min]:
            min = j
    if min != i:
        data[i], data[min] = data[min], data[i]
        count += 1
            
print("%d" %data[0], end="")
for i in range(1, N):
    print(" %d" %data[i], end="")
print()
print(count)


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

int main(void){
	
	int n;
	cin>>n;
	int num=0;
	for(int i=9;i>0;i--){
		if((n%i)==0){
			num=i;
			if((n/i)<10){
				cout<<"Yes"<<endl;
				break;
			}
          	else{
              num=0;
            }
		}
	}
	if(num==0){
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_B

#include <iostream>
#include <iomanip>

#include <vector>
#include <string>
#include <iterator>
#include <algorithm>

typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

using namespace std;

// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template<class T> void output(std::vector<T> & A) {
    const int n = A.size();
    for (int i = 0; i < n - 1; ++i) {
        std::cout << A[i] << " ";
    }
    std::cout << A[n - 1] << std::endl;
}

const int WHITE = 0;
const int GRAY  = 1;
const int BLACK = 2;
vector<vector<int>> M;
vector<int> colour, d, f;
int tt = 0;

void dfs(int u) {
    // if black exit
    if (colour[u] == BLACK) return;
    
    // if white
    if (colour[u] == WHITE) {
        colour[u] = GRAY;
        d[u] = tt++;
        const int nb = M[u].size();
        rep(i, nb) {
            dfs(M[u][i]);
        }
        // if you are here, all the neigbours are already checked
        f[u] = tt++;
        colour[u] = BLACK;
    }
}

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

    // populate M
    int n; cin >> n;
    M = vector<vector<int>>(n);
    colour = vector<int>(n, 0);
    d = vector<int>(n, -1);
    f = vector<int>(n, -1);

    rep(i, n) {
        int from; cin >> from; --from;
        int m; cin >> m;
        rep(j, m) {
            int to; cin >> to; --to;
            M[from].push_back(to);
            // M[to].push_back(from);
        }
    }

    // dfs
    rep(i, n) {
        if (colour[i] == WHITE) {
            dfs(i);
        }
    }

    rep(i, n) {
        cout << (i + 1) << " " << (d[i] + 1) << " " << (f[i] + 1) << endl;
    }

    return 0;
}



Measured memory_bytes: 3168
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;

int main(void){
	scanf("%d %d %d",&n,&m,&k);
	n=n+m+k;
	if(n>=22)printf("bust\n");
	else printf("win\n");
	
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    string s;
    cin>>s;
    bool flag;
    int length=0;
    for(int i=2;i<s.length();i+=2){
        flag=true;
        int half=(s.length()-i)/2;
        for(int j=0;j<half;j++){
            if(s[j]!=s[j+half]){
              flag=false;
              break;
            }
        }
        if(flag==true){
            length=s.length()-i;
            break;
        }
    }
    cout<<length<<endl;
    return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    int N;
    cin >> N;
    vector<lint> L(N);
    rep(i, N) cin >> L[i];
    sort(L.begin(), L.end());
    dump(L);

    lint cnt = 0;
    for (int i = 0; i < N - 2; i++) {
        for (int j = i + 1; j < N - 1; j++) {
            lint a = L[i], b = L[j];
            lint S = a + b;
            // a <= b
            // a+b>c ng? c<a+b
            // a+c>b ok
            // b+c>a ok
            // [j+1,N)の範囲で S=a+b < L[k] を満たす k の個数を求める

            int idx = lower_bound(L.begin(), L.end(), S) - L.begin();
            // dd(i, j);
            // dd(S, idx);
            cnt += max(0, idx - (j + 1));
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3616
// AGC016_A
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    string S;
    cin >> S;
    
    ll num = 0;
    REP(i, S.length()) {
        if (S[0] == S[i]) num++;
    }
    
    if (num == S.length()) {
        cout << 0 << "\n";
    } else if (S.length() == 1) {
        cout << 0 << "\n";
    } else if (S.length() == 2) {
        if (S[0] == S[1]) {
            cout << 0 << "\n";
        } else {
            cout << 1 << "\n";
        }
    } else if (S.length() == 3) {
        if (S[0] == S[1] && S[0] == S[2]) {
            cout << 0 << "\n";
        } else {
            // 真ん中の文字で左右を変える
            cout << 1 << "\n";
        }
    } else {
        char key;
        string tmp;
        bool flag;
        ll res = 1000, times;
        REP(i, S.length()) {
            key = S[i];
            tmp = S;
            times = 0;
        
            flag = true;
            while (flag) {
                REP(i, tmp.length()-1) {
                    if (tmp[i] == key || tmp[i+1] == key) {
                        tmp[i] = key;
                    }
                }
                tmp.pop_back();  // 1文字消す
            
                ll sum = 0;
                REP(i, tmp.length()) {
                    if (tmp[i] == key) sum++;
                }
            
                times++;
            
                if (sum == tmp.length()) {
                    flag = false;
                }
            }
            res = min(res, times);
        }
        cout << res << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
@list = []
@d = [] #?????????????????????d : v??????????????????????????????
@f = [] #?????????????????????f : v????????????????????????????????????
@time = 0

def d_search(i)
  @time += 1
  @d[i] = @time

  @list[i].sort.each do |j|
    d_search(j-1) unless @d[j-1]
  end

  @time += 1
  @f[i] = @time
end


n = gets.chomp.to_i
n.times do
  u, k, *v = gets.chomp.split.map(&:to_i)
  @list[u-1] = v
end
(0..n-1).each do |i|
  d_search(i) unless @d[i]
end

(0..n-1).each do |i|
  puts "#{i+1} #{@d[i]} #{@f[i]}"
end

Measured memory_bytes: 8764
#include<stdio.h>
 
#define MAX 100000
#define NIL -1
  
struct node {
  int p, l, r, t;
};
struct node T[MAX];
 
void depth(int);
int height(int);
void print(int);
 
int n, H, D[MAX], h[MAX];
  
int main()
{
  int i, d, v, c, l, r;
    
  scanf("%d", &n);
    
  for ( i = 0; i < n; i++ ) {
    T[i].p = NIL;
    T[i].l = NIL;
    T[i].r = NIL;
  }
    
  for ( i = 0; i < n; i++ ) {
    scanf("%d %d %d", &v, &l, &r);
    if(l != NIL) {
      T[l].p = v;
    }
    if(r != NIL) {
      T[r].p = v;
    }
    T[v].l = l;
    T[v].r = r;
  }
  for ( i = 0; i < n; i++ ){
    if(T[i].l != NIL) {
      T[i].t++;
    }
    if(T[i].r != NIL) {
      T[i].t++;
    }
  }
    
  for ( i = 0; i < n; i++ ) {
    if(T[i].p==NIL) {
      D[i] = 0; 
      depth(i); 
      break;
    }
  }
  for ( i = 0; i < n; i++ ) {
    h[i] = height(i); 
  }
  
  for ( i = 0; i < n; i++ ) {
    print(i);
  }
 
  return 0;
}
 
void depth(int u)
{
  int d = 0;
 
  if(T[u].r != NIL) {
    D[T[u].r] = D[u]+1;
    depth(T[u].r);
  }
  if(T[u].l != NIL) { 
    D[T[u].l] = D[u]+1;
    depth(T[u].l);
  }
}
  
int height(int u)
{
  int a = 0, s = 0;
 
  if(T[u].r == NIL && T[u].l == NIL) 
    return 0;
  if(T[u].l != NIL) {
    a = height(T[u].l)+1;
  }
  if(T[u].r != NIL) {
    s = height(T[u].r)+1;
  }
  if(a > s) 
    return a;
  else
    return s;
}
  
void print(int u)
{
  printf("node %d: parent = %d,", u, T[u].p);
  if(T[u].p == NIL)
    printf(" sibling = -1, ");
  else if(T[T[u].p].r == u)
    printf(" sibling = %d, ", T[T[u].p].l);
  else if(T[T[u].p].l == u)
    printf(" sibling = %d, ", T[T[u].p].r);
  printf("degree = %d, ", T[u].t);
  printf("depth = %d, height = %d, ", D[u], h[u]);
 
  if(T[u].p == NIL)
    printf("root\n");
  else if(T[u].t == 0)
    printf("leaf\n");
  else
    printf("internal node\n");
}

Measured memory_bytes: 620
#include <stdio.h>

int main()
{
  int i;
  int n;
  int a[100];

  scanf("%d", &n);

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

  while(n--) {
    printf("%d", a[n]);
    if(n) putchar(' ');
  }
  putchar('\n');
  
  return 0;
}
    



Measured memory_bytes: 2040
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace test
{

    class Program
    {
        static void Main(string[] args)
        {
            List<string> resultList = new List<string>();

            string input;
            while ((input = Console.ReadLine()) != null)
            {
                List<int> numList = new List<int>();
                foreach (char c in input)
                {
                    numList.Add(int.Parse(c.ToString()));
                }

                int sum = 0;
                for (int i = 0; i < 10; i++)
                {
                    sum += GetCombination(9, i) * numList[i];
                }

                resultList.Add(sum.ToString().Substring(sum.ToString().Length - 1));

            }

            foreach (string s in resultList)
            {
                Console.WriteLine(s);
            }


        }

        static int GetCombination(int n, int k)
        {
            int mother = 1;
            int child = 1;
            if (k > n / 2)
            {
                k = n - k;
            }

            for (int i = 1; i <= k; i++)
            {
                child *= (n - i + 1);
                mother *= i;
            }

            return child / mother;
        }
        
    }
}

Measured memory_bytes: 5676
import sys


def floor_sum(n, m, a, b):
    ans = n*(b//m)
    b %= m
    while True:
        ans += (n-1)*n*(a//m)//2
        a %= m
        if a*n+b < m:
            return ans
        y_max = (a*n + b)//m
        b -= y_max*m  # now we have x_max = -(b//a)
        ans += (n + b//a)*y_max
        b %= a
        m, a, n = a, m, y_max


def main():
    t = int(sys.stdin.buffer.readline())
    ans = [0]*t
    for i, x in enumerate(sys.stdin.buffer.readlines()):
        n, m, a, b = map(int, x.split())
        ans[i] = floor_sum(n, m, a, b)
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 79356
while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break
    elif m == -1 or f == -1:
        print('F')
    elif m+f >= 80:
        print('A')
    elif 65 <= m+f < 80:
        print('B')
    elif 50 <= m+f < 65:
        print('C')
    elif 30 <= m+f < 50 and r <50:
        print('D')
    elif 30 <= m+f < 50 and r >= 50:
        print('C')
    elif m+f < 30:
        print('F')


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

const int MAX_N = 1e5 + 10, MOD = 1e9 + 7;

char s[MAX_N];

int cnt[26];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n >> s;
	int64_t ans = 0;
	for (int i = 0; i < n; ++i) {
		int64_t lans = 1;
		for (int j = 0; j < 26; ++j) {
			if (j == s[i] - 'a')
				continue;
			lans *= cnt[j] + 1;
			lans %= MOD;
		}
		ans += lans;
		ans %= MOD;
		++cnt[s[i] - 'a'];
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;

int N, S;
vector<int> A;

const long long MOD = 998244353;
long long DP[3001][3001][3];
long long solve() {
    DP[0][0][0] = 1;
    for (int i = 0; i < N; ++i) {
        for (int k = 0; k <= S; ++k) {
            (DP[i+1][k][0] += DP[i][k][0]) %= MOD;
            (DP[i+1][k][1] += DP[i][k][1] + DP[i][k][0]) %= MOD;
            (DP[i+1][k][2] += DP[i][k][2] + DP[i][k][1] + DP[i][k][0]) %= MOD;
            if (k + A[i] <= S) {
                (DP[i+1][k+A[i]][1] += DP[i][k][1] + DP[i][k][0]) %= MOD;
                (DP[i+1][k+A[i]][2] += DP[i][k][1] + DP[i][k][0]) %= MOD;
            }
        }
    }
    return DP[N][S][2];
}

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

    A.assign(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    cout << solve() << endl;

    return 0;
}

Measured memory_bytes: 211328
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

#define Seg_Max_N (1<<18) 

using Value = pair<int,int>;
const Value ini =make_pair(1e9,1e9);
struct segtree {
	int N;
	vector<Value>dat;

	segtree() {}
	segtree(int n) :dat(2 * Seg_Max_N) {
		N = 1;
		while (N < n) N *= 2;
		for (int i = 0; i < 2 * N - 1; i++) {
			dat[i] = ini;
		}
	}
	Value connect(const Value&l, const Value&r) {
		return min(l,r);
	}
	// update k th element
	void update(int k, Value a) {
		k += N - 1;
		dat[k] = a;

		while (k > 0) {
			k = (k - 1) / 2;
			const Value al(dat[k * 2 + 1]);
			const Value ar(dat[k * 2 + 2]);
			dat[k] = connect(al, ar);
		}
	}
	// min [a, b)
	Value  query(int a, int b) { return query(a, b, 0, 0, N); }
	Value  query(int a, int b, int k, int l, int r) {
		if (r <= a or b <= l) return ini;
		if (a <= l and r <= b) return dat[k];
		const int m = (l + r) / 2;
		const Value al(query(a, b, k * 2 + 1, l, m));
		const Value ar(query(a, b, k * 2 + 2, m, r));
		return connect(al, ar);
	}
};

pair<int,pair<int,int>>ps;

int ansl=-1;
int ansr=-1;
int ansm=-1;

void out(vector<int>&v, map<int, int>next) {
	for (int i = 0; i < v.size(); ++i) {
		cout<<next[v[i]];
		if(i==v.size()-1)cout<<endl;
		else cout<<" ";
	}
}

int main() {
	int T;cin>>T;
	while (T--) {
		int X,Y,W,H;cin>>X>>Y>>W>>H;
		int l(X),r(X+W);
		int u(Y),d(Y+H);
		int ans=0,Q;
		cin>>Q;
		while (Q--) {
			int x,y;cin>>x>>y;
			if (l <= x&&x <= r&&u <= y&&y <= d) {
				ans++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3004
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  
  cout<<max(B+C-A,0)<<endl;
}


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

int main() {
    int n;
    cin >> n;
    int dp[n+1];
    dp[0] = dp[1] = 1;
    for (int i = 2; i <= n; i++) {
        dp[i] = dp[i-1] + dp[i-2];
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define x first
#define y second
#define int int long long // 2e9 & 9e18
using namespace std; const int inf = numeric_limits<int>::max();
struct __io{__io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}} __io; // fast I/O
#ifdef LOCAL // setting up print debugging (yes lol)
template<class K, class V>ostream& operator<<(ostream&s,const pair<K,V>&p){s<<'<'<<p.x<<", "<<p.y<<'>';return s;}
template<class T, class=typename T::value_type, class=typename enable_if<!is_same<T,string>::value>::type>
ostream& operator<<(ostream&s,const T&v){s<<'[';for(auto&x:v){s<<x<<", ";}if(!v.empty()){s<<"\b\b";}s<<']';return s;}
void __prnt(){cerr<<endl;} template<class T, class...Ts>void __prnt(T&&a,Ts&&...etc){cerr<<a<<' ';__prnt(etc...);}
#define print(...) __prnt(__VA_ARGS__)
#else
#define print(...)
#endif

bool ok(vector<int> &a, double x, int k) {
    int k0;
    for (int d : a) {
        k0 = ceil(d / (x )) - 1;
    
        k -= k0;
    }

    return k >= 0;
}

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

    int l = 0;
    int r = 1000000001;
    int m;
    while (l < r - 1) {
        m = l + (r - l) / 2;
        if (ok(a, m, k)) {
            r = m;
        } else {
            l = m;
        }
    }
    cout << r << endl;
}


Measured memory_bytes: 4716
#include<bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main(){
	int K;
	scanf("%d",&K);
	int T;
	scanf("%d",&T);
	int a[T+5];
	for(int i=0;i<=T+4;i++){
		a[i]=0;
	}
	for(int i=1;i<=T;i++){
	scanf("%d",&a[i]);
	}
	
	
	int stop=0;
	int ate=0;
	while(stop==0){
	//でかいやつがeatの中に
	int eat=0;
	for(int i=1;i<=T;i++){
		if(i!=ate&&a[i]>a[eat]){
			eat=i;
		}
	}
	if(eat!=0){
		a[eat]--;
		ate=eat;
	}
	
	if(eat==0){
		stop=1;	
	}
	}
	
	
	int ans=0;
	for(int i=1;i<=T;i++){
	ans+=a[i];
	}
  printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int                     long long   
#define double                  long double
#define endl                    "\n"
#define pb                      push_back
#define PI                      3.1415926535897932384626433832795l
#define F                       first
#define S                       second
#define mp                      make_pair
#define f(i,n)                  for(int i=0;i<n;i++)
#define fastio                  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)                  (v).begin(),(v).end()
#define rall(v)                 (v).rbegin(),(v).rend()
#define gcd(a,b)                __gcd((a),(b))
#define fill(a,value)           memset(a,value,sizeof(a));
#define minn(v)                 *min_element(v.begin(), v.end());
#define maxx(v)                 *max_element(v.begin(), v.end());
#define print(x)                cout<<(x)<<endl;
#define sum(v)+x                accumulate(v.begin(), v.end(),x);
#define debug(x)                cout<<#x<<'='<<(x)<<endl;
typedef pair<int,int>           pii;
typedef vector<int>             vi;
signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    string s,t;
    cin>>s>>t;
    int ans=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]==t[i])ans++;
    }
    print(ans)
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 3636
class Dice(object):
    def __init__(self, nums):
        from collections import deque
        self.ns = deque([nums[4], nums[0], nums[1]])
        self.we = deque([nums[3], nums[0], nums[2]])
        self.bk = deque([nums[5]])

    def __str__(self):
        return str({"ns": self.ns, "we": self.we, "bk": self.bk})

    def operation(self, o):
        if o == "N":
            self.n()
        elif o == "S":
            self.s()
        elif o == "W":
            self.w()
        elif o == "E":
            self.e()
        else:
            raise BaseException("invalid", o)

    def n(self):
        self.ns.append(self.bk.popleft())
        self.bk.append(self.ns.popleft())
        self.we[1] = self.ns[1]

    def s(self):
        self.ns.appendleft(self.bk.pop())
        self.bk.appendleft(self.ns.pop())
        self.we[1] = self.ns[1]

    def w(self):
        self.we.append(self.bk.popleft())
        self.bk.append(self.we.popleft())
        self.ns[1] = self.we[1]

    def e(self):
        self.we.appendleft(self.bk.pop())
        self.bk.appendleft(self.we.pop())
        self.ns[1] = self.we[1]

    def rotate_right(self):
        tmp = self.ns
        tmp.reverse()
        self.ns = self.we
        self.we = tmp

    def fit_top_s(self, top, s):
        if not (top in self.ns or top in self.we or top in self.bk) or not (
                s in self.ns or s in self.we or s in self.bk):
            return False
        while self.get_top() != top:
            if top in self.ns:
                self.n()
            elif top in self.we:
                self.w()
            else:
                self.n()
                self.n()
        count = 0
        while self.get_s() != s and count < 4:
            self.rotate_right()
            count += 1
        if count == 4:
            return False
        else:
            return True

    def get_top(self):
        return self.ns[1]

    def get_s(self):
        return self.ns[2]

    def get_e(self):
        return self.we[2]


def resolve():
    n = int(input())
    chk = {}
    for i in range(n):
        nums = [int(i) for i in input().split()]
        key = "-".join([str(i) for i in sorted(nums)])
        if key in chk.keys():
            chk[key]["nums"].append(nums)
            chk[key]["count"] += 1
        else:
            chk[key] = {}
            chk[key]["nums"] = [nums]
            chk[key]["count"] = 1
    for value in chk.values():
        if value["count"] > 1:
            dc = Dice(value["nums"][0])
            top = dc.get_top()
            s = dc.get_s()
            chks = {str(dc)}
            for num in value["nums"][1:]:
                dc = Dice(num)
                dc.fit_top_s(top, s)
                chks.add(str(dc))
            if len(chks) != value["count"]:
                print("No")
                return
    else:
        print("Yes")


resolve()



Measured memory_bytes: 6036
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, Npow, divisor, modinv, bitSearch, bitList, dfs, bfs//
//dijkstra, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vector<vpll> path; ll P; vl isInf;
//***********//
template<typename T>
struct BellmanFord {
	struct Edge {
		ll from, to; ll cost;
		Edge() {}
		Edge(ll from, ll to, ll cost) :from(from), to(to), cost(cost) {}
	};
	ll n; vll G; vl used, reach;
	BellmanFord(ll n) :n(n), G(n), used(n, 0), reach(n, 0) {}

	vector<Edge> es;
	void add_edge(ll from, ll to, ll cost) {
		es.push_back(Edge(from, to, cost));
		G[from].push_back(to);
	}
	void dfs(ll v) {
		if (used[v]) return;
		used[v] = 1;
		for (ll u : G[v]) dfs(u);
	}
	ll build(ll from, ll to, ll& neg_loop) {
		for (ll i = 0; i < n; i++) {
			fill(used.begin(), used.end(), 0);
			dfs(i);
			reach[i] = used[to];
		}
		vector<ll> ds(n, 1e18);
		ds[from] = 0;
		for (ll i = 0; i < n; i++) {
			bool update = 0;
			for (auto e : es) {
				if (!reach[e.from] || !reach[e.to] || ds[e.from] == 1e18) continue;
				if (ds[e.to] > ds[e.from] + e.cost) {
					ds[e.to] = ds[e.from] + e.cost;
					update = 1;
				}
			}
			if (!update)break;
			if (i == n - 1) {
				neg_loop = 1;
				return INF;
			}
		}
		neg_loop = 0;
		return ds[to];
	}
};
int main() {
	cin >> N >> M >> P;
	BellmanFord<ll> G(N);
	for (i = 0; i < M; i++) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		G.add_edge(a, b, P - c);
	}
	ll negativeLoop;
	ll res = G.build(0, N - 1, negativeLoop);
	if (negativeLoop) cout << -1;
	else cout << max((ll)0, -res);
}


Measured memory_bytes: 768
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int [] a = new int[(int) 1e7 + 1];
        for (int i = 1; i <= (int) 1e7; i++) {
            for (int j = i; j <= (int) 1e7; j += i) {
                a[j]++;
            }
        }
        long ans = 0; int k = sc.nextInt();
        for (int i = 1; i <= k; i++) ans = (long) i * a[i] + ans;
        System.out.println(ans);
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

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

int main() {
  int x, y;
  string ans = "Yes";
  cin >> x >> y;
  
  if (x == 2 || y == 2) ans = "No";
  else if (x==4 || x==6 || x==9 || x == 11){
    if (!(y==4 || y==6 || y==9 || y == 11)) ans = "No";
  }
  else {
    if (y==4 || y==6 || y==9 || y == 11) ans = "No";
  }
  cout << ans << endl;
}



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

vector<int> num;
ll d,a,b, k, c,m,mod=1e9+7;
ll DP[20][2520][2];
int mxlids,cnt;

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

    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

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

    ll mx = a*c;

    mx=max(mx,a*d);
    mx=max(mx,b*d);
    mx=max(mx,b*c);

    cout<<mx;
    return 0;
}

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

int main(){
    int H,W;
    cin >> H>>W;
    string S[H];
    char brank='.';
    char bom='#';
    int count=0;

    for(int i=0;i<H;i++){
        cin>>S[i];
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(S[i][j]=='.'){
                for(int k=-1;k<2;k++){
                    for(int l=-1;l<2;l++){
                        if(S[i+k][j+l]=='#'){
                            count++;
                        }
                    }
                }
                cout<<count;
                count=0;
            }else if(S[i][j]=='#'){
                cout<<bom;
            }
        }
        if(i!=H-1){
            printf("\n");
        }
    }
    return 0;  
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
using namespace std;
int main(void){
   int n,k;
   cin >> n >> k;
   vector<int> a(n);
   for(int i = 0;i < n;i++){
       cin >> a[i];
   }
   int ans = 0;
   for(int i = 0;i < n;i++){
       if(a[i] >= k){
           ans++;
       }
   }
   cout << ans << endl;
   
}


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

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

int n, num[100], mx;

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

    cin >> n;
    rep(i, n) {
        int a;
        cin >> a;
        chmax(mx, a);
        num[a]++;
    }
    bool ok = num[mx / 2 + mx % 2] - 1 == mx % 2;
    FOR(i, mx / 2 + 1, mx + 1) ok = ok && num[i] > 1;
    rep(i, mx / 2 + mx % 2) ok = ok && !num[i];
    cout << (ok ? "Possible" : "Impossible");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(){
  int n;
  cin>>n;
  int num=0;
  string vec;
  rep(i,n){
    cin>>vec[i];
  }
  rep(i,n){
    if(vec[i]=='A' && vec[i+1]=='B' && vec[i+2]=='C')
      num++;
  }
  cout<<num<<endl;
}

Measured memory_bytes: 256
N = int(input())


def dfs(s):
    if int(s) > N:
        return 0
    if s == '0':
        s = ''
    ret = 0
    if all(s.count(c) > 0 for c in '753'):
        ret += 1
    for c in '753':
        ret += dfs(c + s)
    return ret


print(dfs('0'))


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

int main(){
   int n ,temp;
   cin>>n;
   temp = n%10;
   if(temp == 2 ||temp == 4 ||temp == 5 ||temp == 7||temp == 9){
   cout<<"hon";
   }
   else if(temp == 0 ||temp == 1 ||temp == 6 ||temp == 8){
   cout<<"pon";
   }else{
   cout<<"bon";
   }
}

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

int main(){
    string s;
    long long k;
    cin >> s >> k;
    for(long long i = 0;i<k;i++){
        if(s[i]=='1'){
            if(i==k-1){
                cout << 1 << endl;
                return 0;
            }
        }else{
            cout << s[i] << endl;
            return 0;
        }
    }
    return 0;
 
}



Measured memory_bytes: 256