akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<climits>

using namespace std;

long long int arr[100001];
long long int store[100001];

long long int find(long long int n, long long int k)
{
	if(store[n]!=-1)
	{
		return store[n];
	}
	else
	{
		long long int min1 = INT_MAX, cost = 0,i;
		for(i=1;n-i>0 && i<=k;++i)
		{
			cost = abs(arr[n] - arr[n-i]) + find(n-i,k);
			if(cost<min1)
			{
				min1 = cost;
			}
		}
		store[n] = min1;
		return store[n];
	}
}

int main()
{
	long long int n,i;
	cin>>n;
	for(i=1;i<=n;++i)
	{
		cin>>arr[i];
	}
	store[1] = 0;
	for(i=2;i<100001;++i)
	{
		store[i] = -1;
	}
	cout<<find(n,2)<<endl;
	return 0;
}

Measured memory_bytes: 8064
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTS(s) printf("%s\n",(s))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

typedef long long ll;


int main() {
	int N;
	int x, y, t;
	scanf("%d", &N);
	int nowX = 0, nowY = 0, nowT = 0;
	int flag = 0;
	REP(i, N) {
		scanf("%d %d %d", &t, &x, &y);
		int dif = abs(x - nowX) + abs(y - nowY);
		if (dif <= t-nowT && abs((t-nowT) - dif) % 2 == 0) {
			nowX = x;
			nowY = y;
			nowT = t;
			continue;
		}
		flag = 1;
		break;
	}
	if (flag) {
		PRINTS("No");
	}
	else {
		PRINTS("Yes");
	}

}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
a.sort()

print(a[-1] - a[0] + sum(map(abs, a[1:-1])))

pos = [a[-1]]
neg = [a[0]]
for x in a[1:-1]:
    if x > 0:
        pos.append(x)
    else:
        neg.append(x)
now = neg[0]
for p in pos[1:]:
    print(now, p)
    now -= p
print(pos[0], now)
now = pos[0] - now
for n in neg[1:]:
    print(now, n)
    now -= n


Measured memory_bytes: 63116
#include<iostream>
#include<string>
#include<stdio.h>
#include<math.h>
using namespace std;

class Dice{
public:
    int f[6];
    Dice(){}
    void roll(int i,int j,int k,int l){
        int b=f[i];f[i]=f[j];f[j]=f[k];f[k]=f[l];f[l]=b;
    }
    void move(char ch){
        if(ch=='S')for(int i=0;i<3;i++)roll(0,1,5,4);
        if(ch=='W')roll(0,2,5,3);
        if(ch=='N')roll(0,1,5,4);
        if(ch=='E')for(int i=0;i<3;i++)roll(0,2,5,3);
    }
    
};
int main(){
    Dice c;
    string com;
    
    for(int i=0;i<6;i++)cin>>c.f[i];
    cin>>com;
    
    for(int i=0;i<com.size();i++)c.move(com[i]);
    
    cout<<c.f[0]<<endl;
    
    return 0;
}



