akhauriyash/Code-Regression huggingface dataset:
open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let R2 T U = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U)
let R3 T U V = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V)
let R4 T U V W = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V),(c.[3]|>W)
let R5 T U V W X = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V),(c.[3]|>W),(c.[4]|>X)
let outl s = stdout.WriteLine(s|>string)
let outsep ls = stdout.WriteLine(String.concat " " (ls|>Array.map string))
let outsepl ls = stdout.WriteLine(String.concat "\n" (ls|>Array.map string))
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    let K=R int
    let ans = (Array.append ([|1;2;3;4;5;6;7;8;9|]) (Array.zeroCreate K))|>Array.map int64
    let mutable i,j=(0,9)
    while j<=K do
        let nx = ans.[i]
        let r = nx%10L
        if r>0L then
            ans.[j] <- nx*10L+(r-1L)
            j <- j+1
        ans.[j]<- nx*10L+r
        j<-j+1
        if r<9L then
            ans.[j] <- nx*10L+(r+1L)
            j<-j+1
        i<-i+1
    ans
    |>Array.filter(fun c->c<>0L)
    |>Array.sort
    |>fun c->c.[K-1]
    |>outl
    0


Measured memory_bytes: 19168
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int A[3000];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  int s = 0;
  rep(i, N) {
    cin >> A[i];
    s += A[i]-1;
  }
  cout << s << "\n";
  return 0;
}


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

