akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)
var ReadString func() string
var ReadLine func() string
var ReadInt64 func() int64
var ReadInt func() int
var ReadIntSlice func(int) []int
var ReadInt64Slice func(int) []int64
var GetIntAbs func(int) int
var Atoi func(string) int
var FindMin func([] int) int
var FindMax func([] int) int
var StrReverse func(string) string

func init() {
	ReadString = newReadString()
	ReadLine = readLine
	ReadInt64 = readInt64
	ReadInt = readInt
	ReadIntSlice = readIntSlice
	FindMin = findMin
	FindMax = findMax
	StrReverse = strReverse
}

func main() {
	a := ReadInt()
	b := ReadInt()
	c := ReadInt()
  
  oneRemain := a - b
  if oneRemain == 0 {
    fmt.Println(c)
  } else {
    if oneRemain < c {
      fmt.Println(c - oneRemain)
    } else {
		fmt.Println(0)
    }
  }
}

func strReverse(s string) string {
	runes := []rune(s)
	l := len(runes)
	for i, j := 0, l-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


func newReadString() func() string {
	sc.Buffer(make([]byte, 1024), 2048)
	sc.Split(bufio.ScanWords)
	return func() string {
		if !sc.Scan() {
			panic("scanできなかった")
		}
		return sc.Text()
	}
}

func readLine() string {
	if !sc.Scan() {
		panic("line をscanできなかった")
	}
	return sc.Text()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		fmt.Println("parseInt失敗")
		panic(err.Error())
	}
	return int64(i)
}

func readInt() int {
	i := ReadInt64()
	return int(i)
}

func readIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}

func readInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt64()
	}
	return arr
}

/*------ number util ------*/

func getIntAbs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func atoi(a string) int {
	i, err := strconv.Atoi(a)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func findMin(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	min := arr[0]
	for _, v := range arr {
		if v < min {
			min = v
		}
	}
	return min
}

func findMax(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	max := arr[0]
	for _, v := range arr {
		if v > max {
			max = v
		}
	}
	return max
}


Measured memory_bytes: 640
//二部グラフ判定
//DFSによる
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<functional>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int BipartiteGraph(const vector<vector<int>> &g) {
        int n = g.size();
        vector<int> color(n, -1);
        int white_cnt = 0;
        function<bool (int, int, int)> dfs = [&](int u, int prev, int c) {
                color[u] = c;
                if (c == 1) white_cnt ++;
                for (auto v : g[u]) if (v != prev) {
                        if (color[v] == -1) {
                                if (!dfs(v, u, 1 - c)) return false;
                        } else if (color[v] != 1 - c) {
                                return false;
                        }
                }
                return true;
        };
        if (!dfs(0, -1, 0)) return -1;
        return white_cnt;
}



int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int> > nlist(N);
  int a, b;
  REP(i, M){
    cin >> a >> b;
    nlist[a-1].push_back(b-1);
    nlist[b-1].push_back(a-1);
  }

  int x = BipartiteGraph(nlist);
  cout << ( (x==-1)? (LINT)N*(LINT)(N-1)/2-M : (LINT)x*(LINT)(N-x)-M ) << endl;

  return 0;
}


Measured memory_bytes: 6784
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] strs = br.readLine().split(" ");
    boolean f = false;
    int sum = 0;
    
    for (String s : strs) {
      sum += Integer.parseInt(s);
    }
    
    for (int i = 0; i < strs.length; i++) {
      for (int j = i + 1; j < strs.length; j++) {
        if (sum/2 == Integer.parseInt(strs[i]) + Integer.parseInt(strs[j])) {
          f = true;
        }
      }
    }
    if (f) System.out.println("Yes");
    else System.out.println("No");
  }
}

Measured memory_bytes: 21204
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int main() {
    vector<int> A(26, -1);
    vector<int> B(26, -1);
    string s,t;
    cin >> s >> t;
    for(int i=0; i<s.size(); i++) {
        int a = s[i] - 'a';
        int b = t[i] - 'a';
        if(A[a] != -1 || B[b] != -1) {
            if(A[a] != b || B[b] != a) {
                cout << "No" << endl;
                return 0;
            }
        }else {
            A[a] = b;
            B[b] = a;
        }
        
    }
    cout << "Yes" << endl;
}

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

int partition(vector<int>& A, int p, int r){
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if (A[j] <= A[r]) {
            i++;
            swap(A[i], A[j]);
        }
    }
    i++;
    swap(A[i], A[r]);
    return i;
}

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for (auto& a : A) cin >> a;
    int pos = partition(A, 0, n - 1);
    for (int i = 0; i < pos; i++) {
        cout << A[i] << " ";
    }
    cout << "[" << A[pos] << "] ";
    for (int i = pos + 1; i < n; i++) {
        cout << A[i] << (i < n - 1 ? " " : "\n");
    }
    return 0;
}

