akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

#define FREE -1
#define NOT_FREE 1

int row[8],col[8],dpos[2*8-1],dneg[2*8-1];

int X[8][8];

void initialize(void);
void print(void);
void recursive(int);

int main(){
  int i,j;
  
  initialize();

  for(i=0;i<8;i++)
    for(j=0;j<8;j++) X[i][j]=0;

  int n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    int r,c;
    scanf("%d%d",&r,&c);
    X[r][c]=1;
  }
  recursive(0);

  return 0;
}

void initialize(){
  int i;
  for(i=0;i<8;i++){
    row[i]=FREE;
    col[i]=FREE;
  }
  for(i=0;i<8*2-1;i++){
    dpos[i]=FREE;
    dneg[i]=FREE;
  }
}

void print(){
  int i,j;

   for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      if(X[i][j]){
	if(row[i]!=j)return;
      }
    }
   }
  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      printf("%c",(row[i]==j)?'Q':'.');
    }
    printf("\n");
  }
}

void recursive(int i){
  int j;
  if(i==8){
    print();
    return;
  }
  for(j=0;j<8;j++){
    if(NOT_FREE==col[j] || NOT_FREE==dpos[i+j] || NOT_FREE==dneg[i-j+8-1]) continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+8-1]=NOT_FREE;
    recursive(i+1);
    row[i]=col[j]=dpos[i+j]=dneg[i-j+8-1]=FREE;
  }
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
inline int ceil(int a, int b) { return a % b == 0 ? a / b : a / b + 1; }
int main() {
    // freopen("data.txt", "r", stdin);
    int n, k, ii;
    scanf("%d%d", &n, &k);
    for (int i = 1, a; i <= n; ++i) {
        scanf("%d", &a);
        if (a == 1) ii = i;
    }
    int ans = n;
    for (int i = max(1, ii - k + 1); i <= ii; ++i) {
        // i, i+k-1
        int cnt = 1 + ceil(i - 1, k - 1);
        if (i + k - 1 < n) {
            cnt += ceil(n - (i + k - 1), k - 1);
        }
        ans = min(ans, cnt);
        // printf("i = %d, cnt = %d\n", i, cnt);
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC159F
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = RInt;
            var S = RInt;
            var A = RInts;

            long mod = 998244353;

            long[] dp = new long[3030];
            long ans = 0;
            for (int i = 0; i < N; i++)
            {
                for (int j = S - A[i]; j >= 0; j--)
                {
                    if (j == 0) dp[A[i]] = (dp[A[i]] + i + 1) % mod;
                    else dp[A[i] + j] = (dp[A[i] + j] + dp[j]) % mod;
                }
                ans += dp[S];
                ans %= mod;
            }

            Console.WriteLine(ans);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String RNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int RInt => int.Parse(RNext());
        public static long RLong => long.Parse(RNext());
        public static int[] RInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] RLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
        public static string RString => RNext();
        //以下未テスト
        public static int[] RIntsC(int c) => Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
        public static long[] RLongsC(int c) => Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
        public static char[][] RMap(int h) => Enumerable.Repeat(0, h).Select(x => Console.ReadLine().ToCharArray()).ToArray();
    }

    static class Debug
    {
        static public void Draw2D<T>(T[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            string[,] map2 = new string[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0.ToString();
                    else if (i == 0) map2[i, j] = (j - 1).ToString();
                    else if (j == 0) map2[i, j] = (i - 1).ToString();
                    else map2[i, j] = map[i - 1, j - 1].ToString();
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j].Last());
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D<T>(T[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


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

using namespace std;

int main()
{
  int n;
  while(cin >> n, n){
    int p[44], t[44];
    p[0] = 0;
    t[0] = 0;
    for(int i = 1; i <= n; i++) cin >> p[i] >> t[i];
    int dp[44][4];
    const int inf = (1 << 25);
    fill(dp[0], dp[44], inf); 
    dp[0][0] = 0;
    for(int i = 1; i <= n; i++){
      for(int j = 0; j <= min(i-1, 3); j++){
	if(j != 3 && abs(p[i]-p[i-1])*(j+1) <= t[i]-t[i-1]){
	  dp[i][j+1] = min(dp[i][j+1], dp[i-1][j] + abs(p[i]-p[i-1]));
	}
	if(p[i]+p[i-1]*(j+1) <= t[i]-t[i-1]){
	  dp[i][1] = min(dp[i][1], dp[i-1][j] + p[i]+p[i-1]);	    
	}
      }
    }
    for(int i = 0; i <= 3; i++) dp[n][i] += p[n];
    int ans = *min_element(dp[n], dp[n] + 4);
    if(ans < inf) cout << "OK " << ans << endl;
    else{
      for(int i = 0; i <= n; i++){
	bool judge = false;
	for(int j = 0; j <= 3; j++){
	  if(dp[i][j] < inf) judge = true;
	}
	if(!judge){
	  cout << "NG " << i << endl;
	  break;
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c)!=EOF)
    {
        if(a==b)printf("%d\n",c);
        else if(b==c)printf("%d\n",a);
        else if(a==c)printf("%d\n",b);
    }
    return 0;
}


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	int ans = ceil(N / 2.0);
	cout << ans << endl;

	return 0;
}

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

using namespace std;

bool block[30][30];

long long int memo[30][30];

int sum(int x, int y){
	if(x == 0 || y == 0){
		return 0;
	}
	if(block[x][y]){
		return 0;
	}
	if(x == 1 && y == 1){
		return 1;
	}
	if(memo[x - 1][y] < 0){
		memo[x - 1][y] = sum(x - 1, y);
	}
	if(memo[x][y - 1] < 0){
		memo[x][y - 1] = sum(x, y - 1);
	}
	return memo[x - 1][y] + memo[x][y - 1];
}

int main(){
	int a, b, n;
	while(true){
		cin >> a >> b;
		if(a == 0){
			break;
		}
		for(int i = 0; i < 30; i++){
			for(int j = 0; j < 30; j++){
				block[i][j] = false;
				memo[i][j] = -1;
			}
		}
		cin >> n;
		for(int i = 0; i < n; i++){
			int num1, num2;
			cin >> num1 >> num2;
			block[num1][num2] = true;
		}
		cout << sum(a, b) << endl;
	}
	return 0;
}

Measured memory_bytes: 2996
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    
    string result = "Odd";
    
    int buf = a * b;
    if(buf % 2 == 0)
    {
        result = "Even";
    }
    
    cout << result << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	int n, m; cin >> n >> m; std::vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];

	std::vector<long> s(n + 1);
	for(int i = 0; i < n; i++) (s[i + 1] = s[i] + a[i]) %= m;
	
	i64 ans = 0;
	std::map<int, int> li;
	for(int i = n; i >= 0; i--) {
		ans += li[s[i]];
		li[s[i]] += 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4352
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int h = rint, w = rint, n = rint;
	if(h >= w){
		((n + h - 1) / h).writeln;
	} 
	else{
		((n + w - 1) / w).writeln;
	}
}

Measured memory_bytes: 256
// 2011/02/20 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		int tim[10][10];
		for(int i=0; i<10; i++)
			for(int j=0; j<10; j++)
				if(i==j)
					tim[i][j] = 0;
				else
					tim[i][j] = -1;

		int m = -1;
		for(int i=0; i<n; i++){
			int a, b, c;
			cin >> a >> b >> c;
			tim[a][b] = tim[b][a] = c;
			if(m<a)
				m = a;
			if(m<b)
				m = b;
		}
		m = m+1;

		for(int k=0; k<m; k++)
			for(int i=0; i<m; i++)
				for(int j=0; j<m; j++)
					if(tim[i][k]==-1||tim[k][j]==-1)
						continue;
					else if(tim[i][j]==-1)
						tim[i][j] = tim[i][k]+tim[k][j];
					else if(tim[i][j]>tim[i][k]+tim[k][j])
						tim[i][j] = tim[i][k]+tim[k][j];

		int m_min = 0;
		int s_min = 0;
		for(int i=0; i<m; i++)
			s_min += tim[0][i];

		for(int i=1; i<m; i++){
			int sum = 0;
			for(int j=0; j<m; j++)
				sum += tim[i][j];
			if(sum<s_min){
				m_min = i;
				s_min = sum;
			}
		}

		cout << m_min << ' ' << s_min << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define DEBUG(x) cerr << #x << " = " << x << endl
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)

int memo[5][5][5][5];

int solve(const int A[2], const int B[2]) {
  // cerr << A[0] << "," << A[1] << "," << B[0] << "," << B[1] << endl;
  int &res = memo[A[0]][A[1]][B[0]][B[1]];
  if(res != 0) return res;
  if(A[0] == 0 && A[1] == 0) return res = -1;
  bool win = false;
  int nb[2];
  if(A[0] > 0) {
    if(B[0] > 0) {
      nb[0] = B[0] + A[0];
      if(nb[0] >= 5) nb[0] = 0;
      nb[1] = B[1];
      if(solve(nb, A) < 0) win = true;
    }
    if(B[1] > 0) {
      nb[0] = B[0];
      nb[1] = B[1] + A[0];
      if(nb[1] >= 5) nb[1] = 0;
      if(solve(nb, A) < 0) win = true;
    }
  }
  if(A[1] > 0) {
    if(B[0] > 0) {
      nb[0] = B[0] + A[1];
      if(nb[0] >= 5) nb[0] = 0;
      nb[1] = B[1];
      if(solve(nb, A) < 0) win = true;
    }
    if(B[1] > 0) {
      nb[0] = B[0];
      nb[1] = B[1] + A[1];
      if(nb[1] >= 5) nb[1] = 0;
      if(solve(nb, A) < 0) win = true;
    }
  }
  return res = win ? 1 : -1;
}

signed main() {
  ios::sync_with_stdio(false);
  int A[2], B[2];
  cin >> A[0] >> A[1] >> B[0] >> B[1];
  memset(memo, 0, sizeof(memo));
  cout << (solve(A, B) > 0 ? "ISONO" : "NAKAJIMA") << endl;
}

Measured memory_bytes: 3228
def main():
  N = int(input())
  minimum = 1000000
  for A in range(1, N):
    B = N - A
    a_nums = list(map(lambda i: int(i), list(str(A))))
    b_nums = list(map(lambda i: int(i), list(str(B))))
    count = 0
    for a in a_nums:
      count += a
    for b in b_nums:
      count += b
    if minimum > count:
      minimum = count
  print(minimum)

main()


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

int main(){
  while(true){
    string s;
    string bottom;
    string top;
    int m;
    int h;
    cin >> s;
    if(s=="-")break;
    cin >> m;
    for(int i=0; i<m; i++){
      cin >> h;
      //cout << h << endl;
      bottom = s.substr(0, h);
      top = s.substr(h, s.length()-h);
      //cout << bottom << " " << top << endl;
      for(int i=0; i<s.length()-h;i++){
        s[i] = top[i];
      }
      for(int i=0; i<h; i++){
        s[i+s.length()-h]=bottom[i];
      }
    }
    cout << s << endl;
  }
}


Measured memory_bytes: 3144
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int a,t,Max = -1;   //Max是最高的，t是当前位置
char c[110];        //将路程存在c中
int main() {
    scanf("%d%s",&a,c);
    for(int i = 0 ; i < a ; ++ i){
        if(c[i] == 'I') {       //判断向上向下
            t ++;
        }
        else t --;              //同上
        Max = max(Max,t);       //取最大值
    }
    if(Max == -1) Max = 0;      //特判Max
    printf("%d",Max);           //输出
    return 0;
}

Measured memory_bytes: 256
n = input()
num = list(map(int,input().split()))

num.sort()
cnt = 0
work = 0
sum = 0
flg = 0
for i in num:
  if work != i:
    if work != 0:
      print(cnt)
      sum += 1
    cnt = 1
    mae = work + 1
    work = i
    if mae != work:
      for i in range(mae,work):
        print(0)
        sum += 1
  elif work == i:
    cnt += 1
  

print(cnt)
sum += 1
sum = int(n) - sum
for i in range(sum):
  print(0)

Measured memory_bytes: 32188
#include<cstdio>
int main(void){char res;int m,f,r;scanf("%d%d%d",&m,&f,&r);while((m!=-1)||(f!=-1)||(r!=-1)){if((m==-1)||(f==-1)||(m+f<30)){res='F';}else{res='D'-((r>=50)||(m+f>=50))-(m+f>=65)-(m+f>=80);}printf("%c\n",res);scanf("%d%d%d",&m,&f,&r);}return(0);}


Measured memory_bytes: 2668
#include<cstdio>
#include<bitset>
using namespace std;

const int MAXN = 200010;

int N, len, a[MAXN];
bool le[MAXN];//bitset<MAXN> le;

bool check(int lim){
	for (int i = 1; i <= len; ++i)
		if (a[i] <= lim)
			le[i] = 1;
		else
			le[i] = 0;
	bool s = le[N];
	for (int j = 1; j < N; ++j)
		if (le[N - j] == le[N + j] && le[N + j] == (s ^ (j & 1)))
			continue;
		else 
			return (s ^ (j & 1)) ^ 1;
	return le[N] ^ (N & 1) ^ 1;
}

int main(){
	scanf("%d", &N);
	len = N * 2 - 1;
	for (int i = 1;  i <= len; ++i)	
		scanf("%d", &a[i]);
	int l = 1, r = len, mid;
	while (l + 1 < r){
		mid = l + r >> 1;
		if (check(mid))
			r = mid;
		else
			l = mid;
	}
	if (check(l))
		printf("%d", l);
	else
		printf("%d", r);
	return 0;
}


Measured memory_bytes: 2688
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1] * (n + 1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0] * (n + 1)
    # ノードxのrootノードを見つける

    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード

    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断

    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    # ノードxが属する木のサイズを返す

    def Count(self, x):
        return -self.root[self.Find_Root(x)]


import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline
n, m = map(int, input().split())
u = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    u.Unite(a, b)
print(max(u.Count(i) for i in range(n)))


Measured memory_bytes: 77188
#include<iostream>
#include<string>

using namespace std;

int main(){
  string S;
  cin >> S;
  if(S=="Sunny"){
    cout << "Cloudy";
  }
  if(S=="Cloudy"){
    cout << "Rainy";
  }
  if(S=="Rainy"){
    cout << "Sunny";
  }

 return 0;
}


Measured memory_bytes: 256
import math

N, D = map(int, input().split())
ARR = []

for i in range(N):
    ARR.append(list(map(int, input().split())))


def calculate(n, d, arr):

    result = 0
    for i in range(n):
        distance = math.sqrt(pow(arr[i][0], 2) + pow(arr[i][1], 2))
        if distance <= d:
            result += 1

    print(result)

calculate(N, D, ARR)


Measured memory_bytes: 45460
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		String s = sc.next();
		int ama1 = 0;
		int add1 = 0;
		for (int i = 0; i < n; i++) {
			if (s.charAt(i) == '(') {
				ama1++;
			} else {
				if (ama1 == 0) {
					add1++;
				} else {
					ama1--;
				}
			}
		}
		StringBuilder fadd = new StringBuilder();
		for (int i = 0; i < add1; i++) {
			fadd.append("(");
		}
		StringBuilder ladd = new StringBuilder();
		for (int i = 0; i < ama1; i++) {
			ladd.append(")");
		}
		StringBuilder sb = new StringBuilder(s);
		System.out.println(fadd.append(sb).append(ladd));
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n,a,b,c;
  cin>>n>>a>>b>>c;
  cout<<n-a-b+c<<endl;

  return 0;
}






Measured memory_bytes: 3100
n,q=io.read():match("(.+)%s(.+)")
s=io.read()
pre=nil
count={[0]=0}
ix=0
for i in s:gmatch(".")do
  if pre=="A" and i=="C" then
    count[ix+1]=count[ix]+1
  else
    count[ix+1]=count[ix]
  end
  pre=i
  ix=ix+1
end
for i=1,q do
  l,r=io.read():match("(.+)%s(.+)")
  print(count[r*1]-count[l*1])
end

Measured memory_bytes: 11028
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


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

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

// edit

void solve() {
    int n;
    cin >> n;
    n %= 10;
    if(n == 3){
        cout << "bon" << endl;
    }else{
        vector<int> pon{0,1,6,8};
        
        for(auto e : pon){
            if(n == e){
                cout << "pon" << endl;
                return;
            }
        }
        
        cout << "hon" << endl;
    }

}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


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

class MainClass
{
    public static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var input = Console.ReadLine().Split(' ');

        var h = new int[N];
        // テーブル
        var dp = new int[N];

        for (var i = 0; i < N; i++)
        {
            h[i] = int.Parse(input[i]);
            dp[i] = int.MaxValue; // 初期値を無限大の大きさに設定
        }

        dp[0] = 0; // 最初の場所は0にする

        // 1番目以降のテーブルを評価する
        for (var i = 1; i < N; i++)
        {
            // 1番目のテーブルを計算するときは、特殊な場合なので条件分岐させる
            dp[i] = chmin(dp[i], dp[i - 1] + Math.Abs(h[i] - h[i - 1]));

            if(i > 1)
            {
                dp[i] = chmin(dp[i], dp[i - 2] + Math.Abs(h[i] - h[i - 2]));
            }
        }

        Console.WriteLine(dp[N - 1]);
    }

    public static T chmin<T> (T a, T b) where T : IComparable
    {
        if (a.CompareTo(b) > 0)
        {
            a = b;
            return a;
        }
        return a;
    }

    public static T chmax<T> (T a, T b) where T : IComparable
    {
        if (a.CompareTo(b) < 0)
        {
            a = b;
            return a;
        }
        return a;
    }
}

