akhauriyash/Code-Regression huggingface dataset:
/*#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T>inline auto vec2(class vector<T>::size_type h,class vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator>inline void psortb(RandomAccessIterator first,RandomAccessIterator last){using P=pair<decltype(first->first),decltype(first->second)>;sort(first,last,[](const P&p1,const P&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
}*/

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    const long long INF = 100000000;
    long long N, M, R;
    cin >> N >> M >> R;
    vector<long long>r(R);
    for(long long i = 0; i < R; ++i){
        cin >> r[i];
        // 0-index -> 1-index
        --r[i];
    }
    vector<vector<long long>>adj(N, vector<long long>(N, INF));
    for(long long i = 0; i < M; ++i){
        long long A, B, C;
        cin >> A >> B >> C;
        // 0-index -> 1-index
        --A;--B;
        // 無向グラフ
        adj[A][B] = adj[B][A] = C;
    }

    for(int k=0;k<N;++k){
        for(int i=0;i<N;++i){
            for(int j=0;j<N;++j){
                if(adj[i][k]!=INF&&adj[k][j]!=INF){
                    adj[i][j]=min(adj[i][j],adj[i][k]+adj[k][j]);
                }
            }
        }
    }
    long long ans=100000000;
    sort(r.begin(),r.end());
    do{
        long long tmp=0;
        for(int i=1;i<R;++i)tmp+=adj[r[i-1]][r[i]];
        ans=min(ans,tmp);
    }while(next_permutation(r.begin(),r.end()));
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int n, k;
int num(int x){
  int cnt = 0;
  while(x<k){
    x *= 2;
    cnt++;
  }
  return cnt;
}
double rm(int x){
  int y = num(x);
  double z = 1;
  for(int i=0; i<y; i++){
    z *= 2;
  }
  double res = 1 / z;
  return res;
}
int main() {
  cin >> n >> k;
  double ans = 0;
  //cout << rm(1) << endl;
  for(int i=1; i<n+1; i++){
    ans += rm(i) / n;
  }
  cout << fixed << setprecision(12) << ans << endl;
}


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

int main() {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  if (a == 5 && b == 5 && c == 7 || b == 5 && c == 5 && a == 7 ||
      c == 5 && a == 5 && b == 7)
    printf("YES");
  else
    printf("NO");
}


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

N, K = map(int, input().split())
S = input()

# print(N)
# print(K)
# print(S)

# print(S[K - 1])

word = ''

# print(len(S))

# for char in S:
for i in range(len(S)):
    # print(char)
    if i == K - 1:
        word += S[i].lower()
    else:
        word += S[i]

# print(S)
print(word)

Measured memory_bytes: 2940
// AOJ 1176: Planning Rolling Blackouts
// 2018.1.9 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int S, sum;
int u[34][34], s[34][34];
int memo[34][34][34][34][2];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
//	while (c < '0') c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

void calc(int h, int w)
{
	int r, c;
	memset(s, 0, sizeof(s));
	for (r = 0; r <  h; r++) for (c = 0; c <  w; c++) s[r+1][c+1]  = u[r][c];
	for (r = 0; r <= h; r++) for (c = 0; c <  w; c++) s[r  ][c+1] += s[r][c];
	for (r = 0; r <  h; r++) for (c = 0; c <= w; c++) s[r+1][c  ] += s[r][c];
}

int rect(int r1, int c1, int r2, int c2)
{
    return s[r2+1][c2+1] - s[r2+1][c1] - s[r1][c2+1] + s[r1][c1];
}

void rec(int *xx, int *yy, int r1, int c1, int r2, int c2)
{
	int r, c, x, y, x1, y1, x2, y2;

	if (memo[r1][c1][r2][c2][0]) {
		*xx = memo[r1][c1][r2][c2][0], *yy = memo[r1][c1][r2][c2][1]; return;
	}
    
	x = 1, y = S - sum + rect(r1, c1, r2, c2);

	for (r = r1; r < r2; r++) {
		if (S - sum + rect(r1 , c1, r , c2) < 0) continue;
		if (S - sum + rect(r+1, c1, r2, c2) < 0) continue;
		rec(&x1, &y1, r1 , c1, r,  c2);
		rec(&x2, &y2, r+1, c1, r2, c2);
		if (x < x1+x2) {
			x = x1+x2;
			if (y1 > y2) y1 = y2;
			if (y  > y1) y  = y1;
		} else if (x == x1+x2) {
			if (y1 > y2) y1 = y2;
			if (y  < y1) y  = y1;
		}
	}
	for (c = c1; c < c2; c++) {
		if (S - sum + rect(r1, c1,  r2, c ) < 0) continue;
		if (S - sum + rect(r1, c+1, r2, c2) < 0) continue;
		rec(&x1, &y1, r1, c1 , r2, c );
		rec(&x2, &y2, r1, c+1, r2, c2);
		if (x < x1+x2) {
			x = x1+x2;
			if (y1 > y2) y1 = y2;
			if (y  > y1) y  = y1;
		} else if (x == x1+x2) {
			if (y1 > y2) y1 = y2;
			if (y  < y1) y  = y1;
		}
    }

	*xx = memo[r1][c1][r2][c2][0] = x, *yy = memo[r1][c1][r2][c2][1] = y;
}