Measured memory_bytes: 3132
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
for i in range(n):
    c=min(a[i],b[i])
    a[i]-=c
    b[i]-=c
    d=min(b[i],a[i+1])
    a[i+1]-=d
    ans+=c+d
print(ans)

Measured memory_bytes: 19116
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

#define EPS 1e-8

int main(){
	
	int n;
	while(cin >> n){
		int w = 512;
		vector<bool> ans(10, false);
		for(int i = 9; i >= 0; i--){
			if(n >= w){
				ans[i] = true;
				n -= w;
			}
			w = w >> 1;
		}
		w = 1;
		bool f = false;
		rep(i, 10){
			if(ans[i]){
				if(f) cout << " ";
				cout << w;
				f = true;
			}
			w = w << 1;
		}
		cout << endl;
	}

	
	return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,rt,tot,d[N],head[N],nex[2*N],to[2*N];
void add(int u,int v)
{
    to[++tot]=v;
    nex[tot]=head[u];
    head[u]=tot;
}
void dfs(int u,int fa)
{
    d[u]=d[fa]+1;
    if(d[u]>d[rt]) rt=u;
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];
        if(v==fa) continue;
        dfs(v,u);
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        add(u,v);
        add(v,u);
    }
    dfs(1,0);
    d[rt]=0;
    dfs(rt,0);
    if(d[rt]%3!=2) printf("First\n");
    else printf("Second\n");
}


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

int main(){
  string s;
  int price = 700;
  cin >> s;
  if(s[0] == 'o')price += 100;
  if(s[1] == 'o')price += 100;
  if(s[2] == 'o')price += 100;
  cout << price << endl;
}

Measured memory_bytes: 256
H,W,D = map(int,input().split())
A = []
for j in range(H):
  for i, a in enumerate(map(int,input().split())):
    A.append([a,i,j])
A.sort()
lenA = len(A)

points = [0] * lenA
for inia in [i for i in range(D)]:
  i = inia + D
  while i < lenA:
    points[i] = points[i-D] + abs(A[i][1]-A[i-D][1]) + abs(A[i][2]-A[i-D][2])
    i += D

Q = int(input())
for _ in range(Q):
  l,r = map(int,input().split())
  print(points[r-1]-points[l-1])

Measured memory_bytes: 65820
# require 'complex'
# require 'scanf'

x1,y1, x2,y2 = gets.split.map(&:to_f)

distance = Math.sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2))
# puts sprintf("%.8f", distance)
puts distance.to_f



Measured memory_bytes: 8876
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main(){
    int N, i;
    double sum = 0;
    cin >> N;
    
    vector< int > a(N);
    for (i=0; i<N; i++){
        cin >> a[i];
    }
    for (i=0; i<N; i++){
        sum += a[i];
    }
    //cout << "sum : " << sum << '\n';
    double mean = sum / N;
    //cout << "mean : " << mean << '\n';

    double diff = 100;
    double diff_;
    int ans = 0;
    for (i=0; i<N; i++){
        diff_ = abs(mean - a[i]);
        //cout << diff_ << '\n';
        if (diff_ < diff ){
            ans = i;
            diff = diff_;
        }
    }

    cout << ans << '\n';

}

Measured memory_bytes: 256
main :: IO ()
main = do
  s' <- getLine
  t <- getLine
  putStrLn $ restore s' t

restore :: String -> String -> String
restore s' t =
  _restoreLoop (length s' - length t)
  where
    _restoreLoop :: Int -> String
    _restoreLoop start
      | start < 0 = "UNRESTORABLE"
      | otherwise = if isContained s' t start
                      then
                        let s'' = take start s' ++ t ++ drop (start + length t) s'
                        in map (replace 'a') s''
                      else
                        _restoreLoop (start - 1)

isContained :: String -> String -> Int -> Bool
isContained s' t start =
  all (\i -> t!!i == s'!!(start + i) || s'!!(start + i) == '?') [0..length t　- 1]

replace :: Char -> Char -> Char
replace c '?' = c
replace _ c0 = c0


Measured memory_bytes: 508
import math
N=int(input())
A,B,C,D,E=[int(input()) for _ in range(5)]
m=math.ceil(N/A)
if A<=B:
  B=A
  m+=1
else:
  m+=math.ceil((N-B*(m-1))/B)
if B<=C:
  C=B
  m+=1
else:
  m+=math.ceil((N-C*(m-2))/C)
if C<=D:
  D=C
  m+=1
else:
  m+=math.ceil((N-D*(m-3))/D)
if D<=E:
  m+=1
else:
  m+=math.ceil((N-E*(m-4))/E)
print(m)

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	s := make([]int, m)
	c := make([]int, m)

	for i := 0; i < m; i++ {
		fmt.Scan(&s[i], &c[i])
	}

	ret := make([]int, n+1)
	for i := 0; i < n; i++ {
		ret[i] = -1
	}

	for i := 0; i < m; i++ {
		if n >= 2 && s[i] == 1 && c[i] == 0 {
			fmt.Println(-1)
			return
		}
		if ret[s[i]] > 0 && ret[s[i]] != c[i] {
			fmt.Println(-1)
			return
		}
		ret[s[i]] = c[i]
	}

	for i := 1; i < n+1; i++ {
		if ret[i] < 0 {
			if i == 1 {
				ret[i] = 1
			} else {
				ret[i] = 0
			}
		}
		fmt.Print(ret[i])
	}
}