Measured memory_bytes: 24032
/*                                                      
 abc150
 */
#include <stdio.h>
#include <math.h>
int main (void)
{ 
    int K,X;
    scanf("%d%d",&K,&X);
    if(X<=500*K) 
        printf("Yes\n");
    else
        printf("No\n");
return 0 ;
} 

Measured memory_bytes: 128
while True:
    n, x = [int(line) for line in input().split()]
    if n == x == 0:
        break
    count = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                # print(i, j, k)
                if i != j and j != k and i != k:
                    if i + j + k == x:
                        count += 1
    print(count)



Measured memory_bytes: 5604
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;


int main(){
	int n;
	while(cin>>n,n){
		vector<pair<double,int> > v;
		FOR(i,n){
			int id,h,w; cin>>id>>h>>w;
			double bmi = w / (double)(h*h) * 10000;
			v.push_back(make_pair(abs(bmi-22),id));
		}
		cout << (*(min_element(v.begin(),v.end()))).second << endl;

	}

	return 0;
}

Measured memory_bytes: 1228
object Main extends App{
def check():Boolean = {
  val Array(a,b,c) = scala.io.StdIn.readLine.split("\\s").map(_.toInt)
  for (i<-1 to b){
    if ((a*i) % b == c) return true
  }
  return false  
}

if (check()) println("YES") else println("NO")
}