int main(void)
{
	int h, w, r, c, ans1, ans2;

	while (h = in()) {
		w = in(), S = in();
		sum = 0; for (r = 0; r < h; r++) for (c = 0; c < w; c++) sum += u[r][c] = in();
		memset(memo, 0, sizeof(memo));
        calc(h, w);
        rec(&ans1, &ans2, 0, 0, h - 1, w - 1);
        printf("%d %d\n", ans1, ans2);
    }
    return 0;
}


Measured memory_bytes: 12212
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			char[] c = br.readLine().toCharArray();
			Arrays.sort(c);
			String max = "", min = "";
			for (int j = 0; j < c.length; j++) {
				min += (c[j] + "");
				max += (c[c.length - j - 1] + "");
			}
			System.out.println(Integer.parseInt(max) - Integer.parseInt(min));
		}

	}

}

Measured memory_bytes: 16884
import math
import fractions
#import sys
#input = sys.stdin.readline

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

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ZipArray(a):
    aa = [[a[i],i]for i in range(n)]

    aa.sort(key = lambda x : x[0])
    for i in range(n):
        aa[i][0]=i+1
    aa.sort(key = lambda x : x[1])
    b=[aa[i][0] for i in range(len(a))]
    return b

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def Zeros(a,b):
    if(b<=-1):
        return [0 for i in range(a)]
    else:
        return [[0 for i in range(b)] for i in range(a)]

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
            
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

#a = list(map(int, input().split()))

#################################################
#################################################
#################################################
#################################################



n,k = list(map(int, input().split()))
a = list(map(int, input().split()))

for i in range(n):
    a[i]-=1

now = 0
count = 0
route = [0]
done = [-1 for i in range(n)]
done[0]= 0
roopStart = -1
roopLen = -1
while(True):
    now = a[now]
    route.append(now)
    count+=1
    if(done[now]>=0):
        roopStart = now
        roopLen = count - done[now]
        break
    else:
        done[now] = count

        
#print(route,roopStart)
#print(done)

if(k<done[roopStart]):
    #print('a')
    print(route[k]+1)
else:
    #print('b',roopStart, roopLen, done[roopStart])
    #print(route)
    print(1+route[done[roopStart] + (k-done[roopStart])%roopLen])























Measured memory_bytes: 115096
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 3000
#define X 1000000007
#define I2 500000004
using namespace std;
int n,m,a[N+5],f[N+5][N+5];
int main()
{
	RI i,j,x,y;for(scanf("%d%d",&n,&m),i=1;i<=n;++i) scanf("%d",a+i);
	for(i=1;i<=n;++i) for(j=1;j<=n;++j) a[i]<a[j]&&(f[i][j]=1);
	for(i=1;i<=m;++i)
	{
		scanf("%d%d",&x,&y),f[x][y]=f[y][x]=1LL*I2*(f[x][y]+f[y][x])%X;
		for(j=1;j<=n;++j) j^x&&j^y&&(f[x][j]=f[y][j]=1LL*I2*(f[x][j]+f[y][j])%X);
		for(j=1;j<=n;++j) j^x&&j^y&&(f[j][x]=f[j][y]=1LL*I2*(f[j][x]+f[j][y])%X);
	}
	RI ans=0;for(i=1;i<=n;++i) for(j=1;j^i;++j) ans=(ans+f[i][j])%X;
	for(i=1;i<=m;++i) ans=2LL*ans%X;return printf("%d\n",ans),0;
}