int main(){
  string w;
  cin >> w;
  for (char c = 'a'; c != '{'; c = char(c + 1)){
    int cnt = 0;
    for(int i = 0; i < w.size(); i++){
      if(w.at(i) == c){
        cnt++;
      }
    }
    if(cnt % 2 == 1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3616
N = int(input())
S = input()

max = 0
for i in range(N):
 cnt = 0
 common = []
 X = S[0:i]
 Y = S[i:N]
 for k in X:
  if k in Y and k not in common:
   common.append(k)
   cnt += 1
 if cnt > max:
  max = cnt

print(max)


Measured memory_bytes: 3060
#ABC084

a,b = map(int,input().split())
s = input()
l = ["0","1","2","3","4","5","6","7","8","9"]
for i in range(a+b+1):
    if i == a:
        if s[i] != "-":
            print("No")
            break
    else:
        if s[i] not in l:
            print("No")
            break
    
else:
    print("Yes") 



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 998244353;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> l(k);
    vector<int> r(k);
    for (int i = 0; i < k; i++) {
        cin >> l[i] >> r[i];
    }
    vector<ll> dp(n + 5, 0);
    dp[1] = 1;
    vector<ll> chart(n + 5, 0);
    chart[1] = 1;
    for (int i = 2; i < n + 5; i++) {
        for (int j = 0; j < k; j++) {
            if (i - l[j] > 0) {
                ll left = max(1, min(i - r[j], i - 1)), right = i - l[j];
                dp[i] =
                    max(dp[i], dp[i] + chart[right] - chart[left - 1]) % MOD;
            }
        }
        chart[i] = chart[i - 1] + dp[i];
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 6404
from collections import deque

while True:
    W, H = map(int, input().split(' '))
    if W == 0 and H == 0:
        break

    field = []
    for _ in range(2 * H - 1):
        row = list(input())
        if len(row) == 2 * W - 2:
            row.append(' ')
        field.append(row)

    gy = 2 * H - 2
    gx = 2 * W - 2

    queue = deque()
    queue.append((0, 0, 1))

    min_step = 0
    while len(queue) > 0:
        y, x, step = queue.popleft()
        if field[y][x] != ' ':
            continue
        else:
            field[y][x] = 'X'

        if y == gy and x == gx:
            min_step = step
            break

        for dy, dx in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
            if 0 <= y + dy <= gy and 0 <= x + dx <= gx:
                if field[y + dy][x + dx] == '0':
                    queue.append((y + 2 * dy, x + 2 * dx, step + 1))

    print(min_step)



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

int main() {
    ll N;
    cin >> N;
   
    vector<ll> ans;
    while(N > 0){
        ll t = 1;
        ll sum =1;
        while(sum < N){
            t++;
            sum += t;
        }
        N-=t;
        ans.push_back(t);
    }
    for(int i=0;i<ans.size();i++){
        cout << ans[i] << endl;
    }
    

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
int main()
{
	int n;
	int time=0;
	scanf("%d",&n);
	rep(i,n)
	{
		int a;
		cin>>a;
		if(a!=i+1)
			time++;
		if(time>2)
		{
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import bisect
import collections

h,w,n = [int(i) for i in input().split()]
jama = {h+1:1}
for _ in range(n):
    x,y=[int(i) for i in input().split()]
    if x < y:
        continue
    if x in jama:
        if y < jama[x]:
            jama[x] = y
    else:
        jama[x] = y
    
#print(jama)

#J = sorted(jama.items(), key=lambda x: x[0])

#print(J)
wmax=1
ans = 1
for i in range(2,h+1):
#    print(i,wmax)
    if i not in jama:
        ans += 1
        wmax += 1
#        print(i,wmax,"not")
        continue

    if jama[i] <= wmax:
#        print(i,wmax,"break")
        break
    elif jama[i] == wmax + 1:
        ans += 1
#        print(i,wmax,"elif")
    else:
        ans += 1
        wmax += 1
#        print(i,wmax,"else")

print(ans)



Measured memory_bytes: 20308
import math

def isPrime(x):
    if x == 2:
        return 1
    if x % 2 == 0:
        return 0
    for i in range(2,int(math.sqrt(x))+1):
        if x%i == 0:
            return 0
    return 1

n=int(input())
ans=0
for i in range(n):
	x=int(input())
	if isPrime(x):
		ans+=1
print(ans)


Measured memory_bytes: 5676
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        int count = 0;
        int ans = 0;
        for(int i=1;i<=N;i+=2){
            for(int j=1;j<=N;j++){
                if(i%j==0){
                    count++;
                }
            }
            
            if(count==8){
                ans++;
            }
            count = 0;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35892
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

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

	ll a, b;
	cin >> a >> b;
	ll g = __gcd(a, b);

	set<ll> primes;
	ll tmp = g;
	for (ll i = 2; i * i <= tmp; i++)
		if (tmp % i == 0)
		{
			primes.insert(i);
			tmp /= i;
			while (tmp % i == 0)
				tmp /= i;
		}
	if (tmp != 1)
		primes.insert(tmp);

	cout << ((int)primes.size() + 1) << endl;

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int x,y;
  x = (N - (N % 10)) % 111;
  y = (N % 1000) % 111;
  
  if (x == 0 || y == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<iomanip>
#include<cstdint>
#include<bits/stdc++.h>
using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}


int atcoder(){
  	int ans=0;
    string s;
  	cin>>s;
  	REP(i,0,s.length()){
    	if(s[i]=='2') ans++;
    }
    cout<<ans<<ENT;
    return 0;
}


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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
map<string,bool> mp;
int n,cnt;
string s;
int main()
{
    cin>>n;
    while(n--)
        cin>>s,mp[s]=1;
    for(auto i: mp)
        cnt++;
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 19200
def main():
  dic = [[] for i in range(31)]
  dic[1].append([1])
  
  def func(n):
    if dic[n]:
      return dic[n]
    else:
      dic[n].append([n])
      for i in range(n - 1, 0, -1):
        for l in func(n - i):
          if i >= l[0]:
            dic[n].append([i] + l)
      return dic[n]
  func(30)
  
  while True:
    n = int(input())
    if not n:
      break
    for l in dic[n]:
      print(" ".join(map(str, l)))
main()


Measured memory_bytes: 9776
use proconio::marker::Chars;
use proconio::{fastout, input};
use std::collections::VecDeque;

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        c: [Chars; h]
    };
    let mut c: Vec<Vec<char>> = c;

    for i in 0..h {
        let mut cc = c[i].clone();
        cc.push('#');
        cc.reverse();
        cc.push('#');
        cc.reverse();

        c[i] = cc;
    }

    let top_bottom_padding: Vec<char> = vec!['#'; w + 2];
    c.push(top_bottom_padding.clone());
    c.reverse();
    c.push(top_bottom_padding.clone());
    c.reverse();

    let mut dp = vec![vec![0; h + 1]; w + 1];
    dp[1][1] = 1;

    for i in 1..=w {
        for j in 1..=h {
            if (i, j) != (1, 1) {
                if c[j][i] == '#' {
                    dp[i][j] = 0;
                } else {
                    dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % (10i32.pow(9) + 7);
                }
            }
        }
    }

    println!("{}", dp[w][h]);
}


Measured memory_bytes: 14756
h,w = map(int,input().split())

def half(h,w):
   h1 = h//2
   h2 = h - h1
   return h1*w, h2*w
def half2(h,w):
   w1 = w//2
   w2 = w-w1
   return w1*h, w2*h

ans = float("inf")
for i in range(h):
   a = i * w
   b,c = half(h-i, w)
   tmp = max(a,b,c) - min(a,b,c)
   if a > 0 and b > 0 and c > 0:
      ans = min(tmp, ans)
   b,c = half2(h-i, w)
   tmp = max(a,b,c) - min(a,b,c)
   if a > 0 and b > 0 and c > 0:
      ans = min(tmp, ans)
   


for i in range(w):
   a = i * h
   b,c = half(h, w-i)
   tmp = max(a,b,c) - min(a,b,c)
   if a > 0 and b > 0 and c > 0:
      ans = min(tmp, ans)
   b,c = half2(h, w-i)
   tmp = max(a,b,c) - min(a,b,c)
   if a > 0 and b > 0 and c > 0:
      ans = min(tmp, ans)
   
print(ans)

Measured memory_bytes: 3064
import collections


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


N = int(input())
count = 0
j = 1

c = collections.Counter(prime_factorize(N))
factor_sets = list(c.items())

fac_num = len(factor_sets)

for i in range(fac_num):
    while True:
        if (j + 1) * (j + 2) / 2 <= factor_sets[i][1]:
            j += 1
        else:
            count += j
            j = 1
            break

print(count)


Measured memory_bytes: 9468
input()
s = [int(i) for i in input().split()]
input()
t = [int(i) for i in input().split()]
sd, td = {}, {}
for i in s:
    if i in sd:
        sd[i] += 1
    else:
        sd[i] =1
for i in t:
    if i in td:
        td[i] += 1
    else:
        td[i] =1
c = 0
for i in td.keys():
    if i in sd.keys():
        c += 1
print(c)


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

int main() {
  int value1;
  int value2;
  string op;
  int ans;

  cin >> value1 >> op >> value2;

  if (op == "+")
  {
    ans = value1 + value2;
  }
  else
  {
    ans = value1 - value2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define INF (1<<21)
#define MAXSIZE 100
int n,A[N][N];
int dis[N];
int Q[MAXSIZE];
int head = 0;
int tail = 1;
void enqueue(int x)
{
Q[tail++] = x;
}
int deq() {
int s;
s = Q[head++];
return s;
}
int empty()
{
return (head == tail);
}
void bfs(int t)
{
int i,j;
enqueue(t);
for(i=0;i<n;i++)dis[i]=INF;
dis[t]=0;
int a;
while(!empty())
{
a=deq();
for(j=0;j<n;j++)
{
if(A[a][j]==0)continue;
if(dis[j]!=INF)continue;
dis[j]=dis[a]+1;
enqueue(j);
}
}
for(i=0;i<n;i++)
{
printf("%d %d\n",i+1,((dis[i]==INF)?(-1):dis[i]));
}
}
int main()
{
int i,j,p,k,pnum;
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
A[i][j]=0;
}
}
for(i=0;i<n;i++)
{
scanf("%d %d",&p,&k);
p--;
for(j=0;j<k;j++)
{
scanf("%d",&pnum);
pnum--;
A[p][pnum]=1;
}
}
bfs(0);
return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int *> P;
typedef pair<long long,int>PP;
typedef long long ll;
int main(){
  int a=0,b=0,k;
  string s;
  cin>>s;
  for(int i=0;s[i]!='\0';i++){
    if(s[i]=='1'){
      a+=1;
    }else if(s[i]=='0'){
      b+=1;
    }
  }
  if(a>b){
    k=a+b-(a-b);
  }else{
    k=a+b-(b-a);
  }
  cout<<k<<endl;
  return(0);
}


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


int main()

{   
    long long int h,cnt=0,atk=1;
    cin>>h;
    while(h!=1)
    {
        h=h/2;
        cnt++;
        atk+=pow(2,cnt);
    }
    cout<<atk<<endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mo 998244353
#define M 2000
long long ksm(long long a,int k) {
    long long s=1;
    while(k)
	{
	    if(k&1) s=s*a%mo;
	    a=a*a%mo;
	    k>>=1;
	}
    return s;
}
int n,k;
long long f[M+5][M+5],h[M+5][M+5],tol[M+5],jc[2*M+5],nc[2*M+5];
long long G(int n,int m) {
    if(n==0&&m==0) return 1;
    if(n<=0||m<0) return 0;
    return jc[n+m-1]*nc[m]%mo*nc[n-1]%mo;
}
long long cal(int l) {
    long long s=0;
    if(l&1)
	{
	    for(int i=1;i<=k;i++) tol[i]=(f[l>>1][i]+f[l>>1][i-1])%mo;
	    tol[0]=1;
	    for(int i=0;i<=k;i++) s=(s+G(n-l,k-i)*tol[i]%mo)%mo;
	}
    else for(int i=0;i<=k;i++) s=(s+G(n-l,k-i)*f[l>>1][i]%mo)%mo;
    s=(s%mo+mo)%mo;
    return s;
}
int main()
{
    //freopen("1.in","r",stdin);
    //freopen("1.out","w",stdout);
    jc[0]=1;
    for(int i=1;i<=2*M;i++) jc[i]=jc[i-1]*i%mo;
    nc[2*M]=ksm(jc[2*M],mo-2);
    for(int i=2*M-1;i>=0;i--) nc[i]=nc[i+1]*(i+1)%mo;
    cin>>n>>k;
    f[0][0]=1;
    for(int i=0;i<=k;i++) h[0][i]=1;
    for(int i=1;i<=n/2;i++)
	for(int j=0;j<=k;j++)
	    {
		if(j) f[i][j]=2*h[i-1][j-1]%mo;
		f[i][j]=(f[i][j]+f[i-1][j])%mo,h[i][j]=(h[i][j-1]+f[i][j])%mo;
	    }
    for(int i=2;i<=2*n;i++)
	{
	    int l=i-1;
	    if(l>n) l=2*n-l;
	    cout<<cal(l)<<'\n';
	}
    return 0;
}

Measured memory_bytes: 35072
import std.stdio, std.string, std.array, std.conv, std.algorithm;

int bubbleSort(int n, int[] x) {
    int cnt = 0;
    bool flag = true;
    for (int i = 0; flag; ++i) {
        flag = false;
        for (int j = n - 1; j >= i + 1; --j) {
            if (x[j] < x[j-1]) {
                swap(x[j], x[j-1]);
                flag = true;
                ++cnt;
            }
        }
    }
    return cnt;
}

void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.chomp.split.to!(int[]);
    int times = bubbleSort(n, a);
    foreach (i, x; a) {
        x.write;
        if (i != n - 1) " ".write;
        else writeln;
    }
    times.writeln;
}


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

#define int long long
#define vc vector<char>
#define vi vector<int>
#define vs vector<string>
#define si set<int>
#define pii pair<int,int>
#define SORT(c) sort(c.begin(),c.end())
#define SORTC(c, cmp) sort(c.begin(),c.end(),cmp)
#define mapii map<int,int>
#define pb push_back
#define F first
#define S second
#define rep(i, j, k) for (int i=j;i<k;i++)
#define repb(i, j, k) for (int i=j;i>=k;i--)
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define ar array

using namespace std;

#define fast ios::sync_with_stdio(false); cin.tie(0)

int n, m, k;
const int mxN = 2e5;
int a[mxN + 1], b[mxN + 1];
int ans = 0;

void solve() {
    cin >> n >> m >> k;
    rep(i, 0, n) {
        cin >> a[i + 1];
        a[i + 1] += a[i];
    }
    rep(i, 0, m) {
        cin >> b[i + 1];
        b[i + 1] += b[i];
    }

    int j = m;
    rep(i, 0, n + 1) {
        if (a[i] > k) {
            break;
        }
        while (a[i] + b[j] > k) {
            --j;
        }
        ans = max(ans, i + j);
    }
    cout << ans;
}

int32_t main() {
    fast;

    int tt{1};
//    cin >> tt;
    while (tt--) {
        solve();
        cout << endl;
    }
    return 0;

}

Measured memory_bytes: 6748
#include<cstdio>
#include<iostream>
using namespace std;
long long h[100001];
int main(void){
	long long n,b,a,low,high,i,sum,ave,d;
	cin>>n>>a>>b;
	high=0;
	for(i=0;i<n;i++){
		cin>>h[i];
		high+=h[i];
	}
	low=1; high=high/b;
	while(1){
		if(low>high) break;
		ave=(high+low)/2;
		sum=0;
		for(i=0;i<n;i++){
			d=h[i]-b*ave;
			if(d<0) d=0;
			sum+=d/(a-b);
			if(d%(a-b)>0) sum++;
		}
		if(sum<=ave) high=ave-1;
		if(sum>ave) low=ave+1;
	}
	cout<<low<<endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  int n, m;
  cin >> n >> m;
  int p[100000], y[100000];
  vector<ll> yd[100001];
  rep (i,m) scanf ("%d%d",&p[i],&y[i]), yd[p[i]].push_back(y[i]);
  rep (i,n) sort (yd[i+1].begin(), yd[i+1].end());
  rep (i,m) printf ("%012lld\n", ll(p[i])*1000000+ int(lower_bound(yd[p[i]].begin(), yd[p[i]].end(), y[i]) - yd[p[i]].begin())+1);
  return 0;
}


Measured memory_bytes: 7808
while True:
    H, W = list(map(int, input().split()))
    if H == 0 & W == 0:
        break

    #????????¶???#??¨.????????????????????????#??????????§?
    for i in range(1,H+1):
        line = []
        for j in range(1,W+1):
            if ((i+j) % 2) == 0:
                line.append('#')
            else:
                line.append('.')
        print(''.join(line))

    print("")

Measured memory_bytes: 7688
num,renzoku=map(int,input().split())
dices=list(map(int,input().split()))
expects=[0]*num
Si=[0]*(num+1)
for i in range(1,num+1):
  Si[i]=Si[i-1]+(1+dices[i-1])/2
max_Si=0
for i in range(0,num-renzoku+1):
  if max_Si<Si[i+renzoku]-Si[i]:
    max_Si=Si[i+renzoku]-Si[i]
print(max_Si)


Measured memory_bytes: 25060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)  for(ll i=x;i<y;++i)
#define For(i,x,y)  for(ll i=x;i<=y;++i)
#define FOr(i,x,y)  for(ll i=x;i>=y;--i)
#define pi acos(-1)
#define mk make_pair<ll,ll>
#define pa pair<ll,ll>
#define lf else if
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)      ((x)*(x))
#define abs(x)      ((x)>0?(x):-(x))
#define Mul(x,y)    (x=(x)*(y)%mod)
#define Mul1(x,y)   (x=(x)*(y)%mod1)
#define Add(x,y)    (x=(x+(y))%mod)
#define Add1(x,y)	(x=(x+(y))%mod1)
#define E(x)        return writeln(x),0
#define p(x)        printf("~%d~\n",x)
#define pp(x,y)     printf("~~%d %d~~\n",x,y)
#define ppp(x,y,z)  printf("~~~%d %d %d~~~\n",x,y,z)
#define pppp(x,y,z,a)  printf("~~~%d %d %d %d~~~\n",x,y,z,a)
#define f_in(x)     freopen(x".in","r",stdin)
#define f_out(x)    freopen(x".out","w",stdout)
#define open(x)     f_in(x),f_out(x)
#define fi first
#define se second
typedef complex<double> E;
namespace SHENZHEBEI{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_;
#endif
#define NEG 1
    inline char gc(){   return getchar();   }
#if NEG
    inline ll read(){    ll x=0,f=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') f=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*f; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
    inline void writeln(ll x){  write(x);   puts("");   }
    inline ld getreal(){    static ld lbc;  scanf("%lf",&lbc);  return lbc; }
}using namespace SHENZHEBEI;
const ll N=1000;
ll ned,n,val,a[N];
int main(){
	n=read();
	For(i,1,n)a[i]=read();
	ll val=100000;
	For(i,2,n)if (a[i]==a[i-1]){
		a[i]=++val;
		++ned;
	}writeln(ned);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String args[]) {
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		char s[] = new char[n];
		String str = sc.nextLine();
		for(int i = 0; i < n; i++) {
			s[i] = str.charAt(i);
		}
		int ans = 1;
		
		for(int i = 1; i < n; i++) {
			if(s[i] != s[i -1]) {
				ans++;
			}
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 27712
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int S, v[10000009], lim = 100000000, mod = 1000000007;
int binpow(int a, int b) {
	int ret = 1;
	while (b) {
		if (b & 1) ret = 1LL * ret * a % mod;
		a = 1LL * a * a % mod;
		b >>= 1;
	}
	return ret;
}
int main() {
	cin >> S;
	for (int i = 1; 10 * i < lim; i++) {
		int b = i;
		while (b > 0) b /= 10, v[i]++;
	}
	int r = 1, s = 0, ret = 0;
	for (int i = 1; i < lim; i++) {
		while (s < S) s += (10 * r < lim ? v[r] : (r < lim ? 8 : 9)), r++;
		if (s == S) ret++;
		s -= (10 * i < lim ? v[i] : 8);
	}
	vector<int> d;
	for (int i = 1; i * i <= S; i++) {
		if (S % i == 0) {
			d.push_back(i);
			if (i * i != S) d.push_back(S / i);
		}
	}
	for (int i : d) {
		if (i <= 8) continue;
		if (S % i == 0) {
			ret = (ret + 9LL * binpow(10, i - 1)) % mod;
			ret = (ret - S / i + 1 + mod) % mod;
		}
	}
	for (int i = 2; 9 * i < S; i++) {
		for (int j = 9 * i; j < S; j += i) {
			if (j > S - i) ret++;
		}
	}
	cout << ret % mod << endl;
	return 0;
}

Measured memory_bytes: 39296
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, k; cin >> n >> k;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    ll lim = min(n, k);
    ll max_num = -inf;
    for (ll a = 0; a <= lim; a++) {
        for (ll b = lim - a; b >= 0; b--) {
            vector<ll> v2;
            rep(i, a) v2.push_back(v[i]);
            for (int i = n - 1; i >= (n - b); i--) v2.push_back(v[i]);
            sort(all(v2));
            ll i;
            for (i = 0; i < k - (a + b); i++) {
                if (i >= v2.size() || v2[i] >= 0) break;
            }
            ll sum = 0;
            for (; i < v2.size(); i++) sum += v2[i];
            max_num = max(max_num, sum);
        }
    }
    cout << max_num << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int arr[] = new int[n];
    for(int i = 0;i < n;i++){
      arr[i] = sc.nextInt();
    }
    
    Arrays.sort(arr);
    
    int x = 0;
    for(int i = 0;i < n-1;i++){
      x += arr[i];
    }
    if(arr[n-1]<x){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }

  }

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int a, b, c, k;
int main()
{
	cin>>a>>b>>c>>k;
	if(k<=a)
	{
		cout<<k;
	}
	else if(k<=a+b)
	{
		cout<<a;
	}
	else
	{
		cout<<2*a+b-k;
	}
	return 0;
}

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

    int n,liu=-1,gmax=0,ans=0;
    cin>>n;

    int dp[n][3],arr[n][3];
    
    for(int i=0;i<n;i++)
    {
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    }

    for(int i=0;i<3;i++)
     dp[0][i]=arr[0][i];

    for(int i=1;i<n;i++)
    {
        dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=arr[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=arr[i][2]+max(dp[i-1][0],dp[i-1][1]);
    } 
  
    ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));


     cout<<ans;
    return 0;
}


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

int main() {
  int N, K;
  char c;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
      cin >> c;
      if (i + 1 == K) cout << (char)(c + 0x20);
      else cout << c;
  }
  cout << endl;
}

Measured memory_bytes: 256
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;
#define int long long
const int N = (int) 1e5 + 5, mod = (int) 0;
int n, a[N], b[N];

int check(int lim) {
    int val = lim;
    for (int j = 0; j < n; ++j) {
        int x = a[j] + val;
        x = x / b[j] * b[j];
        val = x - a[j];
        if (val < 0) return 0;
    }
    return 1;
}

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int j = 0; j < n; ++j) {
        cin >> a[j] >> b[j];
    }
    int bl = -1, br = 1e18 + 1;
    while (bl < br - 1) {
        int bm = bl + br >> 1;
        if (check(bm))
            br = bm;
        else
            bl = bm;
    }
    cout << br << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>

#define TRACE(x) std::cout << #x << " = " << x << "\n"
#define _ << " _ " <<

using namespace std;

int main() {
  std::ios_base::sync_with_stdio(false);
  int N;
  cin >> N;

  vector<vector<int>> cnt(N, vector<int>(N, 0));
  vector<vector<bool>> dead(N, vector<bool>(N, false));

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      cnt[i][j] = min(min(i, j), min(N - i - 1, N - j - 1));
    }
  }

  int ans = 0;
  for (int i = 0; i < N * N; ++i) {
    int v;
    cin >> v;
    v--;

    int y = v % N;
    int x = v / N;

    ans += cnt[x][y];
    dead[x][y] = true;

    queue<int> Q;
    Q.push(x);
    Q.push(y);
    while (!Q.empty()) {
      int x = Q.front();
      Q.pop();
      int y = Q.front();
      Q.pop();

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

      int newCost = cnt[x][y] + (dead[x][y] ? 0 : 1);
      for (int k = 0; k < 4; ++k) {
        int nx = x + dx[k];
        int ny = y + dy[k];
        if (nx < 0 || nx >= N || ny < 0 || ny >= N) continue;
        if (newCost < cnt[nx][ny]) {
          assert(newCost + 1 == cnt[nx][ny]);
          cnt[nx][ny] = newCost;
          Q.push(nx);
          Q.push(ny);
        }
      }
    }
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using ll = int_fast64_t;

ll thick[51], patty[51];

ll recur(ll n, ll x){
	if(n==0 && x) return 1;

	if(x<=1) return 0;
	if(x<=1+thick[n-1]) return recur(n-1, x-1);
	if(x<=2+thick[n-1]*2) return 1 + patty[n-1] + recur(n-1, x-2-thick[n-1]);
	return patty[n];
}

int main(){
	thick[0] = patty[0] = 1;
	for(int i=0; i<50; i++){
		thick[i+1] = thick[i] * 2 + 3;
		patty[i+1] = patty[i] * 2 + 1;
	}

	ll n, x;
	scanf("%ld %ld", &n, &x);
	printf("%ld\n", recur(n, x));
	return 0;
}


Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

struct st {
	double x, y;
	char d;
	st() {}
	st(double a, double b, char c) {
		x = a, y = b, d = c;
	}
}take[(int)1e5+5];

int n;

double f(double t) {
	double x_max = -1e10, x_min = 1e10, y_max = -1e10, y_min = 1e10;
	for(int i=0; i<n; i++) {
		double x = take[i].x, y = take[i].y;
		if(take[i].d == 'R') {
			x += t;	
		}
		else if(take[i].d == 'L') {
			x -= t;
		}
		else if(take[i].d == 'U') {
			y += t;
		}
		else if(take[i].d == 'D') {
			y -= t;
		}
		x_max = max(x_max, x);
		x_min = min(x_min, x);
		y_max = max(y_max, y);
		y_min = min(y_min, y);
	}
	return (x_max - x_min) * (y_max - y_min);
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for(int i=0; i<n; i++) {
		double x, y;
		char d;
		cin >> x >> y >> d;
		take[i] = st(x, y, d);
	}
	double l, r, m1, m2;
	l = 0, r = 1e12;
	for(int i=0; i<300; i++){
		m1 = l + (r - l) / 3.0;
		m2 = l + 2.0 * (r - l) / 3.0;
		if (f(m1) < f(m2)){
			r = m2;
		}
		else{
			l = m1;
		}
	}
	cout << fixed;
	cout << f(l) << endl;
	return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int c[n - 1], s[n - 1], f[n - 1];
  for (int i = 0; i < n - 1; i++) cin >> c[i] >> s[i] >> f[i];
  for (int i = 0; i < n; i++) {
    int t = 0;
    int st = i;
    while (st < n - 1) {
      if (t < s[st]) t = s[st] + c[st];
      else t = ((t - 1) / f[st] + 1) * f[st] + c[st];
      st++;
    }
    cout << t << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.Functor
import Data.List

readInts :: IO [Int]
readInts = map read . words <$> getLine

solve "Sunny" = "Cloudy"
solve "Cloudy" = "Rainy"
solve "Rainy" = "Sunny"

main = getLine >>= putStrLn . solve

Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;cin>>N;
    int a[N], b[N], c[N-1];
    for(int i=0;i<N;i++)cin>>a[i];
    for(int i=0;i<N;i++)cin>>b[i];
    for(int i=0;i<N-1;i++)cin>>c[i];
    int ans =0, index = 0;
    for(int i=0;i<N;i++){
        ans+=b[a[i]-1];
        if(index+1==(a[i]-1)&&i>0)ans+=c[index];
        index = a[i]-1;
    }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <bits/stdc++.h>
#include <set>
#include <vector>
#include <queue>
#include <bitset>
#define NL << endl
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl "\n"
#define fill(x, y) memset(x, y, sizeof(y))
#define debug(x)                          \
    {                                     \
        cerr << #x << " = " << x << endl; \
    }
#define inarr(arr, n)                            \
    {                                       \
        for(int i =0;i<n;i++){              \
            cin >> arr[i];                  \
        }                                   \
    }
typedef long long ll;
const int MOD = 1e9 + 7;
using namespace std;

void solve()
{
int a; cin >> a;
string ans  = a>=30 ? "Yes" : "No";
  cout << ans << endl; return;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t; t = 1; 
    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;
 
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}




 
    
void test_case() {

    int n, k, c;
    cin>>n >>k >> c;

    string s;
    cin>>s;

    vec left(n+1,0), right(n+1, 0);

    int cnt = 0;
    

    for(int i=0; i<n; i++) {
        if(s[i] == 'o') {
            left[cnt] = i;
            cnt++;
            i=i+c;
            if(cnt == k) {
                break;
            }
        }
    }

    for(int i=n-1; i>=0; i--) {
        if(s[i] == 'o') {
            
            cnt--;
            right[cnt] = i;
            i=i-c;
            if(cnt == 0) {
                break;
            }
        }
    }

    for(int i=0; i<k; i++) {
        if(left[i] == right[i]) {
            cout<<left[i]+1<<endl;
        }
    }
    









}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
 
    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 5196
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

def factorial(n):
    if n < 2:
        return 1
    ret = 1
    for i in range(2, n + 1):
        ret *= i
    return ret

import itertools
seq = list(map(lambda x: x + 1, list(range(n))))
ptr = list(itertools.permutations(seq))

print(abs( ptr.index(p) - ptr.index(q) ))


Measured memory_bytes: 8052
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int a[3];
int ans=0;
int main()
{
	for(int i=0;i<3;i++)
		cin>>a[i];
	sort(a,a+3);
	ans+=a[1]-a[0];
	ans+=a[2]-a[1];
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#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(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    int N;
    while (cin >> N, N) {
        int W, H;
        cin >> W >> H;
        vvb field(H, vb(W));
        REP(i, N) {
            int x, y;
            cin >> x >> y;
            x--;
            y--;
            field[y][x] = true;
        }
        int S, T;
        cin >> S >> T;
        int ma = 0;
        REP(y, H) REP(x, W) {
            int xend = x + S, yend = y + T;
            if (xend <= W && yend <= H) {
                int cnt = 0;
                FOR(yy, y, yend) FOR(xx, x, xend) {
                    if (field[yy][xx]) {
                        cnt++;
                    }
                }
                ma = max(ma, cnt);
            }
        }
        cout << ma << endl;
    }
}

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

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i=0;i<n;i++){
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    auto uniq=std::unique(d.begin(),d.end());
    cout << (uniq-d.begin()) << endl;
    return 0;
}



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

int64_t calcV(int64_t a, int64_t b, int64_t x) {
  return (a * x) / b - a * (x / b);
}

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

  if (b > n) {
    cout << calcV(a, b, n) << endl;
  } else {
    cout << calcV(a, b, b - 1) << endl;
  }
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2,147,483,647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cint(n) int n;cin>>n;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename TypeInt>
std::string Itoa(const TypeInt v, int base)
{
    static const char table[] = "0ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string ret;
    static numeric_limits<TypeInt> t;
    TypeInt n = v;
    if (t.is_signed) {
        if (v < 0) n *= -1;
    }

    while (n >= base) {
        ret += table[n%base];
        n /= base;
    }
    ret += table[n];
    if (t.is_signed) {
        if (v < 0 && base == 10) ret += '-';
    }
    // 文字列の順番を逆にする
    std::reverse(ret.begin(), ret.end());

    return ret;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
    ll n;cin>>n;
    ll z;
    string y="zabcdefghijklmnopqrstuvwxy";
    string ans="";
    while(n>0){
        z=n%26;
        ans.push_back(y[z]);
        if(z==0){
            n/=26;
            n--;
        }else{
        n=n/26;
        }
    }
    reverse(ALL(ans));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3580
import java.util.*;
class Main{
	public static void main(String[] a){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int i = scan.nextInt();
			i += scan.nextInt();
			int digit = 0;
			while(i > 0){
				i /= 10;
				digit++;
			}
			System.out.println(digit);
		}
	}
}

Measured memory_bytes: 20428
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  
  vector<int> x(N), y(N), h(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> h[i];
  }
 
  int cx, cy;
  int H;
  bool correct = false;
  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      bool check = true;
      for (int k = 0; k < N; k++) {
        if (h[k] > 0) {
          H = h[k] + abs(x[k] - i) + abs(y[k] - j);
        }
      }
      for (int k = 0; k < N; k++) {
        if (h[k] != max(H - abs(x[k] - i) - abs(y[k] - j), 0)) {
          check = false;
          break;
        }
      }
      if (check) {
        correct = true;
        cx = i;
        cy = j;
      }
      if (correct) break;
    }
    if (correct) break;
  }
  
  cout << cx << " " << cy << " " << H << endl;
  
  return 0;
}

Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N,K;
	string S;
	cin >> N;
	cin >> S;
	cin >> K;
	char t = S[K-1];

	rep(i, N)
	{
		if (S[i]!=t)
		{
			cout << "*";
		}
		else
		{
			cout << t;
		}
		
	}
	cout << endl;

	
	return 0;
}


Measured memory_bytes: 256
def connected_components(graph):
    seen = set()
    def component(n):
        nodes = set([n])
        while nodes:
            n = nodes.pop()
            seen.add(n)
            nodes |= set(graph[n]) - seen
            yield n
    for n in graph:
        if n not in seen:
            yield component(n)

def print_gen(gen):
    print(len([list(x) for x in gen]))

n,m=map(int,input().split())
d={i:[] for i in range(n)}
for i in range(m):
    x,y,z=map(int,input().split())
    d[x-1].append(y-1)
    d[y-1].append(x-1)

print_gen(connected_components(d))

Measured memory_bytes: 49472
def gcd(a,b)
  a,b = a.abs,b.abs
  a,b = b,a if a < b
  if b == 0
    return a
  else
    return gcd(b,a%b)
  end
end
n,pos = gets.split.map(&:to_i)
x = gets.split.map{|v| (v.to_i-pos).abs}
x.sort!
ans = gcd(x[-1],x[0])
x.each do |v|
  if v % ans != 0
    ans = gcd(v,ans)
  end
end
p ans


Measured memory_bytes: 9216
#include<stdio.h>
int change_plus(int a) {
	if (a < 0) { return -a; }
	if (a >= 0) { return a; }
}
int big(int a,  int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

int main() {
	int n;
	int check;
	int x[150], y[150], h[150];
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d%d", &x[i],&y[i],&h[i]);
	}
	for (int i =0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			for (int k= h[1]; k <= h[1] +200;k++) {
				for (int p = 1; p <= n; p++) {
					if (h[p] != big(0, k - change_plus(x[p] - i) - change_plus(y[p] - j))) { goto next; }
				}
				printf("%d %d %d", i, j, k);
			next:
				check++;
			}
		}
	}

}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

const char lose = 'l';
const char back = 'b';
const char goal = 'g';
int main(){
    cout << fixed << setprecision(10);
    while(true){
        int N,T,L,B;
        cin >> N >> T >> L >> B;
        if(N == 0) break;
        vector<char> S(N+1);

        for(int i=0;i<L;i++){
            int l;
            cin >> l;
            S[l] = lose;
        }
        for(int i=0;i<B;i++){
            int l;
            cin >> l;
            S[l] = back;
        }
        S[N] = goal;

        vector<vector<double> > dp(T+3,vector<double>(N+1));
        double goaled = 0;
        dp[0][0] = 1;
        for(int i=0;i<T;i++){
            for(int j=0;j<N;j++){
                for(int k=1;k<=6;k++){
                    double nyan = dp[i][j]/6;
                    int p = j+k;
                    if(p > N){
                        p -= 2*(p-N);
                    }
                    if(S[p] == lose){
                        dp[i+2][p] += nyan;
                    }else if(S[p] == back){
                        dp[i+1][0] += nyan;
                    }else if(S[p] == goal){
                        goaled += nyan;
                    }else{
                        dp[i+1][p] += nyan;
                    }
                }
            }
        }
        cout << goaled << endl;
    }
    return 0;
}

Measured memory_bytes: 1372
#include<stdio.h>
int main()
{
	int debt=100000;
	int i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		debt*=1.05;
	if(debt % 1000 != 0){
	debt=(debt/1000+1)*1000;
	}
	}
	printf("%d\n",debt);
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define INF -99999999 
using namespace std;
 
int main()
{
    string S; cin >> S;
    string K = "keyence";
    if(S == K){
        cout << "YES" << endl;
        return 0;
    }
    for (int i = 0; i < S.size(); i++)
    {
        for (int j = i; j < S.size(); j++)
        {
            string s = "";
            for (int k = 0; k < S.size(); k++)
            {
                if(i<=k and k<=j) continue;
                else s.push_back(S[k]);
            }
            if(s == K){
                cout << "YES" << endl;
                return 0;
            }
        }
        
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

ll n, m;
ll x[112345], y[112345];

int main() {
	cin >> n >> m;
	REP(i, n) scanf("%lld", x + i);
	REP(i, m) scanf("%lld", y + i);
	
	ll dx = 0, dy = 0;
	REP(i, n - 1) {
		dx += (x[i + 1] - x[i]) % MOD * ((i + 1) * (n - 1 - i)) % MOD;
		dx %= MOD;
	}
	
	REP(i, m - 1) {
		dy += (y[i + 1] - y[i]) % MOD * ((i + 1) * (m - 1 - i)) % MOD;
		dy %= MOD;
	}
	
	cout << dx * dy % MOD << endl;
	
	return 0;
}

Measured memory_bytes: 1792