akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

typedef struct DICE{
    int s[6];
}dice;

dice dice_rotate(dice d, char rotate){
    int swap;
    if(rotate == 'E'){
        swap = d.s[2];
        d.s[2] = d.s[0];
        d.s[0] = d.s[3];
        d.s[3] = d.s[5];
        d.s[5] = swap;
    }else if(rotate == 'N'){
        swap = d.s[4];
        d.s[4] = d.s[0];
        d.s[0] = d.s[1];
        d.s[1] = d.s[5];
        d.s[5] = swap;
    }else if(rotate == 'S'){
        swap = d.s[1];
        d.s[1] = d.s[0];
        d.s[0] = d.s[4];
        d.s[4] = d.s[5];
        d.s[5] = swap;
    }else if(rotate == 'W'){
        swap = d.s[3];
        d.s[3] = d.s[0];
        d.s[0] = d.s[2];
        d.s[2] = d.s[5];
        d.s[5] = swap;
    }else if(rotate == 'R'){
        swap = d.s[1];
        d.s[1] = d.s[2];
        d.s[2] = d.s[4];
        d.s[4] = d.s[3];
        d.s[3] = swap;
    }

    return d;
}

dice dice_jig(dice d, int i){
    if(i%2==0){
        d = dice_rotate(d, 'S');
    }else if(i%2==1){
        d = dice_rotate(d, 'E');
    }

    return d;
}

bool same_judge(dice d1, dice d2){
    int i;
    bool judge=true;
    for(i=0;i<6;i++){
        if(d1.s[i] != d2.s[i]) judge = false;
    }

    return judge;
}
int main(){
    dice d1,d2;
    int i,j;
    bool judge=false;

    for(i=0;i<6;i++) cin >> d1.s[i];
    for(i=0;i<6;i++) cin >> d2.s[i];

    for(i=0;i<6;i++){
        if(d1.s[0] == d2.s[0]) break;
        d2 = dice_jig(d2, i);
    }

    for(i=0;i<6;i++){
        for(j=0;j<4;j++){
            if(d1.s[1] == d2.s[1] && d1.s[2] == d2.s[2] && d1.s[4] == d2.s[4] && d1.s[3] == d2.s[3]) break;
            d2 = dice_rotate(d2, 'R');
        }
        if(same_judge(d1,d2)){
            judge = true;
            break;
        }
        d2 = dice_jig(d2, i);
    }

    if(judge){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3132
fun main(args: Array<String>) {
    val (K, N) = readLine()!!.split(" ").map(String::toInt)
    val An = readLine()!!.split(" ").map(String::toInt)

    val diff_list = (0 until (N - 1)).map {An[it + 1] - An[it]}.toMutableList()
    diff_list.add(K + (An[0] - An[N - 1]))
    val diff = diff_list.max()!!
    (K - diff).run(::println)
}

Measured memory_bytes: 80936
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int tmp=0;
	for(int i=1;i<s.size();i++){
		if(s[i]==s[i-1]){
			tmp++;
			if(s[i]=='0') s[i]='1';
			else s[i]='0';
		}
	}
	cout<<tmp<<endl;
	return 0;
} 


Measured memory_bytes: 512
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# rstrip().decode('utf-8')
# INF=float("inf")
#MOD=10**9+7
# sys.setrecursionlimit(2147483647)
# import math
#import numpy as np
# import operator
# import bisect
# from heapq import heapify,heappop,heappush
#from math import gcd
# from fractions import gcd
# from collections import deque
# from collections import defaultdict
# from collections import Counter
#from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# map(int,input().split())


def main():
	n=int(input())
	s=input().rstrip().decode('utf-8')
	
	al="ABCDEFGHIJKLMNOPQRSTUVWXYZ"*3
	ans=""
	
	for i in s:
		ans+=al[al.index(i)+n]
		
		
	print(ans)
	
	
	
	







if __name__ == "__main__":
		main()


Measured memory_bytes: 3060
/* 二分木 */
#include<bits/stdc++.h>
#define N 10000
#define Nil -1
using namespace std;
typedef struct{
	int par,left,right;
}Node;
vector<Node> data(N);
int n;
vector<int> a(N);

void getDepth(int u, int d){
	if(u == Nil) return;
	a.at(u) = d;
	getDepth(data.at(u).left, d+1);
	getDepth(data.at(u).right, d+1);
	/*
	while(data.at(u).par != Nil){
		u = data.at(u).par;
		d++;
	}
	return d;
	*/
}

int getSib(int u){
	if(data.at(u).par == Nil) return Nil;
	if(data.at(data.at(u).par).left != Nil && data.at(data.at(u).par).left != u)
		return data.at(data.at(u).par).left;
	if(data.at(data.at(u).par).right != Nil && data.at(data.at(u).par).right != u)
		return data.at(data.at(u).par).right;
	return Nil;
}

int getDeg(int u){
	int a=0;
	if(data.at(u).left != Nil) a++;
	if(data.at(u).right != Nil) a++;
	return a;
}

int setHeight(int u){
	int h1=0,h2=0;
	if(data.at(u).left != Nil){
		h1 = setHeight(data.at(u).left)+1;
	}
	if(data.at(u).right != Nil){
		h2 = setHeight(data.at(u).right)+1;
	}
	if(h1 > h2) return h1;
	else return h2;
}

/*
void getType(int u){
	if(data.at(u).par == Nil) cout << "root, ";
	else if(data.at(u).left == Nil && data.at(u).right == Nil) cout << "leaf, ";
	else cout << "internal node, ";
}
*/

void printData(){
	int i;
	for(i=0;i<n;i++){
		cout << "node " << i << ": parent = " << data.at(i).par <<  ", sibling = " << getSib(i)
		<< ", degree = " << getDeg(i) << ", depth = " << a.at(i) << ", height = " 
		<< setHeight(i);

	if(data.at(i).par == Nil) cout << ", root" << endl;
	else if(data.at(i).left == Nil && data.at(i).right == Nil) cout << ", leaf" << endl;
	else cout << ", internal node" << endl;
		}
}

int main(){
	int v,l,r,init=0;
	//vector<INFO> data(N);
	cin >> n;
	//親の初期化
	for(int i=0;i<n;i++) data.at(i).par = data.at(i).left = data.at(i).right = Nil;
	
	for(int i=0;i<n;i++){
		//v:節点番号
		cin >> v >> l >> r;
		data.at(v).left = l;
		data.at(v).right = r;
		if(l != Nil) data.at(l).par = v;
		if(r != Nil) data.at(r).par = v;
		}

	for(int i=0;i<n;i++){
		if(data.at(i).par == Nil) init = i;
	}
	getDepth(init,0);
	setHeight(init);
	printData();
	}


Measured memory_bytes: 3248
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
using namespace std;
int main() {
	int num = 0;
	for (int i = 0;i < 10;++i) {
		int a;
		scanf("%d", &a);
		num += a;
	}
	printf("%d\n", num);
}


Measured memory_bytes: 1028
#include<iostream>

using namespace std;

int a[200010];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (a[0] != 0) {
		cout << -1 << endl;
		return 0;
	}
	long long an = 0;
	for (int i = 1; i < n; i++) {
		if (a[i] - a[i - 1] == 1) {
			an++;
		}
		else if (a[i] - a[i - 1] < 1) {
			an += a[i];
		}
		else if (a[i] - a[i - 1] > 1) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << an << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int n,m,a[100005],x,y=100000,z;
int main()
{
    cin>>n>>m;
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
        x+=a[i];
        y=min (y,a[i]);
    }
    z=n;
    m-=x;
    z+=m/y;
    cout<<z;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][] card = new int[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                card[i][j] = sc.nextInt();
            }
        }
        int n = sc.nextInt();
        int[][] card1 = new int[3][3];
        for (int i = 0; i < n; i++) {
            int b = sc.nextInt();
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if(b == card[j][k]){
                        card1[j][k] = 1;
                    }
                }
            }
        }

        int flag = 0;
        int count2 = 0;
        int count3 = 0;
        for (int i = 0; i < 3; i++) {
            int count = 0;
            int count1 = 0;

            for (int j = 0; j < 3; j++) {
                if(card1[i][j] == 1){
                    count ++;
                }
                if(card1[j][i] == 1){
                    count1 ++;
                }
            }
            if(card1[i][i] == 1){
                count2 ++;
            }
            if(card1[i][2-i] == 1){
                count3 ++;
            }
            if(count == 3 || count1 == 3 || count2 == 3 || count3 == 3){
                flag = 1;
                break;
            }
        }
        if(flag == 1) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