Measured memory_bytes: 512
while True:
    n=input()
    if n==0:
        break
    li=[[0]*(n+1) for unused in xrange(n+1)]
    for i in xrange(n):
        li[i][:n]=map(int,raw_input().split())
    for i in xrange(n):
        li[i][n]=sum(li[i])
        li[n][i]=sum([li[j][i] for j in xrange(n)])
    li[n][n]=sum(li[n])
    print "\n".join(["".join(map(lambda x:str(x).rjust(5),li[i])) for i in xrange(n+1)])

Measured memory_bytes: 4264
N = int(input())
MOD = 10**9+7
memo = [{} for i in range(N+1)] #0段目からN段目までを覚えるため

### 条件判定部分
def judge(last4):
    ret = True
    if any([last4[1:] == s for s in ["AGC","ACG","GAC"]]):
        ret = False
    elif last4[0]+last4[2:] == "AGC":
        ret = False
    elif last4[:2]+last4[3] == "AGC":
        ret = False
    return ret

def dfs(cur, last3):
    if last3 in memo[cur]: 
        ret = memo[cur][last3]
    elif cur == N: 
        ret = 1
    else:
        ret = 0
        for c in "ACGT":
            if judge(last3+c): 
                ret = (ret + dfs(cur + 1, last3[1:]+c)) % MOD
        memo[cur][last3] = ret 
    return ret

print(dfs(0,"TTT"))

Measured memory_bytes: 3816
#include<stdio.h>
int main()
{
    int i,j=0;
    float n,probability;
    scanf("%f",&n);
    for(i=1;i<=n;i++){
       if(i%2!=0) {
        j++;
       }
    }
    probability = j / n;
    printf("%f",probability);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.grid2", "r", stdin );
	string str = "";
	int n;

	while (getline (cin, str ) ) {
		stringstream ssn(str);
		ssn >> n;
		
		if (n == 0 ){
			break;
		} // end if

		vector <vector <int> > grid (n, vector <int> (n, 0 ) );
 
		int i,j,k;

		for (i = 0; i < n; ++i ){
			getline (cin, str );
			for (j = 0; j < n; ++j ){
				grid[i][j] = str[j] - '0';
			} // end for
		} // end for

		int res = 0;
		int sum = 0;
		bool found = false;

		for (i = 0; i < n; ++i ){
			sum = 0;
			found = false;

			for (j = 0; j < n; ++j ){
				if (grid[i][j] == 1 ){
					if (!found ){
						sum = 0;
						found = true;
					} // end if
					++sum;
				}else{
					res = max (res, sum );
					found = false;
					sum = 0;
				} // end if
			} // end for
			res = max (res, sum );
		} // end for

		for (j = 0; j < n; ++j){
			sum = 0;
			found = false;

			for (i = 0; i < n; ++i ){
				if (grid[i][j] == 1){
					if (!found ){
						sum = 0;
						found = true;
					} // end if
					++sum;
				}else{
					res = max (res, sum );
					found = false;
					sum = 0;
				} // end if
			} // end for
			res = max (res, sum );
		} // end for

		for (k = -n + 1; k < n; ++k){
			sum = 0;
			found = false;
			int prev_i = -1000;
			int prev_j = -1000;

			for (i = 0; i < n; ++i ){
				for (j = 0; j < n; ++j ){
					if (i - j == k ){
						if (grid[i][j] == 1 ){
							if (!found ){
								sum = 1;
								found = true;
							}else{
							 	if (i == prev_i + 1 
								 && j == prev_j + 1 ){
									++sum;
								}else{
									sum = 0;
									found = false;
								} // end if
							} // end if
							prev_i = i;
							prev_j = j;
						}else{
							res = max (res, sum );
							sum = 0;
							found = false;
						} // end if
					} // end if
				} // end for
			} // end for
			if (found ){
				res = max (res, sum );
			} // end if
		} // end for

		for (k = 0; k <= 2*(n-1); ++k){
			sum = 0;
			found = false;
			int prev_i = 1000;
			int prev_j = 1000;

			for (i = 0; i < n; ++i){
				for (j = 0; j < n; ++j){	
					if (i + j == k ){
						if (grid[i][j] == 1 ){
							if (!found ){
								sum = 1;
								found = true;
							}else{
							 	if (i == prev_i + 1 
								 && j == prev_j - 1 ){
									++sum;
								}else{
									sum = 0;
									found = false;
								} // end if
							} // end if
							prev_i = i;
							prev_j = j;
						}else{
							res = max (res, sum );
							sum = 0;
							found = false;
						} // end if
					} // end if
				} // end for
			} // end for
			if (found ){
				res = max (res, sum );
			} // end if
		} // end for	

		cout << res << endl;	
	} // end loop

		
	return 0;
}

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

