akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
    
    string sa,sb,sc;
    cin >>sa>>sb>>sc;
    int ra = 0,rb = 0,rc = 0;
    char turn = 'a';
    for(int i = 0;i < 300;i++){
        if(turn == 'a'){
            
            if(ra == sa.size()){
                if(turn == 'a') cout << 'A' << endl;
                if(turn == 'b') cout << 'B' << endl;
                if(turn == 'c') cout << 'C' << endl;
                break;
            }
            ra++;
            turn = sa[ra-1];

        }
         if(turn == 'b'){
            
            if(rb == sb.size()){
                if(turn == 'a') cout << 'A' << endl;
                if(turn == 'b') cout << 'B' << endl;
                if(turn == 'c') cout << 'C' << endl;
                break;
            }
            rb++;
            turn = sb[rb-1];
            
            
        }
         if(turn == 'c'){
            
            if(rc == sc.size()){
                if(turn == 'a') cout << 'A' << endl;
                if(turn == 'b') cout << 'B' << endl;
                if(turn == 'c') cout << 'C' << endl;
                break;
            }
            rc++;
            turn = sc[rc-1];
            
            
        }
    }
}

Measured memory_bytes: 256
N, K, Q = map(int, input().split())

# N人の持ち点arrayの初期値を作成する
points = [K-Q]*N

for i in range(Q):
    win = int(input()) -1
    points[win] += 1

for p in points:
    if p > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 6584
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

typedef long long ll;

ll F(ll a, ll b){
	ll numa = 0, numb = 0;
	while(a!=0){
		a/=10;
		numa++;
	}
	while(b!=0){
		b/=10;
		numb++;
	}
	return max(numa,numb);
}