int main(){
    std::ios_base::sync_with_stdio(false);

    int R,G,B,N; cin >> R >> G >> B >> N;

    ll cnt=0LL;

    rep(r, N+1){
        rep(g, N+1){

            int rem = N-r*R-g*G;

            if(rem>=0 && rem%B==0) cnt++;

        }

    }

    cout << cnt << endl;
    

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b[110000],d[60],e[60],cnt=0;
string s;
char c;
pair<int,int> p[110000];
signed main()
{
	cin>>a;
	rep(i,a){
		cin>>b[i];
	}
	rep(i,a){
		cin>>d[i];
		cnt+=d[i];
	}
	rep(i,a-1){
		cin>>e[i];
	}
	rep(i,a-1){
		if(b[i+1]-1==b[i]){
			cnt+=e[b[i]-1];
		}
	}
	cout<<cnt;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}

int main()
{
string s;
cin>>s;
int ans=0;

int len=s.length(),i=0;
for( ;i<len-1;)
{
	if((s[i]=='0'&&s[i+1]=='1')||(s[i]=='1'&&s[i+1]=='0'))
	 {s.erase(s.begin()+i,s.begin()+i+2);
	// cout<<i<<" "<<s[i]<<" "<<s[i+1]<<endl;
	 ans++;
if(i-1>=0)i--;
	 len=s.length();
//	cout<<s<<" "<<i<<" "<<len<<endl;
	
	continue;
	 }
	 i++;
}	


cout<<ans*2;
}



Measured memory_bytes: 512
#include <stdio.h>
int main(){
    int i,result,n,input;
    long int gou=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&input);
        gou+=input;
    }
    result = gou/i;
    printf("%d\n",result);
    return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main(){
  int n;
  while(1){
    cin >> n;
    if(n==0) break;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    int sum=0;
    rep(i,n) sum += a[i];
    int avg = sum / n;
    rep(i,n) {
      if(a[i]>avg) {cout << i << endl;break;}
      if(i==n-1) cout << n << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <bitset>
#include <set>
#include <map>
#include <string>
#include <math.h>

using namespace std;

#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define swap2(x, y) x=x^y; y=x^y; x=x^y;
#define print(x) if (false) {cout << "[" << #x << " = " << x << "] ";}
#define printNL() if (false) {cout << endl;}

const int MAXN = 2e5;
int parent[1 + MAXN];

int root(int i) {
    return (parent[i] < 0) ? i : (parent[i] = root(parent[i]));
}

void setUnion(int i, int j) {
    i = root(i), j = root(j);
    if (i == j) return;
    if (parent[i] < parent[j]) {
        parent[i] += parent[j];
        parent[j] = i;
    } else {
        parent[j] += parent[i];
        parent[i] = j;
    }
}

int main() {
    int n, m; cin >> n >> m;
    for (int i = 1; i <= n; ++i) parent[i] = -1;
    while (m--) {
        int a, b; cin >> a >> b;
        setUnion(a, b);
    }
    cout << -*min_element(parent+1, parent+n+1) << endl;
    return 0;
}


Measured memory_bytes: 4372
#include <string>
#include <iostream>
#include <algorithm>
#include <sstream>

using namespace::std;

int main(void){
  string in;

  cin >> in;

  if(in.size() == 2) cout << in << endl;
  else {reverse(in.begin(),in.end()); cout <<  in << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<bitset>
#include<algorithm>
#include<climits>
#include<vector>
#include<deque>
#include<cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> P;
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define dump(a) rep(i,a.size()){ cout<<a[i]<<" "; } cout<<endl;
#define dumparr(a,n) rep(i,n){ cout<<a[i]<<" "; } cout<<endl;
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define INF INT_MAX/3
#define FINF DBL_MAX/3
#define EPS 1e-7

#define OUT1(n1) cout<<n1<<endl
#define OUT2(n1,n2) cout<<n1<<" "<<n2<<endl
#define OUT3(n1,n2,n3) cout<<n1<<" "<<n2<<" "<<n3<<endl
#define OUT4(n1,n2,n3,n4) cout<<n1<<" "<<n2<<" "<<n3<<" "<<n4<<endl
#define OUT5(n1,n2,n3,n4,n5) cout<<n1<<" "<<n2<<" "<<n3<<" "<<n4<<" "<<n5<<endl
#define OUT6(n1,n2,n3,n4,n5,n6) cout<<n1<<" "<<n2<<" "<<n3<<" "<<n4<<" "<<n5<<" "<<n6<<endl
#define OUT(n, ...) OUT##n(__VA_ARGS__)

/* まず1次元を考える
 * 一番簡単な方法を作る
 *
 */

int main(){
  ll h,w;
  ll a[501][501];
  int c[250001][4];
  cin>>h>>w;
  rep(i,h) rep(j,w){
    cin>>a[i][j];
  }
  int n=0;
  rep(i, h*w-1){
    ll x = i/w;
    ll y = (i/w) % 2 == 0 ? i%w : w - (i%w)-1;
    ll nx = (i+1)/w;
    ll ny = ((i+1)/w) % 2 == 0 ? (i+1)%w : w - ((i+1)%w)-1;

    if(a[x][y] % 2 == 1) {
      a[x][y]--;
      a[nx][ny]++;
      /* cout<<x<<" "<<y<<" "<<nx<<" "<<ny<<endl; */
      c[n][0]=x+1; c[n][1]=y+1; c[n][2]=nx+1; c[n][3]=ny+1;
      n++;
    }
  }
  OUT(1,n);
  rep(i,n) OUT(4,c[i][0],c[i][1],c[i][2],c[i][3]);
  return 0;
}


Measured memory_bytes: 7936
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

int main(){
  int N;
  cin >> N;
  vector<ll> x(N), y(N);
  rep(i,N) cin >> x[i] >> y[i];
  map<P, int> mp;
  rep(i,N) {
    rep(j,N) {
      if (i == j) continue;
      ++mp[P(x[i]-x[j], y[i]-y[j])];
  	}
  }
  int res = 0;
  for (auto x: mp){
    res = max(res, x.second);
  }
  cout << N - res << endl;
}

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

namespace B
{
	class Program
	{
		static void Main(string[] args)
		{
			var preCondition = ParseIntArray(Console.ReadLine());
			var input = ParseIntArray(Console.ReadLine());
			Console.WriteLine(Ride.GetRiderCount(input, preCondition[1]));
		}

		private static int[] ParseIntArray(string input)
		{
			return input.Split(' ').Select(i => int.Parse(i)).ToArray();
		}
	}

	public class Ride
	{
		public static int GetRiderCount(int[] inputs, int tall)
		{
			return inputs.Where(i => i >= tall).Count();
		}
	}
}


Measured memory_bytes: 19296
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	int A = scan.nextInt();
	int B = scan.nextInt();
	int C = scan.nextInt();
	int D = scan.nextInt();

	int first = 0;
	int last = 0;

	if (A > C) {
		first = A;
	}else {
		first = C;
	}

	if (B > D) {
		last = D;
	}else {
		last = B;
	}
	if (last > first) {
		System.out.println(last - first);
	}else {
		System.out.println(0);
	}
	}
}

Measured memory_bytes: 23764
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int64_t> x(n), y(n), z(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> z[i];
    }
    vector<int64_t> v(n);
    int64_t ans = 0L;
    for (int x_sign = -1; x_sign <= 1; x_sign += 2) {
        for (int y_sign = -1; y_sign <= 1; y_sign += 2) {
            for (int z_sign = -1; z_sign <= 1; z_sign += 2) {
                for (int i = 0; i < n; i++) {
                    v[i] = x_sign * x[i] + y_sign * y[i] + z_sign * z[i];
                }
                sort(v.begin(), v.end(), greater<int64_t>());
                int64_t sum = 0L;
                for (int i = 0; i < m; i++) {
                    sum += v[i];
                }
                ans = max(ans, sum);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,S[100000],q,T[50000],c=0,i,i2,toread,cnt;
	cin>>n;
	for(i=0;i<n;i++)cin>>S[i];
	cin>>q;
	for(i=0;i<q;i++)cin>>T[i];
	/*for(i=0;i<n;i++){
		for(i2=0;i2<n;i2++){
			if(S[i]<S[i2]){
				toread=S[i];
				S[i]=S[i2];
				S[i2]=toread;
			}
		}
	}*/
	sort(S,S+n);
	for(i=0;i<q;i++){
		cnt=0;
		toread=n;
		while(toread>1){
			if(toread%2==0)toread/=2;
			else toread=(toread+1)/2;
			if(S[(toread-1)+cnt]<T[i])cnt+=toread;
			else if(S[(toread-1)+cnt]==T[i]){
				c++;
				break;
			}
		}
	}
	cout<<c<<endl;
}

Measured memory_bytes: 3592
import java.util.ArrayList;
        import java.util.List;
        import java.util.Scanner;
        import java.util.function.Consumer;

        import static java.util.stream.Collectors.toList;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
            int H = Integer.valueOf(args.get(0).split(" ")[0]);
            int W = Integer.valueOf(args.get(0).split(" ")[1]);
            List<String> table = args.stream().skip(1).collect(toList());
            Point[] points = new Point[H * W];
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    boolean open = table.get(i).charAt(j) == '.';
                    points[W * i + j] = new Point(open);
                }
            }

            for (int i = 0; i < H; i++) {
                // left
                for (int j = 1; j < W; j++) {
                    if (table.get(i).charAt(j - 1) == '.') {
                        points[W * i + j].left = points[W * i + j - 1].left + 1;
                    }
                }
                // right
                for (int j = W - 2; j >= 0; j--) {
                    if (table.get(i).charAt(j + 1) == '.') {
                        points[W * i + j].right = points[W * i + j + 1].right + 1;
                    }
                }
            }

            for (int i = 0; i < W; i++) {
                // up
                for (int j = 1; j < H; j++) {
                    if (table.get(j - 1).charAt(i) == '.') {
                        points[W * j + i].up = points[W * (j - 1) + i].up + 1;
                    }
                }
                // down
                for (int j = H - 2; j >= 0; j--) {
                    if (table.get(j + 1).charAt(i) == '.') {
                        points[W * j + i].down = points[W * (j + 1) + i].down + 1;
                    }
                }
            }

            int ans = 0;
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    ans = Math.max(ans, points[W * i + j].score());
                }
            }

            System.out.println(ans);
        };
    }

    static class Point {
        boolean open;
        int left;
        int right;
        int up;
        int down;

        Point(boolean open) {
            left = 0;
            right = 0;
            up = 0;
            down = 0;
            this.open = open;
        }

        int score() {
            return open ? left + right + up + down + 1 : 0;
        }
    }

}


