akhauriyash/Code-Regression huggingface dataset:
///cREATED bY BERNARB.01
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
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 priority_queue<int,vector<int>,greater<int>> pqil;
typedef priority_queue<int> pqig;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef priority_queue<pii> pqiig;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<int, int> mii;
#define mid ((l+r)/2)
#define PB push_back
#define PP pop_back
#define PF push_front
#define DF pop_front
#define F first
#define S second
#define MP make_pair
#define C continue
#define B break
#define R return
#define sz(v) (int)(v).size()
#define len(s) (int)(s).length()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define clr(arr, x) memset((arr), (x), sizeof (arr))
#define loop(n) for(int i=0; i<(n); i++)
#define jloop(n) for(int j=0; j<(n); j++)
#define rloop(n) for(ll i=(n)-1; i>=0; i--)
const ll N = 2e5+9;
const ll INF = 2e17+423;
const ll mod = 1e9+7; //998244353;
const ld pi = acos(-1.0);
const ld cmpf = 1e-9;
//__int128_t
#define endl '\n'
ll po(ll,ll);


















int main() {
  /*#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  #endif // ONLINE_JUDGE*/
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, ac=0, w=0;
  cin >> n >> m;
  map<int, int> mp;
  bool vis[200005];
  clr(vis ,0);
  while(m--){
    int p; string v;
    cin >> p >> v;
    if(v=="WA" && !vis[p]) mp[p]++;
    else if(v=="AC" && !vis[p]) ac++, vis[p]=1, w+=mp[p];
  }
  cout << ac << " " << w << endl;
  R 0;
}
/*

*/



































ll po(ll x, ll n){
  if(n==0) R 1;
  ll y = po(x, n/2);
  y = ((y)*(y));
  if(n%2) y = (y*(x));
  R y;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long int ll;
using namespace std;

int main()
{
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    for(int i=0;i<n-1;i++){
        if(s[i]!=s[i+1]) {
            ans++;
        }
    }
    ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allg(v) v.begin(), v.end(), greater<int>()



signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, k;
  cin >> n >> k;
  
  if(n < k) {
    n = min(n, abs(n-k));
    cout << n << "\n";
    return 0;
  }
  if(n == k) {  
    cout << 0 << "\n";
    return 0;
  }
  
  int x = (n/k);
  n -= x*k;
  n = min(n, abs(n-k));
  cout << n << "\n";

}


Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
ain = gets.split.map(&:to_i)
even = []
odd = []
ain.each do |a|
    if a%2 == 0
        even.push(a)
    else
        odd.push(a)
    end
end

if odd.length == 0
    as = even.dup
    bs = [1] + even.dup
    bs[-1] -= 1
elsif odd.length == 1
    as = [odd[0]] + even
    bs = [odd[0]-1, 2] + even
    bs[-1] -= 1
elsif odd.length == 2
    as = [odd[0]] + even + [odd[1]]
    bs = [odd[0]-1, 2] + even + [odd[1]]
    bs[-1] -= 1
else
    puts 'Impossible'
    exit
end
bs.shift if bs[0] == 0
bs.pop if bs[-1] == 0

puts as.join(' ')
puts bs.length
puts bs.join(' ')

Measured memory_bytes: 1788
#include<stdio.h>

char bo[4][4];
int xy4[8];
int check(int x,int y){
  return x*y>-1&&x<4&&y<4;
}
int count(int x,int y,int num){
  int i,j,k,total;
  if(num==8) return 1;
  for(i=0,total=0;i<4;i++){
    if(check(x+xy4[i*2],y+xy4[i*2+1])&&bo[y+xy4[i*2+1]][x+xy4[i*2]]==0){
      bo[y][x]=bo[y+xy4[i*2+1]][x+xy4[i*2]]=num+1;
      for(j=y;j<4;j++)
	for(k=j==y?x:0;k<4;k++)
	  if(bo[j][k]==0) goto find;
    find:
      total+=count(k,j,num+1);
      bo[y][x]=bo[y+xy4[i*2+1]][x+xy4[i*2]]=0;
    }
  }
  return total;
}
int main(){
  int i;
  while(1){
    scanf("%d",xy4);
    if(xy4[0]>4) break;
    for(i=1;i<8;i++) scanf(" %d",xy4+i);
    printf("%d\n",count(0,0,0));
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstring>
using namespace std;
string s,t,u;
int a,b;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>s>>t;
    cin>>a>>b;
    cin>>u;

    if(s==u) a--;
    if(t==u) b--;
    cout<<a<<" "<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	v := 0
	for i := 1; i <= N; i++ {
		v += i * g(N/i)
	}
	fmt.Println(v)
}

func g(n int) int {
	return n * (1 + n) / 2
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
     int a, b; 
     cin >> a >> b; 
     if(a > b) cout << "a > b" << endl; 
     else if(a < b) cout << "a < b" << endl; 
     else if(a == b) cout << "a == b" << endl; 
     return 0; 
}



Measured memory_bytes: 3080
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  int ans = 0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(a[j]==a[i])continue;
      for(int k=j+1;k<n;k++){
        if(a[k]==a[j])continue;
        if(a[i]+a[j]>a[k])ans++;
      }
    }
  }
  cout << ans << endl;