#define fori(i,a,b)    for(int i=a;i<=b;i++)
#define ford(i,a,b)   for(int i=a;i>=b;i--)
#define all(a)        a.begin(), a.end()
#define in(c,x)       ((c).find(x) != (c).end())
#define isp(c,x)      (find(all(c),x) != (c).end())
#define pb             push_back
#define ppb            pop_back
#define sz(x)          (int)x.size()
#define fill(a,v)      memset(a, v, sizeof a)
#define fs first
#define sc second
#define ub upper_bound
#define lb lower_bound
#define en '\n'

typedef long long int lli;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair< int, int > pii;
typedef pair< lli, lli > plli;
typedef list<int> li;
typedef map<int, int> mi;
typedef map<lli, lli> mlli;
lli gcd(lli a,lli b){return (!b)?a:gcd(b,a%b);}
int t = 1; int ti;





const int N = 1e5 + 5;
lli h[N], dp[N], n, k;


void solve(){
    cin>>n>>k;

    fori(i, 1, n){
        cin>>h[i];
        dp[i] = INT64_MAX;
    }

    dp[1] = 0;

    fori(i, 1, n){
        fori(ki, 1, k){
            dp[i+ki] = min(dp[i+ki], dp[i] + abs(h[i+ki]-h[i])); 
        }
    }


    cout<<dp[n];
}
//THINK OF SPECIAL CASES, ARRAY LIMITS, LLI vs INT, 1LL

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

    // cin>>t;

    // for(ti= 1; ti <= t; ti++)
    solve();

//    cout<<"\nTHINK OF SPECIAL CASES, ARRAY LIMITS, LLI vs INT, 1LL";
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int ans{0};
  for(int i=0;i<3;i++){
    if(s[i] == 'R') ans = 1;
  }
  for(int i=1;i<3;i++){
    if(s[i-1] == s[i] && s[i] == 'R') ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3572
while 1:
    W,H = map(int,raw_input().split())
    if W == 0: break
    C = [list(raw_input()) for _ in xrange(H)]
    dp = [[0]*W for _ in xrange(H)]
    ans = 0
    for h in xrange(H):
        for w in xrange(W):
            if C[h][w].isdigit():
                dp[h][w] = max(dp[h][w],int(C[h][w]))
                if w > 0: dp[h][w] = max(dp[h][w],int(str(dp[h][w-1])+C[h][w]))
                if h > 0: dp[h][w] = max(dp[h][w],int(str(dp[h-1][w])+C[h][w]))
                ans = max(ans,dp[h][w])
    print ans

Measured memory_bytes: 4324
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

class Prog
{
    public Prog() { }
    public static int Main()
    {
        new Prog().calc();
        return 0;
    }

    Scanner cin;

    public void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();

        int[] arr = new int[100001];

        for (int i = 0; i < N; i++)
        {
            int a = cin.nextInt();
            arr[a]++;
        }

        int ans = 0;
        int even_cnt = 0;
       
        for(int i = 0;i<arr.Length;i++)
        {
            if (arr[i] == 0) continue;
            ans++;
            if (arr[i] % 2 == 0) even_cnt++;
        }

        if (even_cnt % 2 == 1) ans--;
        
        Console.WriteLine(ans);
    }
}

