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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

lli gcd(lli a, lli b)
{
    if (a < b) swap(a,b);
    return b ? gcd(b, a % b) : a;
}

signed main(){

	lli n;
	cin>>n;
	vector<lli> a(n);
	REP(i,0,n)cin>>a[i];
	vector<lli> l(n+1),r(n+1);
	l[0]=0;
	r[n]=0;

	REP(i,0,n)l[i+1] = gcd(l[i],a[i]);
	for(lli i=n;i>0;i--)r[i-1] = gcd(r[i],a[i-1]);

	lli ans = 1;
	for(lli i=0;i<n;i++){
		ans = max(gcd(l[i],r[i+1]),ans);
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 2560
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let N = lines[0] - 0;
    let Hs = lines[1].split(/\s/).map((v) => v - 0);

    let dp = new Array(N).fill(Number.MAX_SAFE_INTEGER);
    dp[0] = 0;
    for (let n = 1; n < N; n++) {
        dp[n] = Math.min(dp[n], dp[n-1] + Math.abs(Hs[n - 1] - Hs[n]));
        if (n > 1)
        dp[n] = Math.min(dp[n], dp[n-2] + Math.abs(Hs[n - 2] - Hs[n]));
    }

    console.log(dp[N-1]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 25420
#include <bits/stdc++.h>
using namespace std;
const int N = 15;
int n, m, now, d[N];
string itos (int x) {
	string ret = "";
	while (x) {
		ret = char (x % 10 + '0') + ret;
		x /= 10;
	}
	return ret;
}
int main () {
	cin >> n >> m;
	for (int i = 1; i <= m; i ++)
		cin >> d[i];
	now = n;
	while (1) {
		string s = itos (now);
		bool ok = true;
		for (int i = 0; (i < s.size ()) && ok; i ++)
			for (int j = 1; (j <= m) && ok; j ++)
				if (s[i] == char (d[j] + '0'))
					ok = false;
		if (ok) {
			cout << now << endl;
			return 0;
		}
		now ++;
	}
	return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define watch(x); cout<<#x<<"="<<x<<endl;
#define watch2(x,y); cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define endl "\n"
#define int long long
using namespace std;    

long long inverseMod(long long x,long long mod);
long long nCr(long long n,long long r,long long mod){
    //when r is lesser and is greater
    long long res=1;
    if(r>n-r)r=n-r;
    long long div=1;
    for(long long  i=0;i<r;i++){
        res=(res*(n-i))%mod;
    }

    for(long long i=1;i<=r;i++){
        div=(div*i)%mod;
    }
    return (res*inverseMod(div,mod))%mod;
}


long long power(long long x,long long n,long long mod){
//(x^n)%mod
long long result=1;

    while(n){
        if(n%2)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return result;
}

long long inverseMod(long long x,long long mod){

return power(x,mod-2,mod);
}



int32_t main(){

    fast
    int n,k;
    cin>>n>>k;
    set<int>s;
    int temp;
    for(int i=0;i<k;i++){
        int nos;
        cin>>nos;
        for(int i=0;i<nos;i++){
            cin>>temp;
            s.insert(temp);
        }
    }
    cout<<(n-s.size());



    return 0;
}



Measured memory_bytes: 3672
#include<bits/stdc++.h>
#include <unistd.h>
#define lg long long int
#define loop(i,s,e) for(lg i=s;i<=e;i++)
#define iloop(i,s,e) for(lg i=e;i>=s;i--)
#define pb push_back
#define mp make_pair
using namespace std;

lg min(lg a,lg b)
{return a<b?a:b;}
lg max(lg a,lg b)
{return a>b?a:b;}
lg lcm(lg a ,lg b)
{
    return (a*b)/__gcd(a,b);
}
int main()
{
    lg n,x,m;
    cin>>n>>x>>m;
    lg now=x;
    lg ans=x;
    lg in=0;
    bool p = false;
    vector<vector<lg>>past(max(x,m)+1,vector<lg>(2,-1));
    past[x][0] = 0;
    past[x][1] = 0;
    for(lg i=1;i<n;i++)
    {
       now = (now*now)%m;
       if(now == 0)
       {
           break;
       }
       
       if(past[now][0]!=-1)
       {
           lg len = i-past[now][0];
           lg nums = (n-i)/len;
           ans+=nums*(ans-past[now][1]);
           i+=nums*len;
           in=i;
           p=true;
           break;
       }
       else
       {
            past[now][0] = i;
            past[now][1] = ans;
       }
       ans+=now;
    }
    if(p && in<n)
    {
        ans+=now;
        for(lg i=in+1;i<n;i++)
        {
           now = (now*now)%m;
           ans+=now;
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 8804
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int sum = 0, a = 0;
  for (int i = 0; i < N; i++) {
    cin >> a;
    sum += a - 1;
  }
  cout << sum << endl;
  return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)

struct llm{
    ll value=0;
    llm(const ll& val=0){
        this->value = (MOD + val % MOD) % MOD;
    }
    llm(const llm& a) { llm(a.value); }
    llm inv(){
        ll a = 1;
        ll b = this->value;
        for(ll m=MOD-2;m>0;m/=2){
            if(m&1){
                a=a*b%MOD;
            }
            b=b*b%MOD;
        }
        return llm(a);
    }
    llm &operator+=(const llm &a) {
        this->value = (this->value + a.value) % MOD;
        return *this;
    }
    llm &operator-=(const llm &a) {
        this->value = (this->value - a.value + MOD) % MOD;
        return *this;
    }
    llm &operator*=(const llm &a) {
        this->value = (this->value * a.value) % MOD;
        return *this;
    }

    explicit operator ll() const{return (ll)value;}
    explicit operator int() const{return (int)value;}
};
llm operator+(const llm &a, const llm &b) { return llm(a.value + b.value); }
llm operator-(const llm &a, const llm &b) { return llm(a.value - b.value); }
llm operator*(const llm &a, const llm &b) { return llm(a.value * b.value); }

ll N,M;
ll i, j, k;
llm Fa[202020];
vector<ll> pr;
int main(){
    scanf("%lld%lld", &N, &M);
    Fa[0] = 1;
    fornum(i,0,200000){
        Fa[i + 1] = Fa[i] * llm(i + 1);
    }
    fornum(i,2,101010){
        if(M%i>0)
            continue;
        j = 0;
        while(M%i==0){
            M /= i;
            ++j;
        }
        pr.push_back(j);
    }
    if(M>1){
        pr.push_back(1);
    } 
    llm ans = 1;
    fornum(i,0,pr.size()){
        ans *= Fa[N - 1 + pr[i]] * Fa[N - 1].inv() * Fa[pr[i]].inv();
    }
    printf("%lld", (ll)ans);

    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <iostream>
#include <fstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <iterator>
#include <iomanip>
#include <unordered_map>

using namespace std;

#define ll long long int



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, m, total = 0, ans=0;
    cin>>n>>m;
    int a[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
        total+=a[i];
    }
    for (int i = 0; i < n; ++i)
    {
        if(a[i]>= total/(4.0*m)) ans++; 
    }
    if(ans>=m) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define swap(type ,a ,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(i=0;i<n;i++)
#define forR(i,s,n) for(i=s;i<n;i++)
#define ll long long
#define pb(t,d,n) {t p;int i;forN(i,n){cin>>p;d.push_back(p);}}

using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

bool cmp(pii &a, pii &b){
    return a.first < b.first;
}

int main(){
    int hmax,i,n,tmp,res;
    vi h;
    cin >> n;
    pb(int, h, n);
    hmax = 0;
    res = 0;
    forN(i,n){
        if(hmax <= h[i]){
            res++;
            hmax = h[i];
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 888
#include<stdio.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i = 0;i < n;i++)
#define PRN(n) printf("%d\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(s) printf("%c",s)
int main(void){
  int r,d,x[11];
  scanf("%d %d %d",&r,&d,&x[0]);
  FOR(10){
    x[i+1]=r*x[i]-d;
    PRN(x[i+1]);
  }
  return 0;
}
/*
scanf("%d",&n);
scanf("%d %d",&a,&b);
*/

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
#define dbg(x) cerr << #x"= " << x << endl

std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

vector<int> primes;
void erat(unsigned int limit) {
    vector<bool> prime(limit + 1, true);
    const unsigned int n = sqrt(limit);
    unsigned int i, j;
    primes.push_back(2);
    for(i = 3; i <= n; i += 2) {
        if(prime[i]) {for(j = i * i; j <= limit; j += 2*i) prime[j] = false;}
    }
    for(i = 3; i <= limit; i += 2) {if(prime[i]) primes.push_back(i);}
}

void fact(int n,map<ll,int> &ret) { //O (cant primos)
    int idx=0;
    int p=primes[0];
    while (p*p<=n) {
        while(!(n % p)) {
            ++ret[p];//divisor found
            n /= p;
        }
        p = primes[++idx];
    }
    if(n > 1) ++ret[n];
}

void merge(map<ll,int> &source,const map<ll,int> &otro){
    auto it=source.begin();
    auto it2=otro.begin();
    while(it!=source.end() && it2!=otro.end()){
        if (it->first<it2->first) ++it;
        else if (it2->first<it->first){
            source.insert(it,*it2);
            ++it2;
        }else{
            it->second = max(it->second,it2->second);
            ++it; ++it2;
        }
    }
    while(it2!=otro.end()){
        source.insert(*it2);
        ++it2;
    }
}

void add(ui &x, ll y){
    x += y;
    if (x>=MOD) x-=MOD;
}

ui getb(ll b,const map<ll,int> &a){
    ll div=1;
    for(const auto p:a){
        div = div * powmod(p.first,p.second,MOD)%MOD;
    }
    return b * powmod(div,MOD-2,MOD)%MOD;
}

int main() {
    READ(0);
    erat(2000);
    int n;cin>>n;
    vi a(n);
    vector<map<ll,int> > f(n);
    FOR(i,n) {cin>>a[i]; fact(a[i],f[i]);}
    map<ll,int> lcm=f[0];
    for(int i=1;i<n;++i){
        merge(lcm,f[i]);
    }
    ll b=1;
    for(auto p:lcm) b = b*powmod(p.first,p.second,MOD)%MOD;

    ui ret=0;
    for(int i=0;i<n;++i){
        add(ret,getb(b,f[i]));
    }
    cout << ret;
    return 0;
}



Measured memory_bytes: 3840
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;

int main()
{
	char a, b;
	cin >> a >> b;
	int A = (a == 'H' ? 1 : -1);
	int B = (b == 'H' ? 1 : -1);
	char ans;
	if (A * B > 0)ans = 'H';
	else ans = 'D';
	co(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main(){
  int A = 0,B = 0,C = 0;
  cin >> A >> B >> C;
  if(A == B && A != C){
    cout << "Yes";
    return 0;
  }
  if(A == C && A != B){
    cout << "Yes";
    return 0;
  }
  if(C == B && A != B){
    cout << "Yes";
    return 0;
  }
  cout << "No";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main() {
 int a[200],b[200],k=0,i,d;
 while(k<200 && scanf("%d%d",&a[k],&b[k])!=EOF) k++;
 for (i=0;i<k;i++) {
	 d=log10((double)(a[i]+b[i]));
	 printf("%d\n",d+1);
 }
 return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 string s,t ;
 cin >>s>>t ;
 int a,b ;
 cin >>a>>b ;
 string u ;
 cin >> u ;
 if(s==u) 
 cout <<a-1<<" "<<b<<endl;
 else
  cout <<a<<" "<<b-1<<endl ; 
    return 0;
}






Measured memory_bytes: 256
#include<stdio.h>
int main (void)
{
  int h,w,i,j;
  while(1){
    scanf("%d%d",&h,&w);
    if(h==0&&w==0)break;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(i==0||i==(h-1)||j==0||j==(w-1)){
          printf("#");
	}else{
          printf(".");
	}
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

// const abcd = "abcdefghijklnmopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

// var dy = [...]int{1, 1, 0, -1, -1, -1, 0, 1}
// var dx = [...]int{0, 1, 1, 1, 0, -1, -1, -1}

// var dx = [...]int{0, 1, 0, -1}
// var dy = [...]int{1, 0, -1, 0}

// var inf int = 1e9
// var mod = 1000000007

// ---------------------------------------------------------
func main() {
	log.SetFlags(log.Lshortfile)
	next := newScanner()
	h := next.Int()
	w := next.Int()
	n := next.Int()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = next.Int()
	}
	mark := make([]int, h*w)
	k := 0
	for i, n := range a {
		i++
		for j := 0; j < n; j++ {
			// log.Println(k, h, w)
			mark[k] = i
			k++
		}
	}
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			j1 := j
			if i%2 != 0 {
				j1 = w - j - 1
			}
			fmt.Print(mark[i*w+j1])
			if j != w-1 {
				fmt.Print(" ")
			}
		}
		fmt.Println("")
	}

}

// ---------------------------------------------------------

// Pair is liked C++ pair
type Pair struct {
	a, b int
}

// Pairs is sorted by []Pair struct
type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a < p[j].a {
		return true
	} else if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return false
}

// -------------------------------
func in(c, a, z int) bool {
	return c >= a && c < z
}

func btoi(b bool) int {
	if b {
		return 1
	}
	return 0
}

func itob(a int) bool {
	if a == 0 {
		return false
	}
	return true
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ---------- buffered scanner -----------------------------------------
type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) Line() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) Int() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) Int64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

typedef long long ll;
int N;
vector<int> H, A;
vector<ll> bit;

void input_init(void) {
	cin >> N;
	H.resize(N + 1);
	A.resize(N + 1);
	for (int i = 1; i <= N; ++i)
		cin >> H[i];
	for (int i = 1; i <= N; ++i)
		cin >> A[i];
	bit.resize(N + 1, (ll)0);
}

void add(int i, ll x) {
	while (i <= N) {
		bit[i] = max(bit[i], x);
		i += i & -i;
	}
}

ll query(int i) {
	ll s = (ll)0;
	while (i > 0) {
		s = max(s, bit[i]);
		i -= i & -i;
	}
	return s;
}

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

	input_init();
	for (int i = 1; i <= N; ++i) {
		ll tmp = query(H[i]) + (ll)A[i];
		add(H[i], tmp);
	}

	ll ans = query(N);
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  cin >> n >> m;
  if(n == 0){
    n = 1;
  }
  int sc[m][2];
  for(int i = 0; i < m; i++){
    cin >> sc[i][0] >> sc[i][1];
  }
  for(int i = 0; i < 1000; i++){
    int dig = 1;
    int x = i / 10;
    vector<int> a(1,i % 10);
    while(x){   
      dig++;
      a.push_back(x % 10);
      x /= 10;
    }
    reverse(a.begin(), a.end());
    if(n != dig){
      continue;
    }
    bool flg = true;
    for(int j = 0; j < m; j++){
      if(a[sc[j][0]-1] != sc[j][1]){
        flg = false;
      }
    }
    if(flg){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//const int inf=1e9;
struct activity
{
    int A,B,C;
};
int solve(vector<activity>arr,int n)
{
    int dp[n+1][3];
    dp[1][0]=arr[1].A;
    dp[1][1]=arr[1].B;
    dp[1][2]=arr[1].C;
    for(int i=2;i<=n;++i)
    {
        dp[i][0]=arr[i].A+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=arr[i].B+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=arr[i].C+max(dp[i-1][0],dp[i-1][1]);

    }
    return max(dp[n][0],max(dp[n][1],dp[n][2]));

}

int main()
{
    int n;
    cin>>n;
    vector<activity>arr(n+1);
    for(int i=1;i<=n;++i)
    {
        cin>>arr[i].A;
        cin>>arr[i].B;
        cin>>arr[i].C;
    }
    cout<<solve(arr,n)<<endl;
}


Measured memory_bytes: 6692
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}
vector<uint32_t> Num(100000);

int main() {
  uint64_t M1, D1, M2, D2;
  cin >> M1 >> D1 >> M2 >> D2;
  if (M1 != M2) {
    cout << 1 << endl;

  } else {
    cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 640
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]

for i in range(1000):
  t = str(i)
  if len(t) != n: continue
  judge = True
  for s, c in sc:
    if t[s-1] != str(c):
      judge = False
  if judge:
    print(t)
    exit(0)
print(-1)

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

import sys

def parse_input(lines_as_string = None):

    lines = []
    if lines_as_string is None:
        for line in sys.stdin:
            lines.append(line)
    else:
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    params = lines[0].split(" ")
    a = int(params[0])
    b = int(params[1])

    return (a, b)


def solve(a, b):

    result = 0
    if b % a == 0:
        result = a + b
    else:
        result = b - a

    return result

def main():
    # 出力

    a, b = parse_input()
    print("%d" % solve(a, b))

if __name__ == '__main__':

    main()


Measured memory_bytes: 3064
#include<stdio.h>

int main(){
  int N;
  int c=0;
  
  scanf("%d",&N);
  for(int i=0;i<3;i++){
    if(N%10==7){
      c=1;
      break;
    }
    N/=10;
  }
  
  if(c==0)
    printf("No\n");
  else
    printf("Yes\n");
  
  return 0;
}

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

using namespace std;

int f(int n, vector<pair<int, int>> queries) {

//    int max = 0;
//    for (int i = 0; i < queries.size(); i++) {
//        if (max < queries[i].second) {
//            max = queries[i].second;
//        }
//    }

//    vector<int> arr(max + 1);

//    for (int i = 0; i < queries.size(); i++) {
//        for (int j = queries[i].first; j <= queries[i].second; j++) {
//            arr[j]++;
//        }
//    }

//    int count = 0;
//    for (int i = 0; i < arr.size(); i++) {
//        if (arr[i] == queries.size()) {
//            count++;
//        }
//    }

//    return count;

    int min = INT_MIN;
    int max = INT_MAX;
    for (int i = 0; i < queries.size(); i++) {
        if (min < queries[i].first) {
            min = queries[i].first;
        }
        if (max > queries[i].second) {
            max = queries[i].second;
        }
    }

    if (max - min < 0) {
        return 0;
    }

    return max - min + 1;
}

int main() {

    int n, m;
    cin >> n >> m;

    vector<pair<int, int>> queries;
    for (int i = 0; i < m; i++) {
        pair<int, int> p;
        cin >> p.first;
        cin >> p.second;
        queries.push_back(p);
    }

    int result = f(n, queries);
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 1908
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int i,n;
  long long int sum = 0;
  cin >> n;
  for (i=1;i<=n;i++){
  	if (i%3!=0 && i%5!=0){
    	sum += i;
    }
  }
  cout << sum << endl;
  return 0;
}

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

using ll = long long;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

struct data{
	string na;
	int p;
	int e;
};
bool operator<(const data &data1,const data &data2){
	if(data1.na == data2.na){
		return data1.p < data2.p;
	}
	else{
		return data1.na > data2.na;
	}
};

int main(){
	int n;
	cin >> n;
	data a;
	priority_queue<data> q;
	for(int i = 0; i < n; i++){
		cin >> a.na >> a.p;
		a.e = i;
		q.push(a);
	}
	data c[n];
	for(int i = 0; i < n; i++){
		c[i] = q.top();
		q.pop();
	}
	for(int i = 0; i < n; i++){
		cout << c[i].e + 1 << endl;
	}
	return 0; 
}

Measured memory_bytes: 256
declare var require: (x: string) => any;

let p: number[] = [], c: number[] = [];
let ans = 123456789;

function dfs(dep: number, goal: number, current: number, cand: number) {
  if (dep == -1) {
    let idx = p.length - 1;
    let tmp_p = p.slice();
    while(current < goal) {
      if(tmp_p[idx] > 0){
        tmp_p[idx]--;
        cand++;
        current += (idx+1);
        if (tmp_p[idx]==0){
          current += c[idx];
        }
      }
      if(tmp_p[idx] == 0) {
        idx--;
      }
    }
    ans = Math.min(ans, cand);
    return;
  }

  dfs(dep-1, goal, current, cand);
  const old_p = p[dep];
  p[dep] = 0;
  dfs(dep-1, goal, current + (old_p)*(dep+1) + c[dep], cand + old_p);
  p[dep] = old_p;
}

function Main(input: string[]) {
  const [d, g] = input[0].split(' ').map(x => parseInt(x, 10));

  for (let i = 0; i < d; i++) {
    [p[i], c[i]] = input[i+1].split(' ').map(x => parseInt(x, 10));
    c[i] /= 100;
  }

  dfs(d-1, g/100, 0, 0);

  console.log(ans);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8').split('\n'));


Measured memory_bytes: 7468
import math
list = input().rstrip().split(" ")
n = int(list[0])
a = int(list[1])
b = int(list[2])
n_num = n / (a + b) #N個の中にAB周期がいくつあるか
n_number = int(math.floor(n_num)) #↑の整数部分
a_num = n_number * a #周期内のAの数
n_amari = n % (a + b) #周期外のボールの数
n_min_a = n_amari - a #Nあまり引くA
if n_min_a >= 0:
  a_total = a_num + a
else:
  a_total = a_num + n_amari
print(a_total)  

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;
ll kiri(ll a,ll b){return a%b==0?a/b:a/b+1;}

int main(){
  ll n,h; cin >> n >> h;
  vector<pll> v(n);
  ll mxa=0;
  rep(i,n){
    cin >> v[i].second >> v[i].first;
    chmax(mxa,v[i].second);
  }
  sort(all(v));
  reverse(all(v));
  int ans=0;
  rep(i,n){
    int a,b;
    tie(b,a)=v[i];
    if(b<=mxa) break;
    h-=b;
    ans++;
    if(h<=0){
      cout << ans << endl;
      return 0;
    }
  }
  ans+=kiri(h,mxa);
  cout << ans << endl;
}

Measured memory_bytes: 1792
// Remeber Choose Compiler: GCC9
#include <bits/stdc++.h>

using namespace std;

// Debug Output Utility
#ifdef LOCAL
#define dbg(args...)             \
    do {                         \
        cout << #args << " -> "; \
        err(args);               \
    } while (0)
void err() { std::cout << std::endl; }
template <typename T, typename... Args>
void err(T a, Args... args) {
    std::cout << a << ' ';
    err(args...);
}
template <template <typename...> class T, typename t, typename... A>
void err(const T<t> &arg, const A &... args) {
    for (auto &v : arg)
        std::cout << v << ' ';
    err(args...);
}
#else
#define dbg(...)
#endif

// Macro Definitions:
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

// Type Alias:
using int64 = long long;
using PII   = pair<int, int>;

// Global Const Variable
const int64 INF  = 0x3f3f3f3f;
const int MOD  = 1000000007;
const int MAXN = ((1<<18)+5);
const int M = 100005;
const int dir[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};

int64 v[MAXN], w[MAXN];
int64 dp[1030][M];

int64 f(int u, int l) {
    if(l<0) return -INF;
    if(u>1024) {
        return max(f(u>>1,l), f(u>>1,l-w[u])+v[u]);
    } else {
        return dp[u][l];
    }
}

void run() {
    int n,q;
    cin >> n;
    for(int i=1;i<=n;i++) cin >> v[i] >> w[i];
    for(int i=1;i<=min(1024,n);i++) {
        for(int j=1;j<M;j++) {
            dp[i][j] = dp[i>>1][j];
            if(j>=w[i])
                dp[i][j] = max(dp[i][j], dp[i>>1][j-w[i]]+v[i]);
        }
    }
    cin >> q;
    int u,l;
    for(int i=1;i<=q;i++) {
        cin >> u >> l;
        cout << f(u,l) << endl;
    }
}

// Debug Input Redirection
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    run();
}

Measured memory_bytes: 807772
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    string S; cin >> S;
    string T, U;
    vector<int> X;
    int i = 0;
    for (;;) {
        int cnt = 0;
        while (i < S.size() && S[i] == 'x') {
            i++, cnt++;
        }
        X.push_back(cnt);
        if (i >= S.size()) break;
        T.push_back(S[i]);
        i++;
    }
    U = T;
    reverse(begin(U), end(U));
    int ans = 0;
    if (T == U) {
        for (int i = 0; i < X.size()/2; i++) {
            ans += abs(X[i] - X[X.size()-1-i]);
        }
    } else {
        ans = -1;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1148
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<29;

int dp[1<<18][51];

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> b(n);
  rep(i,n) cin >> b[i];
  rep(mask,1<<n)rep(last,51) dp[mask][last]=inf;
  dp[0][0]=0;
  rep(mask,1<<n)rep(last,51)if(dp[mask][last]!=inf){
    rep(i,n){
      if(mask&(1<<i)) continue;
      bool f=abs(__builtin_popcount(mask)-i)%2;
      if(f==0&&a[i]<last||f==1&&b[i]<last) continue;
      int cnt=0;
      rep(j,i) if(!(mask&(1<<j))) cnt++;
      chmin(dp[mask|(1<<i)][f==0?a[i]:b[i]],dp[mask][last]+cnt);
    }
  }
  int ans=inf;
  rep(last,51) chmin(ans,dp[(1<<n)-1][last]);
  if (ans==inf) ans=-1;
  cout << ans << endl;
}

Measured memory_bytes: 52608
#include <stdio.h>

#define N 100
#define INF 2000000000

int min(int, int);


int main() {
  int i, j, k, l;
  int q, n, p[N+1], m[N+1][N+1];

  scanf("%d", &n);

  for (i = 1; i <= n; i++) {
    scanf("%d%d", &p[i-1], &p[i]);
  }

  for (i = 1; i <= n; i++) {
    m[i][i] = 0;
  }

  for (l = 2; l <= n; l++) {
    for (i = 1; i <= n - l + 1; i++) {
      j = i + l -1;
      m[i][j] = INF;
      for (k = i; k <= j; k++) {
	q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
	m[i][j] = min(m[i][j], q);
      }
    }
  }

  printf("%d\n", m[1][n]);

  return 0;
}


int min(int n, int m) {
  if (n > m) return m;
  
  else return n;

}



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

int main() {
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;

  if ((x + r <= W && y + r <= H) && (x <= W && x >= 0) && (y <= H && y >= 0))  {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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 debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
  gearup;
  ll h,w;
  ll n;cin>>h>>w>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  vvs res(h,vs(w));
  string nc = "1";
  ll now = 0;
  rep(i,h){
      rep(j,w){
          int k = j;
          if(i & 1)k = w-1-j;
          res[i][k] = nc;
          a[now]--;
          if(a[now] == 0){
              now++;
              nc = to_string(now+1);
          }
      }
  }
  rep(i,h){
      rep(j,w){
          if(j) cout << " ";
          cout << res[i][j];
      }
      cout << endl;
  }
}


Measured memory_bytes: 896
from sys import stdin, exit
import itertools

if __name__ == "__main__":
  
  while True:
    cnt = 0
    N, X = [int(item) for item in input().split()]
    if N==0 and X==0:
      break
    
    for N_1 in range(1, N+1):
      for N_2 in range(N_1+1, N+1):
        N_3 = X - (N_1 + N_2)
        if 1<=N_3 and N_3<=N and N_2<N_3:
          cnt += 1
          # print(N_1, N_2, N_3)
        
    print(cnt)



Measured memory_bytes: 5636
N = int(input())
a = list(map(int,input().split()))
a.sort()
if N%3==0:
	k = N//3
	flg = 0
	x1, x2, x3 = -1, -1, -1
	if a[0]==a[k-1]:
		x1 = a[0]
		flg +=1
	if a[k]==a[2*k-1]:
		x2 = a[k]
		flg +=1
	if a[2*k]==a[3*k-1]:
		x3 = a[2*k]
		flg +=1
	if flg == 3:
		if (x1^x2)==x3 and (x2^x3)==x1 and (x3^x1)==x2:
			print("Yes")
		else:
			print("No")
	else:
		print("No")
else:
	if a[-1]==0:
		print("Yes")
	else:
		print("No")

Measured memory_bytes: 14704
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	int n;
	ArrayList<Integer>[] g;
	int[] sz;
	int[] sz2;
	final long MOD = 1_000_000_000 + 7;
	int MAX = 10000;
	long[] fac = new long[MAX];
	long[] ifac = new long[MAX];
	long[] inv = new long[MAX];
	{
		fac[0] = fac[1] = ifac[0] = ifac[1] = inv[0] = inv[1] = 1;
		for (int i = 2; i < MAX; ++i) {
			fac[i] = i * fac[i - 1] % MOD;
			inv[i] = MOD - inv[(int) (MOD % i)] * (MOD / i) % MOD;
			ifac[i] = inv[i] * ifac[i - 1] % MOD;
		}
	}

	long comb(int n, int k) {
		if (n < k || n < 0 || k < 0)
			throw new AssertionError();
		return fac[n] * ifac[n - k] % MOD * ifac[k] % MOD;
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		g = new ArrayList[n];
		for (int i = 0; i < g.length; ++i) {
			g[i] = new ArrayList<>();
		}
		for (int i = 0; i < n - 1; ++i) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			--x;
			--y;
			g[x].add(y);
			g[y].add(x);
		}
		sz = new int[n];
		sz2 = new int[n];
		dfs(0, -1);
		int comp = n + 1;
		int center = 0;
		for (int i = 0; i < sz2.length; ++i) {
			if (comp > sz2[i]) {
				comp = sz2[i];
				center = i;
			}
		}
		if (n % 2 == 0 && n == comp * 2) {
			System.out.println(fac[n / 2] * fac[n / 2] % MOD);
			return;
		}
		dfs(center, -1);
		int m = g[center].size();
		int[] a = new int[m];
		for (int i = 0; i < m; ++i) {
			int v = g[center].get(i);
			a[i] = sz[v];
		}
		Arrays.sort(a);
		long[][] dp = new long[m + 1][n + 1];
		dp[0][0] = 1;
		for (int i = 0; i < m; ++i) {
			for (int j = 0; j + a[i] <= n; ++j) {
				for (int k = 0; k <= a[i]; ++k) {
					dp[i + 1][j + k] += dp[i][j] * comb(a[i], k) % MOD * comb(a[i], k) % MOD * fac[k] % MOD;
					dp[i + 1][j + k] %= MOD;
				}
			}
		}

		long ans = 0;
		for (int i = 0; i <= n; ++i) {
			ans += (i % 2 == 0 ? 1 : MOD - 1) * dp[m][i] % MOD * fac[n - i] % MOD;
			ans %= MOD;
		}
		System.out.println(ans);
	}

	void dfs(int cur, int par) {
		sz[cur] = 1;
		int ma = 0;
		for (int dst : g[cur]) {
			if (dst == par)
				continue;
			dfs(dst, cur);
			sz[cur] += sz[dst];
			ma = Math.max(ma, sz[dst]);
		}
		ma = Math.max(ma, n - sz[cur]);
		sz2[cur] = ma;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}
}


Measured memory_bytes: 240140
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	arep(1,i,100000){
		if(a*i%b==c){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#define REP(i,n) for(lint i{}, i##_len=(n); i<i##_len; ++i)
#define DOUBLE_LOOP(i, h, j, w) for(lint i{}; i < (lint)(h); ++i)for(lint j{}; j < (lint)(w); ++j)
#define DOUBLE_LOOP2(i, j, n) for(lint i{}; i < (lint)(n - 1); ++i)for(lint j{i + 1}; j < (lint)(n); ++j)
#define SZ(x) ((lint)(x).size())
using lint = long long; lint N, M, H, W;
using namespace std;
const long long INF{ 1LL << 60 };
const long double PI{ 3.1415926535897932 };
const long long NUM97{ 1000000007 };
template<class T> inline bool chmax(T& x, T y) { if (x < y) { x = y; return 1; } return 0; }
template<class T> inline bool chmin(T& x, T y) { if (x > y) { x = y; return 1; } return 0; }
std::vector<std::string> field;
std::vector<std::vector<bool>> seen(H, std::vector<bool>(W));
const std::vector<int> dx{ 1, 0, -1, 0 };
const std::vector<int> dy{ 0, 1, 0, -1 };

//素数判定
bool is_prime(lint N) {
    if (N == 1) return false;
    for (lint i = 2; i * i <= N; ++i) { if (N % i == 0) return false; }
    return true;
}
//約数列挙
std::vector<lint> divisors(lint N) { std::vector<lint> divisor;
    for (lint i = 1; i * i <= N; ++i) {
        if (N % i == 0) { divisor.push_back(i);
            if (N / i != i) divisor.push_back(N / i); }
    } std::sort(divisor.begin(), divisor.end());
    divisor.erase(std::unique(divisor.begin(), divisor.end()), divisor.end());
    return divisor;
}
//素因数列挙
std::vector<lint> prime_divisors(lint N) { std::vector<lint> p_divisor;
    for (lint i = 1; i * i <= N; ++i) {
        if (N % i == 0) { if (is_prime(i)) { p_divisor.push_back(i); }
            if (N / i != i) { if (is_prime(N / i)) { p_divisor.push_back(N / i); } } }
    } std::sort(p_divisor.begin(), p_divisor.end());
        p_divisor.erase(std::unique(p_divisor.begin(), p_divisor.end()), p_divisor.end());
    return p_divisor;
}

int main() {
    lint A, B; std::cin >> A >> B;
    std::vector<lint>a = prime_divisors(A);
    std::vector<lint>b = prime_divisors(B);
    lint ans = 0;
    for(int i = 0; i < a.size(); ++i)
        for (int j = 0; j < b.size(); ++j) {
            if (a[i] == b[j])
                ++ans;
        }
    std::cout << ans + 1 << std::endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <map>
#include <math.h>
#include <vector>
using namespace std;
map<int, int> ct;
map<int, int> ct2;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPS 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define AFOR(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 100005
int n, m, l;
int a, b, c;
string s[MN];
string str;
string ans;

/*
int N;
cin >> N;
vi vect(N);
FOR(i,N) cin >> vec.at(i);*/
//sort(vec.begin(),vec.end());
//vvi data(N,vi(4));

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin >> N;
	if (N >= 100) {
		N %= 10;

	}
	else if (N >= 10 && N <= 100) N %= 10;

	if (N == 3) {
		cout << "bon" << endl;
	}
	else if (N == 0 || N == 1 || N == 6 || N == 8) cout << "pon" << endl;
	else cout << "hon" << endl;
	 
	
	return 0;
}

Measured memory_bytes: 6780
#include <iostream>

int main() {
  int N;
  std::cin >> N;
  int count = 0;
  for (int i = 1; i <= N; ++i) {
    int a;
    std::cin >> a;
    count += (i % 2) * (a % 2);
  }
  std::cout << count << std::endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--; b--; c--; d--;
    string s;
    cin >> s;
    reps(i, a, c - 1) {
        if ((s[i] == '#') && (s[i + 1] == '#')) {
            cout << "No" << endl;
            return 0;
        }
    }
    reps(i, b, d - 1) {
        if ((s[i] == '#') && (s[i + 1] == '#')) {
            cout << "No" << endl;
            return 0;
        }
    }
    // pattern: A C B D
    if ((a < c) && (c < b) && (b < d)) {
        cout << "Yes" << endl;
        return 0;
    }
    // pattern: A B C D
    if ((a < b) && (b < c) && (c < d)) {
        cout << "Yes" << endl;
        return 0;
    }
    // pattern: A B D C
    bool f = false;
    reps(i, b - 1, d) {
        if (i >= (n - 2)) break;
        if ((s[i] == '.') && (s[i + 1] == '.') && (s[i + 2] == '.')) {
            f = true;
            break;
        }
    }
    cout << (f ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 592
#include <stdio.h>

int main() {
	int N;
	scanf("%d",&N);
	int A[N], ans[N+1];
	for (int i = 0; i < N; i++) {
		scanf("%d",&A[i]);
		ans[i] = -1;
	}
	ans[N] = -1;
	for (int i = 0; i < N; i++) {
		int point = 0;
		while (1) {
			if (ans[point] < A[i]) {
				ans[point] = A[i];
				break;
			}
			else point++;
		}
	}
	int cnt = 0;
	for (int i = 0; ans[i] != -1; i++) {
		cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 896
import math

N = int(input())

a = int(math.sqrt(N))
b = 1

if N % a == 0:
	b = int(N / a)
else:
	a -= 1
	while a > 0:
		if N % a == 0:
			b = int(N / a)
			break
		a -= 1

if a*b == N:
	print(a + b -2)

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

const int mod = 1000*1000*1000+7;

int po(int x, int n) {
    int ret = 1;
    while(n) {
        if(n & 1) ret = 1LL * ret * x % mod;
        x = 1LL * x * x % mod;
        n >>= 1;
    }
    return ret;
}
int inv(int x) { return po(x, mod - 2); }

int fact[4020];
int invf[4020];

int A, B;

int cc1[2020][2020];
int dp1(int a, int b) {
    int &ret = cc1[a][b];
    if(ret != -1) return ret;
    if(a == 0 || b == 0) return ret = 1;

    ret = 0;
    ret += dp1(a - 1, b - 1);
    ret %= mod;
    ret += dp1(a, b - 1);
    ret %= mod;
    return ret;
}

int cc2[2020][2020];
int dp2(int a, int b) {
    int &ret = cc2[a][b];
    if(ret != -1) return ret;
    if(a == 0 || b == 0) return ret = 1;

    ret = 0;
    ret += dp2(a - 1, b);
    ret %= mod;
    ret += dp1(a, b - 1);
    ret %= mod;
    return ret;
}

int cc3[2020];
int dp3(int a) {
    int &ret = cc3[a];
    if(ret != -1) return ret;
    if(a == 0) return ret = 1;

    ret = 0;
    ret += dp3(a - 1);
    ret %= mod;

    for(int i = 0; i <= a; i++) {
        int ra = i, rb = a - i;
        int ua = a - i, ub = B - 1 - rb;
        if(ua < 0 || ub < 0) continue;

        ret += 1LL * fact[ua + ub] * invf[ua] % mod * invf[ub] % mod * dp2(ra, rb) % mod;
        ret %= mod;
    }
    return ret;
}

int main() {
    fact[0] = 1;
    for(int i = 1; i < 4020; i++) {
        fact[i] = 1LL * fact[i - 1] * i % mod;
    }
    for(int i = 0; i < 4020; i++) {
        invf[i] = inv(fact[i]);
    }

    cin >> A >> B;

    memset(cc1, -1, sizeof(cc1));
    memset(cc2, -1, sizeof(cc2));
    memset(cc3, -1, sizeof(cc3));

    printf("%d", dp3(A));
}


Measured memory_bytes: 32256
from sys import stdin, setrecursionlimit, stdout
#setrecursionlimit(1000000)
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def lsi():
    x=list(stdin.readline())
    x.pop()
    return x
def si(): return stdin.readline()
mod=1000000007
#res=['YES', 'NO']
############# CODE STARTS HERE #############
def solve(k):
    l=(k*(k-1))//2
    u=(n*(n+1))//2-((n-k)*(n-k+1))//2
    return u-l+1

n, k=mi()
s=0
while k<=n+1:
    s+=solve(k)
    if s>=mod:
        s%=mod
    k+=1
print(s)

Measured memory_bytes: 9512
#include <bits/stdc++.h>
#define lli long long int
using namespace std;

const int maxN = 100; int n;
struct Point
{
  long double x, y, angle;
  long double distance(Point &other) { return sqrt((x-other.x)*(x-other.x) + (y-other.y)*(y-other.y)); }
  void read() { scanf("%Lf %Lf", &x, &y); angle = atan2(y, x); }
  bool operator<(const Point &other) const { return angle < other.angle; }
  void operator+=(const Point &other) { x += other.x, y += other.y; }
};
Point points[maxN], origin = {0, 0};

int main()
{
  scanf("%d", &n);
  for (int i = 0; i < n; i ++) points[i].read();
  sort(points, points+n);

  long double ans = 0;
  for (int i = 0; i < n; i ++)
  {
    Point at = origin;
    for (int a = 0, j = i; a < n; a ++, j = (j + 1) % n)
    {
      at += points[j];
      ans = max(ans, at.distance(origin));
    }
  }
  printf("%.15Lf\n", ans);

  return(0);
}

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

int n,x,s[1000005],v[1000005],u[1000005],w[1000005],o;
/*void add(int v){
    s[++x]=v;
}*/
int main(){
    scanf("%d",&n);
    x=1;while(n!=1){
        if(n&1){
            v[++o]=x,u[o]=-1;
            v[++o]=x,u[o]=x+1,w[o]=1;
            v[++o]=x,u[o]=x+1,w[o]=(n>>1)+1;
        }else{
            v[++o]=x,u[o]=x+1,w[o]=0;
            v[++o]=x,u[o]=x+1,w[o]=(n>>1);
        }
        n>>=1;
        ++x;
    }
    printf("%d %d\n",x,o);
    for(int i=1;i<=o;i++){
        if(u[i]==-1)u[i]=x;
        printf("%d %d %d\n",v[i],u[i],w[i]);
    }
    return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;

const int INF = 200000000;
const int MOD = 1e9 + 7;

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

    string S;
    cin >> S;
    int N = S.size();
    vector<int> tile;
    REP(i, N) { tile.push_back(S[i] - '0'); }

    int state = tile[0];
    int count1 = 0;
    REP(i, N - 1) {
        if (state == tile[i + 1]) {
            state = (state) ? 0 : 1;
            count1++;
        } else {
            state = tile[i + 1];
        }
    }

    state = (tile[0]) ? 0 : 1;
    int count2 = 1;
    REP(i, N - 1) {
        if (state == tile[i + 1]) {
            state = (state) ? 0 : 1;
            count2++;
        } else {
            state = tile[i + 1];
        }
    }
    cout << min(count1, count2) << "\n";

    return 0;
}


Measured memory_bytes: 972
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;

int main()
{
	int A, B;

	cin >> A >> B;

	if (B % A == 0)
	{
		cout << A + B << endl;
	}
	else
	{
		cout << B - A << endl;
	}

	return 0;
}

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

int main() {
  int N,a,b;
  cin >> N >> a >> b;
  int sum = 0;
  for(int i=1;i<N+1;i++){
    int d,e,f,g,h;
    d = i/10000;
    e = (i-10000*d)/1000;
    f = (i-10000*d-1000*e)/100;
    g = (i-10000*d-1000*e-100*f)/10;
    h = i-10000*d-1000*e-100*f-10*g;
    int S = d+e+f+g+h;
    if(a<=S && S<=b){
      sum += i;
    }
  }
  cout << sum;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 1000000000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repM(i, n) for (int i = n; i > 0; i--)

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> A(N);
    rep(i,N)cin >> A[i];
    int sum = 0;
    rep(i,N)sum += A[i];
    sort(A.begin(), A.end(), greater<int>());
    float rule = sum*((float)1 / (4 * M));
    rep(i,M){
        if(A[i]>=rule){

        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256