Measured memory_bytes: 38984
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	string s;
	cin >> s;
	cout << count(all(s), '1') << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static long MOD = 109+7;

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

        int n = sc.nextInt();
        long limitW = sc.nextLong();

        long[] w = new long[n];
        long[] v = new long[n];

        for(int i = 0; i < n; i++) {
            w[i] = sc.nextLong();
            v[i] = sc.nextLong();
        }

        Knapsack knapsack = new Knapsack(n, limitW, w, v);
        System.out.println(knapsack.calc());
    }

    static class Knapsack {
        int n;
        long limitW;
        Item[] items;

        public Knapsack(int n, long limitW, long[] w, long[] v) {
            this.n = n;
            this.limitW = limitW;
            items = new Item[n];
            for(int i =0; i < n; i++) items[i] = new Item(w[i], v[i]);
        }

        public long calc() {
            Arrays.sort(items);

            Map<Long, Long> map = new HashMap();
            map.put(0L, 0L);
            for(Item item: items) {
                Map<Long, Long> curMap = new HashMap();
                for (long key : map.keySet()) {
                    long weight = key + item.w;
                    long value = map.get(key) + item.v;
                    if (weight <= limitW) {
                        curMap.put(weight, value);
                    }
                }

                for (long key : curMap.keySet()) {
                    if (map.containsKey(key)) {
                        map.put(key, Math.max(curMap.get(key), map.get(key)));
                    } else {
                        map.put(key, curMap.get(key));
                    }
                }
            }

            return Collections.max(map.values());
        }
        class Item implements Comparable<Item> {
            long w, v;
            Item(long w, long v) {
                this.w = w;
                this.v = v;
            }

            private double getEfficiency() {
                return 1.0 * v / w;
            }

            @Override
            public String toString() {
                return "w: " + w + ", " + "v: " + v;
            }

            @Override
            public int compareTo(Item o) {
                if(this.getEfficiency() - o.getEfficiency() > 0) return -1;
                else if(this.getEfficiency() - o.getEfficiency() < 0) return 1;
                else {
                    return (int) (o.w - this.w);
                }
            }
        }
    }
}

Measured memory_bytes: 44892
def conbi(n):
  return n*(n-1)/2
N = int(input())
s = list()
count = 0
ans = 0
for i in range(N):
  s.append(input())
  s[i] = sorted(s[i])
s.sort()
for i in range(N-1):
  if s[i] == s[i+1]:
    count += 1
  else:
    ans += conbi(count+1)
    count = 0
ans += conbi(count+1)
print(int(ans))

Measured memory_bytes: 24652
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        s: String
    };
    println!(
        "{}",
        s.split("S")
            .collect::<Vec<_>>()
            .iter()
            .map(|s| s.len())
            .max()
            .unwrap()
    );
}