Measured memory_bytes: 3216
#include <iostream>
#include <algorithm>
#include <vector>
#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;
int main()
{
  int n,m;cin >> n >> m;
  vector<int> k(m),p(m);
  vector<vector<int>> s(m);
  rep(i,m) {
    cin >> k[i];
    s[i].resize(k[i]);
    rep(j,k[i]){
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  rep(i,m) cin >> p[i];

  int res = 0;
  rep(mask, (1<<n)) {
    vector<int> cnt(m, 0);
    rep(i,m) {
      rep(j,k[i]) {
	if( (mask >> s[i][j]) & 1) cnt[i]++;
      }
    }
    bool f = true;
    rep(i,m) if(cnt[i] % 2 != p[i]) f = false;
    if(f) res++;
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  long long int N, M;
  cin >> N >> M;
  if(N < 2 && M < 2)
    cout << 1 << endl;
  else if(N < 2)
    cout << M-2 << endl;
  else if(M < 2)
    cout << N-2 << endl;
  else
    cout << (M-2)*(N-2) << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
txy = []
txy.append([0, 0, 0])
for i in range(N):
    txy.append(list(map(int, input().split())))
for i in range(N):
    if abs(txy[i + 1][1] - txy[i][1]) + abs(txy[i + 1][2] - txy[i][2]) > txy[i + 1][0] - txy[i][0]:
        print("No")
        break
    else:
        if (txy[i + 1][0] - txy[i][0] - abs(txy[i + 1][1] - txy[i][1]) + abs(txy[i + 1][2] - txy[i][2])) % 2 != 0:
            print("No")
            break
else:
    print("Yes")

Measured memory_bytes: 27300
s=input()
moji=[]
for i in range(0,len(s)):
  if s[i]=="1":
    moji.append("1")
  elif s[i]=="0":
    moji.append("0")
  else:
    try:
      moji.pop(-1)
    except IndexError:
      pass
kk=""
print(kk.join(moji))

Measured memory_bytes: 3060
a,b,c = map(int,input().split())
k=int(input())

count = 0

for l in range(k+1):
    for m in range(k+1-l):
        for n in range(k+1-l-m):
            if a * (2**l) < b * (2**m) and b * (2**m) < c * (2**n):
                count +=1

if count == 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9188
from collections import deque
n, k, c = map(int, input().split())
s = list(map(lambda x: 1 if x == 'o' else 0, input()))
b_a = deque()
b_b = deque()
c_k = 0
for i in range(n-1, -1, -1):
    if c_k == 0 and s[i] == 1:
        b_a.append(i)
        c_k = c
    else:
        c_k = max(c_k-1, 0)
c_k = 0
for i in range(n):
    if c_k == 0 and s[i] == 1:
        b_b.append(i)
        c_k = c
    else:
        c_k = max(c_k-1, 0)

ans = list(set(b_a) & set(b_b))
ans.sort()
if len(ans) <= k:
    for i in ans:
        print(i+1)

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

using namespace std;
using ll=long long;

#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cint int t;cin>>t;while(t--)
#define rep(i,a,b) for(int i=a;i<b;i++)

int mod=1e9+7;

int main(){
    faster;

    int h,w,n;
    cin>>h>>w>>n;

    int tmp=max(h,w);

    cout<<n/tmp+(n%tmp!=0)<<endl;
}


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

int main()
{
  int R, G;
  cin >> R >> G;
  int S = 2 * G - R;
  cout << S << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  char X, Y;
  cin >> X >> Y;
  if(X > Y) {
    cout << ">" << endl;
  } else if(X < Y) {
    cout << "<" << endl;
  } else {
    cout << "=" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
def solve():
    N, M, K = map(int, raw_input().split()) 

    for i in xrange(N + 1):
        cur = M*i
        if cur > K: break
        for j in xrange(M + 1):
            if cur - i*j + (N - i)*j == K:
                return True
    for i in xrange(M + 1):
        cur = N*i
        if cur > K: break
        for j in xrange(N + 1):
            if cur - i*j + (M - i)*j == K:
                return True

    return False

print "Yes" if solve() else "No"


Measured memory_bytes: 2568
#include <stdio.h>

int main(){
	int input;
	scanf("%d", &input);
	
	if(input == 1)
	{
		printf ("Hello World");
	}
	else if(input == 2)
	{
		int a,b;
		scanf("%d\n", &a);
		scanf("%d", &b);
		printf("%d", a+b);
	}
	return 0;
}

Measured memory_bytes: 128
N = input().split()
N = [int(i) for i in N]
pi = [0 for i in range(N[0])]
ci = [0 for i in range(N[0])]
for i in range(N[0]):
    buf = input().split()
    pi[i] = int(buf[0])
    ci[i] = int(buf[1])

num_min = 10*100
G_new = N[1]

flag= [0 for i in range(N[0])]
for i in range(0, pow(2, N[0])):
    G_new = N[1]
    count = 0
    #print(bin(i))
    for j in range(N[0]):
        flag[j] = (i>>j & 1)
        if(flag[j]==1):
            G_new -= ci[j]
            G_new -= 100*(j+1)*pi[j]
            count += pi[j]
    #print(flag)

    if(G_new<=0):
        #print(i, flag)
        if(count < num_min):
            #print(count)
            num_min = count
            #print(count)
    else:
        for j in range(N[0]):
            if((flag[N[0]-1-j])==0):
                #print(i, flag, N[0]-1-j, G_new, pi[N[0]-1-j], count, -(-G_new//(100*(N[0]-j)))   )
                if(G_new - 100*(N[0]-j)*pi[N[0]-1-j] < 0):
                    count += -(-G_new//(100*(N[0]-j)))
                    if(count < num_min):
                       # print(count)
                        num_min = count
                        break

    
print(num_min)


Measured memory_bytes: 3444
package main

import "fmt"

func main() {
	b := SingleStr()

	switch b {
	case "A":
		fmt.Println("T")
	case "T":
		fmt.Println("A")
	case "C":
		fmt.Println("G")
	case "G":
		fmt.Println("C")
	}
}

func SingleStr() string {
	var s string
	fmt.Scan(&s)
	return s
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int answer = 0;
  for(int i=0;i<d;i++) {
   if(a > 0) {
     answer++;
     a--;
     continue;
   } else if(b > 0) {
     b--;
     continue;
   }
    answer--;
  }
  cout << answer << endl;
}

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

public class Main {
	
	static Map<Long, Long> check = new HashMap<Long, Long>();
	
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;
		String[] input;
		long N;
		
		N = Long.parseLong(br.readLine());
		
		System.out.println(solve(N));
	}
	
	static long solve(long n) {
		long a, b;
		
		if(n == 0) return 1;
		if(n == 1) return 2;
		
		if(check.containsKey(n/2)) {
			a = check.get(n/2);
		} else {
			a = solve(n/2) % 1000000007;
			check.put(n/2, a);
		}
		
		if(check.containsKey(n/2-1)) {
			b = check.get(n/2-1);
		} else {
			b = solve(n/2-1) % 1000000007;
			check.put(n/2-1, b);
		}
		
		if(n % 2 == 1) {
			return (2*a + b) % 1000000007;
		} else {
			return (2*b + a) % 1000000007;
		}
	}
}


Measured memory_bytes: 8276
w, h, x, y, r  = gets.split.map(&:to_i)

x1 = x - r
x2 = x + r
y1 = y - r
y2 = y + r

circle_in_range = x1.between?(0, w) && x2.between?(0, w) &&
                  y1.between?(0, h) && y2.between?(0, h)

if circle_in_range
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 6100
N, Q = map(int,input().split())
S = input()
t = [0]*(N+1)
for i in range(N):
  t[i+1] = t[i] + (1 if S[i:i+2] == "AC" else 0)
for _ in range(Q):
  l, r = map(int,input().split())
  print(t[r-1] - t[l-1])

Measured memory_bytes: 7748
#include<stdio.h>
int main(){
	double r; // int ??´??°
	// char ??????
	// double ???????°???°???
	
	
	scanf("%lf",&r);
	
	/*d = a / b;
	r = a % b;
	f = 1.0 * a / b;
	// f = (double)a / b;*/
	
	printf("%lf %lf\n",r*r*3.14159265358979, 2*r*3.14159265358979);
	
	return 0;
}

Measured memory_bytes: 648
import java.util.*;

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

        System.out.println(a == b && b == c ? "Yes" : "No");
    }
}


Measured memory_bytes: 23124
s=input()
t=input()
n=len(t)
ss=[0]*26
tt=[0]*26
for i in range(n):
	x=ord(s[i])-ord("a")
	y=ord(t[i])-ord("a")
	ss[x]+=1
	tt[y]+=1
ss.sort()
tt.sort()
if ss==tt:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3632
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Hamadneh
 */

#include <bits/stdc++.h>

using namespace std;

class DAlterAltar {
public:
    void solve(istream &in, ostream &out) {
        int x;
        in >> x;
        string s;
        in >> s;
        int c = 0;
        for (int i = 0, j = x - 1; i < j;) {
            if (s[i] == 'W') {
                if (s[j] == 'R') {
                    c++;
                    i++, j--;
                } else {
                    j--;
                }
            } else {
                i++;
            }
        }
        out << c;
    }
};


int main() {
    DAlterAltar solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3748
#include<stdio.h>
#include<math.h>
int x[100010], sum[100010];
int min_o(int a, int b, int c)
{
	int min = (a < b) ? a : b;
	min = (min < c) ? min: c;
	return min;
}
int main()
{
	int n, k;
	int i, j, p = 0, min = 0x3f3f3f3f;
	scanf("%d%d", &n, &k);
	for (i = 1; i <= n; i++)
	{
		scanf("%d", &x[i]);
		if (!p&&x[i] >= 0)
			p = i;
	}
	if (p == 0)
		p = n + 1;
	if (k == 1)
	{
		for (i = 1; i <= n; i++)
			min = (min < fabs(x[i])) ? min : fabs(x[i]);
	}
	else
	{
		i = 1, j = k;
		for (; j <= n;)
		{
			if (i < p&&j < p)
				min = (min < fabs(x[i])) ? min : fabs(x[i]);
			else if (i >= p && j > p)
				min = (min < x[j]) ? min : x[j];
			else if (i < p&&j >= p)
				min = min_o(min, 2 * x[j] + fabs(x[i]), 2 * fabs(x[i]) + x[j]);
			i++; j++;
		}
	}
	printf("%d", min);
	return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        boolean b = true;
        int count = x;
        while (b){
            boolean c = true;
            for (int i=2;i<=Math.sqrt(x)&&c;i++){
                    if (count%i==0){
                        c=false;
                        count++;
                    }
            }
            if (c){
                System.out.println(count);
                b=false;
            }
        }


    }

}

Measured memory_bytes: 23764
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    auto ans = new long[](N);
    foreach (a; A)
    {
        ans[a - 1]++;
    }
    foreach (a; ans)
    {
        writeln(a);
    }
}


Measured memory_bytes: 12460
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ll infll=(1ull<<63)-1;
const int inf=(1ull<<31)-1;
int l,r,ans=inf;
 
int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>l>>r;
	if (r-l>=2018)
		cout<<"0";
	else {
		l%=2019;
		r%=2019;
		int t=r-l+1;
		if (t<0)
			t+=2019;
		int a[t];
		for (int i=0;i<t;i++)
			a[i]=(i+l)%2019;
		for (int i=0;i<t;i++)
			for (int j=i+1;j<t;j++)
				ans=min(ans,(a[i]*a[j])%2019);
		cout<<ans;
	}
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    //sieve();
    ll T=1,t,n,m,q,ans=0,i,j;
    // cin>>T;
    while(T--)
    {
        string st;
        char cur;
        cin>>st;
        n = st.length();
        cur = st[0];
        FOR(i,1,n)
        {
            if(st[i]!=cur)
            {
                ans++;
                cur = st[i];
            }
        }
        cout<<ans<<endl;
        
    }
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Curtain
            var line = ReadLine();
            int A = line[0];
            int B = line[1];

            if (A > B * 2)
            {
                Console.WriteLine(A - B * 2);
            }
            else
            {
                Console.WriteLine(0);
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13268
//余計なコード入っていたので再提出
#include<iostream>
using namespace std;

int main(){
    int A,B,K;
    cin >>A>>B>>K;
    int count = 0;

    int m = min(A,B);

    for(int i = m; 0 < i; i-- ){
        //iは変数、mは定数だという認識をちゃんと持っていないと
        //ここをmにしてしまう。
        if(A % i == 0 && B % i == 0){
            count++;
        }
        if(count == K){
            cout << i << endl;
            return 0;
        }
    }
    

}

Measured memory_bytes: 256
#include<cstdio>
     
    int A,B,cnt;
     
    int Get(int x) {
    	return 100*x+x/10%10*10+x/100;
    }
     
    int main() {
    	scanf("%d %d",&A,&B);
    	int a=A/100,b=B/100;
    	for(int i=a;i<=b;i++) {
    		int x=Get(i);
    		if(A<=x&&x<=B) cnt++;
    	}
    	printf("%d\n",cnt);
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    string s;
    cin >> a >> s;
    if(a > 3199){
    cout <<s<< "\n";
    }else{
        cout <<"red" <<  "\n";
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {

    int arr[5];
    scanf("%d %d %d %d %d", &arr[0], &arr[1], &arr[2], &arr[3], &arr[4]);

    int mysum = 0;
    int mindata = 10;

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

        if (arr[i] % 10 == 0) {

            mysum += arr[i];

        } else {

            mysum += ((arr[i] / 10) + 1)*10;

            mindata = (mindata > arr[i] % 10) ? arr[i] % 10 : mindata;

        }

    }

    if (mindata != 10) {
        mysum -= 10;
        mysum += mindata;
    }

    printf("%d", mysum);

    return 0;
}


Measured memory_bytes: 128
//jinhaonan
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
template<class T>inline void read(T &x){
	x=0;char c=getchar();bool f=0;
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';x=(x<<1)+(x<<3)+c-'0',c=getchar());
	x=f?-x:x;
}
template<class T>inline void write(T x){
	if(x<0)putchar('-'),x=-x;
	if(x>=10)write(x/10);
	putchar(x%10+48);
}
template<class T>inline bool chkmax(T &a,T const &b){
	return a<b?a=b,1:0;
}
template<class T>inline bool chkmin(T &a,T const &b){
	return a>b?a=b,1:0;
} 
long long base=9901;
long long mo=1000000000000000031ll;
 
long long Mul(long long a,long long b){
	return (__int128)a*b%mo;
}
long long Add(long long a,long long b){
	return (a+b)%mo;
}
long long Pow(__int128 a,long long b){
	__int128 res=1;
	for(;b;b>>=1,a=a*a%mo)
		if(b&1)
			res=res*a%mo;
	return res;
}
vector<pair<long long,long long>> v;
map<long long,int> mp;
int main(){
	static char s[250000+10];
	int n;
	scanf("%d%s",&n,s);
	long long inv=Pow(base,mo-2);
	long long pos=1,val=0;
	v.push_back(make_pair(val,pos));
	for(int i=0;i<n;++i){
		if(s[i]=='<'){
			pos=Mul(pos,inv);
		}else if(s[i]=='>'){
			pos=Mul(pos,base);
		}else if(s[i]=='+'){
			val=Add(val,pos);
		}else if(s[i]=='-'){
			val=Add(val,mo-pos);
		}
		v.push_back(make_pair(val,pos));
	}
	long long V=v.back().first;
	long long ans=0;
	for(int i=v.size()-1;i>=0;--i){
		auto it=mp.find(Add(v[i].first,Mul(V,v[i].second)));
		if(it!=mp.end()){
			ans+=it->second;
		}
		++mp[v[i].first];
	}
	write(ans),putchar('\n');
	return 0;
}

Measured memory_bytes: 20076
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int n, h[100005], f[100005];
void init(){
    n = read();
    for (int i = 1; i <= n; ++i)    
        h[i] = read();
}
void solve(){
    f[1] = 0, f[2] = abs(h[1] - h[2]);
    for (int i = 3; i <= n; ++i)
        f[i] = min(f[i - 1] + abs(h[i] - h[i - 1]), f[i - 2] + abs(h[i] - h[i - 2]));
    printf("%d\n", f[n]);
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 1024
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use std::mem::swap;
use nalgebra::max;
use std::collections::VecDeque;

#[fastout]
fn main() {
    input! {
    n: usize,
    a:[[Usize1; n - 1]; n]
    }
    let mut a = a;
    let mut g:Vec<Vec<usize>> = vec![vec![]; 1000000];
    let mut id = vec![vec![0; n]; n];
    let mut v = 0;
    for i in 0..n {
        for j in 0..n {
            if i < j {
                id[i][j] = v;
                v += 1;
            }
        }
    }
    let mut es = vec![];
    for i in 0..n {
        for j in 0..n - 1 {
            a[i][j] = to_id(i, a[i][j], &id)
        }
        for j in 0..n - 2 {
            g[a[i][j + 1]].push(a[i][j]);
            es.push((a[i][j], a[i][j + 1]))
        }
    }
    let mut ans = 0;
    if topological(&es, v).len() != v {
        println!("-1");
        return;
    }
    let mut dp = vec![-1; 1000000];
    for i in 0..v{
        let res = dfs(i, &g, &mut dp);
        ans = max(ans, res);
    }
    println!("{}", ans);
}

fn to_id(i: usize, j: usize, id: &Vec<Vec<usize>>) -> usize {
    return if i < j {
        id[i][j]
    } else {
        id[j][i]
    };
}

fn dfs (i: usize, g: &Vec<Vec<usize>>, dp: &mut Vec<i32>) -> i32 {
    if dp[i] > 0 {
        return dp[i];
    }
    dp[i] = 1;
    for &j in &g[i] {
        let res = dfs(j, g, dp);
        dp[i] = max(dp[i], res + 1);
    }
    dp[i]
}

// O(V + E)
fn topological(es: &Vec<(usize, usize)>, n: usize) -> Vec<usize> {
    let mut g = vec![vec![]; n];
    let mut d = vec![0; n];
    for e in es {
        g[e.0].push(e.1);
        d[e.1] += 1;
    }
    let mut res = vec![];
    let mut q = VecDeque::new();
    for i in 0..n {
        if d[i] == 0 {
            q.push_back(i);
        }
    }
    while !q.is_empty() {
        let v = q.pop_front().unwrap();
        for &i in &g[v] {
            d[i] -= 1;
            if d[i] == 0 {
                q.push_back(i);
            }
        }
        res.push(v);
    }
    res
}



Measured memory_bytes: 109460
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
   int cnt, rdge, flr, th, num;
   string mk;
    
   cin >> cnt;
   
   // b棟 f階 r番目 v人
   int a[3][10] = {
            {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
          };
          
    int b[3][10] = {
            {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
          };
    
    int c[3][10] = {
            {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
          };
   
   int d[3][10] = {
            {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
          };
   
   for(int i=0; i < cnt; i++){
       cin >> rdge >> flr >> th >> num;
      
        if(rdge==1) {
            a[flr-1][th-1] = num + a[flr-1][th-1];
        }else if(rdge==2){
            b[flr-1][th-1] = num + b[flr-1][th-1];
        }else if(rdge==3){
            c[flr-1][th-1] = num + c[flr-1][th-1];
        }else if(rdge==4){
            d[flr-1][th-1] = num + d[flr-1][th-1];
        }
   }
   for(int i=0; i<4; i++){
       for(int k=0; k<3; k++){
           for(int m=0; m< 10; m++){
               if(i==0){
                    cout << " "<< a[k][m];      
               }else if(i==1){
                    cout << " " << b[k][m];      
               }else if(i==2){
                    cout << " " << c[k][m];      
               }else if(i==3){
                    cout << " " << d[k][m];
               }
           }
           cout << endl;
       }
       if(i!=3){
            cout << "####################" << endl;    
       }
   }
}



Measured memory_bytes: 3080
def main():
    n,k = map(int, input().split())
    X = list(map(int, input().split()))

    tmp = []
    for i in range(n-k+1):
        l = X[i]
        r = X[i+k-1]
        tmp.append(abs(l)+abs(r-l))
        tmp.append(abs(r)+abs(r-l))
    print(min(tmp))


if __name__ == '__main__':
    main()


Measured memory_bytes: 63256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 104
#define W 300004
#define INF 1e9+7

using namespace std;

ll n,w,ans;
pi ar[N];
ll dp[N][W];

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

    cin >> n >> w;

    rep(i,1,n+1)
    {
        cin >> ar[i].first >> ar[i].second;
    }

    rep(i,1,n+1)
    {
        rep(j,0,w+1)
            dp[i][j] = (j < ar[i].first) ? dp[i-1][j] : max(dp[i-1][j],dp[i-1][j-ar[i].first] + ar[i].second);
    }

    rep(j,0,w+1)
        ans=max(ans,dp[n][j]);

    cout << ans;

    return 0;
}


Measured memory_bytes: 233728
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException {
		// 2020/1/30 No.152
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);

		if (n == m )
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 21076
#include <stdio.h>
#include <string.h>
int main(int argc, char const *argv[]) {
  char S[6];

  scanf("%s",S);
  if(strcmp(S,"Sunny")==0){
    printf("Cloudy");
  }else if(strcmp(S, "Cloudy")==0){
    printf("Rainy");
  }else{
    printf("Sunny");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <utility>
#include <algorithm>
using namespace std;

int main(void){

    vector<int> v(3);
    
    cin>>v[0]>>v[1]>>v[2];
    
    sort(v.begin(), v.end());
    cout<<v[0]+v[1]<<endl;

}


Measured memory_bytes: 764
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

R, C, K = mapint()
last_dp = [[0]*4 for _ in range(C)]
dic = [[0]*C for _ in range(R)]
for _ in range(K):
    r, c, v = mapint()
    dic[r-1][c-1] = v

for r in range(R):
    dp = [[0]*4 for _ in range(C)]
    for c in range(C):
        v = dic[r][c]
        for i in range(4):
            if c!=0:
                dp[c][i] = dp[c-1][i]
            if r!=0:
                dp[c][0] = max(dp[c][0], last_dp[c][i])
        if v!=0:
            for i in range(2, -1, -1):
                dp[c][i+1] = max(dp[c][i+1], dp[c][i]+v)
    last_dp = dp

print(max(dp[C-1]))

Measured memory_bytes: 207748
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/* Coding Space*/
class FermatCombination{
public:
  vector<ll> factrial; // 階乗
  vector<ll> inverse; // 逆元
  FermatCombination(int size){
    factrial.resize(size+1);
    inverse.resize(size+1);
    factrial[0] = 1;
    inverse[0] = 1;
    for(int i = 1; i < size+1; i++){
      factrial[i] = factrial[i-1] * i % DIV;
      inverse[i] = pow(factrial[i],DIV-2,DIV);
    }
  }
  ll combination(int n, int k){
    if(n < k) return 0; 
    return factrial[n]* inverse[k] % DIV * inverse[n - k] % DIV;
  }
  ll permutation(int n, int k){
    if(n < k) return 0; 
    return factrial[n] * inverse[n-k] % DIV;
  }
  ll multi_choose(int n, int k){
    if(n == 0 && k == 0) return 1;
    else return combination(n+k-1,k);
  }
};

ll dp[1010][1010] = {}; // i : members of group, j : number of using.

int main(){
  int n,a,b,c,d; cin >> n >> a >> b >> c >> d;
  FermatCombination fc(n+1);
  rep(i,1010) dp[i][0] = 1;
  
  for(int i = a; i <= b; i++)
    for(int j = 0; j <= n; j++){
      if(dp[i][j] == 0) continue;
      if(j != 0){
        dp[i+1][j] += dp[i][j];
        dp[i][j] %= DIV;
      }
      ll tmp = 1;
      for(int k = 1; k <= d; k++){
        if(j + i * k > n) break;
        tmp *= fc.combination(n-j-i*(k-1), i ) * pow(k, DIV-2,DIV) % DIV;
        tmp %= DIV;
        tmp %= DIV;
        if(k >= c && k <= d){
          dp[i+1][j+i*k] += (1LL * dp[i][j] * tmp) % DIV;
          dp[i+1][j+i*k] %= DIV;
        }
      }
    }
  cout << dp[b+1][n] % DIV << endl;
}

Measured memory_bytes: 8192
<?php
$a = explode(" ",trim(fgets(STDIN)));
$w = 0;
$x = 0;
$y = 0;
$z = 0;
foreach($a as $value){
if($value == 1){
$w = 1;
}
elseif($value == 4){
$x = 1;
}
elseif($value == 7){
$y = 1;
}
elseif($value == 9){
$z = 1;
}
}
if($w+$x+$y+$z==4){
echo 'YES';
}else{
echo 'NO';
}

Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <string.h>
#include <cmath>
#include <algorithm>
#define lli long long int 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

int main()
{
    fio;
    lli a,b;
    cin>>a>>b;
    char arr[a][b];
    for (int i=0;i<a;i++)
    {
        for (int j=0;j<b;j++)
        cin>>arr[i][j];
    }
    lli dp[a][b];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for (int i=0;i<a;i++)
    {
        for (int j=0;j<b;j++)
        {
            if (arr[i][j]!='#')
            {
            if (i>0)
            dp[i][j]+=(dp[i-1][j])%1000000007;
            if (j>0)
            dp[i][j]+=(dp[i][j-1])%1000000007;
            }
        }
    }
    cout<<dp[a-1][b-1]%1000000007;
	return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18,MOD = 1e9 + 7;
const int INT_INF = 1e9,INT_MOD=1e9+7;
#define rep(i, N) for(int i = 0; i < N; i++)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a){
        cout<<k<<endl;
        return 0;
    }else if(k<=a+b){
        cout<<a<<endl;
        return 0;
    }else if(k<=a+b+c){
        cout<<a-(k-a-b)<<endl;
        return 0;
    }else{
        cout<<a-c<<endl;
        return 0;
    }

    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main() {
    int a, b, k;
    cin >> k >> a >> b;
    bool flag = false;
    for (int i = a; i <= b; ++i)
        if (i % k == 0) {
            flag = true;
            break;
        }
    if (flag) cout << "OK\n";
    else cout << "NG\n";
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)

const int N=200005;

int ans[N],stack[N],top;

int main(void) {
	int a,b; scanf("%d%d",&a,&b);
	if (a<=b) return 0&printf("Impossible\n");
	int n=a+b;
	rep(i,0,n-1) {
		if (!top) {
			stack[++top]=i;
			continue;
		}
		printf("? %d %d\n", stack[top],i);
		fflush(stdout);
		char ch[2]; scanf("%s",ch);
		if (ch[0]=='Y') stack[++top]=i;
		else top--;
	}
	ans[stack[top]]=1;
	rep(i,0,n-1) if (i!=stack[top]) {
		printf("? %d %d\n", stack[top],i);
		fflush(stdout);
		char ch[2]; scanf("%s",ch);
		if (ch[0]=='Y') ans[i]=1;
	}
	printf("! ");
	rep(i,0,n-1) putchar(ans[i]+'0');
	puts("");
	return 0;
}

Measured memory_bytes: 632
#include<bits/stdc++.h>
using namespace std;
#define int             long long int
#define ld                 long double
#define ff                 first
#define ss                 second
#define P                 pair<int,int>
#define pb                 push_back
#define mod             1000000007
#define inf             1e18
#define endl            '\n'
const int N = 100005;//change it when needed
unordered_map<int, list<int>>gr;
int vis[N];
int dp[N];
int n, m;
void dfs(int curr) {
    vis[curr] = 1;
    for (auto ch : gr[curr]) {
        if (!vis[ch])
            dfs(ch);
        dp[curr] = max(dp[curr], 1 + dp[ch]);
    }
}
void solve() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        gr[x].pb(y);
    }

    memset(dp, 0, sizeof(dp));
    memset(vis, 0, sizeof(vis));
    for (int i = 1; i <= n; i++) {
        if (!vis[i]) {
            dfs(i);
        }
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, dp[i]);
    }
    cout << ans << endl;
}

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

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

int main() {

  bool flg = true;
  
  int i = 1;
  int x = 0;
  
  while(flg) {
  
    cin >> x;
    
    if (x == 0) {
    	flg = false;
    } else {
      cout << "Case " << i << ": " << x << endl; 
    }
    
    i++;
  }

  return 0;
}


Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

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

	ll ans = n * (n + 1) * (n + 2) / 6;
	ce(ans);

	rep(i, n - 1){
		ll u, v;
		cin >> u >> v;
		if (u > v) swap(u, v);
		ans -= u * (n + 1 - v);
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,x,d=0,ans=1;
	cin>>n>>x;
	int a[n+1];
	for(int i=1;i<=n;i++)cin>>a[i];
	int s[10001];
	s[0]=0;
	for(int i=1;i<=n;i++){
		s[i]=a[i]+s[i-1];
		if(s[i]<=x)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string x = Console.ReadLine();

            if(((x[0] != x[1]) && (x[1] != x[2]) && (x[2] != x[3])))
               
            {
                Console.WriteLine("Good");
            }
            else
            {
                Console.WriteLine("Bad");
            }

        }
        }
    }



Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		int[] num = new int[4];
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String st =sc.nextLine().split(",")[1];
			if(st.equals("A")){
				num[0]++;
			}else if(st.equals("B")){
				num[1]++;
			}else if(st.equals("AB")){
				num[2]++;
			}else if(st.equals("O")){
				num[3]++;
			}
		}
		for(int i = 0 ; i < num.length ; i++){
			System.out.println(num[i]);
		}
		sc.close();
	}
}

Measured memory_bytes: 17336
s=input()
t=input()
l=[]
for i in range(len(s)-len(t)+1):
    for j in range(len(t)):
        if s[i+j]!=t[j] and s[i+j]!='?':
            break
    else:
        a=s[:i]+t+s[i+len(t):]
        l.append(a.replace('?', 'a'))
l.sort()
if l:
    print(l[0])
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  while (true) {
    int n, m; cin >> n >> m;
    if (n == 0) break;
    V<> a(11);
    for (int i = 0; i < n; ++i) {
      int d, p; cin >> d >> p;
      a[p] += d;
    }
    int p = 10;
    while (m > 0) {
      if (a[p] <= m) {
        m -= a[p];
        a[p] = 0;
        if (--p < 0) break;
      } else {
        a[p] -= m;
        m = 0;
      }
    }
    int res = 0;
    for (int p = 0; p <= 10; ++p) {
      res += p * a[p];
    }
    cout << res << '\n';
  }
}


Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <vector>
#include <random>
#include <algorithm>

using std::cout;
using std::cerr;
using std::cin;
using std::endl;

using std::vector;
using std::string;

void func() {

	int a;
	string s;

	cin >> a;
	cin >> s;
  
    cerr << a << endl;
    cerr << s<< endl;
	if (a >= 3200) {
		cout << s << endl;;
	}
	else {
		cout << "red" << endl;
	}
}
int main() {
	func();

}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    string s; cin >> s;
    int si = SIZE(s);
    char c = s[si-1];
    if(c == '2' || c == '4' || c == '5' || c == '7' || c == '9') cout << "hon" << endl;
    else if(c == '3') cout << "bon" << endl;
    else cout << "pon" << endl;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    string c;
    cin >> c;
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        if (c[i] == 'R')
        {
            count++;
        }
    }
    int red_count = 0;
    for (int i = 0; i < count; i++)
    {
        if (c[i] == 'R')
            red_count++;
    }
    cout << count - red_count << endl;
}

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