Measured memory_bytes: 246196
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
 
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 GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

vector<pii> calc(int x, int y, int k){
  vector<pii> res;
  
  if(x+y==k){
    res.emplace_back(x,y);
    return res;
  }
  
  int n=(x+y+k-1)/k;
  if(n<=1)n=2;
  if((x+y)%2!=n*k%2)n++;
  
  if(n==3&&x<k){
    // 特殊パターン
    res.emplace_back(x,x-k);
    int overRight=(k+x-y)/2;
    res.emplace_back(x+overRight,y-(k-overRight));
    res.emplace_back(x,y);
  }else{
    int over=(k*n-(x+y))/2;
    rep(i,n){
      int dist=(i+1)*k;
      if(dist<=y+over){
        res.emplace_back(0,dist);
      }else if(dist<=y+over+x){
        res.emplace_back(dist-(y+over),y+over);
      }else{
        res.emplace_back(x,y+(n-(i+1))*k);
      }
    }
  }
  return res;
}

signed main()
{
  int k,x,y;
  cin>>k>>x>>y;
  
  // x>=0, y>=0, x>=y である前提で計算し、最後に修正
  bool xflg=false;
  bool yflg=false;
  bool xyswap=false;
  
  if(x<0){
    x=-x; xflg=true;
  }
  if(y<0){
    y=-y; yflg=true;
  }
  if(x<y){
    swap(x,y); xyswap=true;
  }
  
  // k:偶数、x+y:奇数は到達不能
  if(k%2==0&&(x+y)%2==1){
    cout<<-1<<endl;
    return 0;
  }
  
  vector<pii> ans = calc(x,y,k);
  int n = ans.size();
  
  // flgに応じて答えを修正
  if(xyswap) rep(i,n){
    swap(ans[i].first,ans[i].second);
  }
  if(xflg) rep(i,n){
    ans[i].first*=-1;
  }
  if(yflg) rep(i,n){
    ans[i].second*=-1;
  }
  
  cout<<n<<endl;
  rep(i,ans.size()){
    cout<<ans[i].first<<" "<<ans[i].second<<endl;
  }
}


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