Measured memory_bytes: 2120
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;
typedef long long ll;
char s[1000005];
struct hhh
{
	int from;
	char h;
	int to;
}arr[1000000];
int main()
{
	scanf("%s", s);
	int q;
	int flag = 0, cnt = 0, head, end;
	scanf("%d", &q);
	head = 0;
	if (strlen(s) == 1)
	{
		arr[0].h = s[0];
		arr[0].to = -1;
		arr[0].from = -1;
	}
	else
	for (int i = 0; i < strlen(s); i++)
	{
		if (i == strlen(s) - 1)
		{
			arr[cnt].from = cnt - 1;
			arr[cnt].h = s[i];
			arr[cnt].to = -1;
			break;
		}
		if (i == 0)
		{
			arr[cnt].from = -1;
			arr[cnt].h = s[i];
			arr[cnt++].to = i + 1;
			continue;
		}
		arr[cnt].from = cnt - 1;
		arr[cnt].h = s[i];
		arr[cnt++].to = i + 1;
	}
	end = cnt;
	while (q--)
	{
		int a;
		scanf("%d", &a);
		if (a == 1)
		{
			flag = (flag + 1) % 2;
		}
		else
		{
			int b;
			char c;
			scanf("%d %c", &b, &c);
			b = (b + flag) % 2;
			if (b == 1)
			{
				cnt++;
				arr[cnt].h = c;
				arr[cnt].to = head;
				arr[cnt].from = -1;
				arr[head].from = cnt;
				head = cnt;
			}
			else if(b == 0)
			{
				cnt++;
				arr[cnt].h = c;
				arr[cnt].to = -1;
				arr[cnt].from = end;
				arr[end].to = cnt;
				end = cnt;
			}
		}
	}
	if (flag == 0)
	{
		for (int i = head; i != -1; i = arr[i].to)
		{
			printf("%c", arr[i].h);
		}
	}
	else
	{
		for (int i = end; i != -1; i = arr[i].from)
		{
			printf("%c", arr[i].h);
		}
	}
	printf("\n");
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REPB(i,n) for(long long i=((n)-1);i>=0;i--)
#define REPB1(i,n) for(long long i=(n);i>0;i--)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();ite++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define REV(arr) reverse(ALL(arr))
typedef long long ll;
typedef pair<int,int> pii;
//---------------------
#define MAXN 100000
//---------------------

ll p,q,r;
ll t[3];
int main(){
	cin>>t[0]>>t[1]>>t[2];
	sort(t,t+3);
	cout<<t[0]+t[1]<<endl;
	return 0;
}

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

int main(void) {
	long long X; cin >> X;

	long long happy = 0;
	happy += (int)(X / 500) * 1000;
	X %= 500;
	happy += (int)(X / 5) * 5;

	cout << happy << endl;

	return 0;
}

Measured memory_bytes: 3604
import sys

MAX = 1000000


def digit_sum(n, b):
    if n == 0:
        return 0
    else:
        return digit_sum(n // b, b) + n % b


def main():
    n = int(input())
    s = int(input())

    if n < s:
        print(-1)
        sys.exit()

    ans = -1

    for b in range(2, min(n + 1, MAX) + 1):
        sm = digit_sum(n, b)
        if sm == s:
            ans = b
            break

    if ans != -1:
        print(ans)
        sys.exit()

    if n + 1 <= MAX:
        print(-1)
        sys.exit()

    for p in reversed(range(1, MAX)):
        if (n - s) % p != 0:
            continue
        b = (n - s) // p + 1
        if b < 2:
            continue
        sm = digit_sum(n, b)
        if sm == s:
            ans = b
            break

    if ans != -1:
        print(ans)
        sys.exit()

    if n == s:
        print(n+1)
        sys.exit()

    print(-1)


if __name__ == '__main__':
    main()


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

const int MOD = 998244353;
const int MAXN = 200005;

int N, p2[MAXN], sub[MAXN];
char x[MAXN];

int main(){
	scanf("%d %s", &N, x);
	for(int i = 0; i < N; i++){
		if(i == 0)p2[i] = 1;
		else p2[i] = 2LL * p2[i - 1] % MOD;
	}
	
	long long res = 0;
	for(int d = N; d >= 1; d--){
		if(d % 2 == 0)continue;
		if(N % d != 0)continue;
		
		int l = N / d;
		
		long long r = 0;
		for(int i = 0; i < l; i++)
			if(x[i] == '1')r = (r + p2[l - i - 1]) % MOD;
	
		bool ok = true;
		for(int i = 0; i < N; i++){
			char y = x[i % l];
			if(i % (2 * l) >= l)y ^= '0' ^ '1';
			
			if(x[i] > y)break;
			else if(x[i] < y){
				ok = false;
				break;
			}
		}
		if(ok)r = (r + 1) % MOD;
		r = (r - sub[d] + MOD) % MOD;
		
		res = (res + 2LL * r * l) % MOD;
		
		for(int d2 = 1; d2 < d; d2++)
			if(d % d2 == 0)sub[d2] = (sub[d2] + r) % MOD;
	}
	printf("%lld\n", res);
	
	return 0;
}


Measured memory_bytes: 1280
# Print a Frame

def draw(h, w):
    for i in range(h):
        for j in range(w):
            if 0 < i < h - 1 and 0 < j < w - 1:
                print('.', end = "")
            else:
                print('#', end = "")
        print()
    return ""

inputEnd = 0
while inputEnd == 0:
    n = [int(i) for i in input().rstrip().split()]
    h = n[0]
    w = n[1]
    if h == 0 and w == 0:
        inputEnd += 1
    else:
        print(draw(h, w))



Measured memory_bytes: 7012
#include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;


int n;
int len;
int N;

int x[10];

bool han(int n){

  if( n == 0 ) return true;
  //桁数 k
  int k= 0;
  for(int i = 0; i < 100 ; i++){
    if(n == 0) break;
    x[i] = n%10;
    n /= 10;
    k++;
  }
  // cout << k << " " ;
  for(int i = 0 ; i < k/2 ; i++ ){
    if(x[i] != x[k-1-i]) return false;
  }
  return true;
}

int main(){

  cin >> n;

  int ansp = n, ansm = n;  
  if(han(n)) cout << n << endl;
  else{
    while(1){

      ansm--;
      if(han(ansm)){
	cout << ansm << endl;
	break;
      }

      ansp++;
      if(han(ansp)){
	cout << ansp << endl;
	break;
      }
    }
  }



  //  han(n);
  return 0;

}
  

 

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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] str = br.readLine().split(" ");
        int a = Integer.parseInt(str[0]);
        int b = Integer.parseInt(str[1]);
        if (a < b) {
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");
        } else if (a == b) {
            System.out.println("a == b");
        }

    }
}

Measured memory_bytes: 24108
#include<stdio.h>
int main (void)
{
    int N,M,i,c=0;
    scanf("%d %d",&N,&M);
    int A[N];
    int S=0;
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
        S+=A[i];
    }
    for(i=0;i<N;i++){
        if(S<=A[i]*4*M)c++;
    }
    if(c>=M)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

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