using namespace std;

using i64 = long long;

const i64 MOD = 998244353;
const i64 INF = 998244353;

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


template <i64 mod = MOD>
struct ModInt{
    i64 p;

    ModInt() : p(0){}
    ModInt(i64 x){p = x >= 0 ? x % mod : x + (-x + mod - 1) / mod * mod;}

    ModInt& operator+=(const ModInt& y){p = p + *y - ((p + *y) >= mod ? mod : 0); return *this;}
    ModInt& operator-=(const ModInt& y){p = p - *y + (p - *y < 0 ? mod : 0); return *this;}
    ModInt& operator*=(const ModInt& y){p = (p * *y) % mod; return *this;}
    ModInt& operator%=(const ModInt& y){if(y)p %= *y; return *this;}

    ModInt operator+(const ModInt& y) const{ModInt x = *this; return x += y;}
    ModInt operator-(const ModInt& y) const{ModInt x = *this; return x -= y;}
    ModInt operator*(const ModInt& y) const{ModInt x = *this; return x *= y;}
    ModInt operator%(const ModInt& y) const{ModInt x = *this; return x %= y;}

    friend ostream& operator<<(ostream& stream, const ModInt<mod>& x){
        stream << *x;
        return stream;
    }

    friend ostream& operator>>(ostream& stream, const ModInt<mod>& x){
        stream >> *x;
        return stream;
    }