Measured memory_bytes: 27320
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N;
  cin >> N;
  int list[5]={135,189,165,105,195};
  sort(list,list+5);
  int i;
  for(i=0;i<5;i++){
    if(N<list[i]) break;
  }
  cout<<i;
}


Measured memory_bytes: 256
#include<stdio.h>


int main(){
  
  int n, j = 1;
  long high, h[100000];
  scanf("%d",&n);
  for(int i = 0; i<n; i++)
    scanf("%ld",&h[i]);
  high = h[0];
  
  while((high <= h[j])&&(j != n)){
    if (high < h[j])
      h[j]--;
    high = h[j];
    j++;
  }
  
  if (j == n)
    printf("Yes");
  else
    printf("No");
  
  return 0;
  
  
}

Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC159B
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var N = S.Length;

            bool ok = true;
            if (S != string.Concat(S.Reverse())) ok = false;

            var s1 = S.Substring(0, (N - 1) / 2);
            var s2 = S.Substring((N + 3) / 2 - 1);
            if (s1 != string.Concat(s1.Reverse())) ok = false;
            if (s2 != string.Concat(s2.Reverse())) ok = false;

            if (ok) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String RNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int RInt => int.Parse(RNext());
        public static long RLong => long.Parse(RNext());
        public static int[] RInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] RLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
        public static string RString => RNext();
        //以下未テスト
        public static int[] RIntsC(int c) => Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
        public static long[] RLongsC(int c) => Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
        public static char[][] RMap(int h) => Enumerable.Repeat(0, h).Select(x => Console.ReadLine().ToCharArray()).ToArray();
    }

    static class Debug
    {
        static public void Draw2D<T>(T[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            string[,] map2 = new string[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0.ToString();
                    else if (i == 0) map2[i, j] = (j - 1).ToString();
                    else if (j == 0) map2[i, j] = (i - 1).ToString();
                    else map2[i, j] = map[i - 1, j - 1].ToString();
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j].Last());
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D<T>(T[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
using i64 = long long;

int main() {
    int a, b, c, k;
    std::cin >> a >> b >> c >> k;
    if (a + b >= k) {
        std::cout << std::min(a, k) << std::endl;
    } else {
        std::cout << a - (k - a - b) << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
  static void Main(string[] args)
  {
        int k  = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        int sLen = s.Length;
        if (sLen <= k) Console.WriteLine(s);
        else
        {
            string sa = s.Substring(0, k) + "...";
            Console.WriteLine(sa);
        }




  }

   

}



Measured memory_bytes: 17592
#include <bits/stdc++.h>
using namespace std;
int main(){
	int long long  a,b,c;
	cin >> a >> b >> c;
	if(c-a-b<=0){
        cout << "No" << endl;
	}
	else{
		if(4*a*b<c*c+a*a+b*b-2*c*a-2*c*b+2*a*b){
			cout << "Yes" << endl;

		}
		else{
			cout << "No" << endl;
		}
	}
}


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

template<typename T>
void fin (T a){
    cout<<a<<endl;
    exit(0);
}

template<typename S>
void print(S a){
    cout<<a<<endl;
}

template<typename U>
void pprint(U a){
    cout<<a;
}


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

    vector<int> a;
    int d,t,s;
    cin>>d>>t>>s;
    if(s*t>=d){
        fin("Yes");
    }else{
        fin("No");
    }

    return 0;
}




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

int n,m,ans,a,b;
int h[100001],ab[100001];

int main(){
  cin >> n >> m;

  for (int i=1; i<=n; i++)
    cin >> h[i];

  for (int i=1; i<=m; i++){
    cin >> a >> b;

    if (h[a]>=h[b])
      ab[b]=1;
  
    if (h[b]>=h[a])
      ab[a]=1;
  }

  for (int i=1; i<=n; i++)
    if (ab[i]==0)
      ans++;
  
  cout << ans << endl;
}

Measured memory_bytes: 4408
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,ans = 0;
	//int a[INT16_MAX] = {0};
	map<int, int> m{};
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		int t = 0;
		cin >> t;
	/*	a[t]++;*/

		m.insert(std::make_pair(t, m[t] += 1));


	}

	for (auto i = m.begin(); i != m.end(); ++i) {
		/*if (m[i] == 0) continue;*/
		if (i->second < i->first) {
			ans += i->second;
		}
		else if (i->second > i->first) {
			ans += i->second - i->first;

		}
	}


	/*for (int i = 1; i <= n; i++)
	{
		if (a[i] == 0) continue;
		if (a[i] < i) {
			ans += a[i];
		}
		else if (a[i] > i) {
			ans += a[i] - i;

		}
	}
*/
	cout << ans << endl;
	
}

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

int n, m, d;

int main() {
    cin >> n >> m >> d;
    long long denominator = 1ll * n * n;
    long long numerator = 1ll * (n - d) * (m - 1);
    if(d > 0) numerator *= 2;
    
    cout << setprecision(12) << (double) numerator / (double) denominator << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define inf 1013161010
#define ninf -1013161010
#define mod 1000000007
#define ll long long
#define lf long double
#define in(x) scanf("%d",&x);
#define sz(x) ((int)x.size())
#define lld l64d
#define rep(i,n) for(i=0;i<n;i++)
#define rrep(i,n) for(i=n-1;i>=0;i--)
#define rep1(i,a,b) for(i=a;i<=b;i++)
#define rrep1(i,a,b) for(i=a;i>=b;i--)
#define stlfor(i,t) for(auto i =t.begin();i!=t.end();i++)
#define fr freopen("x.txt","r",stdin)
#define frc freopen("y.txt","w",stdout)
#define all(x) x.begin(),x.end()
#define set0(x) memset(x,0,sizeof(x))
#define dbg cout<<"yo "<<endl;
#define pset(n) fixed<<showpoint<<setprecision(n)

#define pii pair<int,int>
#define pll pair<ll,ll>
#define min_pq priority_queue<pll, vector<pll>, greater<pll> >
#define vpii vector<pair<int,int> >
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
#define si set<int>
#define mii map<int,int>
#define umii unordered_map<int,int>
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define modulo %
#define moduloe %=

typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> OST;

ll toint(const string &s) { stringstream ss; ss << s; ll x; ss >> x; return x; }
ll add(ll a, ll b) {a+=b; while(a >= mod) a-= mod; while(a<0) a+= mod;}
ll mul(ll a, ll b) {return (a * 1LL *b % mod);}
string tostring ( ll number ){  stringstream ss; ss<< number; return ss.str();}

const lf pi = 2*acos(0);
const int nn = 500006;
const lf EPS = 0.000000001;

ll gcd(ll a,ll b){return (b==0)? a:gcd(b,a%b); }
void nope(int num = 0){ if(num==0) cout<<"NO"; else cout<<"-1"; exit(0); }

int a[22][22];
ll dp[22][(1<<22)+3];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll i,j,n,tt;
    tt=1;
    //cin>>tt;
    while(tt--)
    {
        cin>>n;
        rep(i, n)
           rep(j, n)
                cin>>a[i][j];

        for(i=0; i<n; i++)
            if(a[0][i] == 1)
                dp[0][(1<<i)] = 1LL;

        for(i=0;i<n;i++)
        {
            for(j=0;j<(1<<n);j++)
            {
                int cnt = __builtin_popcount(j);
                if(i+1 == cnt)
                {
                    for(int k=0; k<n; k++)
                    {
                        if(a[i+1][k] == 1 and (((j >> k) & 1) == 0) )
                        {
                            dp[i+1][j | (1<<k)] += dp[i][j];
                            dp[i+1][j | (1<<k)] %= mod;
                        }
                    }
                }
            }
        }

        cout<<dp[n-1][(1<<n) - 1]<<endl;
    }
    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


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

typedef long long ll;

string op[100005];
ll a[3];
string ans;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	cin >> a[0] >> a[1] >> a[2];
	for (int i = 1; i <= n; i++)
	{
		cin >> op[i];
	}
	for (int i = 1; i <= n; i++)
	{
		int id1 = op[i][0] - 'A';
		int id2 = op[i][1] - 'A';
		if( i == n )
		{
			if( a[id1] != 0 ) ans += id2 + 'A';
			else if( a[id2] != 0 ) ans += id1 + 'A';
			else
			{
				cout << "No" << '\n';
				return 0;
			}
			continue;
		}
		if( a[id1] == a[id2] )
		{
			if( a[id1] == 0 )
			{
				cout << "No" << '\n';
				return 0;
			}else if( a[id1] == 1 )
			{
				string t = op[i+1];
				if( t[0] - 'A' == id1 || t[1] - 'A' == id1 ) 
				{
					ans += id1 + 'A';
				}else ans += id2 + 'A'; 
			}else
			{
				ans += id1 + 'A';
			}
		}else
		{
			if( a[id1] > a[id2] )
			{
				ans += id2 + 'A';
			}else ans += id1 + 'A';
		}
		char z = ans[ans.length()-1] - 'A';
		if( id1 == z )
		{
			a[id1] ++;
			a[id2] --;
		}else
		{
			a[id2] ++;
			a[id1] --;
		}
	}
	cout << "Yes" << '\n';
	for (int i = 0; i < ans.length(); i++)
	{
		cout << ans[i] << '\n';
	}
	return 0;
}


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

int mod = 1e9 + 7;

void solution(){

	ll a, b, c, d; 
	cin >> a >> b >> c >> d;
	cout << max({a*c, a*d, b*c, b*d}) << endl;





}	


int main(){ 
	fio;
	int t;
	t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++){
		// cout << "Case #" << i << ": ";
		solution();
	} 
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

llint n, m;
llint d[100005];
vector<P> G[100005];
vector<P> vec;
llint color[100005];
llint w[200005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		cin >> d[i];
		vec.push_back(P(d[i], i));
	}
	sort(vec.begin(), vec.end());
	
	llint u, v;
	for(int i = 1; i <= m; i++){
		cin >> u >> v;
		G[u].push_back(P(v, i));
		G[v].push_back(P(u, i));
	}
	
	for(int i = 0; i < vec.size(); i++){
		llint v = vec[i].second;
		if(color[v]) continue;
		bool flag = false;
		//cout << v << endl;
		for(int j = 0; j < G[v].size(); j++){
			llint u = G[v][j].first, e = G[v][j].second;
			if(d[u] > d[v]) continue;
			if(d[u] == d[v]){
				if(color[u] == 0) color[u] = -1, color[v] = 1;
				else color[v] = -color[u];
				//cout << v << " " << u << " " << color[u] << " " << color[v] << endl;
				w[e] = d[v];
				flag = true;
				break;
			}
			if(d[u] < d[v]){
				color[v] = color[u];
				w[e] = d[v] - d[u];
				flag = true;
				break;
			}
		}
		if(!flag){
			cout << -1 << endl;
			return 0;
		}
	}
	
	for(int i = 1; i <= n; i++){
		if(color[i] > 0) cout << "B";
		else cout << "W";
	}
	cout << endl;
	for(int i = 1; i <= m; i++){
		if(w[i] == 0) w[i] = 1000000000;
		cout << w[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 19056
h, w, a, b = map(int, input().split())
for i in range(b):
    for j in range(a):
        print(0, end='')
    for j in range(w - a):
        print(1, end='')
    print()
for i in range(h - b):
    for j in range(a):
        print(1, end='')
    for j in range(w - a):
        print(0, end='')
    print()


Measured memory_bytes: 5364
//32
#include<iostream>
#include<queue>
#include<string>
#include<vector>
#include<set>
#include<algorithm>

using namespace std;

struct ES{
  int t;
  string s;
  bool operator<(ES a)const{
    return s>a.s;
  }
};

vector<ES> e[40];
bool r[40];
int n,a,s,g;
bool c[40][40];

void dfs(int x){
  if(r[x]++)return;
  for(int i=0;i<n;i++){
    if(c[x][i]){
      dfs(i);
    }
  }
}
 
int main(){
  while(cin>>n>>a>>s>>g,n|a|s|g){
    for(int i=0;i<n;i++){
      e[i].clear();
      r[i]=false;
    }
    fill(c[0],c[n],false);
    for(int i=0;i<a;i++){
      int x,y;
      string l;
      cin>>x>>y>>l;
      ES a={y,l};
      e[x].push_back(a);
      c[y][x]=true;
    }
    dfs(g);
    ES i={s,""};
    priority_queue<ES> que;
    que.push(i);
    set<string> s[40];
    while(!que.empty()){
      ES c=que.top();
      if(c.t==g||c.s.size()>6*n)break;
      que.pop();
      if(!s[c.t].insert(c.s).second)continue;
      for(int i=0;i<e[c.t].size();i++){
	ES n={e[c.t][i].t,c.s+e[c.t][i].s};
	if(r[n.t]){
	  que.push(n);
	}
      }
    }
    if(que.empty()||que.top().s.size()>6*n){
      cout<<"NO"<<endl;
    }else{
      cout<<que.top().s<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2940
object Main extends App {
  var s = scala.io.StdIn.readLine()
  val inputArray =  s.split(" ").map(_.toInt)
  if(inputArray(1) % inputArray(0) == 0) {
    println(inputArray(0) + inputArray(1))
  } else {
    println(inputArray(1)- inputArray(0))
  }
}


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



string s;
int n,ans[202020];


signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

    cin >> s;
    n = s.size();
    s = " "+s;
    int l = 1,r=1,lef,rig;
    for(int i=1;i<=n;i++){
        lef=0;rig=0;
        while(s[i]=='R'){i++;lef++;}
        l = i-1;
        r = i;
        while(s[i]=='L' && i<=n ){i++;rig++;}
        //cout << i << " " << lef << " " << rig;
        if((lef+rig)%2==0){
            ans[l]=(lef+rig)/2;
            ans[r]=(lef+rig)/2;
        }
        else {
            int k = (lef+rig)/2;
            ans[l]=ans[r]=k;
            if(lef%2){
                ans[l]++;
            }
            else ans[r]++;
        }
        i--;
    }
    for(int i=1;i<=n;i++){
        cout << ans[i] << " ";
    }




return 0;
}
///....




Measured memory_bytes: 1388
tmp = list(map(int,input().split()))
As = list(map(int,input().split()))
n,p = tmp[0],tmp[1]
o ,e  = 0,0
for i in range(n):
  if As[i] % 2:
    o += 1
  else:
    e += 1
def comb(j,k):
  if k == 0:
    return(1)
  else:
    return comb(j-1,k-1) * j / k
ans = 0
if p == 0:
  for i in range(o+1):
    if not i % 2:
      ans += int(comb(o,i))
else:
  for i in range(o+1):
    if i % 2:
      ans += int(comb(o,i))
ans *= (2 ** e)
print(ans)

Measured memory_bytes: 3188
import numpy as np

n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

# at = [t - x * 0.006 for x in h]
h = np.array(h)
at = t - h * 0.006
diff = abs(a - at)

print(np.argmin(diff) + 1)


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

int main() {
  int N, a, b, c, d;
  cin >> N;
  a = N / 1000;
  b = N / 100 % 10;
  c = N / 10 % 10;
  d = N % 10;
  if ((a == b && b == c) || (b == c && c == d)) {
  	cout << "Yes" << endl;
  }
  else {
  	cout << "No" << endl;
  }
}


Measured memory_bytes: 3604
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;
	int n; cin >> n;
	//n頂点m枝に対して隣接リストをつくる。
	int u, v;
	//vector< vector <int> > ls(n); //0-origin
	vector< vector <int> > ls(n+1); //1-origin
	vector< int > pa(n+1);
	pa[1] = 0;
	for(int i = 2; i<=n; i++){ 
		cin >> u; 
		ls[u].push_back(i); 
		pa[i] = u;
		//ls[v].push_back(u); //有向グラフならコメントアウトせよ
	}
	vector<int> dep(n+1);
	vector< vector <int> > chd(n+1);
	bool ch[n+1] = {};
	stack<int> q;
	q.push(1);
	while(!q.empty()){
		int now = q.top();
		if(!ch[now]){
			REP(j, (int)ls[now].size()){
				if(!ch[ls[now][j]]) q.push(ls[now][j]);
			}
		}
		else{
			sort(chd[now].rbegin(), chd[now].rend());
			int dd = -1;
			REP(i, chd[now].size()){
				dd = max(dd, chd[now][i] + i);
			}
			//cout << now << " " ; REP(i, chd[now].size()) cout << chd[now][i] << " "; cout << endl;
			dep[now] = dd + 1;
			chd[pa[now]].push_back(dd + 1);
			q.pop();
		}
		ch[now] = true;
	}

	//
	cout << dep[1] << endl;
}

Measured memory_bytes: 14908
#include <iostream>
#include <vector>
#include <algorithm>
#define N_MAX 100
using namespace std;

int main() {
    int N, W, w0, w, v;
    cin >> N >> W;
    vector<int> val[4];
    cin >> w0 >> v;
    val[0].push_back(v);
    for(int i=1; i<N; i++) {
        cin >> w >> v;
        val[w-w0].push_back(v);
    }
    for(int i=0; i<4; i++) sort(val[i].begin(), val[i].end(), greater<int>());
    long long w_sum[4];
    int v_sum[4], ans = 0;
    w_sum[0] = 0; v_sum[0] = 0;
    for(int a=0; a<=val[0].size(); a++) {
        if(a > 0) {
            w_sum[0] += w0; v_sum[0] += val[0][a-1];
            if(w_sum[0] > W) break;
            if(ans < v_sum[0]) ans = v_sum[0];
        }
        w_sum[1] = w_sum[0]; v_sum[1] = v_sum[0];
        for(int b=0; b<=val[1].size(); b++) {
            if(b > 0) {
                w_sum[1] += w0+1; v_sum[1] += val[1][b-1];
                if(w_sum[1] > W) break;
                if(ans < v_sum[1]) ans = v_sum[1];
            }
            w_sum[2] = w_sum[1]; v_sum[2] = v_sum[1];
            for(int c=0; c<=val[2].size(); c++) {
                if(c > 0) {
                    w_sum[2] += w0+2; v_sum[2] += val[2][c-1];
                    if(w_sum[2] > W) break;
                    if(ans < v_sum[2]) ans = v_sum[2];
                }
                w_sum[3] = w_sum[2]; v_sum[3] = v_sum[2];
                for(int d=1; d<=val[3].size(); d++) {
                    w_sum[3] += w0+3; v_sum[3] += val[3][d-1];
                    if(w_sum[3] > W) break;
                    if(ans < v_sum[3]) ans = v_sum[3];
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;

int main(){
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    int n; cin >> n;
    ll A[n+1] , sum = 0 , Count = 0;
    for(int i= 1 ;i <= n ; i++){
        cin >> A[i];
        sum += abs(A[i]);
        if(A[i] < 0)
            Count++;
    }
    if(Count%2 == 0){
        cout << sum << endl;
        return 0;
    }
    
    ll mn1 = Mod , mn2 = Mod;
    for(int i = 1 ; i <= n ; i++){
        if(A[i] >= 0)
            mn1 = min(mn1 , A[i]);
        else
            mn2 = min(mn2 , abs(A[i]));
    }
    
    cout << sum - 2*min(mn1 , mn2) << endl;
    
   return 0;
}

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

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

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (V[i] > C[i]) ans += V[i] - C[i];
  }

  cout << ans << endl;
}

Measured memory_bytes: 256