const int mod = 1000000007;

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

  int n;
  cin >> n;

  string s;
  cin >> s;

  int res = 0;

  char before = '!';
  rep(i, n) {
    if(s[i] != before) res++; 
    before = s[i];
  }


  cout << res << endl;
}


Measured memory_bytes: 1144
#include <iostream>
#include <string>

using namespace std;

int main(void){
	while(1){
		string moji;
		cin >> moji;
		if(moji=="#") break;
		
		char left[] = {'q','w','e','r','t','a','s','d','f','g','z','x','c','v','b'};
		char right[] = {'y','u','i','o','p','h','j','k','l','n','m'};
		bool r=false;
		for(int k=0; k<11; k++){
			if(moji[0]==right[k]){
				r=true;
			}
		}
		
		int count=0;
		for(int i=0; i<moji.size(); i++){
			bool l=true;
			for(int j=0; j<11; j++){
				if(moji[i]==right[j]){
					l=false;
					if(!r){
						r=true;
						count++;
						break;
					}
				}
			}
			if(l&&r){
				r=false;
				count++;
			}
		}
		
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr<<#x <<" "<<x<<endl
int main()
{

   int w , h , n , x_i , y_i , a_i;
   while(cin>>w>>h>>n){

   int BamPass_X = 0, DanPass_X = w, BamPass_Y = 0, DanPass_Y = h;
   while(n--)
   {
      cin>>x_i>>y_i>>a_i;
      if(a_i == 1)  /// x<xi
      {
          BamPass_X = max(BamPass_X, x_i);
          //debug(BamPass_X);
      }
      if(a_i == 2){ /// x>xi
            DanPass_X = min(DanPass_X, x_i);
            //debug(DanPass_X);
      }
      if(a_i == 3) /// y<yi
      {
          BamPass_Y = max(BamPass_Y , y_i);
          //debug(BamPass_Y);
      }
      if(a_i == 4) /// y>yi
      {
          DanPass_Y = min(DanPass_Y , y_i);
          //debug(DanPass_Y);
      }

   }
   int ans =(DanPass_X-BamPass_X)*(DanPass_Y-BamPass_Y);
   if((BamPass_X>=DanPass_X) || (BamPass_Y>=DanPass_Y)){
      cout<<"0"<<endl;
      }
    else cout<<ans<<endl;
   }

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
		
        boolean[] primes = new boolean[55555 + 1];
        Arrays.fill(primes, true);
        for(int i = 2; i * i <= 55555; i++) {
            for(int k = 2; k * i <= 55555; k++) {
            	primes[k * i] = false;
            }
        }
        for(int i = 2, n = 0; i <= 55555 && n < N; i++) {
          	if(primes[i] && i % 5 == 1) {
            	n++;
                System.out.print(i + " ");
            }
        }
    }
}

Measured memory_bytes: 21844
N, M = map(int, input().split(' '))
MOD = 10**9 + 7
if abs(N-M) > 1:
    print(0)
    exit()

ans = 1
for i in range(N):
    ans = ans * (i+1) % MOD
for i in range(M):
    ans = ans * (i+1) % MOD
if N == M:
    ans = ans * 2 % MOD
print(ans)


Measured memory_bytes: 3060
import Control.Applicative
import Data.List

main = do 
	xs <- map (sort . toIntList) . takeWhile (/= "0 0") . lines <$> getContents
	mapM putStrLn $ map showAnswer xs

toIntList :: String -> [Integer]
toIntList = map read . words

showAnswer :: [Integer] -> String
showAnswer (x:y:_) = (show x) ++ " " ++ (show y)


Measured memory_bytes: 4568
#include <bits/stdc++.h>
#define int long long
using namespace std;

int A[8][8];

bool check(int y, int x){
  
  for(int dy=-1;dy<=1;dy++){
    
    for(int dx=-1;dx<=1;dx++){
      
      if( dy == 0 && dx == 0 ) continue;
      
      int ny = y, nx = x;      
      
      while(1){
	
	if( ny < 0 || nx < 0 || 8 <= ny || 8 <= nx ) break;
	
	if( A[ny][nx] != 0 ) return false;
	
	ny += dy;
	nx += dx;
	
      }
      
    }
    
  }
  
  return true;
}

void dfs(int y){
  
  if( y == 8 ){
    
    for(int i=0;i<8;i++){
      
      for(int j=0;j<8;j++){
	
	if( A[i][j] ) cout<<'Q';
	else cout<<'.';
	
      }
      
      cout<<endl;
      
    }
    
    exit(0);
  }
  
  int flg = 0;
    
  for(int j=0;j<8;j++){
    if( A[y][j] == 2 ) flg = 1;
  }
  
  if( !flg ){
    
    for(int j=0;j<8;j++){
      
      if( check( y, j ) == false ) continue;
      
      A[y][j] = 1;
      
      dfs( y + 1 );
      
      A[y][j] = 0;
      
    }
    
  }
  else dfs( y + 1 );
  
}

signed main(){
  
  int n;
  cin>>n;
  
  for(int i=0;i<n;i++){
    
    int y, x;
    cin>>y>>x;
    
    A[y][x] = 2;
    
  }
  
  dfs( 0 );
  
  return 0;
}



Measured memory_bytes: 3104
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl F(10005, 0);
  FOR(x, 1, 101) FOR(y, 1, 101) FOR(z, 1, 101) {
    ll po = (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
    if (po <= 10001)
      F[po]++;
    // if (x == 1 && y == 1 && z == 2)
    //  cout << po << endl;
  }
  REP(i, N) cout << F[i + 1] << endl;
  return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

bool check(int x,int y,vector<string> a,vector<string> b ){
    for(auto i = 0; i<b.size();i++){
        for(auto j =0; j<b.size();j++){
            if(a[x+i][y+j]!= b[i][j]) return false;
        }
    }
    return true;
}

int dist(pii a, pii b){
    return abs(a.first-b.first) + abs(a.second-b.second);
}

bool is_even(string a){
    
    int len = (int)a.size();
    return (a.substr(0,len/2) == a.substr(len/2,len));
    
}

int main() {
    int n;cin>>n;
    int v = 1;
    while(v<=n){
        v*=2;
    }
    if(v>n) v/=2;
    cout<<v<<endl;
    
    return 0;
}







Measured memory_bytes: 256
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
ans = 'No'
for i in range(N-M+1):
    flag1 = False
    for j in range(N-M+1):
        flag = True
        for k in range(M):
            if A[i+k][j:j+M] != B[k]:
                flag = False
                break
        if flag:
            ans = 'Yes'
            flag1 = True
            break
    if flag1:
        break
    
print(ans)

Measured memory_bytes: 38256
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub, itemgetter
import numpy as np

sys.setrecursionlimit(10000)

def read_int():
	return int(sys.stdin.readline().strip())

def read_int_n():
	return [int(x) for x in sys.stdin.readline().strip().split()]

def read_float():
	return float(sys.stdin.readline().strip())

def read_float_n():
	return [float(x) for x in sys.stdin.readline().strip().split()]

def read_str():
	return sys.stdin.readline().strip()

def read_str_n():
	return [str(x) for x in sys.stdin.readline().strip().split()]

def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time
	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap

@mt
def slv(N):
	S = 0
	for i in N:
		S += int(i)
		
	if int(N) % S == 0:
		ans = 'Yes'
	else:
		ans = 'No'
		
	return ans

def main():
	N = read_str()
	print(slv(N))

if __name__ == '__main__':
	main()

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    ll n, k;
    cin >> n >> k;
    ll ans = n % k;
    cout << min(ans, abs(k-ans)) << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
even=[0]*(int(n/2))
odd=[0]*(int(n/2))
inp=list(map(int,input().split()))
for i in range(n):
    if i%2==0:
        even[int(i/2)]=inp[i]
    else:
        odd[int((i-1)/2)]=inp[i]
even.sort()
odd.sort()
def count(lst):
    tmp=cnt=maxcnt=maxi=precnt=0
    for i in lst:
        if tmp==i:
            cnt+=1      
        else:
            if cnt>maxcnt:
                precnt=maxcnt;maxcnt=cnt;maxi=tmp
            else:
                precnt=max(cnt,precnt)
            cnt=1;tmp=i
    if cnt>maxcnt:
        precnt=maxcnt;maxcnt=cnt;maxi=tmp
    else:
        precnt=max(cnt,precnt)
    return maxcnt,precnt,maxi
        
        
ev,od=count(even),count(odd)
if n==2:
    if ev==od:
        print(1)
    else:
        print(0)
    
elif ev[2]!=od[2]:
    print(n-ev[0]-od[0])
else:
    a=n-ev[0]-od[1]
    b=n-od[0]-ev[1]
    print(min(a,b))

Measured memory_bytes: 15172
import java.io.*;
import java.util.*;

public class Main {

    static int N;
    static char[][] S;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        S = new char[N][N];

        for (int i = 0; i < N; i++) {
            String s = sc.next();
            for (int j = 0; j < N; j++) {
                S[i][j] = s.charAt(j);
            }
        }

        System.out.println( solve() );
    }

    static int solve() {
        int ans = 0;
        loop: for (int a = 0; a < N; a++) {
            int b = 0;

            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {

                    if( i == j ) continue;

                    // (i, j) -> (i+a, j+b)
                    // (j, i) -> (j+a, i+b)
                    if( S[(a + i) % N][(b + j) % N] != S[(a + j) % N][(b + i) % N] ) continue loop;
                }
            }
            ans += N;
        }
        return ans;
    }

    @SuppressWarnings("unused")
    static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

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

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}