int main() {
	int K, S;
	cin >> K >> S;

	int res = 0;
	for (int i = 0; i <= K; ++i)
		for (int j = 0; j <= K; ++j)
			for (int k = 0; k <= K; ++k)
				if (i + j + k == S) ++res;

	cout << res << endl;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<=(end);i++)
#define REP(i, n) FOR(i,1,n)
#define IFOR(i, begin, end) for(int i=(begin);i>=(end);i--)
#define IREP(i, n) IFOR(i,1,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())

#define ll long long
using namespace std;

int main()
{
    // 入力
    ll N;
    cin>>N;
    vector<ll> A(N+1,-1);

    FOR(i,1,N){
        cin>>A[i];
    }

    vector<ll> gain(2,0);
    vector<ll> gaintemp(2,0);
    // cout<<gain[1]<<" "<<gain[0]<<endl;
    if(N==2){
        cout<<max(A[1]+A[2],-1*A[1]-A[2])<<endl;
        return 0;
    }
    gain[1]=max(A[N],-2*A[N-1]-A[N]);
    gain[0]=max(A[N],2*A[N-1]-A[N]);
    if(N==3){
        cout<<max(A[1]+A[2]+gain[1],-1*A[1]-A[2]+gain[0])<<endl;
        return 0;
    }
    IFOR(i,N-1,3){
        gaintemp[1]=max(A[i]+gain[1],-2*A[i-1]-A[i]+gain[0]);
        // cout<<A[i]+gain[1]<<endl;
        // cout<<-2*A[i-1]-A[i]+gain[0]<<endl;
        gaintemp[0]=max(A[i]+gain[1],2*A[i-1]-A[i]+gain[0]);
        gain[1]=gaintemp[1];
        gain[0]=gaintemp[0];
        // cout<<gain[1]<<" "<<gain[0]<<endl;
    }

    cout<<max(A[1]+A[2]+gain[1],-1*A[1]-A[2]+gain[0])<<endl;
    return 0;
}

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