return 0;
}
///....


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

using namespace std;

int main(void){

    int n, m, ans = 0;

    cin >> n >> m;
    vector<int> a(m);

    for(int i = 0;i < n;i++){
        int k; cin >> k;
        for(int j = 0;j < k;j++){
            int tmp; cin >> tmp;
            a[tmp-1]++;
        }
    }

    for(int i = 0;i < m;i++){
        if(n == a[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>

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

typedef long long ll;

using namespace std;

int main(){
  int m1,d1,m2,d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if(m1!=m2) cout << 1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    int N;
    cin >> N;

    int countR = 0, countW = 0;
    int count = 0;

    string c; 
    cin >> c;

    for(int i = 0; i < N; i++){

        if(c.at(i) == 'R'){
            countR++;
        }else{
            countW++;
        }
        
    }

    for(int i = 0; i < countR; i++){
    
        if(c.at(i) == 'W'){
            count++;
        }
    
    }

    cout << count << endl;

}

Measured memory_bytes: 3720
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n;
ll T,E,pos[100111];
ll dp[100111];
pair<ll,int> q[100111];
int qb,qe;
void add(int id)
{
	while(qe>qb&&q[qe-1].FF>=dp[id])qe--;
	q[qe++]=MP(dp[id],id);
}
void del(int id)
{
	if(qb<qe&&q[qb].SS==id)qb++;
}
int main()
{
	int tmp;
	getiii(n,tmp,T);
	for(int i=1;i<=n;i++)geti(pos[i]),pos[i]*=2;
	ll mn=1ll*mod*mod;
	int it=-1;
	add(0);
	for(int i=1;i<=n;i++)
	{
//		cerr<<"i="<<i<<endl;
		while(pos[i]-pos[it+2]>T)
		{
			it++;del(it);
			mn=min(mn,dp[it]-pos[it+1]);
		}
//		cerr<<"it="<<it<<" mn="<<mn<<endl;
		dp[i]=mn+pos[i];
		if(qb<qe)dp[i]=min(dp[i],q[qb].FF+T);
//		cerr<<"dp="<<dp[i]<<endl;		
		add(i);
	}
	cout<<dp[n]+tmp<<endl;
	return 0;
}

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

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


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    int64_t x;
    cin >> x;
    vector<int64_t>vec(N);
    for (int i=0; i<N; i++) {
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end());
    int ninzu = 0;
    for (int i=0; i<N; i++) {
        if (x >= vec[i]) {
            ninzu = i + 1;
            x -= vec[i];
        } else {
            ninzu = i;
            break;
        }
    }

    if (ninzu == N && x != 0) {
        ninzu -= 1;
    }

    cout << ninzu << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	string T;
	cin>>T;
	
	for(int i=0;i<T.size();i++){
		if(T[i]=='?')T[i] = 'D';
	}
	
	cout<<T<<endl;
	
	return 0;
}

Measured memory_bytes: 3756
n, p = map(int, input().split())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])
    return arr


ans = 1
for a, b in factorization(p):
    ans *= pow(a, b // n)
print(ans)


Measured memory_bytes: 9464
#include <iostream>
#define int long long
using namespace std;

const int mod = 1000000007;
int n, m;
int x[100000];
int y[100000];

signed main() {
	int i;
	
	cin >> n >> m;
	for (i = 0; i < n; i++) cin >> x[i];
	for (i = 0; i < m; i++) cin >> y[i];
	for (i = 0; i < n; i++) x[i] += 1000000000;
	for (i = 0; i < m; i++) y[i] += 1000000000;
	
	int si = 0, sj = 0, sk = 0, sl = 0;
	
	for (i = 0; i < n - 1; i++) {
		si += (n - 1 - i) * x[i];
		si %= mod;
	}
	for (i = 1; i < n; i++) {
		sj += i * x[i];
		sj %= mod;
	}
	for (i = 0; i < m - 1; i++) {
		sk += (m - 1 - i) * y[i];
		sk %= mod;
	}
	for (i = 0; i < m; i++) {
		sl += i * y[i];
		sl %= mod;
	}
	
	int A = sj * sl; A %= mod;
	int B = sj * sk; B %= mod;
	int C = si * sl; C %= mod;
	int D = si * sk; D %= mod;
	int ans = (A + (mod - B) + (mod - C) + D) % mod;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
N,L=map(int,input().split())

tlist=[]
for i in range(N):
  tlist.append(L+i)
  
#print(tlist)
sum_all = sum(tlist)
min_diff = 10000
aji = 0
for i in range(N):
  ringo = tlist[i]
  sum_min1 = sum_all-ringo
  
  if abs(sum_all-sum_min1) < min_diff:
    min_diff = abs(sum_all-sum_min1)
    aji = sum_min1
    
print(aji)


Measured memory_bytes: 3060
#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;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  vector<vector<int>> dp(n, vector<int>(n, 0));
  for (int r = n - 1; r > 0; r--)
    for (int l = r - 1; l >= 0; l--)
      if (s[r] == s[l])
      {
        if (r == n - 1)
          dp[l][r] = 1;
        else
          dp[l][r] = dp[l+1][r+1] + 1;
        ans = max(ans, min(dp[l][r], r - l));
      }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 98176
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    k = kwargs["k"]
    a = kwargs["a"]
    b = kwargs["b"]
    res = 'NG'

    for i in range(a, b + 1):
        if i % k == 0:
            res = 'OK'

    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    #kwargs["n"] = cin[0]
    #kwargs["n"], kwargs["k"] = cin
    kwargs["k"] = [int(i) for i in cin][0]
    #kwargs["n"], kwargs["k"] = [int(i) for i in cin]

    cin = input().split()
    #kwargs["n"] = cin[0]
    #kwargs["n"], kwargs["k"] = cin
    #kwargs["k"] = [int(i) for i in cin][0]
    kwargs["a"], kwargs["b"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

Measured memory_bytes: 31172
#include<iostream>
#include<algorithm>

using namespace std ;

bool came[ 100000 ] ;

int main()
{
	int n ,last_icicle ;
	cin >> n >> last_icicle ;
	long icicles[ n + 2 ] ,icicle[ n + 2 ] ;
	icicles[ 0 ] = icicles[ n + 1 ] = 0 ;
	for( int i = 1 ; i <= n ; i++ )
		cin >> icicles[ i ] ,icicle[ i ] = last_icicle - icicles[ i ] ;
	for( int i = 1 ; i <= n ; i++ )
	{
		if( came[ i - 1 ] && icicles[ i ] > icicles[ i + 1 ] )
			icicle[ i ] += icicle[ i - 1 ] ,came[ i ] = true ;
		else if( icicles[ i ] > icicles[ i - 1 ] && icicles[ i ] > icicles[ i + 1 ] )
			came[ i ] = true ;
	}
	for( int i = n ; i > 0 ; i-- )
	{
		if( !came[ i ] )
		{
			if( came[ i - 1 ] )
				icicle[ i ] += max( icicle[ i - 1 ] ,icicle[ i + 1 ] ) ;
			else if( icicles[ i ] > icicles[ i - 1 ] )
				icicle[ i ] += icicle[ i + 1 ] ;
		}
	}
	
	sort( icicle + 1 ,icicle + n + 1 ) ;

	cout << icicle[ n ] << endl ;
	return 0 ;
}

Measured memory_bytes: 4808
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	A := ReadInts(N)
	A = append([]int{0}, A...)
	A = append(A, 0)
	sum := 0
	for i := 0; i <= N; i++ {
		sum += Abs(A[i] - A[i+1])
	}
	for i := 1; i <= N; i++ {
		fmt.Println(sum - Abs(A[i-1]-A[i]) - Abs(A[i]-A[i+1]) + Abs(A[i-1]-A[i+1]))
	}
}

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 4888
#include <cstdio>
#include <numeric>
 
int const N = 1000001;
 
int spf[N], u[N], s[17], d, i, j, k;
char const* r = "pairwise";
 
int main() {
    while (++i < N)spf[i] = i;
    for (i = 2; i * i < N; i++) {
        for (j = i * i; j < N; j += i) {
            if (spf[j] == j)
                spf[j] = i;
        }
    }
    for (scanf("%*d"); ~scanf("%d", &j); k = 0) {
        d = std::gcd(d, j);
        for (; j > 1; j /= i) {
            s[k++] = i = spf[j];
            if (u[i]) r = "setwise";
        }
        while(k--)u[s[k]] = 1;
    }
    printf("%s coprime\n", d > 1 ? "not" : r);
    return 0;
}


Measured memory_bytes: 9544
import sys
import itertools
n,m=map(int,input().split())
ab=[]
for _ in range(m):
    ab.append(list(map(int,input().split())))

lis=list(range(1,n+1))
per_lis = itertools.permutations(lis) 

ans=0

for one_case in per_lis:
    if one_case[0]==1:
        tmp=0
        for j in range(n-1):
            for num in ab:
                if one_case[j]==num[0] and one_case[j+1]==num[1]:
                    tmp+=1
                elif one_case[j]==num[1] and one_case[j+1]==num[0]:
                    tmp+=1
                    

        if tmp==n-1:
            ans+=1

print(ans)

Measured memory_bytes: 3064
w, h, n = [int(item) for item in input().split()]

boundary = [[0], [w], [0], [h]]
for i in range(n):
    x, y, a = [int(item) for item in input().split()]
    if a == 1 or a == 2:
        val = x
    elif a == 3 or a == 4:
        val = y
    else:
        exit()
    boundary[a-1].append(val)
    
w = min(boundary[1]) - max(boundary[0])
h = min(boundary[3]) - max(boundary[2])
if w >= 0 and h >= 0:
    print(w*h)
else:
    print(0)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int f(int n)
{
    int sum=0;
    while(n)
    {
        sum+=n%10;
        n/=10;
    }
    return sum;
}
int main()
{
    int n;
    cin>>n;
    cout<<(n%f(n)==0?"Yes":"No")<<endl;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n = read();
  int ryuka[87];
  ryuka[0] = 2;
  ryuka[1] = 1;
  FOR(i, 2, 87) { ryuka[i] = ryuka[i - 1] + ryuka[i - 2]; }
  print(ryuka[n]);
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wall"
#pragma GCC diagnostic ignored "-Wextra"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wpedantic"
#include "atcoder/all"
#pragma GCC diagnostic warning "-Wall"
#pragma GCC diagnostic warning "-Wextra"
#pragma GCC diagnostic warning "-Wconversion"
#pragma GCC diagnostic warning "-Wpedantic"
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) (((n) >> (k)) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = true;
}  // namespace mydef
using namespace mydef;
#define pb push_back
//#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans
using namespace atcoder;

int N, Q;

void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    cin >> N >> Q;
    dsu d(N);
    while (Q--) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) {
            d.merge(u, v);
        } else {
            cout << (d.same(u, v) ? 1 : 0) << endl;
        }
    }

    solve();
    return 0;
}


