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

using namespace std;
using namespace boost;

main() {
  int64_t n, m;
  cin >> n >> m;
  
  vector<bool> a(n + 1, false);
  for (auto i : irange(0L, m)) {
    int64_t aa;
    cin >> aa;
    a[aa] = true;
  }

  vector<int64_t> d(n+1);
  d[0] = 1;
  d[1] = (a[1] ? 0 : 1);
  for (auto i : irange(2L, n+1)) {
    if (!a[i]) {
      d[i] = (d[i - 1] + d[i - 2]) % 1000000007;
    }
  }
  
  cout << d[n] << endl;
}

Measured memory_bytes: 1024
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    h,w,d = LI()
    a = [LI() for _ in range(h)]
    q = I()
    lr = [LI() for _ in range(q)]
    t = {}
    for i in range(h):
        for j in range(w):
            t[a[i][j]] = (i,j)


    k = [0] * (h*w+1)
    for i in range(d+1,h*w+1):
        k[i] = k[i-d] + abs(t[i][0] - t[i-d][0]) + abs(t[i][1] - t[i-d][1])
    rr = []
    for l,r in lr:
        rr.append(k[r]-k[l])

    return '\n'.join(map(str,rr))


print(main())




Measured memory_bytes: 121560
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	a := getNextInt(scanner)
	b := getNextInt(scanner)
	mod := int64(1e9 + 7)
	doubling := make([]int64, 32)
	doubling[0] = 2
	for i := 1; i < 32; i++ {
		doubling[i] = (doubling[i-1] * doubling[i-1]) % mod
	}
	var ans, horobiyo int64
	ans = 1
	for i := 0; i < 31; i++ {
		if n>>uint(i)&1 == 0 {
			continue
		}
		ans = ans * doubling[i]
		ans %= mod
	}
	ans--
	horobiyo = 1
	for i := 0; i < a; i++ {
		horobiyo = ((horobiyo * int64(n-i) % mod) * inv(int64(1+i))) % mod
	}
	ans -= horobiyo
	ans %= mod
	if ans < 0 {
		ans += mod
	}
	horobiyo = 1
	for i := 0; i < b; i++ {
		horobiyo = ((horobiyo * int64(n-i) % mod) * inv(int64(1+i))) % mod
	}
	ans -= horobiyo
	ans %= mod
	if ans < 0 {
		ans += mod
	}
	fmt.Fprintln(writer, ans)
}

func inv(n int64) int64 {
	var ii [32]int64
	mod := int64(1e9 + 7)
	ii[0] = n
	for i := 1; i < 31; i++ {
		ii[i] = (ii[i-1] * ii[i-1]) % mod
	}
	var ans int64
	ans = 1
	m := mod - 2
	for i := 30; i >= 0; i-- {
		for m >= 1<<uint(i) {
			ans = (ans * ii[i]) % mod
			m -= 1 << uint(i)
		}
	}

	return ans
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,s,c=0;
  cin>>k>>s;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      if(s-i-j<=k&&s-i-j>=0) c++;
    }
  }
  cout<<c;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


bool pairCompare(const Pi& firstElof, const Pi& secondElof)
{
	return firstElof.second > secondElof.second;
}

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

	int a[5];
	rep(i, 5)cin >> a[i];

	int t = INF;
	int ta = 0;
	rep(i, 5) {
		if ((a[i] % 10) != 0) {
			t = min(t, a[i] % 10);
			ta = a[i];
			a[i] = (a[i] / 10 + 1) * 10;
		}
	}

	int ans = 0;
	rep(i, 5) {
		//cout << a[i] << endl;
		ans += a[i];
	}
	if (t != INF) {
		ans += -10 + t;
	}

	cout << ans << endl;



	return 0;
}



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

typedef long long ll;
const int maxn = 2e5+10;
const int mod = 1e9+7;

ll a[maxn];
ll sum[maxn];
int main(void){
	int n;
	cin >> n;
	sum[0] = 0;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		sum[i] = sum[i-1]+a[i];
		sum[i] %= mod;	
	}
	ll ans = 0;
	for(int i = 1; i < n; i++){
		ans += a[i]*(sum[n]-sum[i]+mod);
		ans %= mod;
	}
	cout<<ans<<endl;
	return 0;
}



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

#define LL long long

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int n, x; cin >> n; bool ok = 1;
    while(n--) {
        cin >> x;
        if(x % 2 == 0) if(x % 3 && x % 5) ok = 0;
    }    
    cout << (ok ? "APPROVED" : "DENIED");
}

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

typedef pair <int, int> ii;

const int Maxn = 100005;
const int mod = 1000000007;

int n, m;
int a[Maxn];
int b[Maxn];
bool notok[Maxn];
int lef[Maxn], rig[Maxn];
vector <int> un;
vector <ii> seq;
int BIT[Maxn];

void Insert(int x, int val)
{
	for (int i = x; i > 0; i -= i & -i)
		BIT[i] = (BIT[i] + val) % mod;
}

int Get(int x)
{
	int res = 0;
	for (int i = x; i < Maxn; i += i & -i)
		res = (res + BIT[i]) % mod;
	return res;
}