int main() {
  ll n; cin >> n;
  ll p = 1; REP(i, n) p = p * i % MOD;
  cout << p << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fori(x,y)   for(ll i=x;i<y;i++)
#define forj(x,y)   for(ll j=x;j<y;j++)
#define rfori(a,b)  for(int i=a;i>=b;i--)
#define for_it(a)   for(auto it: a)
#define pb          push_back
#define pf          push_front
#define ff          first
#define ss          second
#define all(x)      x.begin(),x.end()
#define mp          make_pair
#define mod         1000000007
#define mem(a,b)    memset(a,b,sizeof(a))
#define ld          long double
#define endl        "\n"
#define ll          long long
#define llu         unsigned long long 
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define vl          vector<ll> ;
#define vi          vector<int> 
#define vc          vector<char> 
#define vs          vector<string> 
#define si          set<int>
#define spii        set<pii>
#define usi         unordered_set<int>
#define uspii       unordered_set<pii>
#define mii         map<int,int>
#define umii        unordered_map<int,int>
#define pqmx        priority_queue<int>
#define pqmn        priority_queue<int,vi,greater<int>>
#define setbits(x)  __builtin_popcountll(x)
#define fast        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int xx[4]={0,0,1,-1};
int yy[4]={-1,1,0,0};

/*-----------------------------------------------------------------------------------------------------------------*/

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("A_IN.txt","r",stdin);
	freopen("A_Out.txt","w",stdout);
	#endif
	fast;
	
	

	int n,c=1,res=0;
	cin>>n;
	while(c<n)
	{
		if(n%c==0)
		{
			res+=n/c-1;
		}
		else
			res+=n/c;
		c++;
	}
 	cout<<res<<endl;

	return 0;
}

Measured memory_bytes: 3620
package main

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

type xy struct {
	y int
	x int
	d int
}
type que struct {
	data []xy
}

func (q *que) enq(i xy) {
	q.data = append(q.data, i)
}

func (q *que) deq() *xy {
	if len(q.data) == 0 {
		return nil
	}
	v := q.data[0]
	q.data = q.data[1:]
	return &v
}

// https://atcoder.jp/contests/agc033/tasks/agc033_a
// https://qiita.com/ruiu/items/8edf22cd5fc8f7511687
// https://qiita.com/aja_min/items/fed640d6835eb343eedf
func main() {
	sc := newScanner()
	var h = sc.readInt()
	var w = sc.readInt()
	var masu = make([][]rune, h)
	var q = que{data: []xy{}}
	for i := 0; i < h; i++ {
		masu[i] = make([]rune, w)
		var s = sc.readString()
		var j = 0
		for _, l := range s {
			masu[i][j] = l
			if masu[i][j] == '#' {
				q.enq(xy{i, j, 0})
			}
			j++
		}
	}
	// for i := 0; i < h; i++ {
	// 	for j := 0; j < w; j++ {
	// 		fmt.Printf(string(masu[i][j]))
	// 	}
	// 	fmt.Println("")
	// }

	depth := 0
	for {
		deq := q.deq()
		if deq == nil {
			break
		}

		var x = deq.x
		var y = deq.y
		var d = deq.d
		if d >= depth {
			depth = d
		}
		if x+1 < w && masu[y][x+1] == '.' {
			masu[y][x+1] = '#'
			q.enq(xy{y, x + 1, d + 1})
		}
		if x-1 >= 0 && masu[y][x-1] == '.' {
			masu[y][x-1] = '#'
			q.enq(xy{y, x - 1, d + 1})
		}
		if y+1 < h && masu[y+1][x] == '.' {
			masu[y+1][x] = '#'
			q.enq(xy{y + 1, x, d + 1})
		}
		if y-1 >= 0 && masu[y-1][x] == '.' {
			masu[y-1][x] = '#'
			q.enq(xy{y - 1, x, d + 1})
		}

	}
	fmt.Println(depth)

}

// -   io

type scanner struct {
	bufScanner *bufio.Scanner
}

func newScanner() *scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &scanner{bufSc}
}

func (sc *scanner) readString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *scanner) readInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *scanner) readInt64() int64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseInt(text, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}


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

int main() {
    int n, m, c, ans = 0;
    cin >> n >> m >> c;
    vector<vector<int>> a(n, vector<int>(m, 0));
    vector<int> b(m);
    rep(i,m) cin >> b[i];
    rep(i,n) {
        int num = c;
        rep(j,m) {
            cin >> a[i][j];
            num += a[i][j]*b[j];
        }
        if(num>0) ans++;
    }
    cout << ans << endl;
    return 0;
}

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


