akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
class Card {
  private:
    char mark;
    int num;
  public:
    Card() {}
    Card(char cardmark, int cardnum) {
      mark = cardmark;
      num = cardnum;
    }
    int getNum() {
      return num;
    }
    char getMark() {
      return mark;
    }
    void print() {
      printf("%c%d", mark, num);
    }
};
void swap(Card *a, Card *b) {
  Card tmp = *a;
  *a = *b;
  *b = tmp;
}
void printCards(Card *arr, int arrsize) {
  for (int i = 0; i < arrsize; i++) {
    arr[i].print();
    if (i == arrsize-1) printf("\n");
    else printf(" ");
  }
}
void cardscpy(Card *arr, Card *org, int arrsize) {
  for (int i = 0; i < arrsize; i++) arr[i] = org[i];
}
void bubbleSort(Card *arr, int arrsize) {
  int flag = 1;
  while (flag) {
    flag = 0;
    for (int i = arrsize - 1; i > 0; i--) {
      if (arr[i].getNum() < arr[i-1].getNum()) {
        swap(&arr[i], &arr[i-1]);
        flag = 1;
      }
    }
  }
}
void selectionSort(Card *arr, int arrsize) {
  int minj = 0;
  for (int i = 0; i < arrsize; i++) {
    minj = i;
    for (int j = i; j < arrsize; j++) {
      if (arr[j].getNum() < arr[minj].getNum()) minj = j;
    }
    swap(&arr[i], &arr[minj]);
  }
}
bool isSame(char *a, char *b, int arrsize) {
  for (int i = 0; i < arrsize; i++) {
    if (a[i] != b[i]) return false;
  }
  return true;
}
void clear(char *arr, int arrsize) {
  for (int i = 0; i < arrsize; i++) arr[i] = '\0';
}
bool isStable(Card *arr, Card *org, int arrsize) {
  char marks1[arrsize],marks2[arrsize];
  int count;
  for (int j = 1; j <= 13; j++) {
    count = 0;
    clear(marks1,arrsize);clear(marks2,arrsize);
    for (int i = 0; i < arrsize; i++) {
      if (arr[i].getNum() == j) {
        marks1[count] = arr[i].getMark();
        count++;
      } else if(arr[i+1].getNum() > j) break;
    }
    count = 0;
    for (int i = 0; i < arrsize; i++) {
      if (org[i].getNum() == j) {
        marks2[count] = org[i].getMark();
        count++;
      }
    }
    if (isSame(marks1,marks2,count)) continue;
    else return false;
  }
  return true;
}
int main() {
  int num,cn;
  Card arr[36],org[36];
  char cm;
  scanf("%d\n", &num);
  for (int i = 0; i < num; i++) {
    if (i == num-1) scanf("%c%d", &cm, &cn);
    else scanf("%c%d ", &cm, &cn);
    Card tmp(cm,cn);
    org[i] = tmp;
    arr[i] = org[i];
  }
  bubbleSort(arr, num);
  printCards(arr, num);
  if (isStable(arr, org, num)) printf("Stable\n");
  else printf("Not stable\n");
  cardscpy(arr,org,num);
  selectionSort(arr, num);
  printCards(arr, num);
  if (isStable(arr, org, num)) printf("Stable\n");
  else printf("Not stable\n");
  return 0;
}



Measured memory_bytes: 2680
<?php
  
$input_line = fgets(STDIN);
$array = explode(" ", $input_line);
$r = $array[0];
$d = $array[1];
$xi = $array[2];

$x;
$tmp;
for ($i = 0; $i < 10; $i ++) {
  $x = $r * $xi - $d;
  $xi = $x;
  
  echo $x . "\n";
}

Measured memory_bytes: 4728
import collections
n = int(input())
s = input()
ans = 0
for l in range(1,n):
  s1 = s[:l]
  s2 = s[l:]
  s1 = collections.Counter(s1)
  s2 = collections.Counter(s2)
  num = 0
  for i in s1:
    if i in s2:
      num += 1
      ans = max(ans,num)
print(ans)

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

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

#define DEBUG(x) cerr << #x << ": " << (x) << endl;

int n,x,a,o;
int m;

struct SCC{
	int n;
	vector<vector<int>> G,rG;
	vector<int> vs, cmp;
	vector<bool> used;

	SCC(int n):n(n),G(n),rG(n),cmp(n){}

	void add_edge(int from, int to){
		G[from].push_back(to);
		rG[to].push_back(from);
	}
	void dfs(int v){
		used[v] = true;
		for(int to : G[v]){
			if(!used[to])dfs(to);
		}
		vs.push_back(v);
	}
	void rdfs(int v, int k){
		used[v] = true;
		cmp[v] = k;
		for(int to : rG[v]){
			if(!used[to])rdfs(to,k);
		}
	}
	int solve(){
		used.assign(n,false);
		vs.clear();
		for(int i=0; i<n; i++){
			if(!used[i])dfs(i);
		}
		used.assign(n, false);
		int k = 0;
		for(int i=(int)vs.size()-1; i>=0; i--){
			if(!used[vs[i]])rdfs(vs[i],k++);
		}
		return k;
	}
	int operator[](int k) const{
		return cmp[k];
	}
};

