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


using ll = long long int;

using namespace std;


const int MAX_N = 1e6;

vector<char> not_prime(MAX_N + 1); // 1 - not_prime, 0 - prime

void calc_sieve()
{
    not_prime[0] = not_prime[1] = 1;
    for(ll i = 2; i * i <= MAX_N; ++i)
    {
        if (not_prime[i] == 0)
        {
            for(ll j = i * i; j <= MAX_N; j += i)
            {
                not_prime[j] = 1;
            }
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int x, i;
    
    cin >> x;
    
    calc_sieve();
    
    for(i = x; i <= MAX_N; ++i)
    {
        if (not_prime[i] == 0)
        {
            break;
        }
    }
    
    cout << i;
    
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
typedef vector<int,vector<int>> vvec;
typedef long double ld;

//----***Like a Pythonista***----
#define REP(i,j,n) for (ll i=j;i<(n);i++)
#define RREP(i,n,j) for (ll i = n; j<i;i--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
inline ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }

//----***定数***----
const int MOD=1000000007;
#define INF 1e9;
#define EPS 1e-9;

//----***入出力***----
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
#define HERE  cout<<"Here"<<endl;

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

signed main(){
  int N,M,a;cin>>N>>M;
  priority_queue<int> que;
  REP(i,0,N){
    cin>>a;
    que.push(a);
  }
  while(M){
    int v=que.top();que.pop();
    que.push(v/2);
    M--;
  }
  int ans=0;
  while(que.size()){
    ans+=que.top();que.pop();
  }
  print(ans)


}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll x, n, p[100];

int main(int argc, char **argv) {
	cin >> x >> n;
	REP(i, n) cin >> p[i];
	REP(i, 101) {
		bool f = true;
		REP(j, n) f &= (p[j] != x-i);
		if (f) {
			cout << (x-i) << endl;
			return 0;
		}
		f = true;
		REP(j, n) f &= (p[j] != x+i);
		if (f) {
			cout << (x+i) << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3624
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var ps = Console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray();
            var sorted = ps.OrderBy(s => s).ToArray();
            var count = 0;
            for(var i = 0;i<sorted.Length;i++)
            {
                if (sorted[i] != ps[i]) count++;
            }
            Console.WriteLine(count < 3 ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 13396
#include <cassert>
#include <iostream>
#include <vector>

using namespace std;

int longestPathHelper(const vector<vector<int>> &edges, int currentVertex,
                      vector<int> &maxCosts) {
  const auto &edge = edges[currentVertex];
  for (const auto i : edge) {
    if (maxCosts[i] == 0) {
      maxCosts[currentVertex] = max(maxCosts[currentVertex],
                                    1 + longestPathHelper(edges, i, maxCosts));
    } else {
      maxCosts[currentVertex] = max(maxCosts[currentVertex], maxCosts[i] + 1);
    }
  }
  return maxCosts[currentVertex];
}

int main() {
  vector<vector<int>> edges;
  int numVertices, numEdges;
  cin >> numVertices >> numEdges;
  edges.resize(numVertices);
  for (int i = 0; i < numEdges; ++i) {
    int x, y;
    cin >> x >> y;
    assert(x <= edges.size());
    edges[x - 1].push_back(y - 1);
  }
  // cost[i] = max(cost[i], runningCost + 1)
  vector<int> maxCosts;
  maxCosts.resize(numVertices, 0);
  for (size_t i = 0; i < edges.size(); ++i) {
    longestPathHelper(edges, i, maxCosts);
  }
  cout << *max_element(maxCosts.begin(), maxCosts.end()) << endl;
  return 0;
}


Measured memory_bytes: 8832
def listint():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a
a,b,k = listint()
if k < b+a:
    if k < a:
        print(a-k,b)
    else:
        print(0,a+b-k)
else:
    print(0,0)

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

    using namespace std;

    long long cost=1e18;
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int n,m,x;
        cin>>n>>m>>x;
        vector<vector<int>>book(n,vector<int>(m+1));
        for(int i=0;i<n;i++){
            for(int j=0;j<=m;j++)
                cin>>book[i][j];
        }
        for(int i=1;i<(1<<n);i++){
            long long total=0;
            vector<long long>val(m);
            for(int j=0;j<n;j++){
                if(i&(1<<j)){
                    total+=book[j][0];
                    for(int k=0;k<m;k++)
                        val[k]+=book[j][k+1];
                }
            }
            bool flag=1;
            for(int j=0;j<m;j++){
                if(val[j]<x){
                    flag=0;
                    break;
                }
            }
            if(flag)
                cost=min(cost,total);
        }
        if(cost==1e18)
            cout<<-1;
        else
            cout<<cost;
        return 0;
    }


Measured memory_bytes: 3624
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a
 
show_flg=False
show_flg=True
 
ans=0

s=input()
n=len(s)

ans+=1+n*(n-1)//2
p=''
c=1
s=sorted(s)
for i in [1]+s+[0]:
    if p==i:
        c+=1
    else:
        ans-=c*(c-1)//2
        c=1
    p=i    
print(ans)


Measured memory_bytes: 67308
// Author : Hardik Upadhyay
// college: SVNIT 
// slogan : Ab to phod dunga
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i = a ; i >= b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int MAXN = 100005;
ll mod=1000000007;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,k;
	cin>>n>>k;
	map<int,int> freq;
	for(int i = 0; i < k; i++){
		int d;
		cin>>d;
		int a[d];
		rep(i,0,d-1){
			cin>>a[i];
			freq[a[i]]++;
		}
	}
	int cnt=0;
	for(int i =1; i <= n; i++){
		if(freq[i]){
		}
		else{
			cnt++;
		}
	}
	cout<<cnt<<nl;
	return 0;
}



Measured memory_bytes: 3652
import math
input_N = int(input())
i = j = k =1
sum_gcd=0
for i in range(input_N):
    for j in range(input_N):
        for k in range(input_N):
            sum_gcd += math.gcd(math.gcd(i+1,j+1),k+1)
print(sum_gcd)

Measured memory_bytes: 67920
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}

int main(){
  fastIO();
  int n;
  cin>>n;
  map<string,int>rep;
  vector<pair<int,string>>ans;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    rep[s]++;
  }
  for(auto k:rep){
    ans.push_back(make_pair(k.second,k.first));
  }
  sort(ans.begin(),ans.end());
  int x=ans[ans.size()-1].first;
  vector<string>final;
  for(int i=ans.size()-1;i>=0;i--){
    if(ans[i].first==x){
      final.push_back(ans[i].second);
    }
  }
  sort(final.begin(),final.end());
  for(int i=0;i<final.size();i++){
    cout<<final[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 30700
#include <iostream>

using namespace std;

int main()
{
 int array[10001];
 int i = 0;
 while (cin>>array[++i]){}
 i = 0;
 while (array[++i])
 {
  cout << "Case " << i << ": " << array[i] << endl;
 }
 return 0;
}



Measured memory_bytes: 3120
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {

            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();

            if (m == -1 && f == -1 && r == -1)
                break;

            if (m == -1 || f == -1) {
                System.out.println("F");
            }else if(m + f >= 80){
                System.out.println("A");
            }else if(m + f >= 65){
                System.out.println("B");
            }else if(m + f >= 50){
                System.out.println("C");
            }else if(m + f >= 30){
                if(r >= 50){
                    System.out.println("C");
                }else{
                    System.out.println("D");
                }
            }else{
                System.out.println("F");
            }
        }
    }
}


Measured memory_bytes: 26188
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

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

    int x;
    cin >> x;
    int a,b,c,d;
    a = x/1000;
    b = (x-1000*a)/100;
    c = (x-1000*a-100*b)/10;
    d = (x-1000*a-100*b-10*c);

    rep(i,2){
        if(i){
            rep(j,2){
                if(j){
                    rep(l,2){
                        if(l){
                            if(a+b+c+d==7){
                                cout << a<< "+"<<b<<"+"<<c<<"+"<<d<<"="<<7;
                                return 0;
                            }
                        }
                        else{
                            if(a-b+c+d==7){
                                cout << a<< "-"<<b<<"+"<<c<<"+"<<d<<"="<<7;
                                return 0;
                            }
                        }
                    }
                }
                else{
                    rep(l,2){
                        if(l){
                            if(a+b-c+d==7){
                                cout << a<< "+"<<b<<"-"<<c<<"+"<<d<<"="<<7;
                                return 0;
                            }
                        }
                        else{
                            if(a-b-c+d==7){
                                cout << a<< "-"<<b<<"-"<<c<<"+"<<d<<"="<<7;
                                return 0;
                            }
                        }
                    }
                }
            }
        }
        else{
            rep(j,2){
                if(j){
                    rep(l,2){
                        if(l){
                            if(a+b+c-d==7){
                                cout << a<< "+"<<b<<"+"<<c<<"-"<<d<<"="<<7;
                                return 0;
                            }
                        }
                        else{
                            if(a-b+c-d==7){
                                cout << a<< "-"<<b<<"+"<<c<<"-"<<d<<"="<<7;
                                return 0;
                            }
                        }
                    }
                }
                else{
                    rep(l,2){
                        if(l){
                            if(a+b-c-d==7){
                                cout << a<<"+"<<b<<"-"<<c<<"-"<<d<<"="<<7;
                                return 0;
                            }
                        }
                        else{
                            if(a-b-c-d==7){
                                cout << a<< "-"<<b<<"-"<<c<<"-"<<d<<"="<<7;
                                return 0;
                            }
                        }
                    }
                }
            }
        }
    }
    return 0;
}

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

ll n, k;
vector<set<int>> v(100010);
vector<int> c1(100010);
ll ans = 1;
ll mod = 1e9 + 7;

void dfs(int i, int p)
{

    ll l = k - c1[p] - 1;
    ans = ans * l % mod;
    v[i].erase(p);
    v[p].erase(i);
    if (i != 1)
        c1[i]++;
    c1[p]++;
    while (v[i].size())
    {
        ll x = *v[i].begin();

        dfs(x, i);
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    c1[0] = -1;
    cin >> n >> k;
    rep(i, 0, n - 1)
    {
        int a, b;
        cin >> a >> b;
        v[a].insert(b);
        v[b].insert(a);
    }

    dfs(1, 0);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 17024
N = int(input())
dic = {}
for i in range(N):
  s = input()
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1
m = 0
for v in dic.values():
  if v > m:
    m = v
l = []
for k, v in dic.items():
  if v == m:
    l.append(k)
l.sort()
for ans in l:
  print(ans)

Measured memory_bytes: 32092
#include"iostream"
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
#include<list>
#include<map>
#include<string>
#include<algorithm> 
#include <queue> 
#include <sstream>
#include <fstream>
#include<cmath>
#define INF 100000000000
#define LL long long
using namespace std;
map<LL , LL> sm,tm;
vector<double> v;
long long N, M, K, ans, ch, l[8], A, B, C;

LL take(LL ban, LL a, LL b, LL c) {
	if (ban == N) {
		if (a == 0 || b == 0 || c == 0) {
			return INF;
		}
		return abs(A - a) + abs(B - b) + abs(C - c)-30;
	}
	LL d[4];
	d[0] = take(ban + 1, a, b, c);
	d[1] = take(ban + 1, a + l[ban], b, c)+10;
	d[2] = take(ban + 1, a, b + l[ban], c)+10;
	d[3] = take(ban + 1, a, b, c + l[ban])+10;
	ch = INF;
	for (int i = 0; i < 4; i++) {
		ch = min(ch, d[i]);
	}

	return ch;
}


int main() {
	cin >> N>>A>>B>>C;
	for (int i = 0; i < N; i++) {
		cin >> l[i];

	}


	
		cout << take(0,0,0,0) << endl;
	
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
dp = [False] * (K + 1)

for i in range(1, K + 1):
    for a in A:
        if i >= a:
            dp[i] |= dp[i - a] ^ True
print('First' if dp[K] else 'Second')


Measured memory_bytes: 41964
#include<iostream>
#include<string>
#include<math.h>
#include<stdio.h>
#include <algorithm>

using namespace std;

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

    int x[1000] = {0},y[1000] = {0};
    double D1=0,D2=0,D3=0,D=0;

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

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

    for(int i = 0;i<n;i++)
    {
        D1 = D1 + pow(abs(x[i]-y[i]),1);
        D2 = D2 + pow(abs(x[i]-y[i]),2);
        D3 = D3 + pow(abs(x[i]-y[i]),3);

        if(D < abs(x[i] -y[i]))
        {
            D = abs(x[i] -y[i]);
        }
    }

    printf("%.6f\n",D1);
    printf("%.6f\n",pow(D2,(double)1/2));
    printf("%.6f\n",pow(D3,(double)1/3));
    printf("%.6f\n",D);

    return 0;
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> nums(m);
  rep_i(i, m){
    cin >> nums[i];
  }
  if (n >= m){
    say("0");
    return 0;
  }

  // int pre;
  // cin >> pre;
  sort_v(nums);
  
  vector<int> sa(m - 1);
  rep_i(i, m - 1){
    sa[i] = abs(nums[i] - nums[i+1]);
  }

  sort_v(sa);
  rep_i(i, n - 1){
    sa.pop_back();
  }

  int sum = sum_vi(sa);
  cout << sum << endl;
  // say(0);
}

Measured memory_bytes: 1024
def main():
    H, W, M = (int(i) for i in input().split())
    hc = [0]*(H+1)
    wc = [0]*(W+1)
    maps = set()
    for _ in range(M):
        h, w = (int(i) for i in input().split())
        hc[h] += 1
        wc[w] += 1
        maps.add((h, w))
    mah = -1
    maw = -1
    hmaps = set()
    wmaps = set()
    for i, h in enumerate(hc):
        if mah < h:
            mah = h
            hmaps = {i}
        elif mah == h:
            hmaps.add(i)
    for i, w in enumerate(wc):
        if maw < w:
            maw = w
            wmaps = {i}
        elif maw == w:
            wmaps.add(i)
    ans = mah+maw

    for h in hmaps:
        for w in wmaps:
            if (h, w) not in maps:
                print(ans)
                return
    else:
        print(ans-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 216276
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mk make_pair
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pf(a) printf("%d\n",a);
#define pfl(a) printf("%lld\n",a);
#define TEST int test; cin >> test;while(test--)
#define ii pair<int,int>
#define iil pair<ll,ll>
#define loop(i,a,b) for(int i = a ; i < b ; i++)
#define INF 2147483647


int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const double pi = acos(-1.0);


ll n, m, x;

void solve()
{
   cin >> n;
   ll x = n%10;
   if(x == 2 || x == 4 || x == 5 || x == 7 || x == 9) cout << "hon" << endl;
   else if(x == 3) cout << "bon" << endl;
   else cout <<"pon" << endl;
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
    return 0;
}


Measured memory_bytes: 3620
use std::io::*;
use std::str::FromStr;

fn main() {
	let x: f64 = read();
	let mut cnt: u32 = 0;
	let mut money: f64 = 100.0;
	while money < x {
		money = (money*1.01).floor();
		cnt += 1;
	}
	println!("{}", cnt);
}

fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 2692
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let k = line[0];
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let a = line[0];
    let b = line[1];
    let mut ans = false;
    for x in a..b+1 {
        ans |= x % k == 0
    }
    if ans {
        println!("OK");
    } else {

        println!("NG");
    }
}


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

using namespace std;

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < v.size();i++)

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long int;
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))


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


int main(){
	int n,m,a[100];
	cin>>n>>m;
	REP(i,n){
		cin>>a[i];
	}
	REP3(k,1,m+1){
		REP(i,n-1){
			if(a[i]%k>a[i+1]%k){
				swap(a[i],a[i+1]);
			}
		}
	}

	REP(i,n){
		cout<<a[i]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define FOR(i,a,b) for (register int i=(a);i<=(b);i++)
#define pii pair<int,int>
#define MP make_pair
using namespace std;
const int N=1e6+5;
int n,pre[N],nxt[N],s[N],cnt[5];
char str[N];
stack <pii> stck;
inline void del(int pos)
{
	cnt[s[pos]]--;
	int z=pre[pos],y=nxt[pos];
	nxt[z]=y,pre[y]=z;
	return;
}
inline void swap_char(int x,int y,int flag)
{
	if (flag) stck.push(MP(x,y));
	for (register int i=nxt[0];i!=n+1;i=nxt[i])
	{
		if (s[i]==x) s[i]=y;
		else if (s[i]==y) s[i]=x;
	}
	return;
}
inline void Work1()//删除相邻相同 
{
	FOR(i,2,n) if (s[i]==s[pre[i]]) del(i);
	return;
}
inline void Work2()//映射A<=B<=C
{
	if (cnt[2]<=cnt[1]&&cnt[2]<=cnt[3]) swap_char(1,2,1),swap(cnt[1],cnt[2]);
	else if (cnt[3]<=cnt[1]&&cnt[3]<=cnt[2]) swap_char(1,3,1),swap(cnt[1],cnt[3]);
	if (cnt[2]>cnt[3]) swap_char(2,3,1),swap(cnt[2],cnt[3]);
	return;
}
inline void Work3()//无代价删除C 
{
	for (register int i=nxt[0];i!=n+1;i=nxt[i]) if (cnt[3]>cnt[2]) if (s[i]==3&&s[pre[i]]!=s[nxt[i]]) del(i);
	return;
}
inline void Work4()//有代价删除C，即删除AC、CA 
{
	for (register int i=nxt[nxt[0]];i!=n+1;i=nxt[i]) if (cnt[3]>cnt[2])
		if ((s[i]==1&&s[pre[i]]==3)||(s[i]==3&&s[pre[i]]==1)) 
			if (s[pre[pre[i]]]!=s[nxt[i]]) del(i),del(pre[i]);
	return;
}
inline void Work5()//删除BC、CB 
{
	for (register int i=nxt[nxt[0]];i!=n+1;i=nxt[i]) if (cnt[2]>cnt[1])
		if ((s[i]==2&&s[pre[i]]==3)||(s[i]==3&&s[pre[i]]==2)) 
			if (s[pre[pre[i]]]!=s[nxt[i]]) del(i),del(pre[i]);
	return;
}
inline void Work6()
{
	while (stck.size()) swap_char((stck.top()).first,(stck.top()).second,0),stck.pop();
	return;
}
inline void debug()
{
	for (register int i=nxt[0];i!=n+1;i=nxt[i]) printf("%d ",s[i]);
	putchar('\n');
	return;
}
int main()
{
	scanf("%s",str+1);
	n=strlen(str+1);
	FOR(i,1,n) s[i]=str[i]-'A'+1;
	s[0]=4,s[n+1]=5,pre[n+1]=n,nxt[0]=1;
	FOR(i,1,n) pre[i]=i-1,nxt[i]=i+1;
	FOR(i,1,n) cnt[s[i]]++;
	Work1();
//	debug();
	Work2();
//	debug();
	Work3();
//	debug();
	Work4();
//	debug();
	if (cnt[2]==cnt[3])
	{
		Work5();
	//	debug();
		Work6();
	//	debug();
		for (register int i=nxt[0];i!=n+1;i=nxt[i]) putchar(s[i]+'A'-1);
	}
	return 0;
}

Measured memory_bytes: 13952
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    template <bool nl>
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { final(); }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
        template <bool f = nl>
        auto final() -> std::enable_if_t<f> { cout << '\n'; }
        template <bool f = nl>
        auto final() -> std::enable_if_t<!f> {}
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy<true> operator,(T&& val)
    {
        cout << val;
        return {};
    }
    proxy<false> noreturn() { return {}; }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
            }
            cout << x;
            first = false;
        }
    }
};