int main() {

	int in = 0;
	int sum = 0;
	scanf( "%d", &in );

	int temp = in;

	while( temp ) {
		int mod = temp % 10;
		sum += mod;
		temp /= 10;
	}

	if( in % sum ) {
		printf( "No\n" );
	}
	else {
		printf( "Yes\n" );
	}
}



Measured memory_bytes: 256
/***************************************************
 * Problem Name : A.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2020-06-14
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.rbegin(), v.rend())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define F first
#define S second
#define MAX 100005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm ( ll a, ll b ) {
    return ( a / __gcd ( a, b ) ) * b;
}
/************************************ Code Start Here ******************************************************/
int main () {
    //~ __FastIO;
    //~ cout << setprecision (10) << fixed;
    vector<int>vec (5);
    int ans = 0;

    for (int i = 0; i < 5; i++) {
        cin >> vec[i];

        if (vec[i] == 0) ans = i + 1;
    }

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


Measured memory_bytes: 3568
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>

#define f first
#define s second
#define mp make_pair
#define eb emplace_back
#define sz(s) ((int) s.size ())
#define all(s) s.begin (), s.end ()

using namespace std;

typedef long long ll;

const int N = (int) 2e5 + 5;
const int mod = (int) 1e9 + 7;

int n, q, a, b, ls;
ll f[N * 4], s[N * 4], pf;

void upd (int p, ll x, int v = 1, int tl = 1, int tr = n) {
        if (tl == tr) {
                f[v] = x - p;
                s[v] = x + p;
        } else {
                int tm = (tl + tr) >> 1;
                if (p <= tm) {
                        upd (p, x, v + v, tl, tm);
                } else {
                        upd (p, x, v + v + 1, tm + 1, tr);
                }
                f[v] = min (f[v + v], f[v + v + 1]);
                s[v] = min (s[v + v], s[v + v + 1]);
        }
}

ll getF (int l, int r, int v = 1, int tl = 1, int tr = n) {
        if (tl > r || l > tr || l > r) {
                return (ll) 1e18;
        } else if (l <= tl && tr <= r) {
                return f[v];
        } else {
                int tm = (tl + tr) >> 1;
                return min (getF (l, r, v + v, tl, tm), getF (l, r, v + v + 1, tm + 1, tr));
        }
}

ll getS (int l, int r, int v = 1, int tl = 1, int tr = n) {
        if (tl > r || l > tr || l > r) {
                return (ll) 1e18;
        } else if (l <= tl && tr <= r) {
                return s[v];
        } else {
                int tm = (tl + tr) >> 1;
                return min (getS (l, r, v + v, tl, tm), getS (l, r, v + v + 1, tm + 1, tr));
        }
}

ll get (int v = 1, int tl = 1, int tr = n) {
        if (tl == tr) {
                return f[v] + tl;
        } else {
                int tm = (tl + tr) >> 1;
                return min (get (v + v, tl, tm), get (v + v + 1, tm + 1, tr));
        }
}

inline void solve () {
        scanf ("%d%d%d%d", &n, &q, &a, &b);
        fill (f, f + 4 * N, (ll) 1e18);
        fill (s, f + 4 * N, (ll) 1e18);
        upd (a, 0); ls = b;
        while (q--) {
                int x; scanf ("%d", &x);
                ll bs = min (getF (1, x) + x, getS (x, n) - x) + pf;
                pf += abs (x - ls);
                upd (ls, bs - pf);
                ls = x;
        }
        printf ("%lld\n", get () + pf);
}

int tests = 1;

int main () {
//        freopen (".in", "r", stdin);
//        freopen (".out", "w", stdout);
//        scanf ("%d", &tests);
        while (tests--) {
                solve ();
        }
        return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
  int i,j,save,sum=0,K,N,l[50];
  scanf("%d %d",&N, &K);
  for(i=0;i<N;i++){
    scanf("%d",&l[i]);
  }
  //sort
  for(i=0;i<N-1;i++){
    for(j=N-1;j>i;j--){
      if(l[j]>l[j-1]){
        save = l[j];
        l[j] = l[j-1];
        l[j-1] = save;
        }
      }
    }
    for(i=0;i<K;i++){
      sum+=l[i];
    }
    printf("%d",sum);
  return 0;
}


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

using namespace std;
int n;
int a[1005];
int gcd(int a,int b)
{
    return b==0?a:gcd(b,a%b);
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    int t=1;
    for(int i=1;i<=n;i++)
    {
        t=t*a[i]/gcd(t,a[i]);
    }
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        sum=sum+t/a[i];
    }
    double res=1.0*t/sum;
    printf("%.10f",res);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[]) {
  string s;
  cin>>s;
  int a[4];
  for(int i=0;i<4;i++){
    a[i]=s[i]-'0';
  }
  if((a[0]+a[1]+a[2]+a[3])==7){
    cout<<a[0]<<"+"<<a[1]<<"+"<<a[2]<<"+"<<a[3]<<"=7"<<endl;
  }else if((a[0]+a[1]+a[2]-a[3])==7){
    cout<<a[0]<<"+"<<a[1]<<"+"<<a[2]<<"-"<<a[3]<<"=7"<<endl;
  }else if((a[0]+a[1]-a[2]+a[3])==7){
    cout<<a[0]<<"+"<<a[1]<<"-"<<a[2]<<"+"<<a[3]<<"=7"<<endl;
  }else if((a[0]+a[1]-a[2]-a[3])==7){
    cout<<a[0]<<"+"<<a[1]<<"-"<<a[2]<<"-"<<a[3]<<"=7"<<endl;
  }else if((a[0]-a[1]+a[2]+a[3])==7){
    cout<<a[0]<<"-"<<a[1]<<"+"<<a[2]<<"+"<<a[3]<<"=7"<<endl;
  }else if((a[0]-a[1]+a[2]-a[3])==7){
    cout<<a[0]<<"-"<<a[1]<<"+"<<a[2]<<"-"<<a[3]<<"=7"<<endl;
  }else if((a[0]-a[1]-a[2]+a[3])==7){
    cout<<a[0]<<"-"<<a[1]<<"-"<<a[2]<<"+"<<a[3]<<"=7"<<endl;
  }else if((a[0]-a[1]-a[2]-a[3])==7){
    cout<<a[0]<<"-"<<a[1]<<"-"<<a[2]<<"-"<<a[3]<<"=7"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


int main(void){
    ll K,N;
    cin>>K>>N;
    vector<ll> A(N),B(N);
    rep(i,N) cin>>A.at(i);
    rep(i,N-1) B.at(i)=A.at(i+1)-A.at(i);
    B.at(N-1)=K+A.at(0)-A.at(N-1);
    sort(ALLOF(B));
    cout<<K-B.at(N-1)<<endl;
    return 0;
}

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

class P
{
    static void Main()
    {
        int[] NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Tree tree = new Tree(NM[0]);
        for (int i = 0; i < NM[1]; i++)
        {
            int[] LRD = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if(!tree.Union(LRD[0] - 1, LRD[1] - 1, LRD[2]))
            {
                Console.WriteLine("No");
                return;
            }
        }
        Console.WriteLine("Yes");
    }
}

public class Tree
{
    //親、データ、加算要素(下からたどってってごにょごにょする)
    TreeD[] data;
    public Tree(int count)
    {
        data = Enumerable.Range(0, count).Select(x => new TreeD(x, 0)).ToArray();
    }
    public bool Union(int x, int y, int Diff)
    {
        int xparent = Parent(x);
        int yparent = Parent(y);
        int xvalue = Value(x);
        int yvalue = Value(y);
        if (xparent != yparent)
        {
            data[yparent].Parent = xparent;
            data[yparent].Value = Diff + (xvalue - yvalue);
        }
        else
        {
            if (yvalue - xvalue != Diff) return false;
        }
        return true;
    }
    public int Parent(int x)
    {
        form(x);
        return data[x].Parent;
    }
    public int Value(int x)
    {
        form(x);
        return data[x].Value;
    }
    //強制的にひっつかせる奴
    private void form(int x)
    {
        while (data[data[x].Parent].Parent != data[x].Parent)
        {
            //親のAddを足して親の親にひっつく
            data[x].Value += data[data[x].Parent].Value;
            data[x].Parent = data[data[x].Parent].Parent;
        }
    }
}
class TreeD
{
    public int Parent;
    public int Value;
    public TreeD(int p, int a)
    {
        Parent = p;
        Value = a;
    }
}

Measured memory_bytes: 24280
#include<bits/stdc++.h>
#include<boost/range/irange.hpp>
#include<boost/multiprecision/cpp_int.hpp>
#include<boost/algorithm/string/classification.hpp>
#include<boost/algorithm/string/split.hpp>
#include<boost/algorithm/string/join.hpp>
#include<boost/algorithm/string/replace.hpp>
#include<boost/math/tools/minima.hpp>
#include<boost/pending/disjoint_sets.hpp>
using namespace std;
using boost::irange;
using boost::multiprecision::cpp_int;
using boost::algorithm::split;
using boost::is_any_of;
using boost::algorithm::join;
using boost::algorithm::replace_all;
using boost::math::tools::brent_find_minima;
typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}
int main(){
    int n;
    double ans;
    cin >> n;
    if(n%2 == 0)ans = (n*0.5)/n;
    else ans = ((n-1)*0.5 + 1)/n;
    cout << fixed << setprecision(15);
    cout << ans << endl;
}   



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define umap unordered_map
#define mp make_pair
#define pb push_back
#define ll long long
#define int long long
#define ld long double
#define f(i, x, n) for(int i = x; i < n; i++)
#define fd(i, n, x) for(int i = n; i >= x; i--)
#define mod 1000000007


int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n;
    cin >> n;
    int d = n % 10;
    if(d == 3)
        cout << "bon\n";
    else if (d == 0 or d == 1 or d == 6 or d == 8)
        cout << "pon\n";
    else   
        cout << "hon\n";
    return 0;
}

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

