akhauriyash/Code-Regression huggingface dataset:
# encoding: "utf-8"

from enum import Enum

class Unreachable(Exception):
    pass


class Type(Enum):
    VAL = 0
    PTR = 1


class Elem:
    def __init__(self, i, value, _type):
        self.idx = i
        self.value = value
        self.type = _type

    def set(self, value, _type):
        self.value = value
        self.type = _type
        

class SetManager:
    def __init__(self, n):
        self.data = list()
        for i in range(n):
            self.data.append(Elem(i, {i}, Type.VAL))

    def get(self, i):
        return self.data[i]

    def set(self, i, value):
        if isinstance(value, set):
            t = Type.VAL
        elif isinstance(value, int):
            t = Type.PTR
        self.data[i].set(value, t)

    def find_root(self, i):
        elem = self.get(i)
        if elem.type == Type.VAL:
            return (i, elem)
        elif elem.type == Type.PTR:
            j, root_elem = self.find_root(elem.value)
            self.set(i, j)
            return (j, root_elem)
        else:
            raise Unreachable

    def run(self, command):
        com, x, y = command
        if com == 0:
            self.unite(x, y)

        elif com == 1:
            if self.same(x, y):
                print(1)
            else:
                print(0)

        else:
            raise Unreachable

    def unite(self, x, y):
        i, elem_x = self.find_root(x)
        j, elem_y = self.find_root(y)
        if i != j:
            new_set = elem_x.value | elem_y.value
            self.set(i, new_set)
            self.set(j, i)

    def same(self, x, y):
        return y in self.find_root(x)[1].value


class Stdin:
    @staticmethod
    def read_line(converter=str):
        return [converter(x) for x in input().split()]
    
    @staticmethod
    def read_lines(n, converter=str):
        result = list()
        for _ in range(n):
            result.append(Stdin.read_line(converter))
        return result
    
    @staticmethod
    def convert(data, n, converter):
        assert(n == len(converter))
        return tuple(map(lambda x, f: f(x), data, converter))

    @staticmethod
    def convert_lines(datas, n, converter):
        return [converter(data, n, converter) for data in datas]


def main():
    n, q = Stdin.read_line(int)
    manager = SetManager(n)
    commands = Stdin.read_lines(q, int)
    
    for command in commands:
        manager.run(command)


if __name__ == "__main__":
    main()

Measured memory_bytes: 32212
#include <cstdio>

int main()
{
    char a;
    scanf("%c", &a);
    if (a == 'a' or a == 'e' or a == 'i' or a == 'o' or a == 'u')
    {
        printf("vowel");
    }
    
    else
    {
        printf("consonant");
    }
}


Measured memory_bytes: 1652
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int pronadjen = 0;
    for (int i = 1; i <= 9; i++){
        for (int j = 1; j <= 9; j++){
            if (i * j == n)
                pronadjen = 1;
        }
    }
    if (pronadjen == 1)
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 256
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func nChar(str string) int {
	// fmt.Printf("-- str %v\n", str)
	max := 0
	for _, j := range []byte(str) {
		if max < int(j) {
			max = int(j)
		}
		// fmt.Printf("-- %v %d\n", i, j)
	}
	return max - 96
}

func main() {
	// var ap [100000]int
	// var bp [100000]int
	// var x, y, c, p int

	io := NewIo()
	defer io.Flush()
	N := io.NextInt()
	// res := "a"
	// fmt.Printf("%v\n", N)
	// fmt.Printf("%v\n", string(97))

	var tab map[int][]string
	tab = make(map[int][]string)
	tab[1] = []string{"a"}

	for i := 2; i <= N; i++ {
		tab[i] = []string{}
		// fmt.Printf("  %d --\n", i)
		for _, j := range tab[i-1] {
			// fmt.Println(j)
			nChar := nChar(j)
			// fmt.Printf("nChar %d %v\n", nChar, j)
			for k := 1; k <= nChar+1; k++ {
				tab[i] = append(tab[i], j+string(k+96))
			}
		}
	}
	// fmt.Printf("%v\n", tab[N])
	sort.Strings(tab[N])
	// fmt.Printf("%v\n", tab[N])
	for _, j := range tab[N] {
		io.PrintLn(j)
	}
	// // tab[2] = []string{"aa", "ab"}

	// // fmt.Printf("%v\n", tab[3])
	// // tab[3] = append(tab[3], "aaa")

	// strs := []string{"abcac", "zyxzx", "abaac", "abcbd"}
	// sort.Strings(strs)
	// for _, j := range strs {
	// 	io.PrintLn(j)
	// }
}