Measured memory_bytes: 4020
#include <iostream>
#include <set>
#define ll long long
using namespace std;
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin>>n;
    ll c = 0, ans = 0;
    set<ll> s;
    while(++ans){
        c = ((c * 10) + 7) % n;
        if(!c) break;
        if(s.find(c) == s.end()){
            s.insert(c);
        }else{
            ans = -1;
            break;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 50060
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=1e5+10;
pair<int,int>p[mx];
pair<int,int>d[9*mx];
uli ans[10];
int main(){
  int h,w,n;
  scanf("%d %d %d",&h,&w,&n);
  int c=0;
  for(int i=0;i<n;i++){
    scanf("%d %d",&p[i].first,&p[i].second);
    for(int dx=-2;dx<=0;dx++)for(int dy=-2;dy<=0;dy++){
      int x=p[i].first+dx,y=p[i].second+dy;
      if(1<=x && x+2<=h && 1<=y && y+2<=w){      
        d[c++]=make_pair(x,y);
      }
    }
  }
  sort(p,p+n);
  sort(d,d+c);
  c=unique(d,d+c)-d;
  for(int i=1;i<c;i++)assert(d[i]!=d[i-1]);
  for(int i=0;i<c;i++){
    int cnt=0;
    for(int dx=0;dx<3;dx++)for(int dy=0;dy<3;dy++){
      int x=d[i].first+dx,y=d[i].second+dy;
      assert(1<=x && x<=h && 1<=y && y<=w);
      pair<int,int>k(x,y);
      int idx=lower_bound(p,p+n,k)-p;
      if(idx<n && p[idx]==k)cnt++;
    }
    ans[cnt]++;
  }
  uli tot=0;
  for(int i=1;i<10;i++)tot+=ans[i];
  ans[0]=uli(w-2)*uli(h-2)-tot;
  for(int i=0;i<10;i++)printf("%lld\n",ans[i]);  
  return 0;
}


Measured memory_bytes: 8064
#include<iostream>

using namespace std;
int main() {
  int r, c;
  cin >> r >> c;
  int table[r+1][c+1] = {};
  for(int i = 0; i < r; i++) {
    for(int j = 0; j < c; j++) {
      cin >> table[i][j];
      table[i][c] += table[i][j];
      table[r][j] += table[i][j];
    }
    table[r][c] += table[i][c];
  }

  for(int i=0;i<=r;i++){
      for(int j=0;j<c;j++) cout << table[i][j] << ' ';
      cout << table[i][c] << '\n';
  }
  return 0;
}



Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define read(x) scanf("%d",&x)
using namespace std;
const int maxn=1e6+5;
int a[maxn];
int main() {
    int n;
    int k;
    read(n),read(k);
    int ps=0;
    for(int i=1;i<=n;i++) {
        read(a[i]);
        if(a[i]==1)ps=i;
    }
    int ans=0;
    ans+=ceil(1.0*(n-1)/(k-1));
    printf("%d\n",ans);
}


Measured memory_bytes: 640
#include <stdlib.h>
#include <stdio.h>

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

    char s[105];
    int i;
    int num_red = 0;
    int num_blue = 0;
    // for(i=0; i<N; i++){
    //     s[i] = getchar();
    //     if(s[i] == "R"){
    //         num_red ++;
    //     }else if(s[i] == "B"){
    //         num_blue ++;
    //     }
    // }
    char dummy = getchar();

    for(i=0; i<N; i++){
        char temp = getchar();
        if(temp == 'R'){
            num_red ++;
        }else if(temp == 'B'){
            num_blue ++;
        }
    }

    if(num_red > num_blue){
        printf("Yes\n");
    }else{
        printf("No\n");
    }


    return 0;
}

Measured memory_bytes: 128
N=int(input())
L=list(map(int,input().split()))
D={}
for i in range(N):
    if L[i] not in D:
        D[L[i]]=1
    else:
        D[L[i]]+=1
L=list(D.items())
L.sort()
#print(L)

if L[-1][1]<=1:
    print("Impossible")
    exit()
if L[-1][0]%2==1:
    if L[-1][0]//2+1==L[0][0] and L[0][1]==2:
        for i in range(1,len(L)):
            if L[i][0]==L[i-1][0]+1 and L[i][1]>=2:
                continue
            else:
                print("Impossible")
                exit()
        print("Possible")
    else:
        print("Impossible")
else:
    if L[-1][0]//2==L[0][0] and L[0][1]==1:
        for i in range(1,len(L)):
            if L[i][0]==L[i-1][0]+1 and L[i][1]>=2:
                continue
            else:
                print("Impossible")
                exit()
        print("Possible")
    else:
        print("Impossible")

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

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

    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;

    int res = 0;
    rep(i, n){
        if(a[i] == b[i]){
            if(b[i] == c[i]) res += 0;
            else ++res;
        }
        else{
            if(b[i] == c[i]) ++res;
            else if(a[i] == c[i]) ++res;
            else res += 2;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $n, $m);
for($i=0; $i < $m; $i++){
    $scores[] = array_map('trim',explode(" ", fgets(STDIN)));
}
$ac = array();
$wa = array();
$ac_num = 0;
$wa_num = 0;
if(! isset($scores)){
    echo "0 0";
    exit;
}
for($i=1;$i<=$n;$i++){
    $wa[$i]=0;
    $ac[$i]=false;
}
foreach($scores as $score){
    if($ac[$score[0]]) continue;
    if($score[1] == "AC"){
        $ac[$score[0]] = true;
        $ac_num++;
        $wa_num += $wa[$score[0]];
    }elseif($score[1] == "WA"){
        $wa[$score[0]]++;
    }
}
echo $ac_num." ".$wa_num;
?>

Measured memory_bytes: 59892
use std::cmp::{max, min};
use std::io::{self, Read};
use std::iter::FromIterator;

#[allow(dead_code)]
struct Source {
    chars: Box<Iterator<Item = char>>,
}

#[allow(dead_code)]
impl Source {
    fn next_chr(&mut self) -> char {
        self.chars
            .by_ref()
            .skip_while(|c| char::is_whitespace(*c))
            .next()
            .expect("eof")
    }

    fn next_str(&mut self) -> String {
        let it = self
            .chars
            .by_ref()
            .skip_while(|c| char::is_whitespace(*c))
            .take_while(|c| !char::is_whitespace(*c));
        let s = String::from_iter(it);
        if s.is_empty() {
            panic!("eof")
        } else {
            s
        }
    }

    fn from_stdin() -> Self {
        let mut data = String::new();
        io::stdin().read_to_string(&mut data).expect("Input error");
        Self::from_str(&data)
    }

    fn from_str(s: &str) -> Self {
        let data = String::from(s);
        let chars = data.chars().collect::<Vec<char>>().into_iter();
        Source {
            chars: Box::new(chars),
        }
    }
}

#[allow(unused_macros)]
macro_rules! input {
    ($src:expr; $($elem:tt)*) => {
        input_inner!($src, $($elem)*)
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($src:expr) => {};
    ($src:expr,) => {};
    ($src:expr, $var:ident : mut $ty:tt $($rest:tt)*) => {
        let mut $var = parse!($src, $ty);
        input_inner!($src $($rest)*)
    };
    ($src:expr, $var:ident : $ty:tt $($rest:tt)*) => {
        let $var = parse!($src, $ty);
        input_inner!($src $($rest)*)
    };
}

#[allow(unused_macros)]
macro_rules! parse {
    ($src:expr, ( $($ty:tt),* )) => {
        ( $(parse!($src,$ty)),* )
    };
    ($src:expr, char) => {
        $src.next_chr()
    };
    ($src:expr, [ $ty:tt; $len:expr ]) => {
        (0..$len).map(|_| parse!($src,$ty)).collect::<Vec<_>>()
    };
    ($src:expr, $ty:tt) => {
        parse_str!($src,$ty)
    };
}

#[allow(unused_macros)]
macro_rules! parse_str {
    ($src:expr, chars) => {
        $src.next_str().chars().collect::<Vec<char>>()
    };
    ($src:expr, $ty:ty) => {
        $src.next_str().parse::<$ty>().expect("Parse error")
    };
}

fn main() {
    let mut src = Source::from_stdin();
    input! { src;
             ab: usize, bc: usize, ca: usize,
    }

    println!("{}", ab * bc / 2);
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main()
{
  int a,b,t,res;
  cin >> a >> b;
  res=a+b;
  t=a-b;
  if(t>res) res=t;
  t=a*b;
  if(t>res) res=t;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M (1000000007)
#define N (100010)
int n,a[N];

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=n-1;i>=1;i--){
		if (a[i]<=a[i+1]) continue;
		else if (a[i]==a[i+1]+1) --a[i];
		else{printf("No"); return 0;}
	}
	printf("Yes");
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  long A,B,K;
  cin >>A>>B>>K;
  if(B-A+1 <= 2*K){
    for(int i = A;i<=B;i++){
      cout << i << endl;
    }
  }
  else{
    for(int u = A;u<A+K;u++){
      cout << u << endl;
    }
    for(int y = B-K+1;y<=B;y++){
      cout << y << endl;
    }
  }
    return 0;
    
}

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

int main() {
    int H, N;
    cin >> H >> N;
    vector<int> S(N);

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

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

    if(H <= 0){
        cout << "Yes" << endl;
    } else
        cout << "No" << endl;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string[] str = Console.ReadLine().Split(' ');
		long sum = long.Parse(str[0]);
		long min = long.Parse(str[0]);
		long max = long.Parse(str[0]);
		for(var i=1;i<N;i++){
			long a = long.Parse(str[i]);
			sum += a;
			min = Math.Min(min,a);
			max = Math.Max(max,a);
		}
		Console.WriteLine(min + " " + max + " " + sum);
	}
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

typedef vector<vector<int>> Graph;
Graph G;
int N, K;
int ans;

int dfs(int v, int p)
{
    int k = 0;
    for (auto u : G[v]) {
        k = max(dfs(u, v), k);
    }

    if (k == K-1 && p != 0 && v != 0) {
        ans++;
        k = 0;
    } else {
        k++;
    }

    return k;
}

int main()
{
    ios::sync_with_stdio(false);

    cin >> N >> K;

    G.resize(N);
    rep(i, N) {
        int A; cin >> A;
        A--;
        if (i == 0) {
            ans += (A != 0);
        } else {
            G[A].push_back(i);
        }
    }

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

Measured memory_bytes: 10368
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];

int head,tail,n;

void enqueue(P x){
  Q[tail]=x;
  if(tail+1==LEN){
    tail=0;
  }
  else tail++;
}

P dequeue(){
  P x;
  x=Q[head];
  if(head+1==LEN)head=0;
  else head++;
  return x;
}

int main(){
  P u;
  int i,n,q,time=0;
  scanf("%d%d",&n,&q);
  for(i=0;i<n;i++){
  scanf("%s",u.name);
  scanf("%d",&u.t);
  enqueue(u);
  }
   
  while(head!=tail){
    u=dequeue();
    if(u.t>q){
      u.t=u.t-q;
      enqueue(u);
      time+=q;
    }
    else{
      printf("%s %d\n",u.name,u.t+time);
      time+=u.t;
    }
  }
  return 0;
}

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

int main() {
int N,M,X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<int> E(M);
  vector<int> D(12);
  long long result = 10000000000000;
  long long count = 0;
  int check = 1;
  vector<vector<int>> A(N, vector<int>(M));
  for(int a = 0;a < N;a++){
    cin >> C.at(a);
    for(int b = 0;b < M;b++){
      cin >> A.at(a).at(b);
    }
  }
  
  for(D[0] = 0;D[0] < 2;D[0]++){
    for(D[1] = 0;D[1] < 2;D[1]++){
      for(D[2] = 0;D[2] < 2;D[2]++){
        for(D[3] = 0;D[3] < 2;D[3]++){
          for(D[4] = 0;D[4] < 2;D[4]++){
            for(D[5] = 0;D[5] < 2;D[5]++){
              for(D[6] = 0;D[6] < 2;D[6]++){
                for(D[7] = 0;D[7] < 2;D[7]++){
                  for(D[8] = 0;D[8] < 2;D[8]++){
                    for(D[9] = 0;D[9] < 2;D[9]++){
                      for(D[10] = 0;D[10] < 2;D[10]++){
                        for(D[11] = 0;D[11] < 2;D[11]++){
                          count = 0;
                          check = 1;
                          for(int a = 0;a < M;a++)E[a] = 0;
                          
                          
                            for(int b = 0;b < N;b++){
                              if(D[b] == 1){
                                count += C.at(b);
                                for(int a = 0;a < M;a++){
                              E[a] += A.at(b).at(a);
                                
                                }
                              }
                          }
                          for(int a = 0;a < M;a++){
                           if(E[a] < X)check = 0; 
                          }
                          if(check == 1){
                            result = min(count,result);
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    
    
  }
  if(result == 10000000000000){
    cout << -1 << endl;
  }else{
  cout << result << endl;
  }
}

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

using namespace std;
int main(){
  int n,r;
  int p,c;
  cin >> n >> r;

  while(n != 0 || r != 0){
    vector<int> card(51,0);
    vector<int>::iterator it;
    it = card.begin();
    for(int i = 0; i < n ; i++){
      card[i] = n-i;
    }
    for(int i = 0 ; i < r;i++){
      cin >> p >> c;
      vector<int> have(c,0);
      have.assign(it+p-1,it+p+c-1);
      card.erase(it+p-1,it+p+c-1);
      card.insert(it,have.begin(),have.end());
    }
    cout << card.at(0) << endl;
    cin >> n>> r;
  }

  return 0;
}


Measured memory_bytes: 2992
n = gets.to_i
min = 100000
1.upto(n/2) do |i|
a = i
b = n - a
sum = a.to_s.split('').map(&:to_i).inject(:+) + b.to_s.split('').map(&:to_i).inject(:+)
min = [min, sum].min
end
puts min

Measured memory_bytes: 2044
def myAnswer(H:int,W:int,S:list) -> int:
   for h in range(H):
      for w in range(W):
         target = S[h][w]
         if(target == "#"):
            if(h != 0 and S[h-1][w] == "#"):# 上を探索
               continue
            elif(w != 0 and S[h][w - 1] == "#"):# 右を探索
               continue
            elif(h != H-1 and S[h + 1][w] == "#"):# 下を探索
               continue
            elif(w != W -1 and S[h][w+1] == "#"):# 左を探索
               continue
            else:
               return "No"
   return "Yes"

def modelAnswer():
   return
def main():
   H,W = map(int,input().split())
   S = []
   for _ in range(H):
      S.append(list(input()))
   print(myAnswer(H,W,S[:]))
if __name__ == '__main__':
   main()

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

int main(){
  int n, ok=0, no=0;
  cin >> n;
  int a[n];
  rep(i,n) cin >> a[i];
  rep(i,n){
    if(a[i]%2!=0){
      continue;
    }
    if(!(a[i]%3==0 || a[i]%5==0)){
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
typedef long long int ll;
#define iceil(a,b) (x+y-1)/y
#define min(x,y)(x<y?x:y)
 
using namespace std;
typedef pair<int, int> P;


int main() {
	FAST;

	int x;
	cin >> x;

	int ans=1;

	rep(i,2,100) {
		int tmp = i*i;
		while(tmp<=x) {
			if (tmp>ans) ans = tmp;
			tmp*=i;
		}
	}

	cout << ans <<"\n";
	return 0;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    
    
    class Program
    {
        static int ch_cnt = 0;

        static void Bubble_Sort(int[] data_ary)
        {
            int length = data_ary.Count();
            int index = 0;
           
            //入れ替え作業を要素数回繰り返す
            for(int i = 0; i < length; i++)
            {
                for(index = length - 1; index >= 1; index--)
                {
                    //交換
                    if(data_ary[index - 1] > data_ary[index])
                    {
                        ch_cnt++;
                        int tmp = data_ary[index];
                        data_ary[index] = data_ary[index - 1];
                        data_ary[index - 1] = tmp;
                    }
                }
                
            }
            
        }
        
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] data_ary = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            Bubble_Sort(data_ary);

            Console.WriteLine(String.Join(" ", data_ary));
            Console.WriteLine(ch_cnt);
            
        }
    }
}


Measured memory_bytes: 18348
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 998244353;

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;
}


/* mint、表示は変数名.x */
struct mint {
  ll x;
  mint(ll x = 0) : x((x % MOD + MOD) % MOD) {
  }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  /* 変数名.pow(n) */
  mint pow(ll t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // 以降はMODが素数のみ
  mint inv() const {
    return pow(MOD - 2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}

int main() {
  ll N;
  cin >> N;
  vector<ll> D(N);
  map<ll, ll> m;
  ll mx = 0;
  rep(i, N) {
    cin >> D[i];
    m[D[i]]++;
    chmax(mx, D[i]);
  }


  if (D[0] != 0) {
    cout << 0 << endl;
    return 0;
  }

  if (m[0] != 1) {
    cout << 0 << endl;
    return 0;
  }

  mint ans = 1;
  rep(i, mx) {
    ans *= modpow(m[i], m[i + 1]);
  }

  cout << ans.x << endl;
}

Measured memory_bytes: 7296
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        n: Chars
    }
    let mut k = 0;
    for c in n {
        let c = c.to_digit(10).unwrap();
        k += c;
        k %= 9;
    }
    if k == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 3084
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in H,W,h,w;
  cin>>H>>W>>h>>w;
  if(W%w==0 && H%h==0){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  bool swp=0;
  if(W%w==0){
    swp=1;
  }
  const in lrg=1e6;
  forn(i,H){
    forn(j,W){
      if(!swp){
	if(j%w==0)
	  cout<<lrg<<" ";
	else if(j%w==w-1)
	  cout<<-lrg-1<<" ";
	else
	  cout<<0<<" ";
      }
      else{
	if(i%h==0)
	  cout<<lrg<<" ";
	else if(i%h==h-1)
	  cout<<-lrg-1<<" ";
	else
	  cout<<0<<" ";
      }
    }
    cout<<endl;
  }
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> X(N), tmp(N);
    rep(i,N) {
        cin >> X.at(i);
        tmp.at(i) = X.at(i);
    }
    int ans;
    sort(tmp.begin(), tmp.end());
    rep (i,N) {
        if (X.at(i) <= tmp.at(N / 2 - 1)) {
            ans = tmp.at(N / 2);
        } else {
            ans = tmp.at(N / 2 - 1);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 4756
#include <bits/stdc++.h>
//#include <iostream>
//#include <algorithm>
//#include <vector>
//#include <prqueue>

using namespace std;

const int maxn=1e6+10;
const int inf=0x3f3f3f3f;

typedef long long ll;

vector<int> ve[maxn];

int main()
{
//	freopen("input.txt","r",stdin);
//	ios::sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
//	
	int n,k;
	cin>>n>>k;
	int a,b;
	for(int i=0;i<n;i++) 
	{
		cin>>a>>b;
		if(a>k) continue;
		ve[k-a+1].push_back(b);
	}
	priority_queue<int> q;
	ll earn=0;
	for(int i=k;i>=1;i--)
	{
		for(int v:ve[i]) q.push(v);
		if(!q.empty())
		{
			earn+=q.top();
			q.pop();
		}
	}
	cout<<earn;
	
	
	return 0;
 } 
 
 //以相同天数，但权值最大的数先挑选。
 //为什么是k-a+1天之前？	 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 26752
s = str(input())
if s[-1] == '0' or s[-1] =='1' or s[-1] == '6' or s[-1] =='8':
  print('pon')
  #print(s[-1])
  exit()
elif s[-1] == '3':
  print('bon')
  exit()
else:
  print('hon')
  exit()

Measured memory_bytes: 8928
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<complex>
#include<stack>
#include<queue>
#include<unordered_map>
#include<map>
using namespace std;

int main() {
  int n, k;
  int tmp;
  bool flag = false;
  cin >> n >> k;
  vector<int> v;
  int i, d;
  for (i = 0; i < k; i++) {
    cin >> d;
    v.push_back(d);
  }
  while (true) {
    tmp = n;
    flag = false;
    while (tmp != 0) {
      for (i = 0; i < k; i++) {
        if (tmp % 10 == v[i]) {
          flag = true;
          break;
        }
      }
      if (flag) {
        break;
      } else {
        tmp /= 10;
      }
    }
    if (flag == false) {
      cout << n << endl;
      return 0;
    }
    n++;
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int a[100010];
void dfs(int n){
	int t=a[n];
	while(a[t]!=-1){
		int temp=a[t];
		a[t]=-1;
		t=temp;
	}
	return;
}
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	if(n==k){
		int x=a[1]-1;
		int flag=1;
		for(int i=1;i<=n;i++)flag&=(a[i]-i+n)%n==x;
		puts(flag?"Yes":"No");
	}else{
		int cnt=0;
		for(int i=1;i<=n;i++)if(a[i]!=-1)dfs(i),cnt++;
		puts((n-cnt)%2&&k%2?"No":"Yes");
	}
}



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

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,l;
    cin>>n>>l;
    ll ans=1e15;
    ll cnt=1e15;
    ll sum=0;
    FOR(i,1,n+1){
      sum+=l+i-1;
    }
    //cout<<sum<<endl;
    FOR(i,1,n+1){
      ll now=l+i-1;
      ll now2=sum-now;
      if(abs(now2-sum)<cnt){
        cnt=abs(now2-sum);
        ans=now2;
      }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256