int main(){
  int a[3],count=0,ans=0;
  cin >> a[0] >> a[1] >> a[2];
  if(a[0] == a[1] && a[1] == a[2]){
    cout << "Yes";
  }else{
  cout << "No";
}
  return 0;
}


Measured memory_bytes: 256
def resolve():
    nclo=range(int(input()))
    from fractions import gcd
    def lcm(a,b):
        return (a*b)//gcd(a,b)
    next=0
    temp=1
    for i in nclo:
        next=int(input())
        temp=lcm(temp,next)
    print(temp)
        
#%%submit!
resolve()

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}

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

    int n; cin >> n;
    cout << (n+1) / 2;










    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

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

	// 初期化 (最小化問題なので INF に初期化)
	for (int i = 0; i < 100010; ++i) dp[i] = INF;

	// 初期条件
	dp[0] = 0;

	// ループ
	for (int i = 1; i < N; ++i) {
		chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}

	// 答え
	cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
n, k, c = map(int, input().split())
s = input()
dp = [0]*(n+1)
nxt = [-1]*n
now = -1
flag = [-1]*n
pre = -c-2
cnt = 0
for i in range(n):
    if s[i] == 'o':
        if now != -1: nxt[now] = i
        now = i
        if pre+c<i and cnt<k:
            pre = i
            flag[i] = cnt
            cnt+=1