int main()
{
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (int j = 0; j < m; j++)
		scanf("%d", &b[j]);

	for (int i = 0; i < n; i++) {
		int ind = upper_bound(b, b + m, a[i]) - b;
		if (ind == 0 || ind == m) { notok[i] = true; continue; }
		lef[i] = a[i] - b[ind - 1];
		rig[i] = b[ind] - a[i];
		un.push_back(rig[i]);
	}
	sort(un.begin(), un.end()); un.erase(unique(un.begin(), un.end()), un.end());
	for (int i = 0; i < n; i++) if (!notok[i]) {
		int tk = lower_bound(un.begin(), un.end(), rig[i]) - un.begin() + 1;
		seq.push_back(ii(-lef[i], tk));
	}
	sort(seq.begin(), seq.end()); seq.erase(unique(seq.begin(), seq.end()), seq.end());
	Insert(Maxn - 1, 1);
	for (int i = 0; i < seq.size(); i++) {
		int ind = seq[i].second;
		Insert(ind, Get(ind + 1));
	}
	printf("%d\n", Get(1));
	return 0;
}

Measured memory_bytes: 3320
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

using namespace std;

int main()
{
  long long N;
  cin >> N;
  long long X;
  cin >> X;

  long long sum = N;
  if(N-X < X)
  {
    long long tmp = N-X;
    N = X;
    X = tmp;
  }
  else
  {
    N = N-X;
  }
  do
  {
    long long a(N/X);
    long long r(N%X);
    sum += 2*a*X;
    if(r==0) sum -= X;
    N = X; X = r;
  } while(X!=0);

  cout << sum << endl;

  return 0;
}


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

int main(){
  long long N;
  cin >> N; // 1 <= N <= 1+10^15 1000000000000001
  string abc = "abcdefghijklmnopqrstuvwxyz";
  string name = "";
  for(int i = 0; i < 11; i++){
    name = abc[(N-1)%26]+name;
    N = (N-1)/26;
    if(N == 0) break;
  }
  cout << name << endl;
}


Measured memory_bytes: 3632
package main

import (
	"fmt"
)

const intMax = 2147483647