    ModInt& operator++(){p = (p + 1) % mod; return *this;}
    ModInt& operator--(){p = (p - 1 + mod) % mod; return *this;}

    bool operator==(const ModInt& y) const{return p == *y;}
    bool operator!=(const ModInt& y) const{return p != *y;}

    const i64& operator*() const{return p;}
    i64& operator*(){return p;}

};

using mint = ModInt<>;

auto mpow = [](auto x, i64 y){
    auto z = x;
    decltype(x) val = y & 1 ? x : decltype(x)(1);
    while(z *= z, y >>= 1)
        if(y & 1)
            val *= z;
    return val;
};




signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    map<int,int> v;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        ++v[a[i]];
    }
    if(a[0] != 0 || v[0] != 1){
        cout << 0 << endl;
        return 0;
    }
    int ma = *max_element(a.begin(), a.end());

    mint ans = 1;
    for(int i = 1; i <= ma; ++i){
        if(v[i] == 0){
            cout << 0 << endl;
            return 0;
        }
        ans *= mpow(mint(v[i - 1]), v[i]);
    }
    cout << ans << endl;
}


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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long
#define ld long double

const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    string a;
    cin >> a;
    vector<int> sufr(n + 1), sufg(n + 1), sufb(n + 1);
    for (int i = n - 1; i >= 0; i--) sufr[i] = sufr[i + 1] + (a[i] == 'R');
    for (int i = n - 1; i >= 0; i--) sufg[i] = sufg[i + 1] + (a[i] == 'G');
    for (int i = n - 1; i >= 0; i--) sufb[i] = sufb[i + 1] + (a[i] == 'B');
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] == a[j]) continue;
            if ((a[i] == 'R' && a[j] == 'G') || (a[i] == 'G' && a[j] == 'R')) {
                ans += sufb[j + 1];
                if (j + j - i < n && a[j + j - i] == 'B') ans--;
            }
            if ((a[i] == 'B' && a[j] == 'G') || (a[i] == 'G' && a[j] == 'B')) {
                ans += sufr[j + 1];
                if (j + j - i < n && a[j + j - i] == 'R') ans--;
            }
            if ((a[i] == 'R' && a[j] == 'B') || (a[i] == 'B' && a[j] == 'R')) {
                ans += sufg[j + 1];
                if (j + j - i < n && a[j + j - i] == 'G') ans--;
            }
        }
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 3600
N = int(input())
A = [0] * N
for i in range(N):
  A[i] = int(input())