Measured memory_bytes: 11904
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
long long n,a[100010],front[100010],back[100010];
int main()
{
	cin>>n;
	for (long long i=0;i<n;i++) cin>>a[i];
	front[0]=abs(a[0]);back[n-1]=abs(a[n-1]);
	for (int i=1;i<n;i++) front[i]=front[i-1]+abs(a[i]-a[i-1]);
	for (int i=n-2;i;i--) back[i]=back[i+1]+abs(a[i]-a[i+1]);
	for (int i=0;i<n;i++) cout<<front[i-1]+back[i+1]+abs(a[i+1]-a[i-1])<<endl;
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

ll N, K, ans;

int main()
{
    cin >> N >> K;
    vector<int> V(N);
    for (int i = 0; i < N; i++)
        cin >> V[i];
    for (int left = 0; left <= N; left++)
    {
        for (int right = 0; right <= N && left + right <= min(K, N); right++)
        {
            ll sum = 0, cnt = left + right;
            priority_queue<int, vector<int>, greater<int>> pq;
            for (int j = 0; j < left; j++)
            {
                sum += V[j];
                if (V[j] < 0)
                    pq.push(V[j]);
            }
            for (int j = 0; j < right; j++)
            {
                sum += V[N - 1 - j];
                if (V[N - 1 - j] < 0)
                    pq.push(V[N - 1 - j]);
            }
            while (cnt < K && !pq.empty())
            {
                cnt++;
                sum -= pq.top();
                pq.pop();
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
S0 = input()
S = S0[::-1]
cands = ["dream"[::-1],"dreamer"[::-1],"erase"[::-1],"eraser"[::-1]]
i = 0
while i < len(S):
  f = False
  for word in cands:
    #print(S[i:],word)
    if S[i:].startswith(word):
        f = True
        i += len(word)
        break
  if f == False:
    print("NO")
    exit(0)
#print(i)
if i == len(S):
  print("YES")
else:
  print("NO")


Measured memory_bytes: 3316
R, G, B, N = map(int, input().split())

count = 0

tmp_lst = [R, G, B]
tmp_lst.sort()
X, Y, Z = tmp_lst[0], tmp_lst[1], tmp_lst[2]

x_max = int(N/X)    #   max の中では一番大きい
y_max = int(N/Y)
z_max = int(N/Z)

#print(x_max, y_max, z_max, X, Y, Z)

for z in range(z_max + 1):
    for y in range(y_max + 1):
        tmp = N - z*Z - y*Y
        if tmp < 0:
            break
        if tmp % X == 0 and tmp // X <= x_max:
#            print(tmp // X, y, z)
            count += 1

print(count)

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

using namespace std;

struct Node{
	int x,y,t;
	Node(int x_,int y_,int t_){
		x = x_;
		y = y_;
		t = t_;
	}
};

int H,W,N;
int area[1001][1001];
bool memo[1001][1001];
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int bfs(int sx,int sy,int HP){
	fill_n(*memo,1001*1001,0);
	queue<Node> Q;
	Q.push(Node(sx,sy,0));
	int ret;

	while(!Q.empty()){
		int X,Y,T;
		Node node = Q.front();
		X = node.x;
		Y = node.y;
		T = node.t;
		Q.pop();
		if(area[X][Y] == HP){
			ret = T;
			break;
		}
		if(memo[X][Y] == 1)continue;
		memo[X][Y] = 1;
		for(int i = 0;i < 4;i++){
			int nx = X + dx[i];
			int ny = Y + dy[i];
			if(nx < 0 || ny < 0 || nx >= W || ny >= H)continue;
			if(area[nx][ny] == -1)continue;
			Q.push(Node(nx,ny,T+1));
		}
	}
	return ret;
}

int main(){
	fill_n(*area,1001*1001,0);
	int sx[10];
	int sy[10];
	char c;
	int ans = 0;
	cin >> H >> W >> N;
	for(int i = 0;i < H;i++){
		for(int j = 0;j < W;j++){
			cin >> c;
			if(c == 'X'){
				area[j][i] = -1;
			}else if(c == '.'){
				area[j][i] = 0;
			}else if(c == 'S'){
				area[j][i] = 0;
				sx[0] = j;
				sy[0] = i;
			}else{
				area[j][i] = c - '0';
				sx[c - '0'] = j;
				sy[c - '0'] = i;
			}
		}
	}
	for(int i = 0;i < N;i++){
		ans += bfs(sx[i],sy[i],i+1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 8028
#include <stdio.h>

void InputNumber(int* a, int* b);
char* Judgment(int a, int b);

int main(void) {
    
    int a;
    int b;
    char* msg;
    
    InputNumber(&a, &b);
    msg = Judgment(a, b);
    
    printf("%s", msg);
    return 0;
}

void InputNumber(int* a, int* b) {
    
    do {
        scanf("%d %d", a, b);
    } while ( (*a < -1000 || *a > 1000) || (*b < -1000 || *b > 1000) );
}

char* Judgment(int a, int b) {
    int judge = ( (a == b) ? 0 : ( (a > b) ? 1 : -1 ) );
    char* msg;
    switch(judge) {
        case 0:
            msg = "a == b\n";
            break;
            
        case 1:
            msg = "a > b\n";
            break;
            
        case -1:
            msg = "a < b\n";
            break;
    }
    return msg;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,k,i,j=0;
	cin>>a>>b>>k;
	for(i=min(a,b);i>=1;i--)
	{
		if(a%i==0&&b%i==0)  j++;
		if(j==k)            break;
	}
	cout<<i;
	return 0;
}

Measured memory_bytes: 256
//#include <iostream>
#include <cstdio>

int main() {
    int n, i, j;
    scanf("%d",&n);
    if (n == 3) {
        printf("2 3 25\n");
        return 0;
    }
    if (n == 5) {
        printf("2 3 4 6 9\n");
        return 0;
    }
    for (i = 1;;i++) {
        if (n % 2 == i % 2) j = (n - 3 * i) / 2;
        else j = (n - 3 * i + 1) / 2;
        if (0 < j && j < 2501 && i < 5001) break;
    }
    //printf("%d %d\n", i, j);
    for (i=3*i-((n - i) % 2);i--;) printf("%d ", 2 * i + 2);
    for (j*=2;--j;) printf("%d ", 6 * j + 3);
    printf("3\n");

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
 
using namespace std;
 
int main()
{
	int a, b;
	cin >> a >> b;
	if((a+b)%2 == 0){
		cout << (a+b)/2;
	}else{
		cout << (int)((a+b)/2.0) + 1;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn=100000+5;
int par[maxn]={};
int n,q;
int vis[maxn]={};
int fin(int x){
    return x==par[x]?par[x]:fin(par[x]);
}
int main()
{
    while(scanf("%d%d",&n,&q)==2 && n &&q){
        long long int ans=0;
        for(int i=0;i<=n;i++) par[i]=i,vis[i]=0;
        for(int i=2;i<=n;i++){
            int x;
            scanf("%d",&x);
            par[i]=x;
        }
        while(q--){
            char c;
            int x;
            scanf("\n%c%d",&c,&x);
            if(c=='M') par[x]=x;
            else ans+=fin(x);
        }
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 3864
#include <stdio.h>

#define MAX 10000
#define NIL -1

// 構造体の宣言 親 子(左) 子(右)
struct Node {int p, l, r;};
struct Node T[MAX];
int n;

/* 先行順巡回 */
void preParse(int u) {
    // もしノードが存在しない(-1だった場合)は関数を終わる
    if(u == NIL) return;
    // 前で出力する(前順)
    printf(" %d",u);
    // 先に左の子へ行って処理をする
    preParse(T[u].l);
    // 左の子の処理が終わったら右の子に行く
    preParse(T[u].r);
}

/* 中間順巡回 */
void inParse(int u) {
    // もしノードが存在しない(-1だった場合)は関数を終わる
    if(u == NIL) return;
    // 先に左の子へ行って処理をする
    inParse(T[u].l);
    // 中で出力する(中順)
    printf(" %d",u);
    // 左の子の処理が終わったら右の子に行く
    inParse(T[u].r);
}

/* 後方順巡回 */
void postParse(int u) {
    // もしノードが存在しない(-1だった場合)は関数を終わる
    if(u == NIL) return;
    // 先に左の子へ行って処理をする
    postParse(T[u].l);
    // 左の子の処理が終わったら右の子に行く
    postParse(T[u].r);
    // 後で出力する(後順)
    printf(" %d",u);
}

int main(void) {
    int i, v, l, r, root;
    // ノードの個数取得
    scanf("%d",&n);
    // ノードの個数分だけ初期化
    for(i=0; i<n; i++) {
        T[i].p = NIL;
    }

    for(i=0; i<n; i++) {
        scanf("%d %d %d",&v,&l,&r);
        // 取得した左右の子を代入
        T[v].l = l;
        T[v].r = r;
        // もし子がいた場合(-1以外だった時)子のノードの親を設定する
        if(l != NIL) T[l].p = v;
        if(r != NIL) T[r].p = v;
    }

    // 親がいないノードがあった場合そこが根になる
    for(i=0;i<n;i++) if(T[i].p == NIL) root = i;

    // 先行順巡回 (Preorder Tree Walk)の出力
    printf("Preorder\n");
    preParse(root);
    printf("\n");

    // 中間順巡回 (Inorder Tree Walk)の出力
    printf("Inorder\n");
    inParse(root);
    printf("\n");

    // 後行順巡回 (Postorder Tree Walk)の出力
    printf("Postorder\n");
    postParse(root);
    printf("\n");

    return 0;
}


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

int main(){
  int w, h, n;
  int x, y, a;
  int r, l, b, t;
  cin >> w >> h >> n;
  l = b = 0; r = w; t = h;
  for(int i = 0; i < n; i++){
    cin >> x >> y >> a;
    if(a == 1 && l < x) l = x; 
    if(a == 2 && r > x) r = x; 
    if(a == 3 && b < y) b = y; 
    if(a == 4 && t > y) t = y; 
  }
  cout << (l >= r || b >= t ? 0 : (r - l) * (t - b)) << endl;
  return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,r = get_nums_l()

if n < 10:
    print(r + 100*(10-n))
else:
    print(r)

Measured memory_bytes: 38384
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    b = S()
    b = b[0]
    if b == "A":
        print("T")
    elif b == "T":
        print("A")
    elif b == "C":
        print("G")
    elif b == "G":
        print("C")
    return

#B
def B():
    s = S()
    agct = ["A", "G", "C", "T"]
    ans = 0
    for num, i in enumerate(s):
        ansb = 0
        if i in agct:
            ansb += 1
            for k in range(num+1, len(s)):
                if s[k] in agct:
                    ansb += 1
                else:
                    break
        ans = max(ans, ansb)
    print(ans)
    return

#C
def C():
    n, q = LI()
    s = S()
    ans = [0 for i in range(n+1)]
    ac = 0
    for num, ss in enumerate(s):
        if (not ac) and ss == "A":
            ac = 1
            ans[num] = ans[num - 1]
        elif ac and ss == "C":
            ac = 0
            ans[num] = ans[num - 1] + 1
        else:
            if ss == "A":
                ac = 1
            else:
                ac = 0
            ans[num] = ans[num - 1]
    lr = LIR_(q)
    for l,r in lr:
        print(ans[r]-ans[l])

    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 69256
#!/usr/bin/python

ar = []
while True:
  tmp = [int(i) for i in input().split()]
  if tmp == [0,0]:
    break
  else:
    ar.append(tmp)

for i in range(len(ar)):
  for j in range(ar[i][0]):
    for k in range(ar[i][1]):
      if ( j + k ) % 2 == 0:
        print('#' , end='' if k !=ar[i][1]-1 else '\n' if j != ar[i][0]-1 else '\n\n')
      else:
        print('.' , end='' if k !=ar[i][1]-1 else '\n' if j != ar[i][0]-1 else '\n\n')

Measured memory_bytes: 9064
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long modpow(long long a, long long b){
  long long ans = 1;
  while (b > 0){
    if (b % 2 == 1){
      ans *= a;
      ans %= MOD;
    }
    a *= a;
    a %= MOD;
    b /= 2;
  }
  return ans;
}
long long modinv(long long a){
  return modpow(a, MOD - 2);
}
vector<long long> mf;
long long modfact(long long a){
  if (mf.size() > a){
    return mf[a];
  } else {
    if (mf.empty()){
      mf.push_back(1);
    }
    for (int i = mf.size(); i <= a; i++){
      long long next = mf.back() * i % MOD;
      mf.push_back(next);
    }
    return mf[a];
  }
}
long long modbinom(long long a, long long b){
  return modfact(a) * modinv(modfact(b)) % MOD * modinv(modfact(a - b)) % MOD;
}
int main(){
  long long X, Y;
  cin >> X >> Y;
  if ((X * 2 - Y) % 3 != 0){
    cout << 0 << endl;
  } else if ((Y * 2 - X) % 3 != 0){
    cout << 0 << endl;
  } else if (X * 2 - Y < 0){
    cout << 0 << endl;
  } else if (Y * 2 - X < 0){
    cout << 0 << endl;
  } else {
    int A = (X * 2 - Y) / 3;
    int B = (Y * 2 - X) / 3;
    cout << modbinom(A + B, A) << endl;
  }
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl);
#define cop(a) for(auto x:(a)){cout << x << endl;}


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;

vector<vector<int>> pref;
vector<int> p, y;
int main(){

    int n, m;
    cin >> n >> m;
    pref.resize(n+1);
    p.resize(m);
    y.resize(m);
    rep(i, m){
        scanf("%d%d", &p[i], &y[i]);
        pref[p[i]].emplace_back(y[i]);
    }
    rep(i, n){
        sort(pref[i+1].begin(), pref[i+1].end());
    }

    rep(i, m){
        printf("%06d%06d\n", p[i],
        (int)( lower_bound( pref[p[i]].begin(), pref[p[i]].end(), y[i] ) -pref[p[i]].begin() ) + 1 
        );
    }


    return 0;
}


Measured memory_bytes: 7808
# coding: utf-8
# input
n = int(input())
data = []
for i in range(n):
    a, b = map(int, input().split())
    data.append([a, b])

# processing
data.sort(key=lambda x: x[1])
tmp = 0
for j in range(n):
    tmp += data[j][0]
    if tmp > data[j][1]:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 38044
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>


using namespace std;


int main() {
  // 入力
  string S;
  cin >> S;
  int N = S.size();
  int input[N];
  for (int i = 0; i < N; ++i) {
    input[i] = S[i] == '1';
  }

  // 候補を生成
  int odd_start[N], even_start[N];
  for (int i = 0; i < N; ++i) {
    odd_start[i] = i % 2 == 0;
    even_start[i] = i % 2 == 1;
  }

  int odd_sum = 0, even_num = 0;
  for (int i = 0; i < N; ++i) {
    if(input[i] != odd_start[i]) odd_sum++;
    if(input[i] != even_start[i]) even_num++;
  }


  cout << min(even_num, odd_sum) << endl;


  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>

typedef long long ll;
#define rep(i,n) for(ll i = 0; i < n; i++)

using namespace std;

int main(){
	/****input****/
	int n;
	cin >> n ;
	string s;
	cin >> s;

	/****calc****/
	string key ="ABC";
	int ans=0;
	int m = s.length();
	rep(i,m-2){
		if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
			ans++;
		}
	}
	/****output****/
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N+1,100);
  vec.at(N) = 0;
  for (int i = 0; i < N; i++) {
  int a;
  cin >> a;
    for (int j = 0; j < N; j++) {
     if (vec.at(j) >= a && a > vec.at(j+1)) {
      for (int k = 0; k < j; k++) {
        vec.at(k) = vec.at(k+1);
      }
      vec.at(j) = a;
      break;
     }
    }
  }//降順並べ替え
  int A = 0;
  int B = 0;
  int i = 0;
  while (i < N) {
    A += vec.at(i);
      i += 2;
  }
  int j = 1;
    while (j < N) {
      B += vec.at(j);
      j += 2;
    }
  cout << A - B << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	var n int
	_, _ = fmt.Scan(&n)
	var jpy, btc float64
	for i := 0; i < n; i++ {
		var a float64
		var b string
		fmt.Scan(&a, &b)
		if b == "JPY" {
			jpy += a
		} else {
			btc += a
		}
	}
	fmt.Println(jpy + btc*380000) // output for debug
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int dp[301][301];

int main(){
    int n;
    while(cin >> n, n){
        memset(dp, 0, sizeof(dp));
        vector<int> v(n);
        for(int i = 0; i < n; i++)  cin >> v[i];
        for(int w = 2; w <= n; w++){
            for(int i = 0; i < n; i++){
                int j = i+w-1;
                if(j >= n)  continue;
                if(dp[i+1][j-1] == w-2 && abs(v[i]-v[j]) <= 1)  dp[i][j] = dp[i+1][j-1]+2;
                for(int k = i; k < j; k++){
                    dp[i][j] = max(dp[i][j], dp[i][k]+dp[k+1][j]);
                }
            }
        }
        cout << dp[0][n-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3436
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int n;
int a[200005];
int main()
{
	cin>>n;
	cout<<n*n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define DIST(x1,x2, y1, y2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)))
#define DIST3D(x1,x2, y1, y2, z1, z2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)) + ((z1-z2)*(z1-z2)))
#define CLR(a) a.clear()
#define VCLR(a, n) for(int i=0; i<=n+3; i++) a[i].clear()
#define SIZE(a) a.size()
#define ERASE(a, b) memset(a, b, sizeof a)
#define pb push_back
#define LL long long
#define ULL unsigned long long
#define DBG cout<<"I Am Here"<<endl
#define DBGA(a) cout<<a<<endl
#define DBGI(b,a) cout<<b<<' '<<a<<endl
#define DBGL(i,s,e,b) or(int i=s; i<=e; i++) cout<<b<<endl
#define INF 1e9
#define INV 1e-6
#define sc(a) scanf("%I64d", &a)
#define pr(a) printf("%I64d\n", a)
#define si(a) scanf("%d", &a)
#define pii pair<int,int>
#define PII pair<LL,LL>
#define MAX 600005
#define CASE(i) printf("Case %d:", i);
#define PI acos(-1)
#define piis pair<int, string>
#define fast1 ios_base::sync_with_stdio(false);
#define fast2 cin.tie(0)
#define CHECK_BIT(var,pos) ((var & (1 << pos)) == (1 << pos))

using namespace std;
//
LL MOD = 1000000007;
//
//LL bigmod(LL a, LL b){
//    LL x = 1, y = a%MOD;
//    while(b > 0) {
//        if(b%2 == 1) {
//            x=(x*y);
//            if(x>MOD) x%=MOD;
//        }
//        y = (y*y);
//        if(y>MOD) y%=MOD;
//        b /= 2;
//    }
//    return x;
//}
//
//LL MODINVERSE(LL a){
//    return bigmod(a, MOD-2);
//}

//LL dp[900][1000];
//LL NCR(int n, int r)
//{
//    if(r==1) return n;
//    else if(n==r) return 1;
//    else
//    {
//        if(dp[n][r]!=-1) return dp[n][r];
//        else
//        {
//            dp[n][r]=NCR(n-1,r) + NCR(n-1,r-1);
//            return dp[n][r];
//        }
//    }
//}

const int MAXN = 1050;
int status[(MAXN/32)+10];

bool check(int n, int pos) { return (bool)(n & (1<<pos)); }
int SET(int n, int pos){ return n=n|(1<<pos);}

void sieve()
{
    int sqrtN=int (sqrt(MAXN));
    status[1>>5]=SET(status[1>>5],1&31);
    for(int j=4; j<=MAXN; j=j+2)
        status[j>>5]=SET(status[j>>5],j&31);
    for(int i=3; i<=sqrtN; i=i+2)
    {
        if(check(status[i>>5],i&31)==0)
        {
            for(int j=i*i; j<=MAXN; j= j + (i<<1))
            {
                status[j>>5]=SET(status[j>>5],j&31);
            }
        }
    }
}

LL arr[100005];
int freq[226];

int main()
{
    string str;
    cin>>str;
    int len = str.size();
    for(int i=0; i<len; i++)
    {
        freq[str[i]]++;
    }
    for(char i='a'; i<='z'; i++)
    {
        if(freq[i]%2==1){
            printf("No"); return 0;
        }
    }
    printf("Yes");
}


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

#define ms(s,n) memset(s,n,sizeof(s))
#define all(a) a.begin(),a.end()
#define present(t, x) (t.find(x) != t.end())
#define sz(a) int((a).size())
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;

const int MOD = (int) 1e9+7;
const int INF = (int) 1e9+1;
inline ll gcd(ll a,ll b){ll r;while(b){r=a%b;a=b;b=r;}return a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll n,m,k;

void inp(){
	cin>>n>>m>>k;
	int a[n],b[m],ans=0,j=0;
	ll suma=0,sumb=0;
	FOR(i,0,n){
		cin>>a[i];
		suma+=a[i];
	}
	FOR(i,0,m)
		cin>>b[i];
	FORd(i,n+1,0){
		if(i<n)
			suma-=a[i];
		if(suma<=k){
			while(j<m&&suma+b[j]+sumb<=k){
				sumb+=b[j];
				j++;
			}
			ans=max(ans,i+j);
		}
	}
	cout<<ans<<endl;
}

int main(){
	//cout<<INT_MAX<<endl;
	inp();
	return 0;
}


Measured memory_bytes: 5156
#include <stdio.h>

#define MAX 500000
#define INFTY 1000000001

void mergeSort(int A[], int, int);
void merge(int A[], int, int, int);

int S[MAX];
int n;
int cnt;

int main(void) {
  int left, right;
  scanf("%d", &n);
  left = 0; right = n;

  for(int i=0; i<n; ++i)
    scanf("%d", &S[i]);

  mergeSort(S, left, right);

  for(int i=0; i<n; ++i) {
    if(i != n-1) printf("%d ", S[i]);
    else printf("%d\n", S[i]);
  }
  printf("%d\n", cnt);
  return 0;
}
void mergeSort(int A[], int left, int right) {
  int mid;

  if(left+1 < right) {
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

void merge(int A[], int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1], R[n2];

  for(i=0; i<n1; ++i)
    L[i] = A[left + i];
  for(i=0; i<n2; ++i)
    R[i] = A[mid + i];
  L[n1] = R[n2] = INFTY;
  i = j = 0;
  for(k=left; k<right; ++k) {
    ++cnt;
    if (L[i] <= R[j]) {
      A[k] = L[i];
      ++i;
    }
    else {
      A[k] = R[j];
      ++j;
    }
  }

}


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    bool f = true;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if (s[i] == 'L'){
                f = false;
            }
        }else{
            if (s[i] == 'R'){
                f = false;
            }
        }
    }
    cout << (f?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

int n, ar[N], col[N];

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> ar[i];
		col[ar[i]]++;
	}
	sort(ar + 1, ar + n + 1);

	if(ar[n] % 2 == 0) {
		int st = ar[n] / 2;
		for(int i = 1; i < st; i++)
			if(col[i]) {
				cout << "Impossible";
				return 0;
			}
		if(col[st] != 1) {
			cout << "Impossible";
			return 0;
		}
		for(int i = st + 1; i <= ar[n]; i++) {
			if(!col[i] || col[i] == 1) {
				cout << "Impossible";
				return 0;
			}
		}
		cout << "Possible";
	} 
	else {
		int st = ar[n] / 2 + 1;
		for(int i = 1; i < st; i++)
			if(col[i]) {
				cout << "Impossible";
				return 0;
			}
		if(col[st] != 2) {
			cout << "Impossible";
			return 0;
		}
		for(int i = st + 1; i <= ar[n]; i++) {
			if(col[i] == 0 || col[i] == 1) {
				cout << "Impossible";
				return 0;
			}
		}
		cout << "Possible";
	}
}

Measured memory_bytes: 2304
/*

This Submission is to determine how many 120/240 min const. delivery point there are.

*/
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 1000000007
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
int main() {
	int n;
	cin >> n;
	vector<string> A;
	REP(i, n) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		A.push_back(s);
	}
	sort(A.begin(), A.end());
	long long now = 1;
	long long ans = 0;
	for (int i = 1; i < A.size(); ++i) {
		if (A[i] != A[i - 1]) {
			ans += now * (now - 1LL) / 2LL;
			now = 1;
		}
		else {
			now++;
		}
	}
	ans += now * (now - 1LL) / 2LL;
	cout << ans << endl;
}

Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
    string s; cin>>s;
    if(s=="AAA"||s=="BBB") cout<<"No";
    else cout<<"Yes";
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.HashMap;
import java.util.Map;
import java.util.Collections;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    private static Scanner sc = new Scanner(System.in);
    private static int mod = (int) 10e8 + 7;

    public static void main(String[] args) {
        int a = sc.nextInt();
        String s = sc.next();
        if (a < 3200) {
            System.out.println("red");
        } else {
            System.out.println(s);
        }
    }

}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}
//long long int ruizyo(long long int aa, long long int bb){
  //  if(aa==0){
    //    return 1;
    //}
    //else if(aa%2==0){
      //  long long int tt=ruizyo(aa/2,bb);
        //return (tt*tt)%MOD;
    //}
    //else{
      //  return (ruizyo(aa-1,bb)*bb)%MOD;
    //}
//}フェルマ－のア


//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//bool f[100001];//1000000以下の素数を調べよう！
//rrep(i,2,100001){
  //      f[i]=false;
    //}
//rrep(i,2,100001){
  //      if(!f[i]){
    //        for(int j=i+i;j<=100000;j+=i){
      //          f[j]=true;
        //    }
        //}
    //}
    //for(int i=3;i<=100000;i+=2){
      //  if(!f[i]){
        //    c[i]++;
      //  }
   // }

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=0,ans=0,a[10000000],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;

//-------------------------↓↓↓↓↓↓----------------------------

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

       cin >> n;
       rep(i,n)cin>>a[i];
       sort(a,a+n);
       pos=a[0];
       reverse(a,a+n);
       cmp=a[0];
       Cout(cmp-pos);
       
return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	value := make([]int, 4)

	for i := 0; i < len(value); i++ {
		fmt.Scan(&value[i])
	}
	//fmt.Printf("%d", value)

	ans := calc(value[0], value[1], value[2], value[3])

	fmt.Printf("%d", ans)
}

func calc(a, b, c, d int) int {
	if a < b {
		ans := a * c
		return ans
	}
	price1 := b * c
	price2 := (a - b) * d

	ans := price1 + price2
	return ans
}

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

int main(){
    int n, x;
    std::cin >> n >> x;

    std::vector<int> m(n);
    for(int i = 0; i < n; ++i){
        std::cin >> m.at(i);
        x -= m.at(i);
    }

    std::sort(m.begin(), m.end());
    while(x >= m.at(0)){
        ++n;
        x -= m.at(0);
    }

    std::cout << n << std::endl;

    return 0;
}


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

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

	int n,d;
	cin >> n >> d;
	vector<vector<int>> P(n, vector<int>(d));
	for(int i=0; i<n; i++){
		for(int j=0; j<d; j++){
			cin >> P[i][j];
		}
	}
	int ans = 0;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			int norm = 0;
			for(int k=0; k<d; k++){
				int diff = abs(P[i][k]-P[j][k]);
				norm += diff*diff;
			}
			bool flag = false;
			for(int k=0; k<=norm; k++){
				if(k*k==norm) flag = true;
			}
			if(flag) ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    vector<vector<int>> dist(H, vector<int>(W, -1));
    int sharp = 0;
    for (int i = 0; i < H; i++) {
        cin >> s.at(i);
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (s.at(i).at(j) == '#') {
                sharp++;
            }
        }
    }
    queue<P> que;
    que.push(make_pair(0,0));
    dist.at(0).at(0) = 0;
    int dx[4] = {1, -1, 0, 0};
    int dy[4] = {0, 0, 1, -1};
    int count = 0;
    while (!que.empty()) {
        P p = que.front();
        que.pop();
        int x = p.first;
        int y = p.second;
        // cout << "x:" << x << " y:" << y << endl;
        if (x == W - 1 && y == H - 1) {
            break;
        }
        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (nx >= 0 && nx <= W - 1 && ny >= 0 && ny <= H - 1 && s.at(ny).at(nx) == '.' && dist.at(ny).at(nx) == -1) {
                que.push(make_pair(nx, ny));
                dist.at(ny).at(nx) = dist.at(y).at(x) + 1;
            }
        }
    }
    if (dist.at(H-1).at(W-1) == -1) {
        cout << -1 << endl;
    }
    else {
        cout << H * W - dist.at(H-1).at(W-1) - sharp - 1 << endl;
    }
}

Measured memory_bytes: 256
package main

import "fmt"

func count_one_in_prefix(s string) int {
	for i, r := range s {
		if r != '1' {
			return i
		}
	}
	return len(s)
}

func main() {
	var S string
	var K int64
	fmt.Scan(&S, &K)
	if numOnes := count_one_in_prefix(S); K <= int64(numOnes) {
		fmt.Println(1)
	} else {
		fmt.Printf("%c\n", S[numOnes])
	}
}


Measured memory_bytes: 512
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;
typedef long long ll;
int power(int n, int m){
	if(m==0) return 1;
	else return n*power(n,m-1);
}

int main(){
  int N;
  cin >> N;
  bool Open[N][10];
  int P[N][11];

  for(int i=0;i<N;i++){
  	for(int j=0;j<10;j++){
  		int tmp;
  		cin >> tmp;
  		if(tmp==1) Open[i][j] = true;
  		else Open[i][j] = false;
  	}
  }
  for(int i=0;i<N;i++){
  	for(int j=0;j<=10;j++){
  		cin >> P[i][j];
  	}
  }

  int search = power(2,10);
  ll ans = -1000000000;

  for(int x=1;x<search;x++){
  	ll candidate = 0;
  	int cnt[N];
  	for(int i=0;i<N;i++) cnt[i] = 0;
  	for(int j=0;j<10;j++){
  		if(x&(1<<j)){
  			for(int i=0;i<N;i++){
  				if(Open[i][j]) cnt[i]++;
  			}
  		}
  	}
  	for(int i=0;i<N;i++){
  		candidate += P[i][cnt[i]];
  	}
  	ans = max(ans, candidate);
  }

  cout << ans <<endl;




  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
class Player implements Comparable<Player>{
	int no;
	double time;
	Player(int n,double t){
		no=n;
		time=t;
	}
	@Override
	public int compareTo(Player a) {
		// TODO 自動生成されたメソッド・スタブ
		if(this.time<a.time){
			return -1;
		}
		else if(this.time>a.time){
			return 1;
		}
		else{
			return 0;
		}
	}
}
public class Main {

	public static void main(String[] args) {
		new Main().run();
	}
	void run(){
		Scanner sc=new Scanner(System.in);
		Player p[][]=new Player[3][8];
		Player all[]=new Player[24];
		for(int i=0;i<3;i++){
			for(int j=0;j<8;j++){
				p[i][j]=new Player(sc.nextInt(),sc.nextDouble());
			}
		}
		Arrays.sort(p[0]);Arrays.sort(p[1]);Arrays.sort(p[2]);
		for(int i=0;i<3;i++){
			for(int j=0;j<2;j++){
				System.out.printf("%d %.2f\n",p[i][j].no,p[i][j].time);
				p[i][j].time=1<<20;
			}
		}
		for(int i=0;i<3;i++){
			for(int j=0;j<8;j++){
				all[8*i+j]=new Player(p[i][j].no,p[i][j].time);
			}
		}
		Arrays.sort(all);
		for(int i=0;i<2;i++) System.out.printf("%d %.2f\n",all[i].no,all[i].time);
	}
}

Measured memory_bytes: 12000
#include<cstdio>
#include<iostream>
#include<cctype>
#include<cstring>
#include<string>
using namespace std;

int main() {
    int n;
    cin >> n;
    if (n >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

namespace AtCoder.Contest.B
{
	static class Program
	{
		public static void Solve(Scanner cin)
		{
			int n = cin.ReadInt();
			int m = cin.ReadInt();
			var a = cin.ReadStringArray(n);
			var b = cin.ReadStringArray(m);
			bool ans = false;
			for (int i = 0; i < n - m + 1; i++)
			{
				for (int j = 0; j < n - m + 1; j++)
				{
					bool ok = true;
					for (int x = 0; x < m; x++)
					{
						for (int y = 0; y < m; y++)
						{
							if (a[i + x][j + y] != b[x][y]) ok = false;
						}
					}
					if (ok) ans = true;
				}
			}

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

		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);
			var cin = new Scanner();
			Solve(cin);
			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Read() => ReadString();

		public string ReadString()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return ReadString();
			i = 0;
			return s[i++];
		}

		public string[] ReadStringArray(int N)
		{
			string[] Array = new string[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadString();
			}
			return Array;
		}

		public int ReadInt()
		{
			return int.Parse(ReadString());
		}

		public int[] ReadIntArray(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadInt() + add;
			}
			return Array;
		}

		public long ReadLong()
		{
			return long.Parse(ReadString());
		}

		public long[] ReadLongArray(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadLong() + add;
			}
			return Array;
		}

		public double ReadDouble()
		{
			return double.Parse(ReadString());
		}

		public double[] ReadDoubleArray(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadDouble() + add;
			}
			return Array;
		}

		public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1));

	}
}

Measured memory_bytes: 11092