int main(int argc, char ** argv){
	ll N;
	cin >> N;
	ll sq_rt = sqrt(N);
	for(ll i=sq_rt; i>0; i--){
		if(N%i == 0){
			cout << F(N/i,i) << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	int e;

	while(cin >> e, e) {
		int min = INT_MAX;	

		for(int z = 0; z*z*z <= e; z++) {
			for(int y = 0; y*y+z*z*z <= e; y++) {
				int x = e-z*z*z-y*y;
					if(x >= 0) {
						if(min > x+y+z) {
							min = x+y+z;
						}
					}				
				
			}
		}

		cout << min << endl;
	}
}

Measured memory_bytes: 0
//package beginner163.c;

import java.io.*;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int numOfEmployees = in.nextInt();

            int[] dep = new int[numOfEmployees];

            for (int i = 0; i < numOfEmployees - 1; ++i) {
                int bossId = in.nextInt();
                dep[bossId-1] += 1;
            }

            for (Integer subCount : dep) {
                out.println(subCount);
            }
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

Measured memory_bytes: 50784
from collections import deque
import sys
input = sys.stdin.readline
##### 高速化テスト #####

mod = 10**9 + 7
INF = 10**6
N, K = map(int, input().split())
edges = [[] * N for _ in range(N)]
for _ in range(N - 1):
    a, b = map(lambda x: int(x) - 1, input().split())
    edges[a].append(b)
    edges[b].append(a)
dq = deque([0])
color = [INF] * N
color[0] = K
ans = K
while dq:
    p = dq.popleft()
    cnt = 0
    for c in edges[p]:
        if color[c] == INF:
            if p == 0:
                color[c] = (K - 1 - cnt) % mod
            else:
                color[c] = (K - 2 - cnt) % mod
            ans = (ans * color[c]) % mod
            cnt += 1
            dq.append(c)
print(ans)


Measured memory_bytes: 90748
N, M = map(int, input().split(' '))

broken_list = []
if M > 0:
    for i in range(M):
        broken_list.append(int(input()))
        
broken_set =set(broken_list)
nums = [0] * (N + 1)
nums[0] = 1

if 1 not in broken_set:
    nums[1] = 1

for i in range(2, N + 1):
    nums[i] = nums[i - 1] + nums[i - 2]
    if i in broken_set:
        nums[i] = 0

print(nums[N] % 1000000007)

Measured memory_bytes: 465724
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

long long MOD = 1e9+7;
int MAX_INT = 1e9;

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

  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int K;
  cin >> K;

  cout << a[K - 1] << endl;
  return 0;
}


Measured memory_bytes: 3588
import sys

input_int = lambda:int(input())
input_ints = lambda:map(int,input().split())
input_ints_list = lambda:list(input_ints())
input_str = lambda:input()
input_strs = lambda:input().split()
input_lines = lambda n,f:[f() for _ in range(n)]

import functools,fractions
gcd = lambda a:functools.reduce(fractions.gcd,a) # 最大公約数（リスト）
lcm_base = lambda a,b:(a*b)//fractions.gcd(a,b) # 最小公倍数(2値)
lcm = lambda a:functools.reduce(lcm_base,a,1) # 最小公倍数(リスト)

import itertools
permutations = lambda a,n:itertools.permutations(a,n) # 順列
combinations = lambda a,n:itertools.combinations(a,n) # 組み合わせ
product = lambda a,b:itertools.product(a,b) # 二つのリストの直積

init_array_1dim = lambda v,n:[v for _ in range(n)]
init_array_2dim = lambda v,n,m:[[v for _ in range(n)] for _ in range(m)]

import math
# 四捨五入はround
ceil = lambda a:math.ceil(a) # 切り上げ
floor = lambda a:math.floor(a) # 切り捨て

class UnionFind(object):
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        x = self.find(x)
        return self.size[x]

# グラフで全部到達できる経路が何個あるか
def dfs_graph(v,n,graph,visited):
	if all(visited):return 1 # 全部到達できたら1を返す
	ans = 0
	for i in range(n):
		if not graph[v][i]:continue # 結ぶ線がないときはスキップ
		if visited[i]:continue # 到達済みだったらスキップ
		visited[i] = True
		ans += dfs_graph(i,n,graph,visited)
		visited[i] = False
	return ans

# ワーシャルフロイド（グラフの要素数、グラフ）
def warshall_floyd(n,graph):
	d = init_array_2dim(float("inf"),n,n)
	# 初期化
	for i in range(n):
		d[i][i] = 0
		for j in range(n):
			if graph[i][j]:d[i][j] = 1
	# 距離算出
	for k in range(n):
		for i in range(n):
			for j in range(n):
				d[i][j] = min(d[i][j],d[i][k] + d[k][j])
	return d

# グラフを初期化（グラフの要素数、グラフの線の両端、有向無向）
def init_graph(n,a,directed=False):
    visited = init_array_1dim(False,n)
    graph = init_array_2dim(False,n,n)
    for e in a:
        graph[e[0]-1][e[1]-1] = True
        if not directed:graph[e[1]-1][e[0]-1] = True # 無向グラフの場合
    return visited,graph

def solution():
	# ここに実装
    N,M = input_ints()
    AB = input_lines(M,input_ints_list)

    ans = []
    count = N*(N-1)//2 # 線一つもない時は2つ選んだ組み合わせ数
    uf = UnionFind(N)
    # 線を後ろから追加していく感じで処理を進める
    while(AB):
        ans.append(count)
        a,b = AB.pop()
        if not uf.is_same(a-1,b-1):
            count -= uf.get_size(a-1)*uf.get_size(b-1)
            uf.union(a-1,b-1)
    
    ans.reverse()
    for _ans in ans:
        print(_ans)
	
if __name__ == '__main__':
    solution()

Measured memory_bytes: 35536
#include<stdio.h>
long long int seg[2000006];
long long int ss;
void set(long long int i, long long int x)
{
	i += ss - 1;
	seg[i] += x;
	while (i > 0)
	{
		i = (i - 1) / 2;
		seg[i] = seg[2 * i + 1] + seg[2 * i + 2];
	}
	return;
}
long long int get(long long int l, long long int r)
{
	l += ss - 1;
	r += ss - 1;
	long long int res = 0;
	while (l < r)
	{
		if (l % 2 == 0)
			res += seg[l];
		l /= 2;
		if (r % 2 > 0)
			res += seg[r];
		r = r / 2 - 1;
	}
	if (l == r)
		res += seg[l];
	return res;
}
int main()
{
	long long int n, q;
	scanf("%lld %lld", &n, &q);
	long long int i;
	ss = 1;
	while (ss < n)
		ss *= 2;
	for (i = 0; i < n; i++)
		scanf("%lld", &seg[i + ss - 1]);
	for (i = ss - 2; i >= 0; i--)
		seg[i] = seg[2 * i + 1] + seg[2 * i + 2];
	long long int x, y, z;
	for (i = 0; i < q; i++)
	{
		scanf("%lld %lld %lld", &x, &y, &z);
		if (x == 0)
			set(y, z);
		else
			printf("%lld\n", get(y, z - 1));
	}
	return 0;
}

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

using namespace std;
using ll = long long;

int main(void){
    string S;
    cin >> S;

    int N = S.size() + 1;

    vector<int> a(N);
    vector<int> lt_succ(N); // < 
    vector<int> gt_succ(N); // >

    gt_succ[0] = 0;
    lt_succ[N-1] = 0;

    for(int i = 0; i < N - 1; i++){
        if(S[i] == '<'){
            lt_succ[i+1] = lt_succ[i] + 1;
        } else {
            lt_succ[i+1] = 0;
        }

        if(S[N - 2 - i] == '>'){
            gt_succ[N-2-i] = gt_succ[N - 1 - i] + 1;
        } else {
            gt_succ[N-2-i] = 0;
        }
    }


    ll sum = 0;

    for(int i = 0; i < N; i++){
        sum += max(gt_succ[i], lt_succ[i]);
    }
    
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 9764
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
xy=n.times.map{gsmi}
dis=[]

#全部の辺の長さ
n.times do |i|
  (i+1).upto(n-1) do |j|
    n1=xy[i]
    n2=xy[j]
    d=Math.sqrt((n1[0]-n2[0])**2+(n1[1]-n2[1])**2)
    dis<<d
  end
end
#puts dis.to_s
kai=(1..n).inject(:*)
edge_cnt=kai*(n-1)/((n-1)*n/2)/2
ans=sum(dis)*edge_cnt/(kai/2)
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    ll n,q; cin>>n>>q;
    vector<vector<ll>> tree(n+1);
    rep(i,n-1){
        ll a, b; cin >> a >> b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    vector<ll> res(n+1, 0);
    rep (i, q) {
        ll p, x; cin >> p >> x;
        res[p]+=x;
    }

    queue<ll> que;
    que.push(1);
    vector<ll> used(n+1, false);
    used[1]=true;

    while(!que.empty()){
        ll x=que.front();
        que.pop();
        for(ll y : tree[x]){
            if(used[y]) continue;
            used[y]=true;

            res[y]+=res[x];
            que.push(y);
        }
    }
    rep(i,n){
        if(i>0) cout<<' ';
        cout<<res[i+1];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 19440
#include <iostream>

using namespace std;

// Function to trace intermediate result
void trace(int A[], int n)
{
	for (int i = 0; i < n; i++) {
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}

int main()
{
	int A[100];
	int n;
	int key;
	int j;
	// Input data 
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> A[i];
	trace(A, n);

	// Inseartion sort	
	for (int i = 1; i < n; i++) {
		key = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > key) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = key;
		trace(A, n);
	}

	return 0;
}

Measured memory_bytes: 3096
#include <stdio.h>

int table[101][1001];

int main(void)
{
    int r, c;
    int i, j;

    scanf("%d%d", &r, &c);
    for (i = 0; i < r; i++){
        for (j = 0; j < c; j++){
            scanf("%d", &table[i][j]);
            table[i][c] += table[i][j];
            table[r][j] += table[i][j];
        }
        table[r][c] += table[i][c];
    }
    
    for (i = 0; i < r + 1; i++){
        for (j = 0; j < c + 1; j++){
            if (j > 0){
                printf(" ");
            }
            printf("%d", table[i][j]);
        }
        printf("\n");
    }
    return (0);
}



Measured memory_bytes: 2148
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

vector<string> S;
int cnt[11][2];

int main() {
	int H, W, K;
	cin >> H >> W >> K;
	S.resize(H);
	for(int i=0; i<H; ++i){
		cin >> S[i];
	}
	int ans=H+W-2;
	for(int i=0; i<(1<<(H-1)); ++i){
		int r=i+(1<<(H-1)), bas=0;
		for(int j=0; j<H; ++j){
			cnt[j][0]=cnt[j][1]=0;
			if(i&(1<<j)) ++bas;
		}
		bool lastReset=true;
		for(int j=0; j<W; ++j){
			int mx=0;
			for(int k=0; k<H; ++k){
				if((r<<1)&(1<<k)) cnt[k][1]=S[k][j]-'0';
				else cnt[k][1]=cnt[k-1][1]+(S[k][j]-'0');
				if(r&(1<<k)){
					mx=max(mx, cnt[k][1]+cnt[k][0]);
				}
			}
			if(mx>K){
				if(lastReset) break;
				else{
					--j;
					++bas;
					for(int k=0; k<H; ++k) cnt[k][0]=0;
					lastReset=true;
				}
			}else{
				lastReset=false;
				for(int k=0; k<H; ++k){
					if(r&(1<<k)) cnt[k][0] += cnt[k][1];
					else cnt[k][0]=0;
				}
			}
			for(int k=0; k<H; ++k) cnt[k][1]=0;
		}
		if(!lastReset) ans=min(ans, bas);
	}
	cout << ans << endl;
	return 0;
}

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

#define ll long long int
#define str string

ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30;
pair <ll, ll> A[10000000] = {}, X[1000000] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
ll a = 0, m = 0, i = 0, n = 0, sum = 0, max = INF;
str S;
ll ans = 0;

int findDigits(int n) {
	int i = 0;
	while (n > 0) {

		sum += n % 10;
		n /= 10;
		i++;
	}
	return i;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Code Line
	cin >> n >> m;
	for (int i = 0; i < n; i++)cin >> A[i].first >> A[i].second;

	sort(A, A + n);
	int i = 0;
	while (1) {
		if (a >= m)break;
		ans += A[i].first * min(A[i].second, m - a);
			a += min(A[i].second, m - a);
		i++;
	}
	cout << ans << endl;
	//Code Line
	return 0;
}


Measured memory_bytes: 172160
n, x, m = map(int, input().split())

flag = [False]*m
a = []
while not flag[x]:
    flag[x] = True
    a.append(x)
    x = pow(x, 2, m)
loop_start_idx = a.index(x)
loop_len = len(a) - loop_start_idx
loop_count = (n - loop_start_idx)//loop_len
loop_amari = (n-loop_start_idx)%loop_len
ans = sum(a[:loop_start_idx])
ans += sum(a[loop_start_idx:])*loop_count
ans += sum(a[loop_start_idx: loop_start_idx + loop_amari])
print(ans)


Measured memory_bytes: 68388
#include<stdio.h>
#include<iostream>
#include<stack>
#include<algorithm>
#define MAX 1400

using namespace std;

struct Rectangle { int height; int pos; };

int getLargestRectangle(int size, int buffer[]) {
    stack<Rectangle> S;
    int maxv = 0;
    buffer[size] = 0;
    
    for ( int i = 0; i <= size; i++ ) {
        Rectangle rect;
        rect.height = buffer[i];
        rect.pos = i;
        if ( S.empty() ) {
            S.push(rect);
        }else {
            if ( S.top().height < rect.height ) {
                S.push(rect);
            }else if ( S.top().height > rect.height ) {
                int target = i;
                while ( !S.empty() && S.top().height >= rect.height ) {
                    Rectangle pre = S.top(); S.pop();
                    int area = pre.height * (i - pre.pos);
                    maxv = max(maxv, area);
                    target = pre.pos;
                }
                rect.pos = target;
                S.push(rect);
            }
        }
    }
    return maxv;
}

int H, W;
int buffer[MAX][MAX];
int T[MAX][MAX];

int getLargestRectangle() {
    for ( int j = 0; j < W; j++ ) {
        for ( int i = 0; i < H; i++ ) {
            if ( buffer[i][j] ) {
                T[i][j] = 0;
            } else {
                T[i][j] = (i > 0) ? T[i - 1][j] + 1 : 1;
            }
        }
    }
    
    int maxv = 0;
    for ( int i = 0; i < H; i++ ) {
        maxv = max(maxv, getLargestRectangle(W, T[i]));
    }
    
    return maxv;
}

int main() {
    scanf("%d %d", &H, &W);
    for ( int i = 0; i < H; i++ ) {
        for ( int j = 0; j < W; j++ ) {
            scanf("%d", &buffer[i][j]);
        }
    }
    cout << getLargestRectangle() << endl;
    
    return 0;
}


Measured memory_bytes: 18556
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	s := next()
	for i := 0; i < len(s); i++ {
		putf("x")
	}
	putf("\n")
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
X,Y = map(int, input().split())

if Y<X:
    print("No")
    exit()

if Y%2 != 0:
    print("No")
    exit()

A = (Y-2*X)/2

if X-A >= 0:
    if A >= 0:
        print("Yes")
        exit()
    print("No")
    exit()

print("No")

Measured memory_bytes: 9176
#include<iostream>
#include<string>
using namespace std;
int main(){
    string a;
    cin>>a;
    int len=a.size();
    int i;
    int x=0,y=0,ans=0;
    for(i=0;i<len;i++)
        if(x==y){x++;if(a[i]=='p') ans--;}
        else{y++;if(a[i]=='g') ans++;}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int a,b,n,s,f,t[1005]={};
  cin >> a >> b >> n;
  for(int i=0; i<n; i++) {
    cin >> s >> f;
    t[s]++,t[f]--;
  }
  for(int i=1; i<1005; i++) {
    t[i]+=t[i-1];
  }
  for(int i=a; i<b; i++) {
    if(t[i]>0) {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}


Measured memory_bytes: 3168
#include <stdio.h>

int main(){
	int N, a[100], i, j, b[100];
    int c, d;
  
    scanf("%d", &N);
    for(i=0; i<N; i++){
     scanf("%d", &a[i]);
    }
    
    d = N;
    
    for(j=0; j<N-1; j++){
      c=0;
	  for(i=j+1; i<N; i++){
      	if(a[j]==a[i]) c++;
      }
      if(c>0) d--;
    }
    printf("%d", d);

return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main()
{
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed << setprecision(8) << sqrt(pow(x2 - x1, 2.0) + pow(y2 - y1, 2.0)) << endl;
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int r = count(s.begin(), s.end(), 'R');
    string t = s;
    sort(s.begin(), s.end());
    int ans = 0;
    for (int i = 0; i < r; ++i) {
        ans += s[i] != t[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3924
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
using ll = long long;
using namespace std;

int main(){
    int n,sum=0,ans;
    double num=100000;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
         cin >> a[i];
         sum+=a[i];
    }
    double avr = (double)sum/n;
    for(int i=0;i<n;i++){
        if(abs(a[i]-avr)<num){
            num = abs(a[i]-avr);
            ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 数値
		int n = sc.nextInt();
		int m = sc.nextInt();
		int count = 0;

		if (n < 2) {

		} else {
			count += n * (n - 1) / 2;
		}

		if (m < 2) {

		} else {
			count += m * (m - 1) / 2;
		}

		out(count);

	}

	/*
	 * 以下メソッド集
	 */

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

}


Measured memory_bytes: 22740
import java.util.*;

/**
 * 区間スケジューリング問題
 */
public class Main {
    public static final int MOD = 1_000_000_007;

    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] X = new int[N];
        int[] L = new int[N];
        for (int i=0; i<N; i++) {
            X[i] = sc.nextInt();
            L[i] = sc.nextInt();
        }

        int ans = solve(N, X, L);

        System.out.println(ans);
    }

    private static int solve(int N, int[] X, int[] L) {
        Pair[] list = new Pair[N];
        for (int i=0; i<N; i++) {
            list[i] = new Pair(X[i] - L[i], X[i] + L[i]);
        }

        Arrays.sort(list, new PairComparator().reversed());
        int count = 0;
        int pos = Integer.MIN_VALUE;
        for (int i=0; i<N; i++) {
            if (pos > list[i].first) continue;
            count++;
            pos = list[i].second;
        }

        return count;

    }

    static class Pair {
        int first;
        int second;

        public Pair(int a, int b) {
            this.first = a;
            this.second = b;
        }
    }

    static class PairComparator implements Comparator {

        public int compare(Object a0, Object b0) {
            Pair a = (Pair)a0;
            Pair b = (Pair)b0;

            return b.second - a.second;
        }
    }
}


Measured memory_bytes: 65192
def getinputdata():

    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])

cnt=1

mindata = float('inf') 

while cnt<n:
    
    mysum=0
    
    for v in str(cnt):
        
        mysum+=int(v)
        
    for v in str(n-cnt):
        
        mysum+=int(v)
    
    
    mindata=min(mindata,mysum)
    
    cnt+=1
    
    
print(mindata)    

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

int main(void)
{
	unsigned long long int a, b, c = 1, i, j, sq;
	long long int ret = 0;

	
	scanf("%lld", &a);

	sq = sqrt(a);

	for (i = 2; i <= sq; i++) {
		if (a % i == 0) {
			c = 1;
			while (1) {
				b = 0;
				for (j = 0; j < c; j++) {
					if (a % i != 0) {
						b = 1;
						break;
					}
					a = a / i;
				}

				if (b == 1) {
					break;
				}

				ret++;
				c++;
			}
			sq = sqrt(a) + 1;
		}
	}

	if (a != 1) {
		(ret)++;
	}

	printf("%d", ret);

	return 0;
}

Measured memory_bytes: 2152
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
//#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#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>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define reps(i, j, k) for(auto i = j; i < k; ++i)
#define rep(i, j) reps(i, 0, j)
#define decs(i, j, k) for(auto i = j; i >= k; --i)
#define dec(i, j) decs(i, j, 0)
#define iter(i, j) for(auto i = j.begin(); i != j.end(); ++i)
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int, int>
#define vpi vector<pi>
#define vb vector<bool>
#define F first
#define S second
#define mp make_pair
#define um unordered_map
#define all(x) (x).begin(), (x).end()  
#define fast_io ios::sync_with_stdio(0); cin.tie(0);
#define file_io freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define IMAX std::numeric_limits<int>::max()
#define IMIN std::numeric_limits<int>::min()
using namespace std;

int main()
{
	int n, k; cin >> n >> k;
	vi p(n); rep(i, n) cin >> p[i];
	sort(all(p));
	ll ans = 0;
	rep(i, k) ans += p[i];
	cout << ans;
	return 0;
}


Measured memory_bytes: 3136
//Author : pakhandi
//
using namespace std;

#include<bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)
#define ss(s) scanf("%s", s)
#define sc(c) scanf("%c", &c)
#define sd(f) scanf("%lf", &f)

#define pi(n) printf("%d\n", n)
#define pll(l) printf("%lld\n", l)
#define ps(s) printf("%s\n", s)
#define pc(c) printf("%c\n", c)
#define pd(f) printf("%lf\n", f)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define mclr(strn) strn.clear()
#define ignr cin.ignore()
#define PB push_back
#define SZ size
#define MP make_pair
#define fi first
#define sec second

ll dp[5003][5003];
int moves, target;
string str1;

ll rec(int move, int ind)
{
	if(move == moves)
	{
		return ind == target;
	}

	ll &ret = dp[move][ind];
	if(ret != -1)
		return ret;
	ret = 0;

	ret += rec(move + 1, max(ind - 1, 0));
	ret += 2 * rec(move + 1, ind + 1);
	return ret %= MOD;
}

int main()
{
	int i, j;

	mem(dp, -1);

	si(moves);

	cin>>str1;

	target = str1.SZ();

	ll ans = rec(0,0);

	ll co = 1LL;

	fl(i,0,target)
	{
		co = co * ((1000000000 + 8) / 2);
		co %= MOD;
	}

	ans *= co;
	cout<<ans % MOD;

	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 195968
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)

	res := solv(N)

	fmt.Println(res)

}

func solv(len int) (broken int) {
	counter := 0
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		if num == counter+1 {
			counter += 1
		} else {
			broken += 1
		}
	}
	if broken == len {
		return -1
	}
	return
}



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


int main(){
    int x, a, b;
    cin >> x >> a >> b;
    int dista = abs(a-x), distb = abs(b-x);
    cout << (dista < distb ? "A\n" : "B\n");
}



Measured memory_bytes: 256
S = input()
while True:
    l = len(S)
    if l == 0:
        print('YES'); break
    if l-5 >= 0 and S[l-5:] == 'dream':
        S = S[:l-5]; continue
    if l-7 >= 0 and S[l-7:] == 'dreamer':
        S = S[:l-7]; continue
    if l-5 >= 0 and S[l-5:] == 'erase':
        S = S[:l-5]; continue
    if l-6 >= 0 and S[l-6:] == 'eraser':
        S = S[:l-6]; continue
    print('NO')
    break

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

namespace ConsoleAppAtCoderBeginnerContest116B
{
    class Program
    {
        public static List<int> sequence= new List<int>();
        static int counter;

        static void Main(string[] args)
        {
            // 整数の入力
            int s = int.Parse(Console.ReadLine());// 初項S

            sequence.Add(s);
            int temp = counter;
            int next_s=progresson(s);
            //Console.WriteLine("next_s:"+next_s);
            while (temp != counter)
            {
                temp = counter;
                next_s=progresson(next_s);
                
            }
                 Console.WriteLine(counter+2);
        }

        public static int progresson(int number)
        {
            int s=number;
            int num;

            if (s % 2 == 1)// 奇数
            {
                num = 3 * s + 1;
                if (sequence.Contains(num) == false)
                    {
                        sequence.Add(num);
                        counter++;
                    }
            }
            else// 偶数
            {
                num = s / 2;
                if (sequence.Contains(num) == false)
                    {
                        sequence.Add(num);
                        counter++;
                    }
            }
            return num;
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int ans; string s, t;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> s >> t;
for (int i=0; i<s.size(); i++)
	if(s[i]!=t[i]) ans++;
	cout << ans << endl;
return 0;
}


Measured memory_bytes: 3792
from itertools import product

N, M = map(int, input().split())

k = []
s = []
for _ in range(M):
    t = list(map(int, input().split()))
    k.append(t[0])
    s.append(t[1:])

p = list(map(int, input().split()))

ans = sum(
    all(
        sum(
            t[j - 1]
            for j in s[i]
        ) % 2 == p[i]
        for i in range(M)
    )
    for t in product(range(2), repeat=N)
)

print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
int d[110];
int main ()
{
	int n,i,j,r=0;
	scanf("%i",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%i",&d[i]);
	}
	for(i=1;i<=n;i++)
	{
		for(j=i+1;j<=n;j++)
		{
			r=d[i]*d[j]+r;
		}
	}
	printf("%i",r);
	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	char s[201], p[101],t[101];

	scanf("%s %s", s, p);
	strcpy(t, s);
	strcat(s, t);

	if (strstr(s, p) == NULL )
	{
		printf("No\n");
	}
	else printf("Yes\n");
}

Measured memory_bytes: 972
#include <iostream>
using namespace std;
const int N = 105;

int main() {
	int n, m, r[N] = {}, c[N] = {};
	string s[N];
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		for (int j = 0; j < m; j++) {
			if (s[i][j] == '#') {
				r[i]++;
				c[j]++;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (!r[i])continue;
		for (int j = 0; j < m; j++) {
			if (!c[j])continue;
			cout << s[i][j];
		}
		cout << '\n';
	}
}


Measured memory_bytes: 256
#ABC-147
#参考 https://atcoder.jp/contests/abc147/submissions/8896111
N = int(input())
evidences = [[] for i in range(N)]

for i in range(N):
    A = int(input())
    for _ in range(A):
        x, y = map(int, input().split())
        evidences[i].append((x-1, y))

result = 0
for i in range(1, 2**N):
    consistent = True
    for j in range(N):
        #すでに矛盾するパターンのiとわかっているならば飛ばす。
        if consistent == False:
            break
        #jが正しいと仮定する。(もし0ならcontinueで飛ばされる。)
        if (i >> j) & 1 == 0:
            continue
        #jの証言を一個ずつ確認していく。
        for x, y in evidences[j]:            
            if (i >> x) & 1 != y:
                consistent = False
                break
    #全ての人の証言で矛盾がないパターンのiだったら、1の数(=正直者の数)をresultに記録しておく。
    if consistent == True:
        result = max(result, bin(i)[2:].count("1"))

print(result)

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

int main() {
long K;
cin>>K;
if(K%2==0||K%5==0){
  cout<<-1<<endl;
  return 0;
}
if(K==1||K==7){
  cout<<1<<endl;
  return 0;
}
long ans=1;
long now=7;
long mul=10;
while(now!=0&&ans<10000000){
  now+=mul*7;
  now%=K;
  mul*=10;
  mul%=K;
  ans++;
}
cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
    int n, m;   cin >> n;
    map<string, int> ma;
    for (int i = 0; i < n; i++) {
        string s;   cin >> s;
        ma[s]++;
    }
    cin >> m;
    for (int i = 0; i < m;i++) {
        string s;   cin >> s;
        ma[s]--;
    }

    int ans = 0;
    for (auto ite = ma.begin(); ite != ma.end(); ite++) {
        ans = max(ans, (*ite).second);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){

vector<int> a = {1,3,5,7,8,10,12};
vector<int> b = {4,6,9,11};
 int x[2];cin>>x[0]>>x[1];
 int group[2] = {0,0};
 for(int i = 0;i<2;i++){
 
for(auto j : a){
   if(x[i] == j){
    group[i] = 1;
    break;
 }
}
for(auto k :b){
 if(x[i] == k){ group[i] = 2; break;}
}
}
if(group[0] == group[1]){ cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
 return 0;
}

Measured memory_bytes: 256
n=int(input())
k=int(input())
dp0=[[0 for i in range(4)] for i in range(len(str(n))+1)]
dp1=[[0 for i in range(4)] for i in range(len(str(n))+1)]

for i in range(1,len(str(n))+1):
    dp0[i][0]=1
dp0[1][1]=int(str(n)[0])-1
dp1[1][1]=1

for N in range(2,len(str(n))+1):
    for num in range(10):
        for K in range(1,4):
            if num!=0:
                if num<int(str(n)[N-1]):
                    dp0[N][K]+=dp0[N-1][K-1]+dp1[N-1][K-1]
                elif num==int(str(n)[N-1]):
                    dp0[N][K]+=dp0[N-1][K-1]
                    dp1[N][K]+=dp1[N-1][K-1]
                else:
                    dp0[N][K]+=dp0[N-1][K-1]
            else:
                if int(str(n)[N-1])>0:
                    dp0[N][K]+=dp0[N-1][K]+dp1[N-1][K]
                elif int(str(n)[N-1])==0:
                    dp1[N][K]+=dp1[N-1][K]
                    dp0[N][K]+=dp0[N-1][K]
#print(dp0)
#print(dp1)
print(dp1[-1][k]+dp0[-1][k])


Measured memory_bytes: 39664
#include<set>
#include<iostream>
main(){
  int n;
  std::cin>>n;
  std::set<int> st;
  for(int i=0;i<n;++i){
    int a;
    std::cin>>a;
    st.insert(a);
  }
  std::cout<<st.size()<<std::endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace	std;
int main(){

  int n,m,tmp1,tmp2;
  bool is[200001]={0};
  cin>>n>>m;

  for(int i=0;i<m;i++){
    cin>>tmp1>>tmp2;
    if(tmp1==1){
      if(is[tmp2]==true){
        cout<<"POSSIBLE"<<endl;
        return 0;
      }
      is[tmp2]=true;
    }
   if(tmp2==n){
      if(is[tmp1]==true){
        cout<<"POSSIBLE"<<endl;
        return 0;
      }
      is[tmp1]=true;
    }
  }
  cout<<"IMPOSSIBLE"<<endl;
  return 0;

}


Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    return gcd(b,a%b);
}

long long lcm(long long a, long long b) {
    return a / gcd(a,b) * b;
}

vector<long long> PrimeFactorization(long long n) {
    vector<long long> res;
    long long t = n;
    for (long long i = 2; i * i <= t; ){
        if (n % i == 0) res.push_back(i), n /= i;
        else i++;
    }
    if(n != 1) res.push_back(n);
    return res;
}

int main ()
{
    ll A,B;
    cin >> A >> B;

    ll g = gcd(A, B);
    vector < ll > p = PrimeFactorization(g);

    set < ll > ans;
    for (auto x : p) ans.insert(x);

    cout << ans.size() + 1 << endl;

    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let y:usize = read();
    let mut ans = (-1, -1, -1);
    'outer: for i in 0..=n {
        for j in 0..=n {
            if i + j > n {
                continue;
            }
            let c = n - i - j;
            if y == i * 10000 + j * 5000 + c * 1000 {
                ans = (i as i32, j as i32, c as i32);
                break 'outer;
            }
        }
    }
    println!("{} {} {}",ans.0, ans.1, ans.2);
}

Measured memory_bytes: 2076
#include<iostream>
#include <algorithm>
using namespace std;
 
int main(){
    int n;
    int ans = 0;
    int b[128] = {0};

    cin >> n;

    for(int i = 0; i < (n-1); i++){
            cin >> b[i];
    }
    for(int j = 0; j < (n-2); j++){
        ans += min(b[j], b[j+1]) ;
    }
    cout << (ans + b[0] + b[n-2]) << endl;

    return 0;
}

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

using namespace std;

#define INF 1e9

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

    while(1){
        long long n,a,b,c,x;
        cin>>n>>a>>b>>c>>x;

        if(n==0)break;

        vector<int> y(n);
        for(int i=0;i<n;i++)cin>>y[i];

        int ans=-1;

        for(int i=0;i<=10000;i++){
            for(int j=0;j<n;j++){
                if(y[j]!=-1){
                    if(y[j]==x)y[j]=-1;
                    break;
                }
            }
            bool f=true;
            for(int j=0;j<n;j++)if(y[j]!=-1)f=false;
            if(f){
                ans=i;
                break;
            }
            x=(a*x+b)%c;
        }
        
        cout<<ans<<endl;

    }

}


Measured memory_bytes: 3096
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n;
  cin >> n;

  int ans = __builtin_popcountll(n);
  REP(i, 32) if(n&1<<i) chmax(ans, i);
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
long long x[10000010], y[10000010];
#define int long long
signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   int a, b, n, cnt = 0, ans = 0;
   string s, ss;

   cin >> n;
   cin >> s;

   for (int i = 0; i < n; i++)
   {
      if (cnt == n)
         break;
      for (int j = cnt; j < n; j++)
      {
         cnt++;
         if (s[j] == s[j + 1])
         {
            ans++;
         }
         else
            break;
     }
   }
   cout << n - ans << '\n';
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import sys;
import string;
sys.setrecursionlimit(20000) # 再起呼び出しの最大数をセット

import copy
import itertools

from functools import lru_cache
#@lru_cache(maxsize = None)

# 整数の入力
n = int(input())
print((n-2)*180)


Measured memory_bytes: 4088
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {
	
	int A, B, C, D;
	scanf("%d%d", &A, &B);

	if ((A + B) % 2 == 0)printf("%d", ((A + B) / 2));
	else printf("%d", (A + B) / 2 + 1);

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007 
#define all(n)      (n).begin(), (n).end()
#define ll long long 
#define PI 3.14159265358979323846

void solve(){
	int r; cin >> r; 
	long double ans;
	ans = (2 * PI * (long double)r);
	cout << setprecision(50) << ans << endl;
	

}


int main (){
	#ifndef ONLINE_JUDGE
		freopen ("input.txt","r",stdin);
		freopen ("output.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	//Write from here.
	
		solve();
	
	return 0;
}

Measured memory_bytes: 3800
n = int(input());A = [] ; s = 0 ; t = 0

for i in range(1,n):
    for j in range(len(str(i))):
        s += int(str(i)[j])
    for k in range(len(str(n-i))):
        t += int(str(n-i)[k])
    a = s + t
    A.append(a)
    s = 0 ; t = 0
    
print(min(A))

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N;
    cin >>N;

    vector<int> A(N);
    vector<int> lm(N),rm(N);
    rep(i,N) cin >> A[i];
    lm[0]=A[0];
    rm[N-1]=A[N-1];
    repd(i,1,N){
        lm[i]=max(lm[i-1],A[i]);
        rm[N-i-1]=max(rm[N-i],A[N-i-1]);
    }
    cout<<rm[1]<<endl;
    repd(i,1,N-1){
        cout<<max(lm[i-1],rm[i+1])<<endl;
    }
    cout<<lm[N-2]<<endl;

    return (0);
}

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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto& x: a) {
        cin >> x;
    }
    vector<int> b(n, 0);
    vector<int> res;
    for (int i = n-1; i >= 0; i--) {
        int sum = 0;
        for (int j = i; j < n; j += i+1) {
            sum ^= b[j];
        }
        b[i] = sum ^ a[i];
        if (b[i]) res.push_back(i+1);
    }
    int sz = res.size();
    cout << sz << "\n";
    for (auto& x: res) {
        cout << x << ' ';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 3192
#include<iostream>
#include<vector>
#include<unordered_map>
using namespace std;
typedef long long li;
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 998244353
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
li fact(li a){
  // unordered_map 必須
  static vector<li> f(1,1);

  if(f.size()>a)return f[a];
  if(df)print(a,"!");
  int n=f.size();
  repa(i,n,a+1){
    f.push_back(f[i-1]*i%MOD);
    if(df)print(i,a+1,f[i]);
  }
  return f[a];
}

li inv(li a){
  // unordered_map 必須
  static unordered_map<li,li> f;
  if(a==0) print("err!!");
  f[1]=1;
  a%=MOD;
  if(f.find(a)!=f.end())return f[a];
  return f[a]=(MOD-MOD/a)*inv(MOD%a)%MOD;
}

li comb(li n,li r){
  if(df)print("n!",n,"r!n-r!",r);
  li a=fact(n),x=fact(r)*fact(n-r)%MOD;
  return a*inv(x)%MOD;
}

li pow(li a,li n){
  if(df)print(a,"^",n);
  li s=1;
  while(n){
    if(n%2)(s*=a)%=MOD;
    n/=2; (a*=a)%=MOD;
  }
    if(df)print(s);
  return s;
}

int main(){
  int n,m,k; cin >>n >>m >>k;
  li s=0;
  rep(i,k+1){
    li a=m*pow(m-1,n-1-i)%MOD;
    if(df)print(49000,a);
    a*=comb(n-1,i);
    if(df)print(51000,a);
    (s+=a)%=MOD;
    if(df)print(53000,s);
  }
  print(s);
}


Measured memory_bytes: 38024