void prog()
{
    input in;
    output out;

    auto s = in.read<std::string>();
    for (int i : boost::irange(1, 4)) {
        if (s[i] == s[i - 1]) {
            out, "Bad";
            return;
        }
    }
    out, "Good";
}

int main()
{
    prog();
    return 0;
}


Measured memory_bytes: 256
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        x: i32,
        n: usize,
        p: [i32; n]
    }

    let mut res = -1000;
    for i in 0..=100 {
        if !p.contains(&(x - i)) {
            res = x - i;
            break;
        } else if !p.contains(&(x + i)) {
            res = x + i;
            break;
        }
    }

    println!("{}", res);
}


Measured memory_bytes: 2152
use strict;
use warnings;

chomp(my $s = <>);
chomp(my $q = <>);
my $rev = 0;
my $w1, my $w2;

while (my $line = <>){
  chomp($line);
  if ( $line == 1 ) {
    $rev++;
  } else {
    my (undef, $q1, $q2) = split(" ", $line);
    if ( ($rev+$q1)%2==0 ) {
      $w1 = $w1 . $q2;
    } else {
      $w2 = $w2 . $q2;
    }
  }
}

if ($rev % 2 == 1) {
  $s = reverse $s;
  $w1 = reverse $w1;
  $s =$w1 . $s . $w2;
} else {
  $w2 = reverse $w2;
  $s = $w2 . $s . $w1;
}