func main() {
	var h, n int
	_, _ = fmt.Scan(&h)
	_, _ = fmt.Scan(&n)
	as := make([]int, n)
	for i, _ := range as {
		var a int
		_, _ = fmt.Scan(&a)
	 	as[i] = a
	}
	res := false
	for _, a := range as {
		h -= a
		if h <= 0 {
			res = true
			break
		}
	}
	if res {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 5504
//created by missever

#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;

int add(int x,int y) {
    x += y;
    if(x >= mod) x -= mod;
    return x;
}

int mul(int x,int y) {
    LL z = 1LL * x * y;
    return z - z / mod * mod;
}

int main(){
#ifdef CX_TEST
    freopen("E:\\program--GG\\test_in.txt", "r", stdin);
#endif
LL x,y;
cin>>x>>y;
int t = 1;
    while(x * 2 <= y) {
        x <<= 1;
        t++;
    }
    cout<<t<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define loop(i,a,b) for(int i = a; i < b; i++)
#define rep(i,a) loop(i,0,a)
typedef long long ll;

int main()
{	
	
	int w,h,n;
	cin>>w>>h>>n;
	int s[100][100]={0};
	
	int x,y,a;
	rep(i,n){
		cin>>x>>y>>a;
		rep(j,w){
			rep(k,h){
				if(a==1&&j<x)
					s[j][k]=1;
				else if(a==2&&j>=x)
					s[j][k]=1;
				else if(a==3&&k<y)
					s[j][k]=1;
				else if(a==4&&k>=y)
					s[j][k]=1;
			}
		}
	}
	int out=0;
	rep(i,w)
		rep(j,h)
			if(s[i][j]==0)
				out++;
	cout<<out<<endl;
	
	return 0;
}



Measured memory_bytes: 256
//配るDP
#include<iostream>
#include<algorithm>
using namespace std;

int X,Y;
int c[15][15];
int dp[15][15];
int main(){
	while(cin>>X>>Y,X|Y){
		int ans=0;
		for(int i=0;i<Y;i++)
			for(int j=0;j<X;j++)
				cin>>c[i][j];
		fill_n((int*)dp,15*15,0);
		for(int j=0;j<X;j++){
			if(c[0][j]!=1)dp[0][j]=1;
		}
		for(int i=0;i<Y;i++){
			for(int j=0;j<X;j++){
				if(dp[i][j]==0)continue;
				if(Y-1==i || c[i][j]==2 && Y-2==i){
					ans += dp[i][j];
					continue;
				}
				for(int dx=-1;dx<=1;dx++){
					if(j+dx<0 || X<=j+dx)continue;
					if(c[i][j]==2){
						if(dx==0 && c[i+2][j]!=1){
							dp[i+2][j] += dp[i][j];
						}
					}
					else{
						if(c[i+1][j+dx]==0)dp[i+1][j+dx] += dp[i][j];
						else if(c[i+1][j+dx]==2 && dx==0)dp[i+1][j] += dp[i][j];
					}
				}
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=b-1;i>=a;i--)
#define per(i,b) ROF(i,0,b)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

ll gcd(ll x,ll y){
  if(x%y==0){
    return y;
  }
  else{
    return gcd(y,x%y);
  }
}

int main(){
  ll q;
  cin >> q;
  rep(t,q){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a<b){
      cout << "No" << endl;
    }
    else if(b>d){
      cout << "No" << endl;
    }
    else if(c>=b){
      cout << "Yes" << endl;
    }
    else{
      ll x=gcd(b,d);
      a%=x;
      if(a==0){
        if(b-x>c){
          cout << "No" << endl;
        }
        else{
          cout << "Yes" << endl;
        }
      }
      else{
        if(b-x+a>c){
          cout << "No" << endl;
        }
        else{
          cout << "Yes" << endl;
        }
      }
    }
  }
}

Measured memory_bytes: 256
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
import string

def main():
    s = input().rstrip()
    t = input().rstrip()
    for i in range(len(s)):
        if s[i] != t[i]:
            print("No")
            exit()
    if len(t) == len(s) +1:
        print("Yes")
    else:
        print("No")

if __name__=="__main__":
    main()


Measured memory_bytes: 72008
function main()
	N=parse(Int,readline())
	A=map(x->parse(Int,x),split(readline()))
	G=[Int[] for _=1:N]
	for i=2:N
		u,v=map(x->parse(Int,x),split(readline()))
		push!(G[u],v)
		push!(G[v],u)
	end
	dp=ones(Int,N+1)*1145141919
	dp[1]=0
	ans=zeros(Int,N)
	function dfs(u,p,R)
		l=1
		r=R
		while r-l>1
			m=div(l+r,2)
			if dp[m]<A[u]
				l=m
			else
				r=m
			end
		end
		pre=dp[r]
		dp[r]=A[u]
		if R==r
			R+=1
		end
		ans[u]=R-2
		for v=G[u]
			if v!=p
				dfs(v,u,R)
			end
		end
		dp[r]=pre
	end
	dfs(1,0,2)
	println.(ans)
end
main()


Measured memory_bytes: 340136
n,m,l = map(int,input().split())
a = []
b = []

for i in range(n):
    a.append(list(map(int,input().split())))
    
for j in range(m):
    b.append(list(map(int,input().split())))

for i in range(n):
    c = []
    for k in range(l):
        su = 0
        for j in range(m):
            su += a[i][j]*b[j][k]
        c.append(su)
    print(" ".join(list(map(str,c))))


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

int N;
vector<vector<bool> > v;

bool book(int i, int j)
{
  return (v[i][2 * j + 1] || v[i][2 * j + 2]);
}

void printDump()
{
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2 * N; j++) {
      printf("%c", ((v[i][j])?'Y':'N'));
    }
    printf("\n");
  }
}

void solve()
{
  //printDump();
  
  int ans = 0;
  bool isMid = false;
  if (v[0][0] && v[1][0]) {
    ans += 2;
    isMid = true;
  } else if (v[0][0]) {
    ans += 1;
    isMid = true;
  } else if (v[1][0]) {
    ans += 2;
    isMid = true;
  }

  for (int i = 0; i < N - 1; i++) {
    if (book(0, i) && book(1, i)) {
      ans += 2;
      isMid = true;
    } else if (book(0, i)) {
      ans += 1;
      isMid = true;
    } else if (book(1, i)) {
      if (isMid) {
	ans += 1;
      } else {
	ans += 2;
      }
      isMid = true;
    }
  }

  if (v[0][2 * N - 1] && v[1][2 * N - 1]) {
    if (isMid) {
      ans += 2;
    } else {
      ans += 3;
    }
  } else if (v[0][2 * N - 1]) {
    ans += 1;
  } else if (v[1][2 * N - 1]) {
    if (isMid) {
      ans += 2;
    } else {
      ans += 3;
    }
  }
  printf("%d\n", ans + N);
}

int main()
{
  int T;
  scanf("%d ", &T);
  v.resize(2);
  for (int i = 0; i < T; i++) {
    scanf("%d ", &N);
    v[0].resize(2 * N), v[1].resize(2 * N);
    for (int i = 0; i < 4 * N; i++) {
      char c;
      scanf("%c ", &c);
      v[i / (2 * N)][i % (2 * N)] = (c == 'Y');
    }
    solve();
  }
}

Measured memory_bytes: 0
#include <cstdio>

using namespace std;

char s[200'009];
int f[10'009];

int main() {
  int n, mod;
  scanf("%d%d%s", &n, &mod, s);
  if (mod == 2 || mod == 5) {
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
      if ((int)(s[i] - '0') % mod == 0) {
        ans += i + 1;
      }
    }
    printf("%lld\n", ans);
    return 0;
  }
  for (int i = 0; i < mod; ++i) {
    f[i] = 0;
  }
  f[0] = 1;
  long long ans = 0;
  int sum = 0;
  int pw = 1;
  for (int i = n - 1; i >= 0; --i) {
    sum = (sum + (int)(s[i] - '0') * pw) % mod;
    int x = (mod - sum) % mod;
    ans += f[x];
    ++f[x];
    pw = pw * 10 % mod;
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 384
fun main(args: Array<String>) {
    abc142e()
}

fun abc142e() {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val keys = (1..m).map {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        val c = readLine()!!.split(" ").map { 1 shl (it.toInt() - 1) }.reduce { acc, i -> acc or i }
        Key(a, c)
    }
    val inf = Long.MAX_VALUE / 100000

    val dp = Array(1100) { LongArray(5000) { inf } }
    dp[0][0] = 0

    for (i in 0 until m) {
        for (j in 0 until (1 shl n)) {
            dp[i + 1][j] = Math.min(dp[i + 1][j], dp[i][j])

            val key = keys[i]
            val next = j or key.targetAsBit
            dp[i + 1][next] = Math.min(dp[i + 1][next], dp[i][j] + key.price)
        }
    }

    val answer = dp[m][(1 shl n) - 1].let { if (it < inf) it else -1 }

    println(answer)
}

private data class Key(val price: Int, val targetAsBit: Int)


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

int main(void)
{
	int n, i;
	scanf("%d", &n);

	int *a = (int *) malloc( n * sizeof(int) );

	for(i = 0; i < n; i++)
		scanf("%d", a+i);
	for(i = n-1; i > 0; i--)
		printf("%d ", *(a+i));

	printf("%d\n", *(a+i));

	return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(c) begin(c), end(c)
using namespace std;

template <class T>
void scrib_impl(char const* title, T v){
    cout << title << " ...... " << v << endl;
}
#define SCRIB(EXPR) (scrib_impl(#EXPR, (EXPR)))

using bint = int64_t;

int main() {
    bint a,b,k;
    cin >> a >> b >> k;
    
    if (a >= k) {
        cout << (a-k) << " " << b << endl;
    }else{
        bint b2 = b - k + a;
        if (b2<0) b2=0;
        cout << 0 << " " << b2 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <ctype.h>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
//整形Shift + alt + f 
int n;
int num1[100002];
int num2[100002];

int main(){
    
    cin >> n;
    for(int i = 1; i <= n; i++){
        int tmp;
        cin >> tmp;
        if(i%2 == 1){
            num1[tmp]++;
        }else{
            num2[tmp]++;
        }
    }

    int res1=0,res2=0;
    int id1,id2;
    for(int i = 0; i <= 100000; i++){
        if(res1 < num1[i]){
            res1 = num1[i];
            id1 = i;
        }

        if(res2 < num2[i]){
            res2 = num2[i];
            id2 = i;
        }
        //res1 = max(res1, num1[i]);
        //res2 = max(res2, num2[i]);        
    }
    //cout << n << " " << res1 << " " << res2 << endl;

    int res3=0,res4=0;
    if(id1 == id2){
        for(int i = 0; i <= 100001; i++){
            if(i != id1)res3 = max(res3, num1[i]);
            if(i != id2)res4 = max(res4, num2[i]); 
        }
        
        if(res3 > res4){
            cout << n - res3 - res2;
        }else{
            cout << n - res4 - res1;
        }
        return 0;
    }


    cout << n - res1 - res2;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll Pow(ll a, ll b, ll c){
    ll ans = 1;
    a %= c;
    while (b){
        if (b & 1) ans = (ans * a) % c;
        a = (a * a) % c;
        b >>= 1;
    }
    return (ans % c);
}

bool cmp(const int &a, const int &b){
    return a < b;
}

ll gcd(ll x, ll y){
    return x % y == 0 ? y : gcd(y, x % y);
}

ll lcm(ll x, ll y){
    return x / gcd(x, y) * y;
}

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

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

int a[MAXN], b[MAXN];
int K;

ll gao(int msk){
	ll ret = 0;
	for (int i = 1; i <= n; i++)
		if ((a[i] | msk) == msk)
			ret += b[i];
	return ret;
}

void solve(int casi){
//	cout << "Case #" << casi << ": ";
	cin >> n >> K;
	for (int i = 1; i <= n; i++)
		cin >> a[i] >> b[i];
	ll ans = gao(K);
	for (int i = 0; i < 30; i++) if ((K >> i) & 1){
		int now = K;
		now ^= (1 << i);
		now |= (1 << i) - 1;
		ans = max(ans, gao(now));
	}
	cout << ans << endl;
	return ;
}

void printans(){

}


int main(){
	std::ios::sync_with_stdio(false);
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}

Measured memory_bytes: 4736
#include <stdio.h>
int main(void){
  long K,A,B;
  scanf("%ld %ld %ld",&K,&A,&B);
  if(B-A>2)printf("%ld",(B-A)*((K-(A-1))/2)+(K-(A-1))%2+A);
  else{printf("%ld",K+1);}
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
const ll mod=1e9+7;

ll a[N],d[N];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
   ll res=0;
    for(int i=1;i<=n;i++)
    {
        if(i&1)res+=a[i];
        else res-=a[i];
    }
    d[1]=res;
    for(int i=1;i<n;i++)
    {
        d[i+1]=2*a[i]-d[i];
    }
    for(int i=1;i<=n;i++)printf("%lld ",d[i]);
    return 0;
}


Measured memory_bytes: 2816
sx, sy, tx, ty = map(int, input().split())
dx, dy = (tx-sx), (ty-sy)
print("U"*dy+"R"*dx+"D"*dy+"L"*dx+"L"+"U"*(dy+1)+"R"*(dx+1)+"DR"+"D"*(dy+1)+"L"*(dx+1)+"U")


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

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

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


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int num[3] = {0, 0, 0};
    for (const char c : s) {
        num[c - 'a']++;
    }
    sort(num, num + 3);
    if (num[2] - num[0] <= 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int MAX_N = 10002;
const int P = 2019;
string S;

void solve()
{
	const int N = S.length();
	vector<int> d(N+1);
	int ten=1;
	for(int i=N-1;i>=0;--i){
		int c=(S[i]-'0')*ten%P;
		d[i]=(c+d[i+1])%P;
		(ten*=10)%=P;
	}
	ll ans = 0;
	vector<int> cnt(P);
	for(int i=N;i>=0;--i){
		ans+=cnt[d[i]];
		cnt[d[i]]++;
	}
	cout << ans << '\n';

}

int main()
{
	cin >> S;
	solve();
	return 0;
}

Measured memory_bytes: 4392
import scala.io.StdIn.readInt
import scala.annotation.tailrec

object Main {
  @tailrec def fib(a:Int, b:Int, c:Int, n:Int):Int = {
    n match {
      case 0 => a
      case n => fib(a+b, a, b, n-1)
    }
  }

  def main(args: Array[String]) = {
    val n = readInt()
    println(fib(1, 0, 0, n))
  }
}

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

const int N=1e5+5;

int a[N],cnt[N];

int main(){
	int n; scanf("%d",&n);
	for(int i=0;i<n;++i){
		scanf("%d",a+i);
	}
	memset(cnt,0,sizeof(cnt));
	int b=a[0],c=cnt[a[0]]=1,d=0,e=0;
	for(int i=2;i<n;i+=2){
		cnt[a[i]]++;
		if(a[i]==b) c++;
		else if(a[i]==d){
			e++;
			if(e>c){
				swap(b,d);
				swap(c,e);
			}
		}else{
			if(cnt[a[i]]>=c)d=b,e=c,b=a[i],c=cnt[a[i]];
			else if(cnt[a[i]]>e)d=a[i],e=cnt[a[i]];
		}
//		cout<<a[i]<<" ";
//		cout<<b<<" "<<c<<" "<<d<<" "<<e<<" -"<<cnt[2]<<endl;
	}
	memset(cnt,0,sizeof(cnt));
	int g=a[1],h=cnt[a[1]]=1,x=0,y=0;
	for(int i=3;i<n;i+=2){
		
		cnt[a[i]]++;
		if(a[i]==g) h++;
		else if(a[i]==x){
			y++;
			if(y>h){
				swap(g,x);
				swap(h,y);
			}
		}else{
			if(cnt[a[i]]>=h)x=g,y=h,g=a[i],h=cnt[a[i]];
			else if(cnt[a[i]]>y)x=a[i],y=cnt[a[i]];
		}
//		cout<<a[i]<<" ";
//		cout<<g<<" "<<h<<" "<<x<<" "<<y<<endl;
	}
//	cout<<b<<" "<<c<<" "<<d<<" "<<e<<endl;
//	cout<<g<<" "<<h<<" "<<x<<" "<<y<<endl;
	int ans;
	if(g==b) ans=n-max(c+y,e+h);
	else ans=n-(c+h);
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x = 0;
    int ans = 0;
    int n;
    string s;
    cin >> n >> s;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'I') x++;
        else x--;
        chmax(ans, x);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/**
*    author:  boutarou
*    created: 09.06.2020 14:36:43
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define fcout cout << fixed << setprecision(15)
using lint = long long;
using P = pair<int, int>;

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

const long long MOD = 1e9 + 7;
const long long INF = 3e18;
const double PI = 3.1415926535897932;

class BIT {
private:
	vector<lint>bit;
	int n;
public:
	BIT(int _n) {
		bit.resize(_n + 1);
		rep(i, _n + 1) bit[i] = 0;
		n = _n;
	}

	BIT() {
		n = 0;
	}

	void set(int _n) {
		bit.resize(_n + 1);
		rep(i, _n + 1) bit[i] = 0;
		n = _n;
	}

	int get() {
		return bit.size();
	}

	lint sum(int i) {
		lint s = 0;
		while (i > 0) {
			s += bit[i];
			i -= (i & -i);
		}
		return s;
	}

	lint sum(int i, int j) {
		lint be = sum(i - 1);
		lint af = sum(j);
		return af - be;
	}

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

int n, k;
int a[200005];
lint sum[200005];
vector<lint>vec;
BIT bit;
lint ans = 0;

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

	cin >> n >> k;
	rep(i, n) {
		cin >> a[i];
	}
	sum[0] = 0;
	vec.push_back(0);
	rep(i, n) {
		sum[i + 1] = sum[i] + (a[i] - k);
		vec.push_back(sum[i + 1]);
	}
	sort(vec.begin(), vec.end());
	vec.erase(unique(vec.begin(), vec.end()), vec.end());
	rep(i, n + 1) {
		sum[i] = lower_bound(vec.begin(), vec.end(), sum[i]) - vec.begin();
	}
	bit.set(vec.size());
	rep(i, n + 1) {
		ans += bit.sum(sum[i] + 1);
		bit.add(sum[i] + 1, 1);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5872
/*
????°??????????????£? = ??????????????????
while(?????? == false){
    ????°??????????????£?++;
}

?????????:1 2 3 4 5 6 
???  ???:X X X O O O
X???1???????????????O???????°??????????

????°????O??¨?????§???X?????????????????????
??????????????????????????°??????
*/
//--- --- --- debug function --- --- ---
// #define DEBUG // switch this macro
#ifdef DEBUG
#include <cstdio>
typedef int (*printf_t)(const char* format, ...);
printf_t printfd = std::printf;
#else
int printfd(const char* format, ...){return 0;}
#endif
//--- --- --- debug function --- --- ---
#include <cassert>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

bool Check(const std::vector<int> Wi, int k, int P)
{
    int p = 0;
    --k;
    for(int i = 0; i < Wi.size(); ++i){
        if(P - p >= Wi[i]){
            p += Wi[i];
        }else{
            p = Wi[i];
            --k;
        }
    }
    return k >= 0;
}
int main()
{
    int n,k;
    std::cin >> n >> k;
    std::vector<int> Wi(n);
    for(int i = 0; i < n; ++i){
        std::cin >> Wi[i];
    }

    int MaxValue = *std::max_element(Wi.begin(), Wi.end());
    int MaxBad  = std::floor(std::accumulate(Wi.begin(), Wi.end(), 0) / k - 0.1);
    int MinGood = std::ceil(((double)n / k)) * MaxValue;
    int P = (MaxBad + MinGood) / 2;
    printfd("Max:%d, Min:%d, P:%d\n", MaxBad, MinGood, P);
    while(MaxBad + 1 != MinGood){
        if(MaxValue <= P && Check(Wi, k, P)){
            MinGood = P;
        }else{
            MaxBad = P;
        }
        P = (MaxBad + MinGood) / 2;
        printfd("Max:%d, Min:%d, P:%d\n", MaxBad, MinGood, P);
    }
    std::cout << MinGood << std::endl;
    return 0;
}

Measured memory_bytes: 1800
#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dup(x, y) (((x) + (y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
typedef vector<vector<int>> Graph;
template <class T> inline void chmax(T &a, T b) {
    if(a < b) {
        a = b;
    }
}
template <class T> inline void chmin(T &a, T b) {
    if(a > b) {
        a = b;
    }
}
template <class T> inline T gcd(T x, T y) {
    if(y == 0) {
        return x;
    } else if(x == 0) {
        return y;
    }
    return gcd(y, x % y);
}
template <class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template <class T> inline void print_vector(vector<T> vec) {
    for(int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    cout << endl;
}
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;

/* つるかめループで行ける */
const int YUKICHI = 10000;
const int HIGUCHI = 5000;
const int HIDEYO = 1000;

int main(void) {
    int N, Y;
    cin >> N >> Y;

    for(int x = 0; x <= N; x++) {
        for(int y = 0; y <= N; y++) {
            int z = (Y - (YUKICHI * x + HIGUCHI * y))/HIDEYO;
            if(z >= 0 and x + y + z == N) {
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }

    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
cont = 1
while(cont):
    a = []
    for i in range(8):
        a.append([int(i) for i in list(input())])
    try:
        _ = input()
    except EOFError:
        cont = 0
    ret = 1
    for i in range(8):
        if ret == 0:
            break
        for j in range(8):
            if ret == 0:
                break
            if a[i][j] == 1:
                ret = 0
                if j+1 < 8 and a[i][j+1] == 1:
                    if j+2 < 8 and a[i][j+2] == 1:
                        print("C")
                    else:
                        if j+2 < 8 and i+1 < 8 and a[i+1][j+2] == 1:
                            print("E")
                        elif i+1 < 8 and a[i+1][j+1] == 1:
                            print("A")
                        else:
                            print("G")
                else:
                    if i+1 < 8 and a[i+1][j] == 1:
                        if i+2 < 8 and a[i+2][j] == 1:
                            print("B")
                        else:
                            if j+1 < 8 and a[i+1][j+1] == 1:
                                print("F")
                            else:
                                print("D")





Measured memory_bytes: 5616
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String a = sc.next();
		String b = sc.next();
		
		for (int i = 0; i < a.length(); i++) {
			System.out.print(a.charAt(i));
			try {
				System.out.print(b.charAt(i));
			} catch (Exception ex) {
				
			}
		}
		
		System.out.println();
	}
	
}


Measured memory_bytes: 22608
#include <iostream>

using namespace std;

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

    double dp[N + 1][N + 1];
    fill(&dp[0][0], &dp[N][N + 1], 0);
    dp[0][0] = 1;

    double p;
    for (int i = 1; i <= N; i++) {
        cin >> p;
        dp[i][0] = dp[i - 1][0] * (1 - p);
        for (int j = 1; j <= i; j++) {
            dp[i][j] = dp[i - 1][j] * (1 - p) + dp[i - 1][j - 1] * p;
        }
    }

    double ans = 0;

    for (int i = N; i > N - i; i--) {
        ans += dp[N][i];
    }

    cout.precision(10);
    cout << ans << endl;
}

Measured memory_bytes: 70528
//2019.7.21 by ljz
//email 573902690@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 1e18+1e9
#define eps 1e-10
#define RG register
#define db double
#define lb long db
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define gc getchar
#define Pi 2.0*acos(-1.0)
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
//inline int read() {
//    res s=0,ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
inline int read() {
    res s=0,ch=gc(),w=1;
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s*w;
}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
inline LL Read() {
    RG LL s=0;
    res ch=gc(),w=1;
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s*w;
}
//inline void write(RG __int128 x){
//    if(x>10)write(x/10);
//    putchar(x%10+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=2e5+10;
namespace MAIN{
    int n;
    LL k;
    int a[N];
    int las[N],pos[N],nxt[N],fi[N];
    vector<int> A;
    inline void MAIN(){
        n=read(),k=Read();
        for(res i=1;i<=n;i++){
            a[i]=read();
            if(!las[a[i]])las[a[i]]=i,fi[a[i]]=i;
            else nxt[las[a[i]]]=i,las[a[i]]=i;
        }
        for(res i=1;i<=n;i++)if(!nxt[i])nxt[i]=fi[a[i]];
//        for(res i=1;i<=n;i++)printf("%d\n",fi[a[i]]);
        res p=1,sum=0;
        while(233){
            if(nxt[p]<=p)sum++;
            p=nxt[p]+1;
            if(p==n+1)break;
        }
        sum++;
        k%=sum;
        p=1;
        if(!k)return;
        while(k>1){
            if(nxt[p]<=p)k--;
            p=nxt[p]+1;
            if(p==n+1)p=1;
        }
        while(p<=n)if(nxt[p]>p)p=nxt[p]+1;else break;
        A.pb(a[p]);
        for(res i=p+1;i<=n;)
            if(nxt[i]>i)i=nxt[i]+1;
            else A.pb(a[i]),i++;
        for(auto x:A)printf("%d ",x);
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 5492
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    tmp = [[False] * 3 for _ in range(3)]
    for i, vals in enumerate(A):
        for j, v in enumerate(vals):
            if v in b:
                tmp[i][j] = True
    for i in range(3):
        found = True
        for j in range(3):
            if not tmp[i][j]:
                found = False
        if found:
            print(YES)
            return
    for i in range(3):
        found = True
        for j in range(3):
            if not tmp[j][i]:
                found = False
        if found:
            print(YES)
            return
    if tmp[0][0] and tmp[1][1] and tmp[2][2]:
        print(YES)
        return
    if tmp[0][2] and tmp[1][1] and tmp[2][0]:
        print(YES)
        return
    print(NO)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(A, N, b)

if __name__ == '__main__':
    main()


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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const long double EPS = 1e-10;

long double p,e,t;

long double search(int sleep_cnt, long double r, long double l, long double prob){
    long double ret = 0.0, h = (r+l)/2;

    if(!sleep_cnt){
        if(abs(h-t) <= e) return prob;
        else return 0.0;
    }
    if((t-e <= r && l <= t) || (t <= r && l <= t+e)) return prob;
    if((r <= t-e && l <= t-e) || (t+e <= r && t+e <= l)) return 0.0;
    
    sleep_cnt--;
    if(h >= t){
        ret += search(sleep_cnt, r, h, prob*(1-p));
        ret += search(sleep_cnt, h, l, prob*p);
    }else{
        ret += search(sleep_cnt, r, h, prob*p);
        ret += search(sleep_cnt, h, l, prob*(1-p));
    }
    return ret;
}

int main(){
    int k;
    long double r,l;
    scanf("%d %Lf %Lf %Lf %Lf %Lf", &k,&r,&l,&p,&e,&t);
    printf("%.12Lf\n", search(k, r, l, 1.0));
}


Measured memory_bytes: 3232
#include<stdio.h>
#include<stdlib.h>
 
int main(void){
 
  int num;
  
  scanf("%d",&num);
  
  while(num>10){
   num= num % 10;
  }
  
  if(num==3){
   printf("bon\n");
  }else if(num==0||num==1||num==6||num==8){
   printf("pon\n");
  }else{
   printf("hon\n");
    }
  return 0;
  
 
}

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

int main(){
  string s;
  cin>>s;
  int k;
  cin>>k;
  int n = s.size();
  
  int dp[105][4][2];
  rep(i,105)rep(j,4)rep(k,2) dp[i][j][k] = 0;
  dp[0][0][0] = 1;
  rep(i,n)rep(j,k+1){
    if(s[i]!='0'){
      dp[i+1][j][1]=dp[i][j][0]+dp[i][j][1];
      if(j) dp[i+1][j][1]+=dp[i][j-1][0]*(s[i]-'1')+dp[i][j-1][1]*9;
      if(j) dp[i+1][j][0]=dp[i][j-1][0];
    }else{
      dp[i+1][j][1]=dp[i][j][1];
      if(j) dp[i+1][j][1]+=dp[i][j-1][1]*9;
      dp[i+1][j][0]=dp[i][j][0];
    }
  }
  
  cout << dp[n][k][0]+dp[n][k][1] << endl;
}
  


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

// const int dx[4] = { 1, 0, -1, 0 };
// const int dy[4] = { 0, 1, 0, -1 };

const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}


struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> siz;
    UnionFind(int N) : par(N),siz(N,1) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        if(siz[rx] < siz[ry])swap(rx,ry);
        siz[rx] += siz[ry];
        par[ry] = rx; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x){
      return siz[root(x)];
    }
};

// TODO: write
int main() {
  int n,m;cin>>n>>m;
  auto tree = UnionFind(n);
  set<int> s;
  rep(i,m){
    int a,b;cin>>a>>b;
    a--;b--;
    tree.unite(a,b);
    s.emplace(a);
    s.emplace(b);
  }
  int ans = 0;
  if(m == 0)ans = 1;
  rep(i,n){
    if(s.count(i))chmax(ans,tree.size(i));
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 14324
use proconio::input;

fn main() {
    input! {
        a: i64,
        b: i64,
        _c: i64,
        k: i64,
    };

    let mut ans = 0;
    let mut rst = k;

    if a >= rst {
        ans += rst;
        rst -= rst;
    } else {
        ans += a;
        rst -= a;
    }

    if b >= rst {
        rst -= rst;
    } else {
        rst -= b;
    }

    ans -= rst;

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


Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <climits>

using namespace std;

int main(){
    int A, B, K;
    cin >> A >> B >> K;
    
    if(2 * K > B - A){
        for(int i = A; i <= B; i++){
            cout << i << endl;
        }
    }
    else{
        vector<int> ans;
    
        int cnt = 0;
        for(int i = A; i <= B; i++){
            if(cnt >= K)     break;
            
            cout << i << endl;
            cnt++;
        }
    
        cnt = 0;
        for(int i = B; i >= A; i--){
            if(cnt >= K)     break;
        
            ans.push_back(i);
            cnt++;
        }
        sort(ans.begin(), ans.end());
        for(int i = 0; i < ans.size(); i++){
            cout << ans[i] << endl;
        }
    }
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    long[] a=new long[n+1];
    long[] r=new long[n+1];
    boolean fl=true;
    for(int i=0;i<n+1;i++){
      a[i]=sc.nextLong();
      if(a[i]!=0){
        fl=false;
      }
    }
    if(fl){
      System.out.println(0);
      return;
    }
    for(int i=n-1;i>=0;i--){
      r[i]=r[i+1]+a[i+1];
    }
//    System.err.println(Arrays.toString(r));
    long ans=0;
    long cur=1;
    for(int i=0;i<n+1;i++){
      ans+=cur;
      if(cur<a[i]){
        System.out.println(-1);
        return;
      }
      cur-=a[i];
      cur=Math.min(cur*2,r[i]);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 61200
//package javaapplication2;
import java.util.*;
import java.io.*;
import static java.lang.System.out;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] s = br.readLine().split("\\s");
        int A = Integer.parseInt(s[0]);
        int B = Integer.parseInt(s[1]);
        System.out.println(solve(A,B));
    }
    
    private static int solve(int A,int B){
        int i = 1;
        while(true){
            int crA  = consumptionRate(i,8);
            int crB  = consumptionRate(i,10);
            //System.out.println(i + " " + crA + " " + crB);
            if(crA == A && crB == B) return i;
            if(crA > A || crB > B) break;
            i++;
        }
        return -1;
    }
    
    private static int consumptionRate(int price,int percent){
        return (int)Math.floor((double)price * percent / 100.0);
    }
}


Measured memory_bytes: 23124
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXH=1000;
const int MAXW=1000;
const int DX[]={-1,0,+1,0},DY[]={0,+1,0,-1};

int h,w;
char g[MAXH][MAXW+1];

pair<int,int> q[MAXH*MAXW]; int qhead,qtail;
int d[MAXH][MAXW];

int solve() {
	REP(x,h) REP(y,w) d[x][y]=INT_MAX;
	qhead=qtail=0; REP(x,h) REP(y,w) if(g[x][y]=='#') d[x][y]=0,q[qhead++]=MP(x,y);
	while(qtail<qhead) {
		int x=q[qtail].first,y=q[qtail].second; ++qtail;
		REP(k,4) {
			int nx=x+DX[k],ny=y+DY[k];
			if(nx<0||nx>=h||ny<0||ny>=w||d[nx][ny]!=INT_MAX) continue;
			d[nx][ny]=d[x][y]+1; q[qhead++]=MP(nx,ny);
		}
	}
	int ret=0; REP(x,h) REP(y,w) ret=max(ret,d[x][y]); return ret;
}

void run() {
	scanf("%d%d",&h,&w);
	REP(x,h) scanf("%s",g[x]);
	printf("%d\n",solve());
}

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


Measured memory_bytes: 12928
import java.util.Scanner;

public class Main {
	private static final int INF = Integer.MAX_VALUE;
	static int n = 1;
	static int[] D;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int n= sc.nextInt();
		int op_num = sc.nextInt();
		String[] op = new String[op_num+1];
		for(int i= 0;i<op.length;i++)
			op[i] = sc.nextLine();
		//System.out.println(n);
		initRMQ(n);
		
		for(int i=1;i<=op_num;i++) {
			String[] Split= op[i].split(" ");
			int x = Integer.parseInt(Split[1]);
			int y = Integer.parseInt(Split[2]);
			if(Integer.parseInt(Split[0]) == 0 ) {
				//System.out.println("Update:"+x+" "+y);
				update(x,y);
			}else {
				//System.out.println("findMin:"+x+" "+y);
				int result = findMin(x,y);
				System.out.println(result);
			}
		}
	}
	private static int findMin(int a, int b) {
		// TODO Auto-generated method stub
		return query(a,b+1,0,0,n);
	}
	private static int query(int a, int b, int k, int l, int r) {
		// TODO Auto-generated method stub
		if(r<=a || b<=l)
			return INF;
		if (a<=l && r <=b)
			return D[k];
		
		int vl=query(a,b,k*2+1,l,(l+r)/2);
		int vr = query(a,b,k*2+2,(l+r)/2,r);
		return Math.min(vl, vr);
	}
	private static void update(int k, int a) {
	
		k =k+n-1;
		D[k] = a;
		while(k>0) {
			k = (k-1)/2;
			D[k] = Math.min(D[k*2+1],D[k*2+2]);
		}
	}
	private static void initRMQ(int N) {
		// TODO Auto-generated method stub
		n = 1;
		while(n<N)
			n*=2;
		D = new int[n*2 - 1];
		for(int i=0;i<2*n-1;i++)
			D[i] = INF;
	}
	
	

}



Measured memory_bytes: 161868