B = sorted(A)
m, n = B[N - 2], B[N - 1]
tie = False
if m == n:
  tie = True

for i in range(N):
  if A[i] == n:
    if tie:
      print(n)
    else:
      print(m)
  else:
    print(n)

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

int main(){
    int n,k;
    string S;
    cin>>n>>k;
    cin>>S;
    if(S[k-1]=='A')S[k-1]='a';
    if(S[k-1]=='B')S[k-1]='b';
    if(S[k-1]=='C')S[k-1]='c';
    
    cout<<S<<endl;
    
    return 0;
}


Measured memory_bytes: 256
const MOD: i64 = 1000000007;


fn main() {
    let (n, k) = read_tuple::<usize>();
    let mut an: Vec<i64> = read_vec();
    an.sort();

    let c = Comb::new(n + 1, MOD);

    let mut ans: i64 = 0;

    for (i, max_x) in an.iter().skip(k-1).enumerate() {
        ans += max_x * c.nck(i + k - 1, k - 1) % MOD;
        ans %= MOD;
        if ans < 0 {
            ans += MOD;
        }
    }
    an.reverse();
    for (i, min_x) in an.iter().skip(k-1).enumerate() {
        ans -= min_x * c.nck(i + k - 1, k - 1) % MOD;
        ans %= MOD;
        if ans < 0 {
            ans += MOD;
        }
    }

    println!("{:?}", ans);

}