Measured memory_bytes: 23992
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
vector<pair<int,int> >v;
int main(){
	int a,b;scanf("%d%d",&a,&b);
	if((a-1)*(a-2)/2<b){
		printf("-1\n");return 0;
	}
	for(int i=1;i<a;i++)v.push_back(make_pair(0,i));
	int req=(a-1)*(a-2)/2-b;
	for(int i=1;i<a;i++)for(int j=i+1;j<a;j++){
		if(req==0){
			goto loop;
		}
		req--;
		v.push_back(make_pair(i,j));
	}
	loop:;
	printf("%d\n",v.size());
	for(int i=0;i<v.size();i++)printf("%d %d\n",v[i].first+1,v[i].second+1);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N;
    vec id(N);
    rep(i,N){
        cin>>A;
        --A;
        id[A] = i;
    }
    ll len = 0, temp = 0;
    reps(i,1,N){
        if(id[i] > id[i-1]){
            ++temp;
        }else{
            len = max(len, temp);
            temp = 0;
        }
    }
    cout<<N - max(len, temp) - 1<<endl;
}

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

const int inf = 1e9;
int n, x, y, rp[200010], rd[200010], bp[200010], bd[200010], ans;
vector<int> re[200010], be[200010];

void T_T(){ puts("-1"); exit(0); }

