akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	string s; cin >> s;
	int mae, ato;
	mae = stoi(s) / 100;
	ato = stoi(s) % 100;
	bool isMaeMM, isAtoMM;
	isMaeMM = isAtoMM = false;
	if (1 <= mae && mae <= 12)isMaeMM = true;
	if (1 <= ato && ato <= 12)isAtoMM = true;
	if (isMaeMM && !isAtoMM)cout << "MMYY" << endl;
	else if (!isMaeMM && isAtoMM)cout << "YYMM" << endl;
	else if (isMaeMM && isAtoMM)cout << "AMBIGUOUS" << endl;
	else cout << "NA" << endl;
}

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

int main() {
    int A, B;
    cin >> A >> B;
    int count = 0;
    
    for (int i = A; i <= B; i++) {
        string num = to_string(i);
        int k = num.size();
        
        for (int j = 0; j <= k/2; j++) {
            if (num.at(j) != num.at(k-1-j)) {
                break;
            }
            if (j == k/2) {
                count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
require "complex"

N, D = gets.chomp.split.map(&:to_i)
X = N.times.map { gets.chomp.split.map(&:to_f) }

ans = 0
X.combination(2) { |y, z|
  sum = 0
  for i in 0..D - 1
    sum += (y[i] - z[i]) ** 2
  end
  n = 1
  while n ** 2 <= sum
    if n ** 2 == sum
      ans += 1
      break
    end
    n += 1
  end
}

puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;

vector<long long int> inverse;
vector<long long int> f, f_inverse;

void factorial_Initialize(int max){
    vector<long long int> a(max+1,1);
    inverse = a;
    f = a;
    f_inverse = a;

    for (int i=2; i<=max; i++){
        inverse[i]   = MOD - inverse[MOD % i] * (MOD / i) % MOD;
        f[i]         = f[i-1]         * i          % MOD;
        f_inverse[i] = f_inverse[i-1] * inverse[i] % MOD;
    }
}

long long int nCr(int n, int r){
    if(n < r || r < 0) return 0;
    else return f[n] * f_inverse[r] % MOD * f_inverse[n-r] % MOD;
}

int main(){
    int h, w, a, b;
    cin >> h >> w >> a >> b;

    long long int ans = 0;
    factorial_Initialize(200000);
    for(int j=b; j<w; j++){
        ans = (ans + nCr(h-a-1+j, h-a-1) * nCr(a-1+w-j-1, a-1) % MOD) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>
#include <string.h>

int main() {
  char s[100],  p[100], s_origin[100], s_var[100], s_left[100];
  int i = 0;
  scanf("%s \n", s);
  scanf("%s \n", p);
  strcpy(s_origin,s);
  for( i = 0; s[i] != '\0' ; i++) {
    strcpy(s_var, s);
    strcat(s_var, s_left);
    if( strstr(s_var, p) != NULL) {
      printf("Yes\n");
      return 0;
    }
    s_left[i] = s[i];
    s_left[i + 1] ='\0';
  }
  printf("No\n");
  return 0;
}


Measured memory_bytes: 2104
#include<queue>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int w,h;
  cin>>h>>w;
  int a[51][51];
  memset(a,-1,sizeof(a));
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      char s;
      cin>>s;
      a[j][i]=s-'0';
    }
  }
  unsigned b[51][51];
  memset(b,-1,sizeof(b));
  queue<pair<pair<int,int>,int> > c;
  c.push(make_pair(make_pair(0,0),0));
  while(c.empty()==0){
    int x,y,z;
    x=c.front().first.first;
    y=c.front().first.second;
    z=c.front().second;
    c.pop();
    if(a[x][y]!=-1&&b[x][y]>(unsigned)z){
      b[x][y]=z;
      c.push(make_pair(make_pair(x+1,y),z+a[x][y]));
      c.push(make_pair(make_pair(x,y+1),z+a[x][y]));
    }
  }
  cout<<b[w-1][h-1]<<endl;
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <vector>
#include <iomanip>

using namespace std;

int main(void) {
  int N;
  cin >> N;
  cout << (N - 2) * 180 << endl;
  return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var input1 = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
        var input2 = Console.ReadLine().Split().Select(x => long.Parse(x)).ToList();
        var _N = input1[0];
        var _M = input1[1];
        var _aList = input2.Distinct().OrderBy(x => -x).Select(x => x / 2).ToArray();
        long total = 1;
        foreach(var a in _aList)
        {
            total = Lcm(total, a);
        }
        long ans = 0;
        var flg = true;
        foreach (var a in _aList)
        {
            if((total / a) % 2 == 0)
            {
                flg = false;
                break;
            }
        }
        if (flg)
        {
            ans = (_M / total);
            ans = (ans / 2) + (ans % 2);
        }
        Console.WriteLine(ans);
        Console.ReadLine();
    }

    public static long Lcm(long a, long b) => a * b / Gcd(a, b);
    public static long Gcd(long a, long b) => a > b ? GcdRecursive(a, b) : GcdRecursive(b, a);
    static long GcdRecursive(long a, long b) => b == 0 ? a : GcdRecursive(b, a % b);
}

Measured memory_bytes: 28892
#include <bits/stdc++.h>
using namespace std;
template<class T> void chmin (T &a, T b) { if (a > b) a = b; }
constexpr long long INF = (1LL<<60);

int main() {
    int n, k;
    cin >> n >> k;
    vector<long long> a(n+1);
    for (int i = 0; i < n; i++) cin >> a[i+1];
    
    vector<vector<long long>> dp(n+1, vector<long long>(k+1, INF));
    dp[0][k] = 0;
    for (int from = 0; from < n; from++) {
        for (int j = 0; j <= k; j++) if (dp[from][j] < INF) {
           for (int to = from+1; to <= n and to-from-1 <= j; to++) {
               chmin(dp[to][j-(to-from-1)], dp[from][j] + max(0LL, a[to] - a[from]));
           }
        }
    }
    
    long long ans = INF;
    for (int i = 0; i <= k; i++) chmin(ans, dp[n-i][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpln(n)
a.sort()
if n%2 == 0:
    res = 0
    for i in range(n//2-1):
        res -= a[i] * 2
        res += a[n-i-1] * 2
    res += a[n//2] - a[n//2-1]
    print(res)
else:
    res_1 = 0
    res_2 = 0
    l = a[:n//2]
    r = a[n//2:]
    res_1 = sum(r)*2 - (r[0] + r[1]) - sum(l)*2 
    
    l = a[:n//2+1]
    r = a[n//2+1:]
    res_2 = sum(r)*2 - sum(l)*2 + l[-1]+l[-2]
    print(max(res_1, res_2))


Measured memory_bytes: 71640
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var L = one[0];
	var R = one[1];
	var d = one[2];
	var output = 0;
	for(var i = L; i <= R; i++){
		if(i % d == 0){
			output++;
		}
	}
	myout(output);
}


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

int main(){
  unsigned long long int a,b,c;
  cin>>a>>b>>c;
  unsigned long long int d=a/c;
  unsigned long long int e=b/c;
  if(a%c==0)
    cout<<e-d+1<<endl;
  else
    cout<<e-d<<endl;
}

Measured memory_bytes: 256
import sys, math

# input = sys.stdin.readline

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
S = [[1 if s=='.' else 0 for s in input()] for _ in range(H)]
costs = [[math.inf]*W for _ in range(H)]
costs[Ch-1][Cw-1] = 0
que = [(0, Ch-1, Cw-1)]
next_que = []

while len(next_que)>0 or len(que)>0:
    while len(que)>0:
        c, h, w = que.pop(0)
        if c >= costs[Dh-1][Dw-1]:
            print(costs[Dh-1][Dw-1])
            sys.exit()
        for i, j in [(h-1, w), (h+1, w), (h, w-1), (h, w+1)]:
            if i < 0 or j < 0 or i>=H or j>=W:
                continue
            if i == Dh - 1 and j == Dw - 1:
                print(c)
                sys.exit()
            if S[i][j] and costs[i][j] > c:
                costs[i][j] = c
                que.append((c, i, j))
        for dw in [-2, -1, 0, 1, 2]:
            for dh in [-2, -1, 0, 1, 2]:
                if w+dw < 0 or h+dh < 0 or w+dw>=W or h+dh>=H:
                    continue
                if S[h+dh][w+dw] and costs[h+dh][w+dw] > c+1:
                    costs[h+dh][w+dw] = c+1
                    next_que.append((c+1, h+dh, w+dw))
    que = next_que
    next_que = []

print(-1)


Measured memory_bytes: 129608
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(1000000000)

N, *XY = map(int,open(0).read().split())
MOD = 10**9 + 7

neighbor = [[] for _ in range(N)]
for x,y in zip(*[iter(XY)]*2):
    neighbor[x-1] += y-1,
    neighbor[y-1] += x-1,

parent = {0}

def dp(node):
    black_output = white_output = 1
    for child in neighbor[node]:
        if child in parent:
            continue
        else:
            parent.add(child)
            tmp_black, tmp_white = dp(child)
            black_output *= tmp_white
            white_output *= tmp_black + tmp_white
    black_output %= MOD
    white_output %= MOD
    return black_output, white_output

print(sum(dp(0)) % MOD)

Measured memory_bytes: 216336
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define I using
#define AK namespace
#define IOI std
#define mod 1000000007
#define ll long long

I AK IOI;

const int N = 0;

int a, b;

int main()
{
	scanf("%d%d", &a, &b);
	printf("%d\n", (a + b + 1) / 2);
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
ab = [[int(i) for i in input().split()] for j in range(m)]

im_b = [0]*(n)

for i in range(m):
    im_b[ab[i][0]-1] += 1
    im_b[ab[i][1]-1] -= 1

if im_b[0] % 2 == 1:
    print('NO')
    exit()

#im_a = [0]*(n)
#im_a[0] = im_b[0]

for i in range(n-1):
    #print(i)
    if im_b[i] % 2 == 1:
        print('NO')
        exit()

print('YES')

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

if (N%1000==0){
cout<<0<<endl;
}
else {
cout<<(((N/1000)+1)*1000)-N<<endl;
}    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}

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


int main() {
  int a,b,x;
  cin >> a >> b >> x;
  int c = a + b;
  if (a <= x) {
    if (c >= x) cout << "YES";
    else cout << "NO";
  }
  else cout << "NO";
  cout << endl;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long    ll;
typedef long double  ld;

#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)

#define endl '\n'
#define INF  0x7f7f7f7f7f7f7f7f
#define INFi 0x7f7f7f7f


ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll solve(ll N, ll R) {
  return 10 <= N ? R : R + 100 * (10 - N);
}

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

  ll N, R;
  
  cin >> N >> R;

  auto ans = solve(N, R);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3128
n, a, b, c, d = map(int, input().split())
s = input()

a -= 1
b -= 1
c -= 1
d -= 1

s += '#'

flg = True
ok = False
cnt = 0
for i in range(b, d):
    if s[i] == '#':
        cnt = 0
        if s[i+1] == '#':
            flg = False
    else:
        cnt += 1
        if cnt == 3:
            ok = True     
if cnt + 1 == 3:
    ok = True

if s[b-1] == '.' and s[b] == '.' and s[b+1] == '.':
    ok = True

if s[d-1] == '.' and s[d] == '.' and s[d+1] == '.':
    ok = True

for i in range(a, c):
    if s[i] == '#' and s[i+1] == '#':
        flg = False

if c < d:
    print('Yes' if flg else 'No')

else:
    print('Yes' if flg and ok else 'No')
    

Measured memory_bytes: 9564
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define int long long
#define For(i,x,y) for(int i = x; i <= y; ++i)
#define FOR For
#define rev_For(i,x,y) for(int i = x; i >= y; --i)
#define REV_FOR rev_For
#define ll long long
#define Size(v) ((int)v.size())
#define _section "\n--------------------\n"
#define fi first
#define se second
#define pb push_back
using namespace std;
// using namespace __gnu_pbds;


int a, b, c, k;

void input() {
	cin >> a>> b >> c >> k;
}

void solve() {
	if (a >= k) {
		cout << k;
		return;
	}
	if (a + b >= k) {
		cout << a;
		return;
	}
	else {
		cout << a + (-1) * (k - (a + b));
		return;
	}
}

signed main() {
#ifdef _DEBUG
	// freopen("INPUT.inp", "r", stdin);
	//freopen("OUTPUT.out", "w", stdout);
	clock_t start, end;
	start = clock();
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
//------------------------------------------------------------------------------------
//----------------------------------MAIN PROGRAM--------------------------------------
	int t = 1;
	while (t--) {
		input();
		solve();
	}
//--------------------------------------END-------------------------------------------
//------------------------------------------------------------------------------------
#ifdef _DEBUG
	end = clock();
	cerr << "\n----------\nTime Elapsed: " << fixed << double(end - start) / double(CLOCKS_PER_SEC) << setprecision(6) << '\n';
#endif
	return 0;
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

class A {
    static StreamWriter Out = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    static void Main(string[] args) {
        int N;
        Input(out N);
        Print(N / 2 + N % 2);
        Out.Flush();
    }
    static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
    static void Input<A>(out A a) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
    }
    static void Input<A, B>(out A a, out B b) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
    }
    static void Input<A, B, C>(out A a, out B b, out C c) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
    }
    static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
    }
    static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d, out E e) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
    }
    static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d, out E e, out F f) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
        f = ChangeT<F>(words[5]);
    }
    static void InputArray<T>(out T[] array) {
        array = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries).Select(s => ChangeT<T>(s)).ToArray();
    }
    static void Print<T>(T s) => Out.WriteLine(s);
    static void Print<T>(params T[] s) => Out.WriteLine(string.Join(" ", s));
    static void Print<T>(IEnumerable<T> e) => Out.WriteLine(string.Join(" ", e));
}

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

using namespace std;
typedef long long ll;

const ll INF = 1e18;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n + 1), c(n + 1);
    for (int i = 1; i <= n; i++) cin >> p[i];
    for (int i = 1; i <= n; i++) cin >> c[i];
    ll res = *max_element(c.begin() + 1, c.end());
    for (int i = 1; i <= n; i++) {
        ll j = i, sum = 0, len = 0;
        do {
            sum += c[j], j = p[j], len++;
        } while (j != i);
        ll r = k >= len ? len + k % len : k;
        ll base = ((k - r) / len) * max(sum, 0ll), add = -INF;
        sum = 0;
        for (int t = 1; t <= r; t++) {
            sum += c[j], j = p[j];
            add = max(add, sum);
        }
        res = max(res, base + add);
    }
    cout << res << "\n";
}


Measured memory_bytes: 3684
N,M,Q = map(int, input().split())

matrix = [[0]*(N+1) for _ in range(N+1)]
for _ in range(M):
    l,r = map(int, input().split())
    matrix[l][r] += 1
accmatrix = [[0]*(N+1) for _ in range(N+1)]
for l in range(1,N+1):
    accmatrix[l] = [x+y for x,y in zip(accmatrix[l-1],matrix[l])]
for l in range(1,N+1):
    lis = accmatrix[l]
    for r in range(1,N+1):
        lis[r] += lis[r-1]

for _ in range(Q):
    p,q = map(int, input().split())
    ans = accmatrix[q][q] - accmatrix[p-1][q]- accmatrix[q][p-1] + accmatrix[p-1][p-1]
    print(ans)

Measured memory_bytes: 20688
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_11_C&lang=jp
  * Structure and Class - Dice III
  */
object Main {

  case class Dice(numbers: IndexedSeq[Int]) {
    def apply(number: Int): Int = {
      numbers(number)
    }

    def rotateTo(direction: Char): Dice = {
      direction match {
        case 'N' => Dice(IndexedSeq(numbers(1), numbers(5), numbers(2), numbers(3), numbers(0), numbers(4)))
        case 'S' => Dice(IndexedSeq(numbers(4), numbers(0), numbers(2), numbers(3), numbers(5), numbers(1)))
        case 'W' => Dice(IndexedSeq(numbers(2), numbers(1), numbers(5), numbers(0), numbers(4), numbers(3)))
        case 'E' => Dice(IndexedSeq(numbers(3), numbers(1), numbers(0), numbers(5), numbers(4), numbers(2)))
      }
    }

    def find(number: Int): Int = {
      // returns -1 if not found
      numbers.indexWhere(_ == number)
    }

    def adjustWith(dice: Dice): Dice = {
      val operationsToTop = Seq("", "", "N", "W", "E", "S", "NN")
      val operationsToFront = Seq("", "S", "", "WSE", "ESW", "SEEN", "N")
      val dice2 = operationsToTop(this.find(dice(0)) + 1).foldLeft(this)(_.rotateTo(_))
      val dice3 = operationsToFront(dice2.find(dice(1)) + 1).foldLeft(dice2)(_.rotateTo(_))
      dice3
    }
  }

  def main(args: Array[String]): Unit = {
    val dice1 = Dice(io.StdIn.readLine().split(" ").map(_.toInt))
    val dice2 = Dice(io.StdIn.readLine().split(" ").map(_.toInt))
    if (dice1 == dice2.adjustWith(dice1))
      println("Yes")
    else
      println("No")
  }
}

Measured memory_bytes: 44116
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	#b , c = tin()
	a, b = input().split()
	a = int(a)
	b = int('1'+b[0]+b[2]+b[3])
	r = a*b-a*1000
	if r <=99:
		return 0
	return int(str(r)[:-2])
	
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 62112
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
    
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <limits>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<vector<int>> vec(n);
    vector<int> SIZE;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        int num;
        cin >> num;
        SIZE.push_back(num);
        for(int j = 0;j< num;j++){
            int y;
            cin >> y;
            vec[x-1].push_back(y-1) ;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            bool hantei=0;
            for(int k=0;k<SIZE[i];k++){
                
                if(vec[i][k]==j) {
                    if(j!=n-1){
                        cout << 1 <<" "; 
                        hantei = 1;
                    }else{
                        cout << 1;
                        hantei = 1;
                    }    
                }
            }
            if(hantei==0){ 
                if(j!=n-1){
                    cout <<0<<" ";
                }else{
                    cout << 0;
                }
                
            }
        }cout << endl;
    }
}