print "$s\n";


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

int main() {
  string S, T;
  cin >> S >> T;
  T.pop_back();
  if (T == S)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3600
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<LL>>g;
vector<edge>ed;
vector<Pll>pv;
map<string, LL>ma;
set<LL>st;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m,k, p, q, w, h, ans, cnt, dp[2000][2000], sum, a[200000], b[200000];
string str, ss;
bool f;
char c[1100][1100];
int main() {
	cin >> a[0] >> a[1] >> a[2] >> n;
	for (int i = 0; i <= n / a[0]; i++) {
		for (int j = 0; j <= (n - (i*a[0])) / a[1]; j++) {
			if ((n - a[0] * i - a[1] * j) % a[2] == 0)
				ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2304
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int n, a[100009];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	long long l = 2, r = 3;
	for (int i = n - 1; i >= 0; i--) {
		l = (l + a[i] - 1) / a[i] * a[i];
		r = (r - 1) / a[i] * a[i] + a[i];
	}
	if (l >= r) cout << -1 << endl;
	else cout << l << ' ' << r - 1 << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

int n, m, q;
vector<int> a, b, c, d;

ll ans;

void dfs(vector<int> &v){

	int l = v.size();
	if(l == n){
		ll t = 0;
		rep(i, q){
			if(v[b[i]] - v[a[i]] == c[i]) t += d[i];
		}

		ans = max(ans, t);
		return;
	}

	for(int i = 1; i <= m; i++){
		if(l > 0 && i < v[l-1]) continue;
		v.push_back(i);
		dfs(v);
		v.pop_back();
	}
}

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

	cin >> n >> m >> q;

	a.resize(q);
	b.resize(q);
	c.resize(q);
	d.resize(q);

	rep(i, q){
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--;
		b[i]--;
	}

	ans = 0;
	vector<int> v;
	dfs(v);

	cout << ans << endl;
}


Measured memory_bytes: 3596
n,d=map(int,input().split())
a=[]
for _ in range(n):
  w=list(map(int,input().split()))
  a.append(w)
  
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    c=0
    for f in range(d):
      c+=(a[i][f]-a[j][f])**2
      
    for r in range(0,151):
      if c==r**2:
        ans+=1
        
print(ans)

Measured memory_bytes: 9196
X, Y, A, B, C = [int(x) for x in input().split()]
p_l = sorted([int(x) for x in input().split()], reverse=True)
q_l = sorted([int(x) for x in input().split()], reverse=True)
r_l = sorted([int(x) for x in input().split()], reverse=True)
L = p_l[:X] + q_l[:Y]
L = sorted(L)
for i in range(min(X+Y, C)):
  if L[i] < r_l[i]:
    L[i] = r_l[i]
  else:
    break
print(sum(L))

Measured memory_bytes: 22720
def lcm(a,b):
  return a//gcd(a,b)*b
def gcd(a,b):
  while b != 0:
    r=a%b
    a=b
    b=r
  return a
while True:
  try:
    a=list(map(int,input().split()))
    print(gcd(a[0],a[1]),lcm(a[0],a[1]))
  except EOFError:
    break


Measured memory_bytes: 5600
// https://atcoder.jp/contests/abc048/tasks/abc048_b
// Difficulty:806
// 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    ll a,b,x;
    cin >> a >> b >> x;
    ll Cs = (a-1)/x + 1;
    if(a==0) Cs = 0;
    ll Ce = b/x + 1;
    if(b==0) Ce = 1;
    cout << Ce -Cs << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define MOD 1000000007
#define vec(a) vector<int>a
using namespace std;


int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
		ll  n,i,j,k;
		cin>>n;
		string str,s1,s2;
		cin>>str;
		s1="";
		for(i=0;i<n/2;i++)
		{
			s1+=str[i];
		}
		s2="";
		for(j=i;j<n;j++)
			s2+=str[j];
		if(s1==s2)
			cout<<"Yes\n";
		else
			cout<<"No\n";
		return 0;
}
	

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
ll read(){ll a;scanf("%lld",&a);return a;}

const int inf = TEN(9) + 10;
const int mod = TEN(9) + 10;

int dp[2010][2010];

int N;
pii A[2010];

signed main()
{
	cin >> N;

	rep(i, N) {
		cin >> A[i].fst;
		A[i].scd = i;
	}

	sort(A, A + N, greater<pii>());

	rep(i, N) {
		int cur = i;
		rep(j, cur + 1) {
			int l = cur - j, r = j;

			chmax(dp[l + 1][r], dp[l][r] + A[cur].fst * abs(l - A[cur].scd));
			chmax(dp[l][r + 1], dp[l][r] + A[cur].fst * abs(N - 1 - r - A[cur].scd));
		}
	}

	int mx = 0;

	rep(i, N + 1) {
		chmax(mx, dp[i][N - i]);
	}

	cout << mx << endl;
}




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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vvvi> vvvvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<vvvll> vvvvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<pair<ll,ll> > > vvpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define PI 3.141592653589793
#define MOD 1000000007

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

vvll g;
int main()
{
	IOS;
	ll n;
	cin>>n;
	vvc v(2,vc(n));
	for(ll i=0;i<2;i++)
	{
		for(ll j=0;j<n;j++)
		{
			cin>>v[i][j];
		}
	}
	/*g=vvll(53);
	vvll v2(2,vll(n));
	map<char,ll> m;
	for(ll i=1;i<=26;i++)
	{
		char ch='A'+i-1;
		m[ch]=i;
	}
	for(ll i=1;i<=26;i++)
	{
		char ch='a'+i-1;
		m[ch]=i+26;
	}
	for(ll i=0;i<2;i++)
	{
		for(ll j=0;j<n-1;j++)
		{
			if(v2[i][j]!=v2[i][j+1])
			{
				ll a=v2[i][j];
				ll b=v2[i][j+1];
				g[a].pb(b);
				g[b].pb(a);
			}
		}
	}
	for(ll i=0;i<n;i++)
	{
		if(v2[0][i]!=v2[1][i])
		{
			ll a=v2[0][i];
			ll b=v2[1][i];
			g[a].pb(b);
			g[b].pb(a);
		}
	}*/
	ll ctstraight=0;
	ll ctvert=0;
	vll st;
	vll st2;
	for(ll i=0;i<n;i++)
	{
		if(v[0][i]==v[1][i])
		{
			ctvert++;
			st.pb(i);
		}
		else
		{
			st2.pb(i);
			i++;
		}
	}
	ctstraight=(n-ctvert)/2;
	ll ans=1;
	if(st.size()>0)
	{
		if(st[0]==0)
		{
			ans*=3;
			ans%=MOD;
		}
		for(ll i=1;i<st.size();i++)
		{
			if(st[i]-st[i-1] == 1)
			{
				ans*=2;
				ans%=MOD;
			}
		}
	}
	if(st2.size()>0)
	{
		if(st2[0]==0)
		{
			ans*=6;
			ans%=MOD;
		}
		else
		{
			ans*=2;
			ans%=MOD;
		}
		for(ll i=1;i<st2.size();i++)
		{
			if(st2[i]-st2[i-1]==2)
			{
				ans*=3;
				ans%=MOD;
			}
			else
			{
				ans*=2;
				ans%=MOD;
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
w,h,n=map(int,input().split())
S=w*h
bigx,smax,bigy,smay=0,w,0,h
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        bigx=max(x,bigx)
    elif a==2:
        smax=min(x,smax)
    elif a==3:
        bigy=max(y,bigy)
    else:
        smay=min(y,smay)
if bigx>=smax or bigy>=smay:
    print(0)
else:
    print((smax-bigx)*(smay-bigy))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

using namespace std;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}
 
const int mod = (int)1e9 + 7;
 
vector <int> g[2002];
int cnt[2002], n, k;
bool used[2002];

void dfs(int c, int v, int lvl = 0)
{
	used[v] = 1;
	if(lvl > k / 2) cnt[c]++;
	for(auto to : g[v]) if(!used[to]) dfs(c, to, lvl + 1);
}

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();
	cin >> n >> k;
	for(int i = 1; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		g[a].pb(b);
		g[b].pb(a);
	}
	if(!(k & 1))
	{
		for(int i = 1; i <= n; i++)
		{
			memset(used, 0, sizeof used);
			dfs(i, i);
		}
		cout << *min_element(cnt + 1, cnt + n + 1);
	}
	else
	{
		int ans = mod;
		for(int i = 1; i <= n; i++)
		{
			for(auto to : g[i])
			{
				memset(used, 0, sizeof used);
				memset(cnt, 0, sizeof cnt);
				used[to] = 1;
				dfs(i, i);
				memset(used, 0, sizeof used);
				used[i] = 1;
				dfs(to, to);
				ans = min(ans, cnt[to] + cnt[i]);
			}
		}
		cout << ans;
	}
}


Measured memory_bytes: 512
//सत्यान्न प्रमदितव्यम्  ||
//Still, Taking my time to perfect the beats
//And I still got love for the streets, it's the A-D-D-U
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define nt _int128
#define fir first
#define sec second
#define fast_as_levi ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define debug(x) cout<<x<<"\n";
#define debugged cout<<"debugged\n";
#define inf 0x3f3f3f3f
#define LINF  0x3f3f3f3f3f3f3f3fll
#define rall(v) v.rbegin(),v.rend()
#define all(v) v.begin(),v.end() 
 
const ll mod = 999983;
#define mx 1000005
const ll mxi = 105;

using namespace __gnu_pbds;
#define ordered_set tree<pair<ll, ll>, null_type,less<pair<ll, ll>>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    fast_as_levi;
    ld x,y;
    cin>>x>>y;
    cout<<(ll)(x*y);
}

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

int main() {
  int n,m; cin >> n >> m;
  vector<pair<ll,ll>> vec(n+m);
  rep(i,n){
    cin >> vec[i].first;
    vec[i].second = 1;
  }
  for(int i = n; i < n+m; i++){
    cin >> vec[i].second >> vec[i].first;
  }



  sort(vec.begin() , vec.end());
  reverse(vec.begin() , vec.end());

  /*rep(i,n+m){
    cout << vec[i].first <<" "<< vec[i].second << endl;
  }*/

  int count = 0;
  bool b = false;
  ll ans = 0;
  while(count <= n){
    rep(i,n+m){
      rep(j,vec[i].second){
        ans += vec[i].first;
        count++;
        if(count == n){
          b = true;
          break;
        }
      }
      if(b){
        break;
      }
    }
    if(b){
      break;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3328
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>
#include <complex>
#include <queue>
#include <stack>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
  int n,m;
  cin>>n>>m;
  int a[100010]={};
  rep(_,m){
    int l,r;
    cin>>l>>r;
    a[l]++,a[r+1]--;
  }
  rep(i,n){
    a[i+1]+=a[i];
  }
  int ans=0;
  rep(i,n+1){
    ans+=a[i]==m;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1280
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>

//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;



vector<ll> getdiv(int k) {
	vector<ll> res;
	for (int i = 1; i * i <= k; i++) {
		if (k % i == 0) {
			res.push_back(i);
			res.push_back(k / i);
			if (i == k / i)res.pop_back();
		}
	}
	sort(res.begin(), res.end());
	return res;
}


int main()
{
	

	string s;
	int q;
	int t;
	int f;
	char c;
	char b[200000], e[200000];
	int i = 0, j = 0;
	cin >> s>>q;
	
	bool rev = false;
	while (q--) {
		
		cin >> t;
		if (t == 1) {
			rev = !rev;
		}
		else {
			
			cin >> f >> c;
			if (!(f == 1 && !rev || f == 2 && rev)) {
				e[j] = c;
				j++;
			}
			else {
				b[i] = c;
				i++;
			}
		}
	}
	if (!rev) {

		for (int it = i-1; it >= 0; it--) {
			cout << b[it];
		}
		cout << s;
		for (int it = 0; it < j; it++) {
			cout << e[it];
		}
	}
	else {
		for (int it = j-1; it >= 0; it--) {
			cout << e[it];
		}
		for (int it = s.length()-1; it >= 0; it--) {
			cout << s[it];
		}
		
		for (int it = 0; it < i; it++) {
			cout << b[it];
		}
	}



}

Measured memory_bytes: 1024