akhauriyash/Code-Regression huggingface dataset:
import sys

sys.setrecursionlimit(10 ** 9)

class UnionFind:
    def __init__(self, n):
        self.parents = [i for i in range(n + 1)]
        self.sizes = [1] * (n + 1)

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

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        # これかああああ！！！！
        # 逆にするといいらしいけどなぜ？
        # if y < x:
        #     x, y = y, x
        self.parents[y] = x
        self.sizes[x] += self.sizes[y]
        self.sizes[y] = self.sizes[x]

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

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


n, m, k = map(int, input().split())
uf = UnionFind(n)
friends = [0] * n
blocks = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    friends[a - 1] += 1
    friends[b - 1] += 1
    uf.unite(a - 1, b - 1)
for i in range(k):
    c, d = map(int, input().split())
    if uf.same(c - 1, d - 1):
        blocks[c - 1] += 1
        blocks[d - 1] += 1
ans = [0] * n
for i in range(n):
    ans[i] = uf.size(i) - friends[i] - blocks[i] - 1
print(*ans)

Measured memory_bytes: 41312
using System;
using System.Text;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            int input = int.Parse(Console.ReadLine());
            var output = new StringBuilder();
            for(int i = 1; i <= input; ++i){
                if (i % 3 == 0 || i.ToString().Contains("3")) {
                    output.Append(" " + i.ToString());
                }
            }
            Console.WriteLine(output);
        }
    }
}