Measured memory_bytes: 3160
#include <iostream>
using namespace std;
int main()
{
    long long n,i,ma,mi,sum=0;
    cin>>n;
    long long a[n+1];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
        ma = a[0];
        mi = a[0];
        for(i=0;i<n;i++)
    {
         if(ma>a[i])
         {
            ma = a[i];
         }
         if(mi<a[i])
         {
             mi = a[i];
         }
         sum = sum + a[i];
    }
        cout<<ma<<" "<<mi<<" "<<sum<<endl;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
//ll a[10000000], d[10000000];

signed main() {

    ll i, j, k, l, n, b, c, test, a;
    cin >> n >> k;
    if (n % k == 0) cout << n / k;
    else cout << n / k + 1;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
const double pi=acos(-1.0);

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int max3(int a,int b,int c) {return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
int min3(int a,int b,int c) {return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}

#define  f(i,n){for(int i=0;i<(int)(n);i++)}              ////for文



int main(void){
    string s,t;
    int count;
    cin>>s;
    cin>>t;
    count=0;
    for(int i=0;i<s.size();++i){
        if(s.at(i)!=t.at(i)){s.at(i)=t.at(i);count++;}
        
    }
    cout<<count<<endl;
    
}


Measured memory_bytes: 3852
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int a, b;
	while(~scanf("%d%d",&a,&b))
	{
		int ans, ans1;
		ans = max(a + b, a - b);
		ans1 = max(ans, a * b);
		printf("%d\n",ans1);
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <cmath>
 
using namespace std;
#define EPS 1e-8
typedef long long int lli;
int w,h,v,t,x,y,p,q;
 
int getnum(int bottom, int up, int s, int div){
//	printf("getnum(%d, %d, %d, %d) = %d\n", bottom, up, s, div, max(0, (s-bottom+1)/div + (up-s+1)/div) + (bottom <= s && s <= up));
	if(bottom <= s && s <= up) return max(0, (s-bottom)/div + (up-s)/div) + 1;
	if(s < bottom) return max(0, (s-bottom-1)/div + (up-s)/div);
	if(up < s) return max(0, (s-bottom)/div + (up-s-1)/div);
//	return max(0, (s-bottom+1)/div + (up-s+1)/div) + (bottom <= s && s <= up);
}
 
double dist(double x, double y){
	return sqrt(x*x+y*y);
}
double geth(double w, double r){
	return sqrt(r*r-w*w)+EPS;
}
main(){
	int i,j;
	while(cin>>w>>h>>v>>t>>x>>y>>p>>q){
		int a=h-q,b=q,c=w-p,d=p;
		int dy=2*a+2*b, dx=2*c+2*d;
		lli ans=0;
		for(lli i=0;dist(p+i-x, q-y)<(double)v*t+EPS;i+=dx){
			// x is p+i
			ans += getnum(ceil(y-geth(p+i-x, v*t)), y+geth(p+i-x, v*t), q, dy);
			ans += getnum(q, y+geth(p+i-x, v*t), q+2*a, dy);
			ans += getnum(ceil(y-geth(p+i-x, v*t)), q, q-2*b, dy);
			// x is p+i+2*c
			if(dist(p+i+2*c-x, q-y)<(double)v*t+EPS){
				ans += getnum(ceil(y-geth(p+i+2*c-x, v*t)), y+geth(p+i+2*c-x, v*t), q, dy);
				ans += getnum(q, y+geth(p+i+2*c-x, v*t), q+2*a, dy);
				ans += getnum(ceil(y-geth(p+i+2*c-x, v*t)), q, q-2*b, dy);
			}
		}
		for(lli i=0;dist(p-i-x, q-y)<(double)v*t+EPS;i+=dx){
			// x is p-i
			if(i){
				ans += getnum(ceil(y-geth(p-i-x, v*t)), y+geth(p-i-x, v*t), q, dy);
				ans += getnum(q, y+geth(p-i-x, v*t), q+2*a, dy);
				ans += getnum(ceil(y-geth(p-i-x, v*t)), q, q-2*b, dy);
			}
			// x is p-i-2*d
			if(dist(p-i-2*d-x, q-y)<(double)v*t+EPS){
				ans += getnum(ceil(y-geth(p-i-2*d-x, v*t)), y+geth(p-i-2*d-x, v*t), q, dy);
				ans += getnum(q, y+geth(p-i-2*d-x, v*t), q+2*a, dy);
				ans += getnum(ceil(y-geth(p-i-2*d-x, v*t)), q, q-2*b, dy);
			}
		}
//		if(dist(x-p, y-q) < v*t+EPS) ans ++;
		cout << ans << endl;
	}
	return 0;
}

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

int main () {

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

    int P[N + 1];
    for (int i = 0; i < N; i++) {
        int num;
        scanf("%d", &num);

        P[num] = i;
    }

    int sequence = 1;
    int prev = P[1];
    int ans = 1;
    for (int i = 2; i <= N; i++) {
        if (prev < P[i])
            sequence++;
        else {
            ans = max(ans, sequence);
            sequence = 1;
        }

        prev = P[i];
    }
    ans = max(ans, sequence);
    printf("%d\n", N - ans);

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

vector<LLi> pri={1, 2, 3};

void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

bool VV(vector<int> vv1, vector<int> vv2) {
	if(vv1.size()!=vv2.size()) return false;
	rep(i, vv1.size()) if(vv1[i]!=vv2[i]) return false;

	return true;
}

bool VVL(vector<LLi> vv1, vector<LLi> vv2) {
	if(vv1.size()!=vv2.size()) return false;
	rep(i, vv1.size()) if(vv1[i]!=vv2[i]) return false;

	return true;
}

int main(){

	int n, tmp, ans=0;
	vector<int> v, che;
	cin>> n;

	v.resize(1000100);
	che.resize(1000100);
	rep(i, n){
		cin >> tmp;
		v[tmp]++;
	}
	
	for(int i=1;i<=1000000;i++){
		if(che[i]) continue;
		if(v[i]>0){
			for(int j=2;i*j<=1000000;j++) che[i*j]=1;
		}
		if(v[i]==1) ans++;
	}

	cout<< ans <<endl;

	return 0;
}

//0と1のコーナーケースに気をつける

Measured memory_bytes: 11176
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main implements Runnable {

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        HashMap<Integer, Integer> map = new HashMap<>();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            if (map.get(a[i]) == null) {
                map.put(a[i], 1);
            } else {
                map.put(a[i], map.get(a[i]) + 1);
            }
        }
        List<Map.Entry<Integer, Integer>> entries = new ArrayList<>(map.entrySet());
        entries.sort((o1, o2) -> o2.getValue().compareTo(o1.getValue()));

        int count = 0;
        for (int i = k; i < entries.size(); i++) {
            count += entries.get(i).getValue();
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 103304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
  ld a, b, x, rag;
  cin >> a >> b >> x;
  ld s = a * b - x / a;
  if (s <= a * b / 2) {
    ld h = 2 * (a * b - x / a) / a;
    rag = atan2(h, a);
  } else {
    ld w = 2 * x / a / b;
    rag = atan2(b, w);
  }

  ld PI = acos(-1);
  ld ans = rag / PI * 180;
  printf("%.10Lf", ans);
  return 0;
}


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

int main(){

    int count=0;
    
    std::string str; // 数字列
    std::cin>>str;
    
    int s=str.size();

    std::vector<int> nums(s); // 同じ長さのint列

if(str.size()!=1){
    // char -> int 変換
    transform(str.begin(), str.end(), nums.begin(), [](char ch) { return ch - '0';});
   
    for(int i=0;i<s-1;i++){
        if(nums[i]==nums[i+1]){
            if(nums[i+1]==0){
                nums[i+1]=1;
            }else{
                nums[i+1]=0;
            }
            count++;
        }
    }

    if(count<s/2.0){
         std::cout<<count<<std::endl;
    }else{
         std::cout<<s-count<<std::endl;
    }
}else{
    std::cout<<0<<std::endl;
}

    return 0;

}

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

using namespace std;

constexpr int MAXN = 1e5 + 5, MOD = 1e9 + 7;

template <typename T>
inline void read(T& x, T f = 1, char ch = getchar()) {
    x = 0;
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

struct BIT {  // Binary Index Trees, 1based
    int lowbit(int x) { return x & (~x + 1); }
    /* O(n) 建树*/
    void build(int x = 2, int sub = 1) {
        while (x <= n) {
            for (int i = x; i <= n; i += x) c[i] += c[i - sub];
            x <<= 1, sub <<= 1;  // 2 ^ n
        }
    }
    /*@param x the position to add val*/
    void add(int x, int val) {
        while (x <= n) c[x] += val, x += lowbit(x);
    }
    /*查询 [1, x] 的前缀和*/
    int query(int x, int res = 0) {
        while (x) res += c[x], x -= lowbit(x);
        return res;
    }
    int n;
    array<int, MAXN> c;
};

struct Node {
    Node *lson, *rson;
    int cnt, tag, l, r;
};

int tc, n, m;
array<int, MAXN> a;

int main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	cout << (n ^ 1) << endl;
    return 0;
}

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

using namespace std;

int main(){
  int n,k,d;
  cin>>n>>k;
  vector<int> F(n,0);
  for(int i=0;i<k;i++){
    cin>>d;
    for(int j=0;j<d;j++){
      int a;
      cin>>a;
      F[a-1]++;
    }
  }
  int cnt =0;
  for(int i=0;i<n;i++){
    if(F[i]==0) ++cnt;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <stack>
#include <string>
#include <cstdlib>
using namespace std;

int main(){

  string str;
  long long n, a, b;
  stack<long long> s;

  while(cin >> str){
    if(str == "+"){
      a = s.top();
      s.pop();
      b = s.top();
      s.pop();
      s.push(a + b);
    }else if(str == "-"){
      a = s.top();
      s.pop();
      b = s.top();
      s.pop();
      s.push(b - a);
    }else if(str == "*"){
      a = s.top();
      s.pop();
      b = s.top();
      s.pop();
      s.push(a * b);
    }else{
      n = atoi(str.c_str());
      s.push(n);
    }
  }
  cout << s.top() << endl;
  return 0;
}


Measured memory_bytes: 3160
import java.util.*;
class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    int[]a=new int[9];
    for(int i=0;i<9;i++)a[i]=sc.nextInt();
    int n=sc.nextInt();
    Map<Integer,Boolean> m=new HashMap<>();
    for(int i=0;i<n;i++)m.put(sc.nextInt(),true);
    boolean b=false;
    if(m.containsKey(a[0])&&m.containsKey(a[1])&&m.containsKey(a[2]))b=true;
    if(m.containsKey(a[3])&&m.containsKey(a[4])&&m.containsKey(a[5]))b=true;
    if(m.containsKey(a[6])&&m.containsKey(a[7])&&m.containsKey(a[8]))b=true;
    if(m.containsKey(a[0])&&m.containsKey(a[3])&&m.containsKey(a[6]))b=true;
    if(m.containsKey(a[1])&&m.containsKey(a[4])&&m.containsKey(a[7]))b=true;
    if(m.containsKey(a[2])&&m.containsKey(a[5])&&m.containsKey(a[8]))b=true;
    if(m.containsKey(a[0])&&m.containsKey(a[4])&&m.containsKey(a[8]))b=true;
    if(m.containsKey(a[2])&&m.containsKey(a[4])&&m.containsKey(a[6]))b=true;
    
    System.out.print(b?"Yes":"No");
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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


// combination mod prime
// mintが必要
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
    ll k;
    cin >> k;
    string s;
    cin >> s;
    ll l = s.size();
    combination c(10000000);
    mint ans = 0;
    for(int j=1;j<=k+1;j++){
        mint tmp;
        tmp = c(l+k-j,l-1);
        tmp *= modpow(25,k-j+1);
        tmp *= modpow(26,j-1);
        ans += tmp;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 160580
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        System.out.println(execute(arr, n, k));
        sc.close();
    }

    private static int execute(int[] arr, int n, int k) {

        int[] dp = new int[n];
        dp[0] = 0;

        dp[1] = Math.abs(arr[1] - arr[0]);
        for (int i = 2; i < n; i++) {

            int min = Integer.MAX_VALUE;
            for (int j = 0; j < k; j++) {
                if (i - 1 - j < 0) break;
                ;
                int val = dp[i - 1 - j] + Math.abs(arr[i] - arr[i - 1 - j]);
                if (val < min) {
                    min = val;
                }
            }

            dp[i] = min;

        }
        return dp[n - 1];
    }
}


Measured memory_bytes: 50800
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  string n;
  cin >> n;
  if(n[0]==n[1]||n[1]==n[2]||n[2]==n[3]){
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(void){
    int A,B,H,M;
    long double a,b,h,m,x,j,s;
    double answer;
    scanf("%d %d %d %d",&A,&B,&H,&M);
    a=A;
    b=B;
    h=H%12;
    m=M;

    s=(60.0L*h-11.0L*m)/360.0L*3.14159265358979L;
    j=a*a+b*b-2.0L*a*b*cosl(s);
    x=sqrtl(j);
    answer =x;
    printf("%.20lf",answer);
    return 0;
}

Measured memory_bytes: 2540
#include"bits/stdc++.h"
#include<cassert>
#define fr first
#define sc second
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 998244353;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P> PP;

signed main() {
	string s; cin >> s;
	string t = s + s;
	int n = s.size();
	int k; cin >> k;
	vector<int>v;
	char now = s[0];
	int cnt = 0;
	rep(i, n) {
		if (now == s[i])cnt++;
		else {
			v.push_back(cnt);
			now = s[i];
			cnt = 1;
		}
	}
	v.push_back(cnt);
	int z = v.size();
	int ans = 0;

	if (v.size() == 1) {
		ans = k*s.size() / 2;
	}
	else {
		for (int i = 1; i < z - 1; i++) {
			ans += k*(v[i] / 2);
		}
		if (s[0] == s[n - 1]) {
			ans += v[0] / 2;
			ans += v[z - 1] / 2;
			ans += (k - 1)*((v[0] + v[z - 1]) / 2);
		}
		else {
			ans += k*(v[0] / 2);
			ans += k*(v[z - 1] / 2);
		}
	}
	cout << ans << endl;
}

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

int stones(vector<int>&v,int k){
       int dp[k+1];
          memset(dp,0,sizeof(dp));
    
          for(int i=1; i<= k; i++){
               for(int x : v){ 
                  if(i < x)
                    continue;
                 if(dp[i - x] == 0)
                    dp[i] = 1;
                    // if taro starts with k ans removing some value 
                    // dp[i-ai] = 1 then other person will win from that k.
               }
          }
   return dp[k];
}


void solve(){
    int n,k;
    cin >> n >> k;
    vector<int>v;
    for(int i=0;i<n; i++){
        int x;
        cin >> x;
        v.push_back(x);
    }  
    
    if(stones(v,k) == 1)
         cout<< "First";
    else
       cout<<"Second";    
}
int main(){
//  #ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
// #endif 
solve();

return 0;
}

Measured memory_bytes: 640
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datN) = readLine.split(" ").map(_.toInt)

    val ans = (datN % 10) match {
      case x if (x == 2) || (x == 4) || (x == 5) || (x == 7) || (x == 9) => "hon"
      case x if (x == 0) || (x == 1) || (x == 6) || (x == 8) => "pon"
      case x => "bon"
    }
    println(ans)
  }
}


Measured memory_bytes: 54700
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
	
bool pairComparesecond(const p& firstElof, const p& secondElof)
{
    return firstElof.second > secondElof.second;
}

int main(){
	ll k,a,b;
	cin>>k>>a>>b;
	if(k+1>k-2-a+b||k+1<a)cout<<k+1<<endl;
	else{
		ll x=(k+1-a)/2;
		ll ans=k+1-2*x-a*x+x*b;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=998244353;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
vector<int>kaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    //if(!kaijo[0])init_fact(2000010);
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,m,k;
int Pow[200010];
signed main(){
    cin>>n>>m>>k;
    Pow[0]=1;
    init_fact(400000);
    int ans=0;
    rep(r,k+1){
        ans+=comb(n-1,r)*modpow(m-1,n-r-1)%mod;
        ans%=mod;
    }
    cout<<ans*m%mod<<endl;
    return 0;
}

Measured memory_bytes: 6404
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#define ll long long
using namespace std;
char a[15];
int main()
{
    scanf("%s",a);
    ll ans=0;
    int len=strlen(a);
    int n=1<<(len-1);
    for(int i=0;i<n;i++)
    {
        ll t=a[0]-'0';
        for(int j=0;j<len;j++)
        {
            if(j==len-1||i&(1<<j))
            {
                ans+=t;
                t=0;
                if(j==len-1) break;
            }
            t=t*10+a[j+1]-'0';
        }
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i, a, b, s;
  int count[4];
  for(i = 0;i < 4;i++) count[i] = 0;
  for(i = 0;i < 3;i++){
    scanf("%d %d", &a, &b);
    count[a-1]++;
    count[b-1]++;
  }
  s = 1;
  for(i = 0;i < 4;i++) s *= count[i];
  if(s == 4) printf("YES\n");
  else printf("NO\n");
  return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

class UnionFind {
    public:
        UnionFind(){}
        UnionFind(int size) { Init(size); }
        // size: Union-Find で扱いたい要素の数
        void Init(int size) { m_Data.assign(size, -1); }

        // x と y の属する集合を併合
        // 既に一緒な集合内にいるなら false を
        // 新たに併合されたなら true を返す
        bool Unite(int x, int y) {
            x = Find(x), y = Find(y);
            if(x == y) { return (false); }
            if(m_Data[x] > m_Data[y]) { swap(x, y); }
            m_Data[x] += m_Data[y];
            m_Data[y] = x;
            return (true);
        }

        // 要素 k が属する集合の根を返す
        int Find(int k) {
            if(m_Data[k] < 0) { return (k); }
            return (m_Data[k] = Find(m_Data[k]));
        }

        // 要素 k と同じ集合の要素数を返す
        int Size(int k) { return (-m_Data[Find(k)]); }

        // 要素のうち独立しているグループの数 O(NlogN)
        int GetGroupNum() {
            map<int, bool> groups;
            for(int i = 0; i < m_Data.size(); ++i) { groups[Find(i)] = true; }
            return static_cast<int>(groups.size());
        }

    private:
        vector<int> m_Data;
};

ll N;

ll X[MAX_N];            // id が i のものの x 座標
ll Y[MAX_N];            // id が i のものの y 座標
vector<ll> Xs[MAX_N];   // x 座標が i のものの id 一覧
vector<ll> Ys[MAX_N];   // y 座標が i のものの id 一覧
bool isChecked[MAX_N];  // id が i のものが dfs 済みか
UnionFind uf;
set<ll> group_val_x[MAX_N]; // グループ i で出てくる x 座標のバリエーション
set<ll> group_val_y[MAX_N]; // グループ i で出てくる y 座標のバリエーション


// x 座標もしくは y 座標が同じものを同じグループにする
void dfs(ll id) {
    if(isChecked[id]) { return; }
    isChecked[id] = true;

    ll x = X[id];
    for(auto& next_id : Xs[x]) {
        uf.Unite(id, next_id);
        dfs(next_id);
    }
    ll y = Y[id];
    for(auto& next_id : Ys[y]) {
        uf.Unite(id, next_id);
        dfs(next_id);
    }
}


signed main()
{
    cin >> N;
    REP(i, N) {
        ll x, y;
        cin >> x >> y;
        X[i] = x;
        Y[i] = y;
        Xs[x].push_back(i);
        Ys[y].push_back(i);
    }

    uf.Init(N);
    REP(i, N) { dfs(i); }

    set<ll> valid_group;
    REP(i, N) {
        ll root = uf.Find(i);
        group_val_x[root].insert(X[i]);
        group_val_y[root].insert(Y[i]);
        valid_group.insert(root);
    }

    ll ans = 0;
    for(auto& group_id : valid_group) {
        ans += (group_val_x[group_id].size() * group_val_y[group_id].size()) - uf.Size(group_id);
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 35328
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> A(N+1);
    vector<int> ans(N+1);
    for(int i=2;i<=N;i++)
    {
        cin>>A.at(i);
    }
    for(int i=2;i<=N;i++)
    {
        ans.at(A.at(i))++;
    }
    for(int i=1;i<=N;i++)
    {
        cout<<ans.at(i)<<endl;
    }

return 0;


}

Measured memory_bytes: 4404