struct TwoSAT {
	int n;
	SCC scc;
	vector<bool> ans;
	TwoSAT(int n):n(n),scc(n*2),ans(n){}
	void add(int a, int b){
		a = a > 0 ? a-1 : (n-a-1);
		b = b>0 ? b-1 : (n-b-1);
		scc.add_edge((a+n)%(2*n), b);
		scc.add_edge((b+n)%(2*n), a);
	}
	void addng(int a, int b){
		add(-(a+1), -(b+1));
	}
	bool solve(){
		scc.solve();
		for(int i=0; i<n; i++){
			if(scc.cmp[i] == scc.cmp[n+i])return false;
		}
		for(int i=0; i<n; i++){
			ans[i] = scc.cmp[i] > scc.cmp[n+i];
		}
		return true;
	}
};

int main(){
	cin>>n>>x>>a>>o;
	m = 1<<(n+1);
	if(x==0){
		// ng
		puts("No");
		return 0;
	}
	TwoSAT twosat(m);
	int msk = (1<<(n+1))-1;
	REP(i,1<<(n+1)){
		int op = x ^ i;
		twosat.addng(i,op);
		twosat.add(i+1, op+1);
	}
	// and
	REP(i,1<<(n+1)){
		if((i&a)!=a)continue;
		int po = msk ^ i;
		int op = po;
		while(true){
			twosat.addng(i,(i&a) ^ op);
			if(op==0)break;
			op = (op - 1) & po;
		}
	}
	// or
	REP(i,1<<(n+1)){
		if((i|o)!=o)continue;
		int po = i;
		int op = po;
		while(true){
			twosat.addng(i,((~i)&o) ^ op);
			if(op==0)break;
			op = (op - 1) & po;
		}
	}
	if(!twosat.solve()){
		puts("No");
		return 0;
	}
	puts("Yes");
	vector<int> ans;
	REP(i,m)if(twosat.ans[i]){
		ans.push_back(i);
	}
	REP(i,m/2){
		printf("%d%c",ans[i]," \n"[i==m/2-1]);
	}

	// REP(i,1<<(n+1)){
	// 	int op = x ^ i;
	// 	if(twosat.ans[i] && twosat.ans[op]){
	// 		puts("NG");
	// 		DEBUG(i); DEBUG(op);
	// 		return 1;
	// 	}
	// 	twosat.addng(i,op);
	// }
	// // and
	// REP(i,1<<(n+1)){
	// 	if((i&a)!=a)continue;
	// 	int po = msk ^ i;
	// 	int op = po;
	// 	while(true){
	// 		if(twosat.ans[i] && twosat.ans[(i&a) ^ op]){
	// 			puts("NG - and");
	// 			DEBUG(i); DEBUG(((i&a) ^ op));
	// 			return 1;
	// 		}
	// 		twosat.addng(i,(i&a) ^ op);
	// 		if(op==0)break;
	// 		op = (op - 1) & po;
	// 	}
	// }
	// // or
	// REP(i,1<<(n+1)){
	// 	if((i|o)!=o)continue;
	// 	int po = i;
	// 	int op = po;
	// 	while(true){
	// 		if(twosat.ans[i] && twosat.ans[((~i)&o) ^ op]){
	// 			puts("NG - or");
	// 			DEBUG(i); DEBUG((((~i)&o) ^ op));
	// 			return 1;
	// 		}
	// 		twosat.addng(i,((~i)&o) ^ op);
	// 		if(op==0)break;
	// 		op = (op - 1) & po;
	// 	}
	// }
	return 0;
}



Measured memory_bytes: 266988
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main()
{
    while (true) {
        int n, k, s;
        cin >> n >> k >> s;
        if (n == 0 && k == 0 && s == 0) {
            break;
        }

        vector<int> v(n);
        iota(begin(v), end(v), 1);

        int count = 0;

        std::string bitmask(k, 1); // K leading 1's
        bitmask.resize(n, 0);      // N-K trailing 0's

        // print integers and permute bitmask
        do {
            int sum = 0;
            for (int i = 0; i < n; ++i) // [0..N-1] integers
            {
                if (bitmask[i]) {
                    sum += i + 1;
                }

                // std::cout << " " << i;
            }
            if (sum == s) {
                count += 1;
            }
            // std::cout << std::endl;
        } while (std::prev_permutation(bitmask.begin(), bitmask.end()));
        cout << count << endl;
    }
}


Measured memory_bytes: 3200
import sys
from itertools import accumulate
from collections import defaultdict
from operator import mul
from functools import reduce
def input(): return sys.stdin.readline().strip()

def comb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def main():
    N, A, B = map(int, input().split())
    V = list(map(int, input().split()))
    V.sort(reverse=True)

    num_kind = defaultdict(int)
    same_kind = [1] * N
    pre = V[0]
    num_kind[V[0]] += 1
    for i in range(1, N):
        num_kind[V[i]] += 1
        if pre == V[i]:
            same_kind[i] = same_kind[i - 1] + 1
        pre = V[i]

    S = [0] + list(accumulate(V))
    average = defaultdict(int)
    max_val = 0
    for i in range(A, B + 1):
        val = S[i] / i
        if val >= max_val:
            max_val = val
            n, r = num_kind[V[i - 1]], same_kind[i - 1]
            average[max_val] += comb(n, r)
    print(max_val)
    print(average[max_val])



if __name__ == "__main__":
    main()


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

using namespace std;

int arr[105];