/*
    public void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();

        int[] arr = new int[100001];

        for (int i = 0; i < N; i++)
        {
            int a = cin.nextInt();
            arr[a]++;
        }

        int ans = 0;
        int min = -1;
        int max = -1;
        
        for(int i = 0;i<arr.Length;i++)
        {
            if (arr[i] == 0) continue;

            if (min == -1) min = i;
            max = i;
            ans++;
        }

        //両端のうち片方が偶数で、かつ真ん中がすべて奇数なら1を引く
        bool between_all_odd = true;
        for (int i = 0; i < arr.Length; i++)
        {
            if (arr[i] == 0) continue;

            if (i == min || i == max) continue;

            if (arr[i] % 2 == 0) between_all_odd = false;
        }

        if (((arr[min] % 2) != (arr[max] % 2)) && between_all_odd) ans--;
        Console.WriteLine(ans);
    }
*/


class Scanner
{
    string[] s;
    int i;

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

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

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

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}


Measured memory_bytes: 9816
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++)
			a[i] = sc.nextInt();
		StringBuilder ans = new StringBuilder();
		for(int i = n-1; i >= 0; i-=2)
			ans.append(a[i]+" ");
		int x = n % 2 == 0 ? 0 : 1;
		for(int i = x; i < n; i+=2)
			ans.append(a[i]+" ");
		ans.deleteCharAt(ans.length()-1);
		System.out.println(ans);
	}

}


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

int main(){
	int i,j,h,w;

	cin >>h >>w;
	char array[h][w];
	for(i=0;i<h;i++){
		for(j=0;j<w;j++)cin >>array[i][j];
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(array[i][j]=='#'){
				if(array[i][j+1]=='#'||array[i][j-1]=='#'||array[i-1][j]=='#'||array[i+1][j]=='#')continue;
				else break;
			}
		}
		if(j!=w)break;
	}
	if(i==h)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}

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


char str[11];

char max_char(int pos){
    char res = 'a';
    for(int i=0; i <= pos; i++){
        res = max(res, str[i]);
    }
    return res;
}

void hoge(int pos, long long N){
    if(pos == N - 1){
        str[N] = '\0';
        printf("%s\n", str);
        return;
    }
    char last = max_char(pos);
    for(char c='a'; c <= last + 1; c++){
        str[pos + 1] = c;
        hoge(pos + 1, N);
    }
}

void solve(long long N){
    str[0] = 'a';
    hoge(0, N);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    while(s.size()>0){
        int size=5;
        if(s.substr(s.size()-size, size)=="erase"||s.substr(s.size()-size, size)=="dream"){
            s.erase(s.size()-size,size);
        }
        else if(s.substr(s.size()-6, 6)=="eraser"){
            s.erase(s.size()-6, 6);
        }
        else if(s.substr(s.size()-7, 7)=="dreamer"){
            s.erase(s.size()-7, 7);
        }
        else{
            cout<<"NO"; return 0;
        }
    }
    cout<<"YES";
}

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