void f(int t, int x, int pr, int de, int *p, int *d){
	if(!t && bd[x] <= de) return;
	d[x] = de;
	p[x] = pr;
	if(t){
		for(auto &i : be[x]){
			if(i != pr) f(t, i, x, de + 1, p, d);
		}
	}
	else{
		for(auto &i : re[x]){
			if(i != pr) f(t, i, x, de + 1, p, d);
		}
	}
}

int main(){
	scanf("%d%d%d", &n, &x, &y);
	auto in = [](int t){
		for(int i = 0, x, y; i < n - 1; i++){
			scanf("%d%d", &x, &y);
			(t ? be[x] : re[x]).push_back(y);
			(t ? be[y] : re[y]).push_back(x);
		}
	};
	in(0); in(1);
	f(1, y, 0, 0, bp, bd);
	fill(rd + 1, rd + n + 1, inf);
	f(0, x, 0, 0, rp, rd);
	for(int i = 1; i <= n; i++){
		for(auto &j : re[i]){
			int a = i, b = j;
			if(bd[a] > bd[b]) swap(a, b);
			if(bp[b] == a || bp[bp[b]] == a || bp[a] == bp[b]) continue;
			if(bd[a] > rd[a] || bd[b] > rd[b]) T_T();
		}
	}
	for(int i = 1; i <= n; i++) if(rd[i] < inf) ans = max(ans, 2 * bd[i]);
	printf("%d\n", ans);
}

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

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main() {
	
	int n;
	int t[101];
	int m;
	cin >> n;
	int sum = 0;
	REP(i, n) {
		cin >> t[i+1];
		sum += t[i + 1];
	}
	cin >> m;

	REP(i, m) {
		int p, x;
		cin >> p >> x;
		cout << sum - t[p] + x<<endl;
	}



	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <cctype>
#include <cmath>
#include <cstring>
#include <climits>
#include <complex>
#include <set>
#include <deque>
#define DEBUG(x) cerr<<"line:"<<__LINE__<<", "<<#x" == "<<(x)<<endl;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(it,s) for(__typeof(s.begin()) it=s.begin();it!=s.end();it++)
#define fst first
#define snd second
#define ALL(a) a.begin(),a.end()
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d%d",&(x),&(y))
#define RIII(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define DRI(x) int (x);scanf("%d",&(x))
#define DRII(x,y) int (x),(y);scanf("%d%d",&(x),&(y))
#define DRIII(x,y,z) int (x),(y),(z);scanf("%d%d%d",&(x),&(y),&(z))
using namespace std;

typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ULL;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;
struct Point{
     int x, y;
     Point(int x = 0, int y = 0) : x(x), y(y) {}
};
typedef Point Vector;
#define INF (int)1e9
#define EPS (1.0e-8)
LL gcd(LL a, LL b) {return !b ? a : gcd(b, a % b);}
LL lcm(LL a, LL b) {return a / gcd(a,b) * b;}
LL qpow(LL a, LL b) {
    LL res = 1;
    while (b > 0) {
        if (b & 1) res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
LL qpow(LL a, LL b, LL mod) {
    a %= mod;
    LL res = 1;
    while (b > 0) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}
// ------------------

const int maxn = 2e5 + 10;
int L[maxn], R[maxn];
int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    // freopen(".in", "r", stdin);
    // freopen(".out", "w", stdout);
#endif
    // DRIII(N, K, C);
    int N, K, C; cin >> N >> K >> C;
    string s; cin >> s;
    int cur = 0;

    REP(i, 0, K) {
        int tmp;
        if (i == 0) {
            tmp = 0;
        }
        else {
            tmp = C;
        }
        while (s[cur] != 'o' || tmp > 0) {
            tmp--;
            cur++; 
        }
        // ok, find one
        L[i] = cur+1;
        cur++;
    }
    // REP(i, 0, K) cout << L[i] << " "; cout << endl;
    
    cur = N-1;
    for (int i = K-1; i >= 0; i--) {
        int tmp;
        if (i == K-1) {
            tmp = 0;
        }
        else {
            tmp = C;
        }
        while (s[cur] != 'o' || tmp > 0) {
            tmp--;
            cur--; 
        }
        // ok, find one
        R[i] = cur+1;
        cur--;
    }
    // REP(i, 0, K) cout << R[i] << " "; cout << endl;

    // REP(i, 0, K) if (L[i] == R[i]) cout << L[i] << ' ';
    REP(i, 0, K) if (L[i] == R[i]) cout << L[i] << endl;

#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

using namespace std;

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)

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

ll n, a, b, ans, h[100001];

bool taosu(ll k) {
  ll cost = 0;
  rep(i, 0, n) {
    ll z = h[i] - b * k;
    if(z > 0) {
      cost += ceil((double)z / (double)(a - b));
      if(cost > k) return false;
    }
  }
  return true;
}

int main() {
  cin >> n >> a >> b;
  rep(i, 0, n) cin >> h[i];
  ll left = 0, right = 1000000000, mid, ans;
  while(left <= right) {
    mid = (left + right) / 2;
    taosu(mid) ? ans = mid, right = --mid : left = ++mid;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

#define FOR(i,m,n) for(ll i=m; i<(ll)n; ++i)
#define REP(i,n) FOR(i,0,n)

ll gcd(ll a, ll b){
  return a%b ? gcd(b, a%b) : b;
}

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

int main(){
  ll n; scanf("%lld", &n);
  vector<ll> t(n);
  REP(i,n) scanf("%lld", &t[i]);
  ll res = t[0];
  FOR(i,1,n) res = lcm(res, t[i]);
  printf("%lld\n", res);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n,x,cnt = 0;
    cin >> n >> x;
    int a[n];
    for(int i = 0;i < n;i++) cin >> a[i];
    
    sort(a,a+n);
    
    if(a[0] > x){
        cout << 0 << endl;
        return 0;
    }
    
    for(int i = 0;i < n;i++){
        if(i != n-1){
        x -= a[i];
        if(x >= 0)
        cnt++;
        if(x <= 0)
        break;
        }else{
            if(x == a[n-1])
            cnt++;
        }
    }
    
    cout << cnt<< endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  rep(i,a,b)for(int i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const int INF=1000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;

ll k=1;
int main() {
	string s;
	cin>>s;
	int ans=INF;
	for(int i=0;i<s.size()-2;++i){
		if(ans>abs(753-(s[i]-'0')*100-(s[i+1]-'0')*10-(s[i+2]-'0'))){
			ans=abs(753-(s[i]-'0')*100-(s[i+1]-'0')*10-(s[i+2]-'0'));
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i, n) for(int i=((int)(n));i>0;i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define LOOP while(true)
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	int X, A, B;
	cin >> X >> A >> B;
	X -= A;
	LOOP{
		if(X - B < 0)break;
		else X -= B;
	}
	cout << X << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	s := make([]int, 3)
	fmt.Scan(&s[0], &s[1], &s[2])

	sort.Ints(s)

	if s[0]+s[1] == s[2] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key) return u;
  if(k<u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key) x=x->left;
    else x=x->right;
  }
    z->parent=y;
    if(y==NIL) root=z;
    else if(z->key<y->key) y->left=z;
    else y->right=z;
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}

void preorder(Node u){
  if(u!=NIL){
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
  }  
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  return 0;
}

Measured memory_bytes: 19364