int main()
{
  int n;
  cin >> n;
  
  for(int i=1;i<=n;i++)cin >> arr[i];
  
  int ans = INT_MAX;
  
  for(int p=1;p<=100;p++)
  {
    int d=0;
    for(int i=1;i<=n;i++)
    {
      d+=((arr[i]-p)*(arr[i]-p));
    }
    
    ans=min(ans,d);
  }
  
  cout << ans;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> wacnt(n);
    set<int> s;
    int ac = 0, wa = 0;
    for (int i = 0; i < m; i++)
    {
        int p;
        string str;
        cin >> p >> str;
        if (s.count(p))
        {
            continue;
        }
        if (str == "AC")
        {
            s.insert(p);
            ac++;
            wa += wacnt[p - 1];
        }
        else
        {
            wacnt[p - 1]++;
        }
    }
    cout << ac << " " << wa << "\n";
}

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

#define MOD 1000000007

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;

  double do_h = h * 30 + m / 2;
  double do_m = m * 6;
  double rad = abs(do_h - do_m) * M_PI / 180;

  double ans = sqrt(a*a + b*b - 2 * a * b * cos(rad));

  printf("%.20f\n", ans);
}


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


int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    int ans;
    ans = max({a, b, c}) - min({a, b, c});
    cout << ans << endl;
    return 0;
}


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 <ios>
#include <iomanip>

using namespace std;
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;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef tuple<ll,ll,ll> Tl;

int atcoder(){
    //入力
    int n;
    cin >> n;
    int dp[n];
    dp[0]=0;
    
    REP(i,1,n+1){
        int tmp=INT_MAX;
        for(int j=1; i-pow(6,j)>=0; ++j){
            int check = i-pow(6,j);
            chmin(tmp,dp[check]);
        }
        for(int j=1; i-pow(9,j)>=0; ++j){
            int check = i-pow(9,j);
            chmin(tmp,dp[check]);
        }
        chmin(tmp,dp[i-1]);
        dp[i]=tmp+1;
    }
    
    //出力
    cout << dp[n] << ENT;
    return 0;
}

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


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
static const int MAX_N = 200000;

int N, Q; ll S, T;
ll diff[MAX_N + 1];

int main(){
	cin >> N >> Q >> S >> T;
	fill(diff, diff + N, 0);
	ll pos_sum = 0, neg_sum = 0;
	int cur, prev = 0;
	for(int i = 0; i < N + 1; i++){
		cin >> cur;
		diff[i] = cur - prev;
		if(cur - prev > 0) pos_sum += cur - prev;
		else neg_sum += cur - prev;
		prev = cur;
	}
	for(int i = 0; i < Q; i++){
		int l, r, x;
		cin >> l >> r >> x;
		r++;
		if(diff[l] < 0 && diff[l] + x >= 0){
			neg_sum -= diff[l];
			pos_sum += diff[l] + x;
		}else if(diff[l] > 0 && diff[l] + x <= 0){
			pos_sum -= diff[l];
			neg_sum += diff[l] + x;
		}else if(diff[l] + x < 0){
			neg_sum += x;
		}else{
			pos_sum += x;
		}
		diff[l] += x;
		if(r == N + 1) ;
		else if(diff[r] < 0 && diff[r] - x >= 0){
			neg_sum -= diff[r];
			pos_sum += diff[r] - x;
		}else if(diff[r] > 0 && diff[r] - x <= 0){
			pos_sum -= diff[r];
			neg_sum += diff[r] - x;
		}else if(diff[r] - x < 0){
			neg_sum -= x;
		}else{
			pos_sum -= x;
		}
		if(r <= N) diff[r] -= x;
		//for(int i = 0; i < N + 1; i++) cout << diff[i] << endl;
		cout << - pos_sum * S - neg_sum * T << endl;
	}
	return 0;
}