int main() {
  int64_t n, a, b, s = 0;
  cin >> n >> a >> b;
  if((n == 1 && a != b) || n > 1 && b < a) cout << 0 << endl;
  else cout << (b - a) * (n - 2) + 1 << endl;
  return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    ll ans = K;
    for(int i=2; i<=N; i++){
        ans *= (K-1);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Harshad
 */

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

class a {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n; in>>n;
        int arr[n];
        f(i, n) in>>arr[i];
        ll res=LLONG_MAX;
        rep(i, -100, 100){
            ll temp=0;
            f(j, n){
                temp+=pow(i-arr[j], 2);
            }
            res=min(res, temp);
        }
        out<<res;
	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	a solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

char s[100001];
char t[100001];
int a[100001];
int b[100001];
int main(void){
	int m=nextstr(s);
	for(int i=0; i<m; i++){
		a[i+1]=a[i]+s[i]-64;
	}
	int n;
	for(n=0; ; n++){
		char c=getchar();
		if(c==10) break;
		b[n+1]=b[n]+c-64;
	}
	int q=nextint();
	for(; q>0; q--){
		int s1=nextint();
		int s2=nextint();
		int t1=nextint();
		int t2=nextint();
		if((a[s2]-a[s1-1])%3==(b[t2]-b[t1-1])%3){
			puts("YES");
		}else{
			puts("NO");
		}
	}
}


Measured memory_bytes: 1536
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

s=ss()
if s=="AAA"or s=="BBB":
    print("No")
else:
    print("Yes")


Measured memory_bytes: 65516
#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;
}

ll ds(ll k){
	ll res = 0;
	while(k>0){
		res += k%10;
		k /= 10;
	}
	return res;
}

int main(){
	ll N;
	cin >> N;
	ll res = 101010101010;
	REP(i, N-1){
		ll A = i+1;
		ll B = N-A;
		res = min(ds(A)+ds(B), res);
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
package main
 
import (
	"fmt"
)
 
func main() {
	var N, A, ANS int
	max := 0
	min := 101
	fmt.Scan(&N)
	l := make([]int, N)
	for i := 0; i < N; i++ {
	    fmt.Scan(&A)
		min = calcmin(min, A)
		max = calcmax(max, A)
		l[i] = A
	}
	ANS = 1000000000000
	for i := min; i <= max; i++ {
		SUM := 0
		for _, v := range l {
			SUM += (v - i) * (v - i)
		}
		ANS = calcmin(ANS, SUM)
	}
	fmt.Println(ANS)
}

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

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


Measured memory_bytes: 1776
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
		int l,d,r;
		cin>>l>>r>>d;
		vector<int>arr(r+1,0);
		for(int i=1;d*i<=r;i++)
		{
			arr[d*i]=1;
		}
		int ans=0;
		for(int i=l;i<=r;i++)
		{
			if(arr[i]==1)
			ans++;
		}
			cout<<ans;	 
			
		
		   
}

			
			
           
    



   



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = a; i < (int) (b); i++)
#define REP(i, n)    for (int i = 0; i < (int) (n); i++)
#define REP1(i, n)   for (int i = 1; i <= (int) (n); i++)
#define all(x)       (x).begin(), (x).end()
#define SZ(x)        ((int) (x).size())
using ll = long long;

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 1; i <= n; i++) {
	  ll cnt = n / i;
	  ans += i * cnt * (cnt + 1) / 2;
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
def main():
    n, m = map(int, input().split())
    a = [int(x) for x in input().split()]
    cards = {}
    for aa in a:
        if aa in cards:
            cards[aa] += 1
        else:
            cards[aa] = 1
    for _ in range(m):
        b, c = map(int, input().split())
        if c in cards:
            cards[c] += b
        else:
            cards[c] = b
    cards = sorted(cards.items(), key=lambda x: x[0], reverse=True)
    answer = 0
    for val, count in cards:
        if n <= 0:
            break
        else:
            answer += min(n, count) * val
            n -= min(n, count)
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 43040
#include <stdio.h>
#define MAX 2000000

int H,A[MAX+1];

void maxHeapify(int i){
    int l,r,largest,temp;
    l=2*i;
    r=2*i+1;
    if(l <= H && A[l] > A[i])
        largest=l;
    else
        largest=i;
    if(r <= H && A[r] > A[largest])
        largest=r;

    if(largest != i){
        temp=A[i];
        A[i]=A[largest];
        A[largest]=temp;
        maxHeapify(largest);
    }
}

int main(void){
    int i;
    scanf("%d",&H);
    for(i=1;i<=H;i++)
        scanf("%d",&A[i]);
    for(i=H/2;i>=1;i--)
        maxHeapify(i);
    for(i=1;i<=H;i++)
        printf(" %d",A[i]);
    puts("");
    return 0;
}



Measured memory_bytes: 3676
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;

//ll num[50];
//ll num2[50];
ll num[ten52];
//stack<char> stk;
//set<ll> sll;
//map<string,ll> mp,mp1;
map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<char> deq;
vector<ll> vll[2003];

/*void dfs(ll n,ll t)
{
    for(int i=1;i<vll[n].size();i++)
}*/

int main(void)
{
    double ans=0.0,d,d1,d2;
    //float f,g,h;
    long long int m,n,i,j,k=1;
    long long int a,a1,a2,a3,sum;
    string s,s1,s2;
    char c,c1;
    sum=a=a1=a2=a3=0;
    for(i=0;i<3;i++)
    {
        cin>>c;
        if(c=='7')
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}





Measured memory_bytes: 3668
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const double eps = 0.0000001;
const double PI = acos(-1.0);
const int MOD = 1e9+7;
const int N  = 1e5+5;

int a[305], n;
double dp[305][305][305];

double solve (int i, int j, int k) {
	if (i < 0 || j < 0 || k < 0) return 0;
	if (i == 0 && j == 0 && k == 0) return 0;
	if (dp[i][j][k]) return dp[i][j][k];
	dp[i][j][k] = (double)n/(i+j+k)*(1 + (double)i/n*solve(i-1,j,k) + (double)j/n*solve(i+1,j-1,k) + (double)k/n*solve(i,j+1,k-1));
	return dp[i][j][k];
}

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

    cin >> n;
    int ii, j, k;
    ii = j = k = 0;
    for (int i = 0; i < n; i++)
    {
    	cin >> a[i];
    	if (a[i] == 1) ii++;
    	if (a[i] == 2) j++;
    	if (a[i] == 3) k++;
    }
   	cout << fixed << setprecision(10) << solve(ii,j,k);
    return 0;
}

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

int main(){
	int n, m, sum = 0;
	cin >> n;
	int t[n];
	for(int i = 0; i < n; i++){
		cin >> t[i];
		sum += t[i];
	}
	cin >> m;
	while(m--){
		int p, x;
		cin >> p >> x;
		cout << sum + x - t[--p] << endl;
	}
}

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

const double PI=3.141592653589793;

int main()
{
  int a;
  cin>>a;
  int b = a + pow(a, 2.0) + pow(a, 3.0);
  cout << b << endl;

  return 0;
}


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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MOD  1000000007
#define mod1 1000000009
#define var    int i,j,c=0,t,l,r,mid,z=0,k,x,y
#define aloc(n,t) ((t*)malloc((n)*sizeof(t)))

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

ll n;
string s,t;
int main()
{
    cin>>s>>t;
    int c =0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])c++;
    }
    pf("%d\n",c);
}


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