/// for nCk
pub struct Comb {
    max: usize,
    m: i64,
    fac: Vec<i64>,
    finv: Vec<i64>,
}

impl Comb {
    /// initialize table 
    /// max: maximum that n as nCk takes
    /// m: MOD, a prime number
    /// O(n)
    pub fn new(max: usize, m: i64) -> Comb {
        let n = max;
        let mut fac = Vec::with_capacity(n);
        fac.push(1);
        fac.push(1);
        let mut finv = Vec::with_capacity(n);
        finv.push(1);
        finv.push(1);
        let mut inv = Vec::with_capacity(n);
        inv.push(1);
        inv.push(1);

        for i in 2..n {
            let i = i as i64;
            let tmp = fac.last().unwrap() * i % m;
            fac.push(tmp);
            let tmp = m - inv[(m % i) as usize] * (m / i) % m;
            inv.push(tmp);
            let tmp = finv.last().unwrap() * inv.last().unwrap() % m;
            finv.push(tmp);
        }

        Comb {
            max: max,
            m: m,
            fac: fac,
            finv: finv
        }
    }

    /// nCk
    pub fn nck(&self, n: usize, k: usize) -> i64 {
        // since n, k are usize, do not need to check `n < 0 || k < 0`
        if n < k || n > self.max {
            panic!("Invalid query (n, k) = ({}, {})", n, k);
        } else {
            self.fac[n] * (self.finv[k] * self.finv[n - k] % self.m) % self.m
        }
    }
}


fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let temp = read_vec();
    (temp[0], temp[1])
}


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

int main() {
  string s;
  cin >> s;
  
  int judge = 0, i, j;
  for(i = 0; i <= s.size() - 2; i++){
    for(j = i + 1; j <= s.size() - 1; j++){
      if(s.at(i) == s.at(j)){
        judge++;
        break;
      }
    }
  }
  
  if(judge > 0){
    cout << "no" << endl;
  }
  else{
    cout << "yes" << endl;
  }
}


Measured memory_bytes: 256