Measured memory_bytes: 6564
@a=map~~<>,1..<>;
@c=<>;
for(@a){
	($a,$b)=glob;
	$m=1e9;
	$i=0;
	for(@c){
		$i+=/ /;
		$m-=$-=$m-abs($`-$a)-abs$'-$b;
		$-&&($z=$i)
	}
	print$z,$/
}


Measured memory_bytes: 768
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.flush();
	int a,b,c,d;
	cin >> a >> b >> c >> d;
  	cout<<min(a,b)+min(c,d);
	return 0;
	// BYE BYE
}


Measured memory_bytes: 256
N=int(input())
ans=[0,0,0,0]
for _ in range(N):
  result=input()
  for i in range(4):
    if result==["AC","WA","TLE","RE"][i]:
      ans[i]+=1
      break
for i in range(4):
  print(["AC","WA","TLE","RE"][i]+" x "+str(ans[i]))

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//実行部
void Main()
{
  ll a, b, x; cin >> a >> b >> x;
  if(a <= x&&a + b >= x) fin("YES")
  else fin("NO")
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

double	sort[100];
int count;

void BubbleSort(void);

int main(void)
{
	int i=0;
	
	while (scanf("%lf", &sort[i]) != EOF){
		i++;
		count++;
	}
	
	//ソート開始
	BubbleSort();
	//ソート終了
	
	printf("%.1f\n", sort[count-1]-sort[0]);
	
	return 0;
}

void BubbleSort(void)
{
	int i, flag,k;
	double j;
	
	k = 0;
	do {
		flag = 0;
		for (i=0; i<count-1-k; i++){
			/* 先頭から順に見ていく */
			if (sort[i] > sort[i+1]){
				/* 左右が逆であれば直す */
				flag = 1;
				j = sort[i];
				sort[i] = sort[i+1];
				sort[i+1] = j;
			}
		}
		k++;
	} while (flag == 1);
}

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

int n,k;
long long a[200005],ans;
map<long long,int> mp;
int bit[200005];

int sum(int pos){
    int res=0;
    while(pos>0){
        res+=bit[pos];
        pos-=pos&-pos;
    }
    return res;
}

void add(int pos,int val){
    while(pos<=n+1){
        bit[pos]+=val;
        pos+=pos&-pos;
    }
}

int main(){

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

    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        a[i]=a[i]-k+a[i-1];
        mp[a[i]]=0;
    }
    mp[0]=0;
    int cnt=0;
    for(map<long long,int>::iterator it=mp.begin();it!=mp.end();it++){
        it->second=++cnt;
    }
    add(mp[0],1);
    for(int i=1;i<=n;i++){
        ans+=sum(mp[a[i]]);
        add(mp[a[i]],1);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int digit = n%10;
	if(digit == 2 || digit == 4 || digit == 5 || digit == 7 || digit == 9){
		cout << "hon"; 
	}
	else if(digit == 0 || digit == 1 || digit == 6 || digit == 8){
		cout << "pon";
	}
	else{
		cout << "bon";
	}
}


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

int main()
{
	int n;
	cin >> n;
	long long array[n];
	int i;
	for (i=0;i<n;i++)
	{
		cin >> array[i];
	}

	long long sum[n];
	sum[0] = array[0];
	for (i=1;i<n;i++)
	{
		sum[i] = array[i] + sum[i-1];
	}
	long long answer1=0,answer2=0;
	//For 1st positive.
	long long tempf=0;
	for (i=0;i<n;i++)
	{
		sum[i] += tempf;
		if (i%2==0)
		{
			if (sum[i]<=0)
			{
				answer1 += (abs(sum[i])+1);
				tempf += (abs(sum[i])+1);
			}

		}
		else
		{
			if (sum[i]>=0)
			{
				answer1 += (abs(sum[i])+1);
				tempf -= (abs(sum[i])+1);
			}
		}
	}
	tempf=0;
	sum[0] = array[0];
	for (i=1;i<n;i++)
	{
		sum[i] = array[i] + sum[i-1];
	}

	//1st negative
	for (i=0;i<n;i++)
	{
		sum[i] += tempf;
		if (i%2==0)
		{
			if (sum[i]>=0)
			{
				answer2 += (abs(sum[i])+1);
				tempf -= (abs(sum[i])+1);
			}
		}
		else
		{
			if (sum[i]<=0)
			{
				answer2 += (abs(sum[i])+1);
				tempf += (abs(sum[i])+1);
			}
		}
	}

	cout << min(answer1,answer2);


	return 0;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-

n = int(input())

def cntd(x):
    digits = 0

    while x/10>0:
        x = x//10
        digits += 1
    return digits

ans = cntd(n)

a = 1
while a*a<=n:
    if n%a!=0:
        a += 1
        continue

    b = n//a
    cur = max(cntd(a), cntd(b))
    if ans>cur:
        ans = cur
    a += 1

print(ans)


Measured memory_bytes: 3060
package main

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

const (
	MAX = 100
	INF = 1 << 21
	WHITE = 0
	GRAY = 1
	BLACK = 2
)

var (
	n int
	M [MAX][MAX]int
)

func prim() int {
	var u, minv int
	var d [MAX]int
	var p [MAX]int
	var color [MAX]int

	for i := 0; i < n; i++ {
		d[i] = INF
		p[i] = -1
		color[i] = WHITE
	}
	d[0] = 0
	for {
		minv = INF
		u = -1
		for i := 0; i < n; i++ {
			if minv > d[i] && color[i] != BLACK {
				u = i
				minv = d[i]
			}
		}
		if u == -1 {
			break
		}
		color[u] = BLACK
		for v := 0; v < n; v++ {
			if color[v] != BLACK && M[u][v] != INF {
				if d[v] > M[u][v] {
					d[v] = M[u][v]
					p[v] = u
					color[v] = GRAY
				}
			}
		}
	}
	sum := 0
	for i := 0; i < n; i++ {
		if p[i] != -1 {
			sum += M[i][p[i]]
		}
	}
	return sum
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _ = strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			scanner.Scan()
			e, _ := strconv.Atoi(scanner.Text())
			if e == -1 {
				M[i][j] = INF
			} else {
				M[i][j] = e
			}
		}
	}
	fmt.Println(prim())
}


Measured memory_bytes: 1176
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int int_pow(int a, int b)
{
	int r = 1;
	int i = 0;
	while (i < b)
	{
		r = r*a;
		i++;
	}
	return(r);
}
int main(void)
{
	int n;
	scanf("%d",&n);
	printf("%d\n",int_pow(n,3));
	return(0);
}


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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<int> l(n);
    for(auto& x : l) cin >> x;
    sort(begin(l), end(l));
    int s = accumulate(begin(l), prev(end(l)), 0);
    if(s > l.back()) cout << "Yes\n";
    else             cout << "No\n";
}

Measured memory_bytes: 256
N, K = map(int, input().split())
a = list(map(int, input().split()))
max_a = 10**9
min_a = 0

while max_a-min_a>1:
    count = K
    mean_a = (max_a+min_a)//2
    for i in range(N):
        count -= -(-a[i]//mean_a)-1
    if count >= 0:
        max_a = mean_a
    else:
        min_a = mean_a

print(max_a)

Measured memory_bytes: 30768
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
//max=({});
//条件式が真ならwhileの中身を回し続ける

int n;

int main() {
	cin >> n;
	vector<int>p(n);
	rep(i, n) {
		cin >> p[i];
	}
	int big = 300000;
	int ans = 0;
	rep(i, n) {
		if (big >= p[i]) {
			ans++;
			big = p[i];
		}
	}
	cout << ans << endl;
	return 0;
}


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

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

int main() {
    int n;cin>>n;
    int cnt=1;
    vector<int>a(n);
    rep(i,n){
        cin>>a[i];
    }
    int max=a[0];

    rep2(i,1,n){
        if(a[i]>max){
            max=a[i];
        }
        if(a[i-1]<=a[i]&&max<=a[i]){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}



Measured memory_bytes: 256
class SegmentTree:
    """
    0-indexed
    query : [L, R)
    """
    def __init__(self, size, initValue):
        self.size = 1 << (size.bit_length())  # 完全二分木にする
        self.data = [initValue] * (2 * self.size - 1)
        self.initValue = initValue

    def cmpFunc(self, left, right):
        return left | right

    def build(self, rawData):
        self.data[self.size - 1: self.size - 1 + len(rawData)] = rawData
        for i in range(self.size - 1)[:: -1]:
            self.data[i] = self.cmpFunc(self.data[2 * i + 1], self.data[2 * i + 2])

    def update(self, index, value):
        index += self.size - 1
        self.data[index] = value
        while index >= 0:
            index = (index - 1) // 2
            self.data[index] = self.cmpFunc(self.data[2 * index + 1], self.data[2 * index + 2])

    def query(self, left, right):
        L = left + self.size
        R = right + self.size
        ret = self.initValue
        while L < R:
            if R & 1:
                R -= 1
                ret = self.cmpFunc(ret, self.data[R - 1])
            if L & 1:
                ret = self.cmpFunc(ret, self.data[L - 1])
                L += 1
            L >>= 1
            R >>= 1
        return ret

def cToI(s):
    return ord(s) - ord('a')

N = int(input())
S = list(map(cToI, input()))

S = [1 << s for s in S]
tree = SegmentTree(N, 0)
tree.build(S)

Q = int(input())
ans = []
for _ in range(Q):
    q1, q2, q3 = input().split()

    if q1 == '1':
        tree.update(int(q2) - 1, 1 << cToI(q3))
    else:
        ans.append(tree.query(int(q2) - 1, int(q3)))

for a in ans:
    cnt = 0
    while a > 0:
        cnt += a % 2
        a //= 2
    print(cnt)


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


int main() {
  string s;
  string t="";
  cin >> s;
  int n = s.size();
  ll sum = 0;
  ll sumA=0;
  for(int i=0;i<n-1;i++){
    if(s[i]=='B' && s[i+1]=='C'){
      t+='D';
      i++;
    }
    else{
      t+=s[i]; 
    }
  }
  rep(i,t.size()){
    if(t[i]=='A' || t[i]=='D'){
      if(t[i]=='D'){
        sum += sumA;
      }
      else sumA++;
    }
    else sumA=0;
  }
  cout << sum << endl;  
}


Measured memory_bytes: 776
#include <stdio.h>
#define MAX_N (105)

static
void
swap( int A[], int i, int j )
{
    int tmp = A[i];
    A[i] = A[j];
    A[j] = tmp;

    return;
}


static
void
printArray( int A[], int N )
{
    int i;
    for ( i = 0; i < N; i++ ) {
	printf("%d%c", A[i], (i == N-1) ? '\n' : ' ');
    }
    
    return;
}


static
void 
selectionSort( int A[], int N )
{
    int i, j;
    int count = 0;
    for ( i = 0; i < N-1; i++ ) {
	int min_i = i;
	for ( j = i + 1; j < N; j++ ) {
	    if ( A[min_i] > A[j] ) {
		min_i = j;
	    }
	}
	
	if ( min_i != i ) {
	    swap( A, i, min_i );
	    count++;
	}
    }
    
    printArray( A, N );
    printf("%d\n", count);

    return;
}

int main()
{
    int i;
    int N;
    int A[MAX_N];
    scanf("%d", &N);

    for ( i = 0; i < N; i++ ) {
	scanf("%d", &A[i]);
    }

    selectionSort( A, N );

    return 0;
}

Measured memory_bytes: 1028
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
import random
import time
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def scorei(ti, i, last, minus):
        k = [i for i in last]
        mi = minus-(i+1-last[ti])*c[ti]
        v = s[i][ti]-mi
        mi += sum_
        k[ti] = i+1
        return v, k, mi

    def score(t):
        n = 26
        v = 0
        minus = sum_ = sum(c)
        last = [0]*n
        for i in range(d):
            ti = t[i]-1
            minus -= (i+1-last[ti])*c[ti]
            v += s[i][ti]-minus
            minus += sum_
            last[ti] = i+1
        return v
    start = time.time()
    d = I()
    c = LI()
    s = LIR(d)
    n = 26
    m = 10
    sum_ = sum(c)
    q = [(0, [], [0]*n, sum_)]
    argmax = 0
    for i in range(d):
        nq = []
        for _ in range(m):
            if not q:
                break
            v, t, last, minus = heappop(q)
            for ti in range(n):
                nt = [i for i in t]
                vi,nl,nm = scorei(ti,i,last,minus)
                nv = v-vi
                nt.append(ti)
                heappush(nq,(nv,nt,nl,nm))
        q = [i for i in nq]
    t = [i+1 for i in heappop(q)[1]]
    v = score(t)
    i = 0
    while time.time() < 1.8+start:
        nt = [i for i in t]
        r = random.randrange(1,n+1)
        nt[i] = r
        nv = score(nt)
        if v < nv:
            t = [i for i in nt]
            v = nv
        i += 1
        i %= d
    for i in t:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 181768
nb_people, nb_foods = [int(x) for x in input().split()]
like_count = {}
for _ in range(nb_people):
    _, *liked = [int(x) for x in input().split()]
    for i in liked:
        like_count[i] = like_count.get(i, 0) + 1
cnt = 0
for x in like_count.values():
    if x == nb_people:
       cnt += 1
print(cnt)




Measured memory_bytes: 3060
s = list(input())
s_revers = s[::-1]


kaibun = True
n = len(s)
for i in range(n // 2):
    if s[i] != s[-i - 1]:
        kaibun = False
moji = (n - 1) // 2 - 1
for i in range(moji):
    if s[i] != s[moji - i]:
        kaibun = False
for i in range(moji):
    if s_revers[i] != s[moji - i]:
        kaibun = False
if kaibun:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
using namespace std;
typedef long long ll;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))//なるべくこれを使う
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define fi first
#define se second
#define MAX 100100//5
#define MAX_N 200100
#define MAX_B 1001001//6
#define MAX_S 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
using Graph=vector<vector<P> >;
ll h,w;
ll cost[10][10];
void solve(){
    rep(k,10)rep(i,10)rep(j,10){
        cost[i][j]=c_min(cost[i][j],cost[i][k]+cost[k][j]);
    }
}
int main(){
    cin>>h>>w;
    Graph G(10);
    rep(i,10)rep(j,10)cost[i][j]=INFTY;
    rep(i,10)cost[i][i]=0;
    rep(i,10)rep(j,10){
        ll a;cin>>a;
        G[i].push_back(P(a,j));
        cost[i][j]=a;
    }
    ll A[201][201];
    rep(i,h)rep(j,w){
        cin>>A[i][j];
    }
    solve();
    ll ans=0;
    rep(i,h)rep(j,w){
        if(A[i][j]!=-1){
            ans+=cost[A[i][j]][1];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

/* --------- ここから --------- */
using _ll = long long;

#define PRIME_FACTORIZE_MAX 2000010
_ll primes[PRIME_FACTORIZE_MAX];

void pre_osa_k() {
    for(_ll i = 0; i < PRIME_FACTORIZE_MAX; i++) {
        primes[i] = 1;
    }
    for(_ll i = 2; i < PRIME_FACTORIZE_MAX; i++) {
        if(primes[i] != 1) continue;
        for(_ll j = i; j <= PRIME_FACTORIZE_MAX; j += i) {
            primes[j] = i;
        }
    }
}

vector<pair<_ll,_ll>> factorize(_ll n){
    vector<pair<_ll,_ll>> res;
    while(n != 1) {
        _ll cur = primes[n];
        _ll cnt = 0;
        while(n % cur == 0) {
            n /= cur;
            cnt++;
        }
        res.push_back({cur, cnt});
    }
    reverse(res.begin(), res.end());
    return res;
}
/* --------- ここまで --------- */

ll gcd(ll a, ll b){
    if(a < b) return gcd(b, a);
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b){
    ll ret = a / gcd(a,b) * b;
    return ret;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    bool pair_wise = true;
    set<ll> seen;
    pre_osa_k();
    rep(i, 0, n) {
        auto v = factorize(a[i]);
        for(auto e : v) {
            if(seen.count(e.first)) {
                pair_wise = false;
                break;
            }
            seen.insert(e.first);
        }
        if(!pair_wise) break;
    }
    if(pair_wise) {
        cout << "pairwise coprime" << endl;
        return 0;
    }
    ll g = a[0];
    rep(i, 0, n) g = gcd(g, a[i]);
    if(g == 1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
    return 0;
}


Measured memory_bytes: 26692
#include <stdio.h>
     
    int power(int,int);
     
    int power(int a, int b){
        int i, w=1;
        for(i=0; i<b; i++) w *= a;
        return w;
    }
     
    int main(void){
        int D, N;
        scanf("%d %d", &D, &N);
        if(N==100) N++;
        printf("%d\n", power(100, D) * N);
        return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

using ll = long long;

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

const ll MAX_V = 100010;

using P = pair<ll,ll>;

vector<P> G[MAX_V];
bool used[MAX_V];

ll V;

ll prim() {
  priority_queue<P,vector<P>,greater<P> > que;
  rep(i,V)used[i] = false;

  for(auto v : G[0]) {
    que.push(v);
  }

  used[0] = true;

  ll cou = 0;
  ll ret = 0;

  while(cou < V - 1 || !que.empty()) {
    P v = que.top();
    que.pop();

    if(!used[v.second]) {
      ret += v.first;
      used[v.second] = true;
      cou++;
      for(auto w : G[v.second]) {
        if(!used[w.second]) {
          que.push(w);
        }
      }
    }
  }
  return ret;
}

int main() {
  cin >> V;
  ll E;
  cin >> E;

  rep(i,E) {
    ll s,t,w;
    cin >> s >> t >> w;

    G[s].push_back(P(w,t));
    G[t].push_back(P(w,s));
  }

  cout << prim() << endl;
}



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N, x;
	cin >> N >> x;
	vector<ll> a(N);
	REP(i, N) cin >> a[i];

	vector<ll> m(N);
	REP(i, N) m[i] = a[i];

	ll res = LLONG_MAX/3;
	REP(i, N){
		REP(j, N){
			m[j] = min(m[j], a[(j-i+N)%N]); 
		}
		ll tmp = 0;
		tmp += x*i;
		REP(j, N) tmp += m[j];
		res = min(res, tmp);
	}
	cout << res << endl;
    return 0;
}

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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main(){
    string s; cin >> s;
    reverse(s.begin(),s.end());
    rep(i,4) reverse(divide[i].begin(),divide[i].end());
    bool can = true;
    for(int i = 0; i < s.size();){
        bool can2 = false;
        for(int j = 0; j < 4; j++){
            string d = divide[j];
            if(s.substr(i,d.size())==d){
                can2 = true;
                i += d.size();
            }
        }
        if(!can2){
            can = false;
            break;
        }
    }
    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
def mirror?(s)
  (s.size / 2).times.all?{|i| s[i] == s[s.size - 1 - i]}
end

S = gets.chomp
L = S.size / 2
puts S.size.odd? && mirror?(S) && mirror?(S[0,L]) && mirror?(S[L + 1, L]) ? "Yes" : "No"



Measured memory_bytes: 1916
import java.util.*;
 
public class Main {
  public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      long n = sc.nextLong();
      long m = sc.nextLong();
      System.out.println(2 * n > m ? m/2 : (m - 2 * n) / 4 + n);
  }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

ll n,a[55],x=INF,y=-INF,id1,id2;

vector <pi> ans;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        x=min(x,a[i]);
        y=max(y,a[i]);
        if(a[i]==x) id1=i;
        if(a[i]==y) id2=i;
    }
    if(x+y<=0){
        for(int i=n;i>1;i--){
            while(a[i]<a[i-1]){
                a[i-1]+=x;
                ans.pb({id1,i-1});
                if(x>=a[i-1]) x=a[i-1],id1=i-1;
            }
        }
    }
    else{
        for(int i=1;i<n;i++){
            while(a[i]>a[i+1]){
                a[i+1]+=y;
                ans.pb({id2,i+1});
                if(y<=a[i+1]) y=a[i+1],id2=i+1;
            }
        }
    }
    cout << ans.sz << '\n';
    for(pi i : ans){
        cout << i.x << ' ' << i.y << '\n';
    }
}


Measured memory_bytes: 256
#include<stdio.h>
main(){
	int a[3],tmp,i,j;
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	for(j=0;j<2;j++){
		for(i=j+1;i<3;i++){
			if(a[j]>a[i]){
				tmp=a[j];
				a[j]=a[i];
				a[i]=tmp;
			}
		}
	}
	printf("%d %d %d\n",a[0],a[1],a[2]);
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define se second
int main(){
	ll n; cin>>n;
	ll ans=n-1;
	for(ll i=1;i<=sqrt(n);i++){
		if(n%i==0){
			int a=i;
			int b=n/i;
			ans=min(ans,i+n/i-2);
		}
	}
	cout<<ans;
}


Measured memory_bytes: 3676
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
	ll N,W;
	cin>>N>>W;
	
	ll wt[N];
	ll val[N];
	
	for(ll i=0;i<N;i++)
	{
		cin>>wt[i]>>val[i];
	}
	
	ll dp[W+1][N+1];
	
	for( ll w=0;w<=W;w++)
	{
		for(ll i=0;i<=N;i++)
		{
			if(w==0||i==0)
			{
				dp[w][i]=0;
			}
			
			else
			{
				
				if(wt[i-1]<=w)
				{
					dp[w][i]=max(dp[w][i-1],dp[w-wt[i-1]][i-1]+val[i-1]);
				}
				
				else
				{
					dp[w][i]=dp[w][i-1];
				}
			}
		}
	}
cout<<dp[W][N]<<endl;
}


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

void fnInput(vector<int>& rvnNum)
{
  string sNum;
  cin >> sNum;

  for (int i = 0; i < rvnNum.size(); i++)
    rvnNum[i] = sNum[i] - '0';                 // char → int 変換
}

int fnBitFullSch(const vector<int>& cnrvnNum)
{
  for (int n = 0; n < (1 << 3); n++)
  {
    int nSum = cnrvnNum[0];
    for (int i = 0; i < 3; i++)
      if (n & (1 << i))  nSum += cnrvnNum[i + 1];
      else               nSum -= cnrvnNum[i + 1];

    if (nSum == 7)  return n;
  }
  return 7;
}
    
void fnResult(const vector<int>& cnrvnNum, int nRslt)
{
  cout << cnrvnNum[0];
  for (int i = 0; i < 3; i++)
  {
    if (nRslt & (1 << i))  cout << "+";
    else                   cout << "-";

    cout << cnrvnNum[i + 1];
  }
  cout << "=7" << endl;
}

int main()
{
  vector<int> vnNum(4);
  
  fnInput(vnNum);
  int nRslt = fnBitFullSch(vnNum);
  fnResult(vnNum, nRslt);

  return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  int s=0;
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    s+=a.at(i);
  }
  sort(a.begin(),a.end());
  if(a.at(n-m)*4*m>=s){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;

  if (a + b < 10) {
	cout << a + b << endl;
  }
  else {
	cout << "error" << endl;
  }

  return (0);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
const long long MAXN=16,MOD=1e9+7;
long long n,m;
long long ts=0;
long long f[1<<MAXN],cnt[MAXN][1<<MAXN];
vector<int>w[MAXN];
int main()
{
	scanf("%lld %lld",&n,&m);
	for(long long i=1;i<=m;i++)
	{
		long long u,v;
		scanf("%lld %lld",&u,&v);
		w[u].push_back(v);
	}
	ts=(1<<n)-1;
	for(long long i=1;i<=n;i++)
	{
		for(long long S=0;S<=ts;S++)
		{
			for(long long j=0;j<int(w[i].size());j++)
			{
				long long v=w[i][j];
				if((1<<(v-1))&S)
				{
					cnt[i][S]++;
				}
			}
		}
	}
	for(long long S=0;S<=ts;S++)
	{
		if((S&1)==((S>>1)&1))
		{
			f[S]=1;
			for(long long jS=(S-1)&S;jS;jS=(jS-1)&S)
			{
				if((jS&1)==((jS>>1)&1))
				{
					long long bS=S-jS;
					long long inc=f[bS];
					for(long long i=1;i<=n;i++)
					{
						if(bS&(1<<(i-1)))
						{
							inc=inc*((1<<cnt[i][jS])-1)%MOD;
						}
						else if(jS&(1<<(i-1)))
						{
							inc<<=cnt[i][bS];
							inc%=MOD;
						}
					}
					f[S]=(f[S]+inc)%MOD;
				}
			}
		}
	}
	long long ans=1;
	for(long long i=1;i<=m;i++)
		ans=ans*2%MOD;
	ans-=f[ts];
	ans=(ans%MOD+MOD)%MOD;
	printf("%lld\n",ans);
}

Measured memory_bytes: 7424
a = int(input())
b = int(input())
c = int(input())
total = int(input())

max_a = a if total // 500 > a else total // 500
max_b = b if total // 100 > b else total // 100
max_c = c if total // 50 > c else total // 50
ans = 0
for i in range(0, max_a + 1):
  for j in range(0, max_b + 1):
    for k in range(0, max_c + 1):
      sum = 500 * i + 100 * j + 50 * k
      if (sum == total) :
        ans += 1
print(ans)

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

int main(){
  string a;
  int cnt=0;

  cin >> a;

  if(a=="RRR") cnt=3;
  else if(a=="RRS" || a=="SRR") cnt=2;
  else if(a=="SSS") cnt=0;
  else cnt=1;
  
  cout << cnt << endl;
}

Measured memory_bytes: 3620
S = input()
k = int(input())
flag = False
pre = 0
cans = 0

for s in S:
    bit = format(5000000000000000-1,"b")
    temp = int(s)
    ans = 1
    for i in bit[::-1]:
        temp = (temp**2)
        if i == "1":
            ans *= temp
        if cans + ans >= k:
            print(s)
            flag = True
            break
    cans += ans
    if flag:
        break

Measured memory_bytes: 3064
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

int main() {
    int N;
    cin>>N;
    
    int pre[50];
    rep(i,N){
        string s;
        cin>>s; int a=0, nxt[50]={0};
        for(char c='a'; c<='z';c++,a++){
            rep(j,s.size()) if(s[j]==c) nxt[a]++;
        }
        if(i){
            rep(j,26){
                nxt[j] = min(nxt[j],pre[j]);
            }
        }
        swap(pre,nxt);
    }
    int i=0;
    for(char c='a'; c<='z'; c++,i++){
        if(pre[i]){
            rep(j,pre[i]){
                cout<<c;
            }
        }
    }
    cout<<endl;
}

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

//#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

#define FST first
#define SND second

#define MAX_N   (1000)                  // 10^5
// #define MAX_N   (1000000000)              // 10^9
// #define MAX_N   (1000000000000000000)     // 10^18
#define BASE    (1000000000 + 7)          // 10^9 + 7
#define INFI    (1000000000 + 7)          // 10^9 + 7
#define INFL    (1000000000000000000 + 7) // 10^18 + 7

struct edge{
  int to; ll cost;
  edge(int to, ll cost) : to(to), cost(cost) {}
};

int N, M;
vector<edge> G[MAX_N], G_INV[MAX_N];
ll DIST[MAX_N];
set<int> REACH;

template <class T>
bool set_member(set<T> &st, T x) {
  return st.find(x) != st.end();
}

void calc_reachable(int s, vector<edge> g[], set<int> &st) {
  st.insert(s);
  stack<int> stk;
  stk.push(s);
  while (!stk.empty()) {
    int v = stk.top(); stk.pop();
    for (int i = 0; i < g[v].size(); i++) {
      int u = g[v][i].to;
      if (!set_member(st, u)) {
        stk.push(u);
        st.insert(u);
      }
    }
  }
}

string bellman_ford() {
  set<int> st_s, st_t;
  calc_reachable(0, G, st_s);
  calc_reachable(N - 1, G_INV, st_t);

  for (int i = 0; i < N; i++) DIST[i] = -INFL;
  DIST[0] = 0;

  for (int x = 0; x < N; x++) {
    bool update = false;
    for (int v = 0; v < N; v++) {
      for (int i = 0; i < G[v].size(); i++) {
        edge e = G[v][i];
        int u = e.to;
        if (DIST[u] < DIST[v] + e.cost) {
          if (x == N - 1 && set_member(st_s, u) && set_member(st_t, u))
            return "inf";
          DIST[u] = DIST[v] + e.cost;
          update = true;
        }
      }
    }
    if (!update) break;
  }
  return to_string(DIST[N - 1]);
}

void solve() {
  cout << bellman_ford() << endl;
}

int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b; ll c;
    cin >> a >> b >> c;
    a--; b--;
    G[a].push_back(edge(b, c));
    G_INV[b].push_back(edge(a, c));
  }

  solve();

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int N;

	cin >> N;
	if (N % 2 == 0)
		printf("%lf\n", N / 2.0 / N);
	else
		printf("%lf\n", (N + 1.0) / 2.0 / N);
}



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

int dp[1000000][3];

int main()
{
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	for( int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
		dp[i][0]=1000000000;
		dp[i][1]=1000000000;
		dp[i][2]=1000000000;
	}
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	for( int i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
		dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
		dp[i][2]=max(dp[i-1][1]+c[i],dp[i-1][0]+c[i]);
	}
	int ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	cout<<ans<<endl;
}

Measured memory_bytes: 5984
just_in = []
not_just = []
for i in range(5):
    t = int(input())
    if t%10:
        not_just.append(t)
    else:
        just_in.append(t)
not_just.sort(key = lambda x:-x%10)

time = 0
src = just_in + not_just
for i in range(5):
    if i == 4:
        time += src[i]
        break
    if src[i]%10:
        time += (src[i]//10 + 1)*10
    else:
        time += src[i]
        
print(time)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	set<string> st;
	for (int i = 0; i <= 999; ++i) {
		string tmp = to_string(i);
		while (tmp.size() < 3) tmp = '0' + tmp;
		int pos = 0;
		rep(i, n) {
			if (s[i] == tmp[pos]) pos++;
			if (pos == 3) break;
		}
		if (pos == 3) st.insert(tmp);
	}
	printf("%d\n", (int)st.size());
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
#define pi 3.141592653589793283462
int main(){
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
    return 0;
}

Measured memory_bytes: 1176
N = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

data_list = [a,b,c,d,e]

min_data = min(data_list)

if min_data!= 1:
    print(N//min_data+5)
else:
    print(N-1+5)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <iterator>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

int main(int argc, char* argv[])
{
    long a,b,c;
    scanf("%ld %ld %ld", &a, &b, &c);

    if(a+b>=c) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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 <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin >> n;
    auto a = make_vec<ll>(n, n);
    rep(i, n) rep(j, n) cin >> a[i][j];
    ll ans = 0;
    rep(i, n) {
        rep(j, i) {
            ll now = LINF;
            rep(k, n) {
                if (k == i || k == j) continue;
                chmin(now, a[i][k] + a[k][j]);
            }
            //cout << i << " " << j << " " << now << endl;
            if (now < a[i][j]) {
                cout << -1 << endl;
                return 0;
            }
            if (now > a[i][j]) {
                ans += a[i][j];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(string s) {
    int n = cast(int)s.length;
    for (int i = 1; i < n; i++) {
        if ((n - i) % 2 == 1) continue;

        int m = (n - i) / 2;
        auto a = s[0..m];
        auto b = s[m..m*2];
        if (a == b) {
            return m * 2;
        }
    }
    assert(false);
}

void main() {
    string s = read!string;
    writeln(calc(s));
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    from collections import deque
    H, W = (int(i) for i in input().split())
    c = [input() for i in range(H)]
    seen = [[False]*W for _ in range(H)]
    que = deque()
    for h in range(H):
        for w in range(W):
            if c[h][w] == "#":
                que.append((h, w))

    def bfs(sy, sx):
        que = deque()
        que.append((sy, sx))
        d = ((1, 0), (0, 1), (-1, 0), (0, -1))
        flag = True  # Trueなら黒マス
        bla = 0
        whi = 0
        while que:
            uh, uw = que.popleft()
            if seen[uh][uw]:
                continue
            if c[uh][uw] == "#":
                flag = True
                bla += 1
                seen[uh][uw] = True
            else:
                flag = False
                whi += 1
                seen[uh][uw] = True
            for dy, dx in d:
                next_h = uh + dy
                next_w = uw + dx
                if not(0 <= next_h < H and 0 <= next_w < W):
                    continue
                if seen[next_h][next_w]:
                    continue
                if flag and c[next_h][next_w] == '#':
                    continue
                if not(flag) and c[next_h][next_w] == '.':
                    continue
                que.append((next_h, next_w))
        return whi*bla

    ans = 0
    for q in que:
        if seen[q[0]][q[1]]:
            continue
        ans += bfs(q[0], q[1])
    print(ans)


if __name__ == '__main__':
    main()


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

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

const int INF = 1001001001;

using namespace std;

signed main() {

    int n; cin >> n;
    vector<int> h(n); rep(i,n) cin >> h[i];

    vector<int> dp(n,INF);

    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);

    for(int i=2; i<n; i++) {

        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));

    }

    cout << dp[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
struct var{
	long long to,nxt;
}edge[201001];
long long u,v,c[101001],x1,x2,n,m,head[101001],cnt;
bool flag;
void add(long long u,long long v)
{
	cnt++;
	edge[cnt].to=v;
	edge[cnt].nxt=head[u];
	head[u]=cnt;
}
void dfs(long long o,long long cc)
{
	c[o]=cc;
	if(c[o]==1)x1++;
	else x2++;
	for(int i=head[o];i;i=edge[i].nxt)
	{
		int v=edge[i].to;
		if(c[v])
		{
			if(c[v]==c[o])
			{
				flag=true;
				return ;
			}
		}else
		{
			dfs(v,3-cc);
		}
	}
}
int main()
{
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%lld%lld",&u,&v);
		add(u,v);
		add(v,u);
	}
	dfs(1,1);
	if(flag)
	{
		printf("%lld",n*(n-1)/2-m);
	}else printf("%lld",x1*x2-m);
}

Measured memory_bytes: 5504
<?php
while (true) {
    fscanf(STDIN, "%d %d", $inputNumX, $inputNumY);
    if ($inputNumX === 0 && $inputNumY === 0) {
        break;
    }
    echo orderByAskForTwoNums($inputNumX, $inputNumY), PHP_EOL;
}
  
function orderByAskForTwoNums($inputNumX, $inputNumY)
{
    return min($inputNumX, $inputNumY).' '.max($inputNumX, $inputNumY);
}

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

typedef long long ll;

int get_length(ll a) {
    int res = 0;
    for (; a; a/=10) res += 1;
    return res;
}

ll find_last_terms(ll a, ll b, ll l, int len) {
    ll res = -1;
    for (ll lo=0,hi=l-1; lo<=hi; ) {
        ll mid = (lo + hi) / 2;
        ll ret = get_length(a + b * mid);

        if (ret <= len) {
            res = max(res, mid);
            lo = mid + 1;
        } else {
            hi = mid - 1;
        }
    }
    return res;
}

ll fast(ll a, ll p, ll mod) {
    if (p == 0) return 1;
    ll res = fast(a, p >> 1, mod);
    res = (res * res) % mod;
    if (p & 1) res = (res * a) % mod;
    return res;
}

pair<ll,ll> dnc(ll n, ll a, ll b, ll mod, ll len) {
    if (n == 0) return make_pair(0, 0);

    const ll ONE = fast(10, len, mod);
    const ll HALF = fast(ONE, n >> 1, mod);
    const ll OFFS = (b * (n / 2)) % mod;
    const ll LAST = (a + b * (n-1)) % mod;

    pair<ll,ll> res = dnc(n >> 1, a,b,mod, len);

    res.first = (
        ((res.first * HALF) % mod)
        + ((res.first + res.second * OFFS) % mod)
    ) % mod;
    res.second = (res.second * (HALF + 1)) % mod;

    if (n & 1) {
        res.first = (res.first * ONE + LAST) % mod;
        res.second = (res.second * ONE + 1) % mod;
    }

    return res;
}

int main() {
    ll l; scanf("%lld", &l);
    ll a,b; scanf("%lld %lld", &a, &b);
    ll mod; scanf("%lld", &mod);

    int _start = get_length(a);
    int _end = get_length(a + b * (l-1));

    long long res = 0;
    for (int i=_start; i<=_end; i++) {
        ll start = find_last_terms(a,b,l,i-1) + 1;
        ll end = find_last_terms(a,b,l,i);

        const ll SHIFT = fast(fast(10, i, mod), end-start+1, mod);
        ll ret = dnc(end-start+1, a + b * start,b,mod, i).first;
        res = (res * SHIFT + ret) % mod;
    }

    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
     int A,B;
     string S,T,U;
     cin>>S>>T;
     cin>>A>>B;
     cin>>U;
     if( U==S)A--;
     else{
          B--;
     }
     cout<<A<<" "<<B;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize, k: usize,
        pv: [usize; n]
    };

    let cusum = vec![0_f64]
        .into_iter()
        .chain(pv.into_iter().scan(0_f64, |acc, p| {
            *acc += ((1 + p) * p) as f64 / 2_f64 / p as f64;
            Some(*acc)
        }))
        .collect::<Vec<_>>();
    let mut res = 0_f64;
    for i in 0..n {
        if i + k > n {
            continue;
        }
        let sum = cusum[i + k] - cusum[i];
        if sum > res {
            res = sum;
        }
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 5244
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N,ans,i;cin >> N;
    for (i = 1; i*i <= N; i++) if(N%i==0) ans = N/i;
    string a = to_string(ans);
    cout << a.length() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int n;
    cin >> n;
    map<int,int>mp;
    vector<int>a(n);
    rep(i,n){
        cin >> a[i];
        mp[a[i]]++;
    }
    sort(a.rbegin(),a.rend());
    int ans = 0;
    rep(i,n){
        if(mp[a[i]]>0){
            int k = (int)log2(a[i]);
            k++;
            assert(k<=30);
            int hoge = 1<<k;
            if(hoge-a[i] == a[i]){
                if(mp[hoge-a[i]]>=2){
                    ans++;
                    mp[hoge-a[i]]-=2;
                }
            }else if(mp.count(hoge-a[i])==1 and mp[hoge-a[i]]>0){
                ans++;
                mp[hoge-a[i]]--;
                mp[a[i]]--;
            }
        }
    }
    cout << ans << endl;
}

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

int main(){
    string s1;
    while(cin>>s1){
        string s2;
        s2=s1;
        reverse(s2.begin(), s2.end());
        
        vector<vector<short> >v1;
        vector<vector<pair<short,short> > >v2;
        
        vector<short>v(s1.length()+1,0);
        v1.resize(s1.length()+1,v);
        
        vector<pair<short,short> >v3(s1.length()+1,make_pair(-1,-1));
        v2.resize(s1.length()+1,v3);
        
        for(int i=0;i<s1.length();i++){
            for(int j=0;j<s1.length();j++){
                if(s1[i]==s2[j]){
                    v1[i+1][j+1]=v1[i][j]+1;
                    v2[i+1][j+1]=make_pair(i, j);
                }
                else if(v1[i+1][j]>v1[i][j+1]){
                    v1[i+1][j+1]=v1[i+1][j];
                    v2[i+1][j+1]=v2[i+1][j];
                }
                else{
                    v1[i+1][j+1]=v1[i][j+1];
                    v2[i+1][j+1]=v2[i][j+1];
                }
            }
        }
        pair<short,short>p=v2[s1.length()][s2.length()];
        while(1){
            if(p.first==-1&&p.second==-1)break;
            cout<<s1[p.first];
            p=v2[p.first][p.second];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 24828