struct Line {
	ll lx, rx, y;
};

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

	int N;
	while(cin >> N, N) {
		vector<ll> x(N), y(N);
		vector<ll> xs;
		for(int i = 0; i < N; i++) {
			cin >> x[i] >> y[i];
			xs.push_back(x[i]);
		}

		vector<ll> ax(4), ay(4);
		for(int i = 0; i < 4; i++) {
			cin >> ax[i] >> ay[i];
			xs.push_back(ax[i]);
		}
		sort(xs.begin(), xs.end());
		xs.erase(unique(xs.begin(), xs.end()), xs.end());

		vector<Line> ls, cls;
		for(int i = 0; i < N; i++) {
			if(y[i] == y[(i + 1) % N]) {
				ll lx = min(x[i], x[(i + 1) % N]);
				ll rx = max(x[i], x[(i + 1) % N]);
				ls.push_back({ lx, rx, y[i] });
			}
		}
		for(int i = 0; i < 4; i++) {
			if(ay[i] == ay[(i + 1) % 4]) {
				ll lx = min(ax[i], ax[(i + 1) % 4]);
				ll rx = max(ax[i], ax[(i + 1) % 4]);
				cls.push_back({ lx, rx, ay[i] });
			}
		}

		typedef pair<ll, int> P; // <y, curtain>

		ll ans = 0;
		for(int i = 0; i < (int)xs.size() - 1; i++) {
			ll lx = xs[i], rx = xs[i + 1];
			ll w = xs[i + 1] - xs[i];
			vector<P> ys;
			for(auto l : ls) {
				if(l.lx <= lx && rx <= l.rx) {
					ys.push_back({ l.y, 0 });
				}
			}
			for(auto l : cls) {
				if(l.lx <= lx && rx <= l.rx) {
					ys.push_back({ l.y, 1 });
				}
			}

			sort(ys.begin(), ys.end());
			bool in = false, in_curtain = false;
			for(int j = 0; j < (int)ys.size() - 1; j++) {
				if(ys[j].second) {
					in_curtain = !in_curtain;
				}
				else {
					in = !in;
				}
				if(in && !in_curtain) {
					ans += w * abs(ys[j].first - ys[j + 1].first);
				}
			}
		}
		cout << ans << endl;
	}
}

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


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    string S,T;
    cin >>S>>T;

    string U;
    U = S+T[S.size()];

    if(T==U){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    



    return 0;
    

}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++)
	{
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k)
{
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
	int x, y; cin >> x >> y;
	int a, b;
	if ((x + y) % 3 != 0)
	{
		cout << 0 << endl;
		return 0;
	}
	int l = min(x, y);
	int r = max(x, y);
	//if (l * 2 < r)
	//{
	//	cout << 0 << endl;
	//	return 0;
	//}
	a = (x + y) / 3;
	b = y - a;

	COMinit();

	cout << COM(a, b) << endl;
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
#define ll long long int 
#define w(x) int x; cin>>x; while(x--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
using namespace std;
int main(){
#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll a,b,c;
	cin>>a>>b>>c;
	a=a-b;
	cout<<a%c;

}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S; cin >> S;

    VI wmemo(N+2);
    VI bmemo(N+2);
    wmemo[0] = 0;
    bmemo[N+1] = 0;
    for(int i = 1; i < N+1; i++)
    {
        if(S[i-1] == '#') wmemo[i] = wmemo[i-1]+1;
        else wmemo[i] = wmemo[i-1];
    }
    dump("ok")
    for(int i = N; i > 0; i--)
    {
        dump(i)
        if(S[i-1] == '.')
        {
            bmemo[i] = bmemo[i+1] + 1;
        }
        else
        {
            bmemo[i] = bmemo[i+1];
        }

    }
    dump("ok")
    LL ans = LINF;

    for(int i = 0; i < N+1; i++)
    {
        LL tmp = wmemo[i] + bmemo[i+1];
        if(ans > tmp) ans = tmp;
    }
    cout << ans << endl;


}


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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