dp = [0]*(n+1)
for i in range(n)[::-1]:
    if s[i] == 'x':
        dp[i] = dp[i+1]
        continue
    dp[i] = 1 if i+c+1 >= n else dp[i+c+1]+1
for i in range(n):
    if flag[i] == -1:
        continue
    if flag[i]+dp[nxt[i]]<k:
        print(i+1)

       


Measured memory_bytes: 54220
using System;

class Program {
  static void Main(string[] args) {
    string[] val = Console.ReadLine().Split();
    int n = int.Parse(val[0]);
    int k = int.Parse(val[1]);

    double ans = k * Math.Pow(k - 1, n - 1);

    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <regex>
#include <set>
#include <cmath>

using namespace std;

int main()
{
    double r;
    std::cin >> r;
    std::cout << 2.0 * r * M_PI;


    return EXIT_SUCCESS;
} 

Measured memory_bytes: 3236
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
    int n;
    scanf("%d", &n);
    vector< int> a(n), b(n);
    for (int &e : a) cin >> e;
    for (int &e : b) cin >> e;

    int ans = 0;
    for (int i = 0; i < 29; ++i) {
        vector< int> B(n);
        int m = 1 << (i + 1);
        for (int j = 0; j < n; ++j) B[j] = b[j] % m;

        sort(B.begin(), B.end());
        ll cnt = 0;
        int c = 1 << i;
        for (int j = 0; j < n; ++j) {
            int t = a[j] % m;
            cnt += distance(lower_bound(B.begin(), B.end(), c - t), lower_bound(B.begin(), B.end(), 2 * c - t));
            cnt += distance(lower_bound(B.begin(), B.end(), 3 * c - t), lower_bound(B.begin(), B.end(), 4 * c - t));
        }
        if (cnt % 2) ans or_eq (1 << i);
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<vector<int> >g;
vector<int>mm;
int dfs(int v)
{
	if(mm[v]!=-1)
	{
		return mm[v];
	}
	mm[v]=0;
	for(int i=0;i<g[v].size();i++)
	{
		int u=g[v][i];
		mm[v]=max(mm[v],dfs(u)+1);
	}
	return mm[v];
}
int main()
{
	cin>>n>>m;
	g.resize(n);
	for(int i=0;i<n;i++)
	{
		mm.push_back(-1);
	}
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		g[a].push_back(b);
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		ans=max(ans,dfs(i));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 200000000000
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()

bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    ll H,A;
    cin >>H>>A;
    ll ans;
    if(H%A == 0){
        ans = H/A;
    }else{
        ans = H/A +1;
    }
    
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+10;
char s[N];
int main()
{
	scanf("%s",s+1);
	int n=(int)strlen(s+1);
	if(s[n]=='1'||s[1]=='0'||s[n-1]=='0'){
		printf("-1\n");
		return 0;
	}
	int now = 2;
	while(now<=n-now){
		if(s[now]!=s[n-now]) {
			printf("-1\n");
			return 0;
		}
		now++;
	}
	int root=2,num=1;
	now=2;
	printf("2 1\n");
	while(now<=n-now){
		if(s[now]=='1'){
			printf("%d %d\n",++now,root);
			root=now;
		}else{
			printf("%d %d\n",++now,root);
		}
		num++;
	}
	for(int i=num+1;i<n;i++){
		printf("%d %d\n",root,++now);
	}

}


Measured memory_bytes: 1536
S = list(input())
p = S.copy()

cnt1 = 0
cnt2 = 0
for i in range(1,len(S)):
    if S[i] == S[i-1]:
        if S[i] == '1':
            S[i] = '0'
        else:
            S[i] = '1'
        cnt1 += 1

for j in range(len(p)-2,-1,-1):
    if p[j] == p[j+1]:
        if p[j] == '1':
            p[j] = '0'
        else:
            p[j] = '1'
        cnt2 += 1

print(min(cnt1,cnt2))

Measured memory_bytes: 10256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;


//-------------------------
//再帰関数を使う
//------------------------
string f(ll n){
  if(n == 0) return "";
  n--;
  return(f(n/26)) + string(1, 'a' + n %26);
}

int main() {
  ll n;
  //string al = "abcdefghijklmnopqrstuvwxyz";
  cin >> n;
  cout << f(n) << endl;
  return 0;
}

Measured memory_bytes: 3600
import sys
from itertools import accumulate
 
def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    S = str(input().strip())
    S += 'x'
 
    A = []
    S0 = S[0]
    cnt = 0
    for s in S:
        if S0 == s:
            cnt += 1
        else:
            A.append(cnt)
            cnt = 1
            S0 = s
 
 
    n = len(A) // 2
    if len(A) % 2 == 1 and S[0] == '0':
        n += 1
 
    if n <= K:
        return sum(A)
 
    if S[0] == '0':
        A = [0] + A
    if S[-2] == '0':
        A = A + [0]
    A = [0] + list(accumulate(A))
 
    ans = 0
    for i in range(0, len(A) - 2*K, 2):
        ans = max(ans, A[i + 2*K + 1] - A[i])
 
    return ans
 
 
if __name__ == '__main__':
    print(main())

Measured memory_bytes: 9324