Measured memory_bytes: 4668
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
const ll MOD = 1000000007;
ll modpow (ll radix,ll index){
    if(index == 0)return 1;
    if(index == 1)return radix%MOD;
    ll c;
    c = modpow(radix,index/2);
    c = c * c % MOD;
    if(index % 2){
        return c * radix % MOD;
    }else{
        return c;
    }
}
int main(){
    ll N,ans=0;
    cin >> N;
    vector<ll>A(N);
    REP(i,N){
        cin>>A[i];
        (ans+=modpow(A[i],MOD-2))%=MOD;
    }
    for(int i = 2; i*i <= 1e6;i++){
        int cnt = 0;
        for(int j=0;j<N;j++){
            int now=0;
            while(A[j]%i==0){
                now++;
                A[j]/=i;
            }
            if(cnt < now)cnt = now;
        }
        (ans*=modpow(i,cnt))%=MOD;
    }
    REP(i,N){
        if(A[i]>1){
            REP2(j,i+1,N){
                if(A[i]==A[j])A[j]=1;
            }
            (ans*=A[i])%=MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	min, max := 1 << 30, 0
	for i := 0; i < n; i++ {
		a := nextInt()
		if min > a {
			min = a
		}
		if max < a {
			max = a
		}
	}

	fmt.Println(max - min)
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){
    int N;
    scanf("%d",&N);
    if(N>=1&&N<=9){
        printf("%d\n",N);
    }
    else if(N>=10&&N<=99){
        printf("9\n");
    }
    else if(N>=100&&N<=999){
        printf("%d\n",N-90);
    }
    else if(N>=1000&&N<=9999){
        printf("909\n");
    }
    else if(N>=10000&&N<=99999){
        printf("%d\n",N-9090);
    }
    else{
        printf("90909\n");
    }
    return 0;
    
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

using namespace std;

int main() {
  int N;
  cin >> N;
  int a[N];
  REP(i, N) cin >> a[i];

  int result = 0;

  REP(i, N) { result = result ^ a[i]; }

  if(result == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    vi v;
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        v.pb(k);
    }
    sort(v.rbegin(),v.rend());
    int ans=0;
    ans+=1;
    int t=v[0];
    for(int i=1;i<n;i++){
        if(v[i]<t){
            ans+=1;
            t=v[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque

def bfs():
    dist = [[f_inf] * w for _ in range(h)]
    
    D = ((1,0), (0,1), (-1,0), (0, -1))

    que = deque([])
    que.append((0, 0))
    dist[0][0] = 0

    while que:
        p = que.popleft()
        for d in D:
            nx = p[0] + d[0]
            ny = p[1] + d[1]

            if h > nx >= 0 and w > ny >= 0 and \
               C[nx][ny] != '#' and \
               dist[nx][ny] == f_inf:
                que.append((nx, ny))
                dist[nx][ny] = dist[p[0]][p[1]]+1
    return dist[h-1][w-1]

h, w = map(int, input().split())
C =[input() for _ in range(h)]
f_inf = float('inf')

cnt = 0
for c in C:
    cnt += c.count('.')

if bfs() == f_inf:
    print(-1)
else:
    print(cnt - 1 - bfs())



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

using namespace std;

#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define INF 0x3f3f3f3f
#define f1(n) for(int i=0 ; i<n ; i++)
#define f2(m) for(int j=0 ; j<m ; j++)
#define ll long long
typedef pair<int, int> iPair;
const double epsilon = 1e-7;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int y = n / 1000;
  int res;
  if (y * 1000 == n) res = 0;
  else res = (y + 1) * 1000 - n;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
ll dp[55][55][2505]={0};
int main(){
  ll n,a;
  cin>>n>>a;
  dp[0][0][0]=1;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    for(int j=0;j<=i;j++){
      for(int k=0;k<2505;k++){
        dp[i+1][j][k]+=dp[i][j][k];
        if(k+x<2505) dp[i+1][j+1][k+x]+=dp[i][j][k];
      }
    }
  }
  ll ans=0;
  for(int i=1;i<=n;i++) ans+=dp[n][i][a*i];
  cout<<ans<<endl;
}


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

#define endl '\n'
#define int ll
using namespace std;
typedef long long ll;

const int N = 303;

int n, m;
int peo[N][N];

void init();
void process();

int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n >> m;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            cin >> peo[i][j];
}

void process()
{
    int mn = N;
    int ptr[N] = {0};
    int cnt[N] = {0};
    bool shutdown[N] = {false};

    for(int i = 0; i < n; i++) cnt[peo[i][ptr[i]]]++;

    for(int t = 0; t < m; t++)
    {
        int mx = 0, idx = -1;
        for(int i = 1; i <= m; i++) 
        {
            if(cnt[i] > mx) mx = cnt[i], idx = i;
        }
        mn = min(mn, mx);
        cnt[idx] = 0;
        shutdown[idx] = true;
        if(t == m-1) break;
        for(int i = 0; i < n; i++)
        {
            if(shutdown[peo[i][ptr[i]]])
            {
                while(shutdown[peo[i][ptr[i]]]) ptr[i]++;
                cnt[peo[i][ptr[i]]]++;
            }
        }
    }

    cout << mn << endl;
}



Measured memory_bytes: 1024
#include <stdio.h>
const int N=1e5+10;
int main(){
    int n,a[N],l,r,mid,q,temp,up,lo;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    scanf("%d",&q);
    while(q--){
        scanf("%d",&temp);
        if(a[n-1]<temp)lo=n;
        else if(a[0]>=temp)lo=0;
        else{
            l=0;
            r=n-1;
            while(r-l>1){
                mid=(r+l)>>1;
                if(a[mid]>=temp)r=mid;
                else l=mid;
            }
            lo=r;
        }
        if(a[n-1]<=temp)up=n;
        else if(a[0]>temp)up=0;
        else{
            l=0;
            r=n-1;
            while(r-l>1){
                mid=(r+l)>>1;
                if(a[mid]>temp)r=mid;
                else l=mid;
            }
            up=r;
        }
        printf("%d %d\n",lo,up);
    }
}


Measured memory_bytes: 3120
import java.util.Scanner;
public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        
        if((x + r) > W || (y + r) > H || (x - r) < 0 || (y - r) < 0){
        	System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 26324
ans :: Int -> Int -> Int -> Int
ans n a b
 	| diff `mod` 2 == 0 = diff `div` 2
	| a' > (n - b')     = n - a' + diff `div` 2 + 1
	| otherwise         = b' + diff `div` 2 + 1
	where
		a' = max a b
		b' = min a b
		diff = a' - b'

main :: IO ()
main = do
	[n, a, b] <- map read . words <$> getLine :: IO [Int]
	print $ ans (n - 1) (a - 1) (b - 1)


Measured memory_bytes: 508
// {{{ Template for Competitive Programming
// -std=c++14 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FOR(i, a, b)  for (int(i) = (a); (i) < (b); ++(i))
#define CFOR(i, a, b) for (int(i) = (a); (i) <= (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) >= (b); --(i))
#define rep(i, n) FOR((i), 0, (n))
#define crep(i, n) CFOR((i), 0, (n))
#define rrep(i, n) RFOR((i), (n), 0)
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(ALL(x), 0)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1'010'000'000'000'000'017LL;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

using vint = vector<int>;
using pint = pair<int, int>;
// }}}

int ceil(int a, int b) {
	return (a + (b - 1)) / b;
}

signed main() {
	string s;
	cin >> s;
	int n = s.size();
	vint a(n);

	int pos = 0;

	while (!s.empty()) {
		int r_cnt = 0;
		while (s[0] == 'R') {
			s.erase(0, 1);
			pos++;
			r_cnt++;
		}
		int r_pos = pos - 1;

		int l_cnt = 0;
		while (s[0] == 'L') {
			s.erase(0, 1);
			pos++;
			l_cnt++;
		}
		int l_pos = r_pos + 1;

		a[r_pos] = ceil(r_cnt, 2) + l_cnt / 2;
		a[l_pos] = ceil(l_cnt, 2) + r_cnt / 2;
	}

	rep(i, n) {
		cout << a[i];
		if (i != n-1) cout << ' ';
		else cout << endl;
	}

}



Measured memory_bytes: 1536
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    int n,k; cin >> n >> k;
    int x;

    int ans = 0;

    for(int i = 0;i < n;i ++){
        cin >> x;

        if(x < k-x) ans += x * 2;
        else ans += k*2-x*2;
    }
    cout << ans << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); --i)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    string T; cin >> T;

    string res = "";
    F0R(i,sz(T)) {
        if (T[i] == '?') {
            if (i-1 >= 0 && T[i-1] == 'P') res += "D";
            else {
                if (i+1 < sz(T) && (T[i+1] == 'D' || T[i+1] == '?')) {
                    res += "PD"; i++;
                } else res += "D";
            }
        } else res += T[i];
    }

    assert(sz(res) == sz(T));

    cout << res << "\n";

}


Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
const int D = 8003;
bool dp[D][2*D];

bool simu(vector<int> &v,int start,int goal){
    int m = v.size();
    
    rep(i,D)rep(j,2*D)dp[i][j] = false;
    
    dp[0][D] = true;
    rep(i,m)rep(j,2*D){
        if(j+v[i]<=2*D-1)dp[i+1][j+v[i]] |= dp[i][j];
        if(j-v[i]>=0)dp[i+1][j-v[i]] |= dp[i][j];
    }
    //rep(j,2*D)cout << j << " " << dp[m][j] << endl;
    int hoge = D+goal-start;

    if(hoge >=0 && hoge < 2*D)return dp[m][hoge];
    else return false;
}
signed main(){
    string s;cin >> s;
    int x,y;cin >> x >> y;
    vector<int> joge,sayu;
    int sx = 0,sy = 0;
    int n = s.size();
    int now = 0;
    int ccnt = 0;
    rep(i,n){
        if(s[i] =='F')now++;
        else {
            if(ccnt == 0)sx = now;
            else{
            if(ccnt%2)joge.push_back(now);
            else sayu.push_back(now);
            }
            ccnt++;
            now = 0;
        }
    }
    if(ccnt == 0)sx = now;
    else{
    if(ccnt%2)joge.push_back(now);
    else sayu.push_back(now);
    }
    //for(auto e:joge)cout << e << endl;
    //for(auto e:sayu)cout << e << endl;
    bool ok1 = simu(sayu,sx,x);
    rep(i,D)rep(j,2*D)dp[i][j] = false;
    bool ok2 = simu(joge,sy,y);
    if(ok1 && ok2)cout<< "Yes" << endl;
    else cout << "No" << endl;



    return 0;
}


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

int main(){
    ll A,B;
    
    cin >> A >> B;
    if(A < B){
        ll tmp = A;
        A = B;
        B = tmp;
    }
    if(A == B){
        cout << 2 * A << "\n";
        return 0;
    }
    cout << A + A - 1 << "\n";
    return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;

//入力
ll n;

int main(){
    cin >> n;
    vector<P> ans;
    if(n%2==0){
        for(int i=1;i<n;i++){
            for(int j=i+1;j<=n;j++){
                if(i+j==n+1)continue;
                ans.push_back({i,j});
            }
        }
    }
    else{
        for(int i=1;i<n;i++){
            for(int j=i+1;j<=n;j++){
                if(i+j==n)continue;
                ans.push_back({i,j});
            }
        }
    }
    ll m = ans.size();
    cout << m << endl;
    rep(i,m){
        cout << ans[i].first << ' ' << ans[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 3684
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner stdin=new Scanner(System.in);
		int a=stdin.nextInt();
		int b=stdin.nextInt();

		String s;
//		String t="0";
//		String s_a=""+a;
//		String s_b=""+b;
		StringBuffer sb=new StringBuffer();
		sb.append(a);
		sb.append(b);
		s=sb.toString();
		int check=Integer.parseInt(s);
//		System.out.println(check);
		int flag=0;
		for(int i=1;i<1000;i++)
			if(check==i*i)
				flag=1;

		if(flag==1)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}

Measured memory_bytes: 23124
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	Info(ll arg_value){
		value = arg_value;
	}
	bool operator<(const struct Info &arg) const{
		return value < arg.value;
	};
	ll value;
};

int main(){

	ll N;
	ll P,Q,tmp;

	scanf("%lld %lld %lld",&N,&P,&Q);

	priority_queue<Info> PQ;

	for(ll i = 1; i <= N; i++){
		scanf("%lld",&tmp);
		PQ.push(Info(tmp+P*(i-1)));
	}

	ll sum = 0;
	ll num_self = N;
	ll ans = P*(num_self*Q + num_self*(num_self-1));

	while(!PQ.empty()){
		num_self--;
		sum += PQ.top().value;
		ans = max(ans,sum+P*(num_self*Q+num_self*(num_self-1)));
		PQ.pop();
	}

	ans -= P*(((N)*(N-1))/2);

	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 7004
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const ll INF = 1LL << 60;

const int m = 10;

int main(){
  ll n; cin >> n;
  vvi f(n,vi(m)); rep(i, n) rep(j, m) cin >> f[i][j];
  vvi p(n,vi(m+1)); rep(i, n) rep(j, m+1) cin >> p[i][j];

  int ans = -1e9;
  for (int bit = 1; bit < (1 << m); bit++) {
    int sum = 0;
    rep(i, n){
      int cnt = 0;
      rep(j, m){
        if(bit & (1 << j)) if(f[i][j]) cnt++;
      }
      sum += p[i][cnt];
    }
    chmax(ans, sum);
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int main(){
    int n;
    cin >> n;
    cout << 180*(n-2) << endl;
    return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = s; i < (int)(n); ++i)
using namespace std;
using ll = long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
constexpr int INF = 1e9 + 7;
constexpr ll LINF = 1LL << 60;

int dp[1005][10005];

void solve() {
    int H, n;
    cin >> H >> n;
    V<int> a(n);
    V<int> b(n);
    rep(i, n) { cin >> a[i] >> b[i]; }
    rep(i, n + 1) fill(dp[i], dp[i] + H + 1, INF);
    rep(i, n + 1) dp[i][0] = 0;

    rep(i, n) {
        rep(h, H + 1) {
            int nh = max(0, h - a[i]);
            dp[i + 1][h] = min(dp[i][h], dp[i + 1][nh] + b[i]);
        }
    }
    cout << dp[n][H] << "\n";
}
int main() {
    cin.tie(nullptr);
    // ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 42760
#include<bits/stdc++.h>
using namespace std;
void solve()
{
	//1
	int N,M;
	cin>>N>>M;
	if(N==0)exit(0);
	int A[100],W[10]={0,0,0,0,0,0,0,0,0,0};
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
	}
	for(int i=0;i<M;i++)
	{
		cin>>W[i];
	}

	vector<int>diffs;
	for(int i0=0;i0<3;i0++)
		for(int i1=0;i1<3;i1++)
			for(int i2=0;i2<3;i2++)
				for(int i3=0;i3<3;i3++)
					for(int i4=0;i4<3;i4++)
						for(int i5=0;i5<3;i5++)
							for(int i6=0;i6<3;i6++)
								for(int i7=0;i7<3;i7++)
									for(int i8=0;i8<3;i8++)
										for(int i9=0;i9<3;i9++)
	{
		int W_L=0,W_R=0;
		if(i0==1)W_L=W_L+W[0];
		else if(i0==2)W_R=W_R+W[0];
		if(i1==1)W_L=W_L+W[1];
		else if(i1==2)W_R=W_R+W[1];
		if(i2==1)W_L=W_L+W[2];
		else if(i2==2)W_R=W_R+W[2];
		if(i3==1)W_L=W_L+W[3];
		else if(i3==2)W_R=W_R+W[3];
		if(i4==1)W_L=W_L+W[4];
		else if(i4==2)W_R=W_R+W[4];
		if(i5==1)W_L=W_L+W[5];
		else if(i5==2)W_R=W_R+W[5];
		if(i6==1)W_L=W_L+W[6];
		else if(i6==2)W_R=W_R+W[6];
		if(i7==1)W_L=W_L+W[7];
		else if(i7==2)W_R=W_R+W[7];
		if(i8==1)W_L=W_L+W[8];
		else if(i8==2)W_R=W_R+W[8];
		if(i9==1)W_L=W_L+W[9];
		else if(i9==2)W_R=W_R+W[9];

		int diff=abs(W_L-W_R);
		diffs.push_back(diff);
	}
	sort(diffs.begin(),diffs.end());
	diffs.erase(unique(diffs.begin(),diffs.end()),diffs.end());

	//2,3
	vector<int>Y;
	bool first=true;
	for(int i=0;i<N;i++)
	{
		vector<int>X;
		bool flag=false;
		for(int j=0;j<diffs.size();j++)
		{
			int diff=diffs.at(j);
			X.push_back(diff+A[i]);
			if(diff>=A[i])
			{
				X.push_back(diff-A[i]);
			}
			else
			{
				X.push_back(A[i]-diff);
			}
			if(diff==A[i])
			{
				flag=true;
			}
		}
		if(flag==false)
		{
			sort(X.begin(),X.end());
			X.erase(unique(X.begin(),X.end()),X.end());

			if(first==true)
			{
				first=false;
				Y=X;
			}
			else
			{
				vector<int>result;
				set_intersection(Y.begin(),Y.end(),
								X.begin(),X.end(),
								inserter(result,result.end()));
				Y=result;
			}
		}
	}
	if(first==true)
	{
		cout<<0<<endl;
	}
	else
	{
		if(Y.size()==0)
		{
			cout<<-1<<endl;
		}
		else
		{
			cout<<Y[0]<<endl;
		}
	}
}
int main()
{
	while(true)
	{
		solve();
	}
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    string s;
    cin>>s;

    stack<char> st;
    rep(i,n){
        if(!st.empty()){
            char x = st.top();
            if(x=='(' && s[i]==')'){
                st.pop();
            }else{
                st.push(s[i]);
            }
        }else{
            st.push(s[i]);
        }
    }
    string a;
    string b;
    while (!st.empty()){
        char x = st.top();
        st.pop();
        if(x==')'){
            a += '(';
        }else{
            b += ')';
        }
    }
    cout<<a+s+b<<endl;
    return  0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#define N  3
#define N2 9
using namespace std;
struct Puzzle{
	int f[N2];
	int space;
	string path;
	bool operator < (const Puzzle &p) const 
	{
		for (int i = 0; i < N2; ++i)
		{
			if (f[i] == p.f[i]) continue;
			return f[i] < p.f[i];			
		}
		return false;
	}
};

static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char dir[4] = {'u','l','d','r'};

bool isTarget(Puzzle p)
{
	for (int i = 0; i < N2; ++i)
	{
		if (p.f[i] != (i+1)) return false;
	}
	return true;
}

string bfs(Puzzle s)
{
	queue<Puzzle> Q;
	map<Puzzle, bool> V;
	Puzzle u,v;
	s.path = "";
	Q.push(s);
	V[s] = true;
	while(!Q.empty())
	{
		u = Q.front(); Q.pop();
		if (isTarget(u)) return u.path;
		int sx = u.space / N;
		int sy = u.space % N;
		for (int r = 0; r < 4; ++r)
		{
			int tx = sx + dx[r];
			int ty = sy + dy[r];
			if( tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
			v = u;
			swap(v.f[u.space], v.f[tx * N + ty]);
			v.space = tx * N + ty;
			if (!V[v])
			{

				V[v] = true;
				v.path += dir[r];
				Q.push(v);
			}
		}
	}
	return "unsolvable";
}

int main()
{
	Puzzle in;
	for (int i = 0; i < N2; ++i)
	{
		cin>>in.f[i];
		if (in.f[i]==0) {
			in.space = i;
		        in.f[i] = 9;
		}
	}
	string ans = bfs(in);
	cout<<ans.size()<<endl;
	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define _A_ true

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

struct Data {
  ll v;
  ll cnt;
};

int main() {
  string s;
  cin >> s;
  long long K;
  cin >> K;
  vector<Data> vec;
  int n= s.size();
  bool other = false;
  int not_one = 1;
  rep(i,n) {
    if( s[i]-'0' != 1 ) {
      other = true;
      if( not_one == 1 ) {
	not_one = s[i]-'0';
      }
    }
  }
  if( other == false ) {
    puts("1");
    return 0;
  }
  ll leading_one = 0;
  rep(i,(int)s.size()) {
    if( s[i] != '1' ) break;
    ++leading_one;
  }
  if( leading_one >= K ) {
    puts("1");
    return 0;
  }
  cout << not_one << endl;  

  
  compute();
  return 0;
}


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

using namespace std;

#define int long long

int f(int i,int x = 10) {
	int ans = 1;
	while(i--)  ans *= x;
	return ans;
}

signed main()   {
	int s = 0;
	for(int i = 1 ; i < 11 ; ++i)   {
		cout << "? " << f(i) << "\n";
		cout.flush();
		char c; cin >> c;
		if(c == 'N')    {
			s = i;
			break;
		}
	}
	
	if(s == 0)
		for(int i = 1 ; i < 11 ; ++i)   {
			cout << "? " << f(i) - 1 << "\n";
			cout.flush();
			char c; cin >> c;
			if(c == 'Y')    {
				cout << "! " << f(i - 1) << "\n";
				cout.flush();   exit(0);
			}
		}
	
	int L = f(s - 1), R = f(s) - 1;
	
	while(L != R)   {
		int M = (L + R) / 2;
		cout << "? " << M * 10 << "\n";
		cout.flush();
		char c; cin >> c;
		if(c == 'Y')
			R = M;
		else
			L = M + 1;
	}
	
	cout << "! " << L << "\n";
	cout.flush();
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll n; cin >> n;
    vector<ll> a(n);
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (i != 0) {
            ll gap = max((ll)0, a[i - 1] - a[i]);
            a[i] += gap;
            ans += gap;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    ll n;
    cin >> n;
    ll ans = n;
    for(ll i = 1;i*i<=n;i++){
        if(n%i==0){
            ans = min(ans,n/i+i-2);
        }
    }
    cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b, p=0; cin>>a>>b;
	for(int i=0; i<=a; i++){
		if(2*i + 4*(a-i) == b) {
			cout<<"Yes\n"; p=1;
		}
	}
	if(p==0) cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3604
n = int(input())
s = input()

left = ""
right = ""

if n % 2 == 1:
    print("No")
else:
    for i in range(0, int(n / 2)):
        left += s[i]
    for j in range(int(n / 2), n):
        right += s[j]
    
    if left == right:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll base = 1'000'000'000 + 7;
ll ans;
ll powermod(ll a, ll b)
{
	ll ret = 1;
	while (b)
	{
		if (b & 1) ret = (ret * a) % base;
		a = (a * a) % base; b >>= 1;
	}
	return ret;
}
ll f0(ll f, ll v)
{
	ll c = (9 * powermod(10, f - 1)) % base;
	if (f >= 10 || v <= c) return (c - v + 1) % base;
	return 0;
}
// returns g = gcd(a, b); finds x, y such that d = ax + by
ll extended_euclid(ll a, ll b, ll& x, ll& y) {
	ll xx = y = 0;
	ll yy = x = 1;
	while (b) {
		ll q = a / b;
		ll t = b; b = a % b; a = t;
		t = xx; xx = x - q * xx; x = t;
		t = yy; yy = y - q * yy; y = t;
	}
	return a;
}
ll flr(ll u, ll d)
{
	ll q = u / d, r = u % d;
	if (r < 0) q--;
	return q;
}
// # of sols ax+by=z with 1<=x<=xlim, 1<=y<=ylim
ll f2(ll a, ll xlim, ll b, ll ylim, ll z)
{
	ll x0, y0;
	ll g = extended_euclid(a, b, x0, y0);
	if (z % g) return 0;
	x0 *= (z / g); y0 *= (z / g);
	ll dx = b / g, dy = a / g;
	// x0+k*dx, y0-k*dy is a solution
	ll maxk = min(flr(xlim - x0, dx), flr(y0 - 1, dy));
	ll mink = max(flr(dx - x0, dx), flr(y0 - ylim + dy - 1, dy));
	return mink <= maxk ? (maxk - mink + 1) % base : 0;
}
ll f1(ll x0, ll y0, ll f)
{
	ll maxk = flr(x0 - 1, f + 1);
	ll mink = flr(f - y0, f);
	return mink <= maxk ? (maxk - mink + 1) % base : 0;
}
int main()
{
	ll N;
	scanf("%lld", &N);
	{
		// f(l) = f(r)
		for (ll f = 1; f * f <= N; f++)
		{
			if (N % f == 0)
			{
				ans = (ans + f0(f, N / f)) % base;
				if (f < N / f)
				{
					ans = (ans + f0(N / f, f)) % base;
				}
			}
		}
	}
	{
		// f(r) - f(l) >= 2
		ll c[16] = { 0, };
		c[1] = 9;
		for (int i = 2; i <= 12; i++) c[i] = c[i - 1] * 10;
		for (int s = 2; c[s] * s < N; s++)
		{
			ll T = 0;
			for (int e = s; c[e] * e < N; e++)
			{
				T += c[e] * e;
				if (T >= N) break;
				if ((s - 1) * c[s - 1] + T + (e + 1) * c[e + 1] < N) continue;
				ans = (ans + f2(s - 1, c[s - 1], e + 1, c[e + 1], N - T)) % base;
			}
		}
	}
	{
		// f(l) + 1 = f(r)
		ll c = 9;
		for (ll f = 1; f + (f + 1) <= N && f <= 9; f++)
		{
			if (f <= 9 && f * c + (f + 1) * c * 10 < N)
			{
				c = (c * 10) % base;
				continue;
			}
			ans = (ans + f2(f, c, f + 1, c * 10, N)) % base;
			c = (c * 10) % base;
		}
		ll flim = 9;
		for (ll f = 10; f * f <= N && f + (f + 1) <= N; f++)
		{
			ll q = N / f, r = N % f;
			ans = (ans + f1(q - r, r, f)) % base;
			flim = f;
		}
		for (ll q = 2;; q++)
		{
			ll sf = max(flim, N / (q + 1)) + 1, ef = N / q;
			if (sf > ef) break;
			for (ll f = ef, r = N % ef; r < q && f >= sf; f--, r += q)
			//for(ll f=sf;f<=ef;f++)
			{
				//ll r = N % f;
				ans = (ans + f1(q - r, r, f)) % base;
			}
		}
	}
	printf("%lld\n", ((ans % base) + base) % base);
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#define _CRT_DISABLE_PERFCRIT_LOCKS
#include <bits/stdc++.h>

using namespace std;
#define BOOST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define fileIn freopen("1.txt", "r", stdin)
#define fileOut freopen("output.txt", "w", stdout)
#define dbg(n) cout << n <<"\n"
#define dbg2(n) cout << n <<" "
#define all(a) a.begin(), a.end()
#define cinArr(arr) for(auto &v : arr) cin>>v
#define coutArr(arr) for(auto &v : arr) cout<<v<<" "
#define FOR(i, a, b) for(int i = a; i < b; i++)
typedef int64_t ll;
typedef uint64_t ull;
typedef vector<int> vi;
typedef vector<vi > vii;


int main()
{
    BOOST;
    int n;
    cin>>n;
    int ans = 1, mx;
    cin>>mx;
    FOR(i, 1, n){
        int tmp;
        cin>>tmp;
        if(tmp >= mx) mx = tmp, ans++;
    }
    cout<<ans;
    return 0;
}





















Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    
    let fizzbuzz = [];
    
    for(let i=1; i<1000000; i++) {
        if(i % 3 === 0 && i % 5 === 0) {
            fizzbuzz.push(0);
        } else if(i % 3 === 0) {
            fizzbuzz.push(0);
        } else if(i % 5 === 0) {
            fizzbuzz.push(0);
        } else {
            fizzbuzz.push(i);
        }
    }
    
    //console.log(fizzbuzz);
    console.log(fizzbuzz.slice(0, N).reduce((m,n)=>m+n));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 72376
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if(a == b)swap(a, c);
	else if(a == c)swap(a, b);
	printf("%d\n", a);
	
	Please AC;
}


Measured memory_bytes: 256