// index が条件を満たすかどうか
template <typename T>
bool isOK(const vector<T> &a, ll index, T key) {
  REP(i, a.size()) {
    key -= (ll)ceil(double(a[i]) / double(index)) - 1;
  }
  if (key >= 0)
    return true;
  else
    return false;
}

// 汎用的な二分探索のテンプレ
template <typename T>
ll binary_search(const vector<T> &a, T key) {
  ll ng = 0;
  ll ok = (ll)1e9 + 1;

  /* ok と ng のどちらが大きいかわからないことを考慮 */
  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;

    if (isOK(a, mid, key)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  return ok;
}

void solve(long long N, long long K, std::vector<long long> A) {
  cout << binary_search<ll>(A, K) << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, K, std::move(A));
  return 0;
}


Measured memory_bytes: 4808
import sys
sys.setrecursionlimit(10**6)
n, k = map(int, input().split())
a = list(map(int, input().split()))

length = [-1] * n
path = [-1, []]
route = []


def func(now, depth):
    global path, length, a, route
    route.append(now)
    if length[now] == -1:
        length[now] = depth
        func(a[now]-1, depth+1)
    else:
        path = [length[now], route[length[now]:depth]]


func(0, 0)

if (k < path[0]):
    print(route[k] + 1)
else:
    tmp = k - path[0]
    tmp %= len(path[1])
    print(path[1][tmp] + 1)


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


// Useful container manipulation / traversal macros
#define fori(i,a,b)    for(int i=a;i<=b;i++)
#define ford(i,a,b)   for(int i=a;i>=b;i--)
#define all(a)        a.begin(), a.end()
#define in(a,b)       ( (b).find(a) != (b).end())
#define tr(c,i)       for(auto i = (c).begin(); i != (c).end(); i++)
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define pb             push_back
#define fill(a,v)      memset(a, v, sizeof a)

typedef long long int lli;
typedef vector<int> vi;
typedef vector<long long int> vlli;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	
    if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }

    int n;
    cin>>n;

    int h[n+1];

    fori(i, 1, n){
        cin>>h[i];
    }

    int is = 1;

    int s, c = 0;
    while(is <= n){
        int isOne = 0;
        s = is;

        while(h[s] != 0 && s <= n){
            h[s] = h[s] - 1;
            s++;
            isOne = 1;
        }

        if(isOne)
            c++;

        

        int l = 1;
        while(h[l] == 0 && l <= n){
            l++;
        }

        is = l;
    }

    cout<<c;
}

Measured memory_bytes: 256
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ls = make_divisors(N)
count =0
for i in ls:
    if N/i -1 >= 1 and i < N/i-1:
        count+= N/i -1 
    

print(int(count))

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

int main() {
	char c;
	cin >> c;
	c++;
	cout << c << endl;
	return 0;
}


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

#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

signed main() {
	int n; cin >> n;
	int x = 0, y = 0;
	cin >> x >> y;
	rep(i, n - 1) {
		int t, a;
		cin >> t >> a;
		int k = max((y / a + !!(y % a)), (x / t + !!(x % t)));
		x = k * t;
		y = k * a;
	}
	cout << x + y << endl;
	system("pause");
}

Measured memory_bytes: 504
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }.toList()

    val countArray = LongArray(200000){0}
    a.forEach { countArray[it]++ }
    val ans = countArray.map { it*(it-1)/2 }.sum()
    for (i in 0 until n){
        val count = countArray[a[i]]
        println(ans-count+1)
    }
}

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



int main(void){
    int N,M;
    cin  >> N >> M;
    int cnt[10][10]={};

    int p[10];
    int check[10];
    rep(i,M){
            cin >> k;
            rep(j,k){
                int x;
                cin >> x;
                cnt[x-1][i] = 1;
            } 
    }
    
    rep(i,M) cin >> p[i];
    int m,q;
    rep(i,pow(2,N)){
        q = i/2;
        m = i%2;
        fill(check,check+M,0);
        rep(j,N){
             rep(k,M){
                 if(m==1) check[k] =(check[k] +  cnt[j][k]) %2;
             }
           
             m = q%2;
             q = q/2;
        }
        
        int flag=0;
        rep(j,M){
            if(check[j] == p[j]) flag++;
        }
        if(flag==M)ans++;
    }

    cout << ans << endl;
}



Measured memory_bytes: 256