akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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 long long INF = 1LL << 60;

int main(){
  ll n, m; cin >> n >> m;

  if(n>1) n -= 2;
  if(m>1) m -= 2;

  cout << m*n << endl;

  return 0;
}


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

int main() {
  int n, m; cin >> n >> m;
  vector<pair<int, int>> v(n);
  int a, b;
  for(int i=0; i<n; ++i){
     cin >> a >> b;
     v[i] = pair<int, int>(a, b);
   }

  sort(v.begin(), v.end());

  map<int, int> ma;
  long long ans = 0;
  int index = 0;
  for(int d = 2; d<=m+1; ++d){
    while(v[index].first < d && index < n){
      ma[v[index].second]++;
      ++index;
    }

    if(ma.size() > 0){
      auto f = ma.end(); f--;
      ans += f->first;
      f->second--;
      //cout << f->first << " ** " << f->second << endl;
      if(f->second == 0) ma.erase(f);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <algorithm>

#define lli long long int

using namespace std;

int main() {
	lli a, b, q, s[100010], t[100010], x, a1, a2, b1, b2, left, right, mid, ans;
	scanf("%lld %lld %lld", &a, &b, &q);
	s[0] = -1000000000000;
	t[0] = -1000000000000;
	s[a + 1] = 1000000000000;
	t[b + 1] = 1000000000000;
	for (lli i = 1; i <= a; i++)
		scanf("%lld", &s[i]);
	for (lli i = 1; i <= b; i++)
		scanf("%lld", &t[i]);
	while (q--) {
		scanf("%lld", &x);
		left = 1;
		right = a;
		a1 = 0;
		while (left <= right) {
			mid = (left + right) / 2;
			if (s[mid] < x) {
				a1 = mid;
				left = mid + 1;
			}
			else
				right = mid - 1;
		}
		a2 = a1 + 1;
		left = 1;
		right = b;
		b1 = 0;
		while (left <= right) {
			mid = (left + right) / 2;
			if (t[mid] < x) {
				b1 = mid;
				left = mid + 1;
			}
			else
				right = mid - 1;
		}
		b2 = b1 + 1;
		ans = min(x - min(s[a1], t[b1]), max(s[a2], t[b2]) - x);
		ans = min(ans, s[a2] - t[b1] + min(x - t[b1], s[a2] - x));
		ans = min(ans, t[b2] - s[a1] + min(x - s[a1], t[b2] - x));
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2816
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();
        int count = 0;

        if(a >= k){
            a = a - k;
        }else{
            k = k - a;
            a = 0;
            if(b >= k){
                b = b - k;
            }else{
                b = 0;
            }
        }

        System.out.print(a + " " + b);
    
	}
}

Measured memory_bytes: 22740
#!/usr/bin/env python3
import sys
from collections import defaultdict
INF = float("inf")


def bit_sum(n):
    return bin(n).count("1")


def solve(N: int, A: "List[int]", B: "List[int]"):

    DP = [[INF]*51 for _ in range(1 << N)]
    DP[0][0] = 0

    for bit in range(1 << N):

        ketawa = bit_sum(bit)

        # bit集合で表現されない値の位置を確認する
        rest = []
        counter = ketawa
        for i in range(N):
            if bit & (1 << i):
                continue
            rest.append((i, counter))
            counter += 1

        # 最後の数がsである場合から配るDP
        for s in range(51):
            if DP[bit][s] == INF:
                continue
            for orig, curr in rest:
                # 元の並びでorig番目にあったカードをketawa番目に移動する。
                # 表の値が確定する
                if (orig-ketawa) % 2 == 0:
                    front = A[orig]
                else:
                    front = B[orig]
                # 値がs以上なら、単調増加にできる
                if front >= s:
                    DP[bit | 1 << orig][front] = min(DP[bit | 1 << orig][front],
                                                     DP[bit][s]+abs(curr-ketawa))
    ans = min(DP[-1])
    if ans == INF:
        print(-1)
    else:
        print(ans)


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 409920
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <random>

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

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

#define INF 1000000

ll evalNow(vector<vector<int>>& s, vector<int>& c, vector<int>& t, int d, vector<int> last) {
    ll ans = 0;
    ans += s[d][t[d]-1];
    last[t[d]-1] = d+1;
    rep(j, 26) {
        ans -= c[j]*(d+1 - last[j]);
    }
    return ans;
}

ll evalAll(vector<vector<int>>& s, vector<int>& c, vector<int>& t, int d) {
    ll ans = 0;
    vector<int> last(26,0);
    rep(i, d) {
        ans += s[i][t[i]-1];
        last[t[i]-1] = i+1;
        rep(j, 26) {
            ans -= c[j]*(i+1 - last[j]);
        }
    }
    return ans;
}

int main(){
    int d; cin >> d;
    vector<int> c(26);
    rep(i, 26) {
        cin >> c[i];
    }
    vector<vector<int>> s(d, vector<int>(26,0));
    rep(i, d) {
        rep(j, 26) {
            cin >> s[i][j];
        }
    }
    vector<int> t(d);
    ll ans = 0;
    vector<int> last(26,0);

    rep(i, d) {
        ll tmpmax = - (1LL << 60);
        ll candidate = -1;
        rep(j, 26) {
            t[i] = j+1;
            if(tmpmax < evalNow(s,c,t,i,last)) {
                tmpmax = evalNow(s,c,t,i,last);
                candidate = j+1;
            }
        }
        last[t[i]-1] = i + 1;
        t[i] = candidate;
    }
    ll tmpmax = evalAll(s,c,t,d);

    double start,end;
    start = 20000;
    end = 0;

    double loop = 100000;

    rep(x, loop) {
        int i = rand()%d;
        int j = rand()%26;
        int original = t[i];
        t[i] = j+1;
        ll tmp = evalAll(s,c,t,d);
        if(tmpmax < tmp) {
            tmpmax = tmp;
        } else {
            double temp = start + (end - start)*x/loop;
            double prob = exp((tmpmax-tmp)/temp);
            ll diff = tmpmax - tmp;
            if (prob > (rand()%INF)/(double)INF) {
                t[i] = original;
            }
        }
    }


    rep(i, d) {
        cout << t[i] << endl;
    }
}


Measured memory_bytes: 4348
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


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


def main():
    A, B, N = map(int, input().split())

    def func(x):
        res = (A * x) // B - A * (x // B)
        return res

    print(func(min(N, B - 1)))


if __name__ == "__main__":
    main()


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

int main() {

	string s; cin >> s;
	int left;
	int right;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A') {
			left = i;
			break;
		}
	}
	for (int i = s.size() - 1; i >= 0; i--) {
		if (s[i] == 'Z') {
			right = i;
			break;
		}
	}
	cout << right - left + 1 << endl;
	return 0;
}

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

int main() {
	int A,B,C,D;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;
    int sum = 0;
    if(A<B){
      sum = sum+A;
    }
    else{
      sum = sum+B;
    }
    if(C<D){
      sum = sum+C;
    }
    else{
      sum = sum+D;
    }
    cout << sum << endl;
}
      

Measured memory_bytes: 256
def nc2(n):
    return int(n*(n-1)/2)


def main():
    import sys
    input = sys.stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    from collections import Counter as cc
    a_ = cc(a)
    sum_ = sum([nc2(k) for k in a_.values() if k > 1])
    for i in range(n):
        if a_[a[i]] < 2:
            print(sum_)
        else:
            print(sum_ - (a_[a[i]] -1))


if __name__ == '__main__':
    main()

Measured memory_bytes: 25312
fun main() {
    val x = readLong()
    var a = 100L
    var i = 0
    while (x > a) {
        a += a / 100
        i++
    }
    println(i)
}

private fun read() = readLine()!!

private fun readInt() = read().toInt()

private fun readLong() = read().toLong()

private fun readDouble() = read().toDouble()

private fun readListString() = read().split(" ")

private fun readListInt() = readListString().map { it.toInt() }

private fun readListLong() = readListString().map { it.toLong() }

private fun readListDouble() = readListString().map { it.toDouble() }

private fun readMatrixString(n: Int): List<List<String>> {
    val matrix = mutableListOf<List<String>>()
    for (i in 0 until n) {
        val list = readListString()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixInt(n: Int): List<List<Int>> {
    val matrix = mutableListOf<List<Int>>()
    for (i in 0 until n) {
        val list = readListInt()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixDouble(n: Int): List<List<Double>> {
    val matrix = mutableListOf<List<Double>>()
    for (i in 0 until n) {
        val list = readListDouble()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixLong(n: Int): List<List<Long>> {
    val matrix = mutableListOf<List<Long>>()
    for (i in 0 until n) {
        val list = readListLong()
        matrix.add(list)
    }
    return matrix
}



Measured memory_bytes: 34496
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vec A(n);
    rep(i,n) cin>>A[i];
    map<int,int> num;
    rep(i,pow(2,n)){
        int a=0;
        rep(j,n) if(i>>j&1) a+=A[j];
        num[a]++;
    }
    int q;
    cin>>q;
    rep(query,q){
        int m;
        cin>>m;
        if(num[m]) cout<<"yes\n";
        else cout<<"no\n";
    }
}


Measured memory_bytes: 3376
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t;
	cin>>t;
    ll mid=t%10;
  if(mid==2||mid==4||mid==5||mid==7||mid==9)
     {cout<<"hon"<<endl; return 0 ;}
  else if(mid==0||mid==1||mid==6||mid==8)
    cout<<"pon"<<endl;
  else if(mid==3)
    cout<<"bon"<<endl;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
    static List<Integer>[] to; // [i]と隣接する頂点のリスト
    static int[] dist;
    static int n;
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        int u = sc.nextInt() - 1;
        int v = sc.nextInt() - 1;
        
        to = new List[n];
        for (int i = 0; i < n; i++) {
            to[i] = new ArrayList<Integer>();
        }
        
        // リストの作成
        for (int i = 0; i < n - 1; i++) {
            int s = sc.nextInt() - 1;
            int t = sc.nextInt() - 1;
            to[s].add(t);
            to[t].add(s);
        }
        
        // u/vから各点までの距離を計算
        int[] distU = calcDist(u);
        int[] distV = calcDist(v);
        
        
        // uの方が近い点のうち、最も遠い点までの距離を取得
        int max = -1;
        for (int i = 0; i < n; i++) {
            if (distU[i] < distV[i]) {
                max = Math.max(max, distV[i]);
            }
        }
        
        System.out.println(max - 1);
    }
    
    public static int[] calcDist(int p) {
        dist = new int[n];
        dfs(p, 0, -1);
        return dist;
    }
    
    // 頂点pと隣接する点に自分の値+1を配ることで距離を与える
    public static void dfs(int p, int d, int par) {
        dist[p] = d;
        
        for (Integer q : to[p]) {
            if (q == par) continue;
            
            dfs(q, d+1, p);
        }
    }
}

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

int main(){

int N;

cin >> N;

vector<int> A(N);

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

  cin >> A.at(i);

}

sort(A.begin(),A.end());

string res;

res = "YES";

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

 if(A.at(i) == A.at(i+1)){
    res = "NO";
    break;
 } 

}

cout << res << endl;

}


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

int main() {
  long long N; cin >> N;
  string ans = "";
  while (N) {
    N--;
    ans += (char)('a' + (N % 26));
    N /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

Measured memory_bytes: 3604
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();	//音1回
		int b = sc.nextInt();	//所持金
		int c = sc.nextInt();	//満足

		int d = c*a;		//満足の必要金額

		int e = b/d;		//満足回数
		int f = e*c;		//聴回数

		if(e<1){
			f = b/a;
		}		

		System.out.println(f);
	}
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a, b, q, i;
        String str0, str1, str2, cmd, p;
        
        str0 = sc.next();
        str1 = str0;
        q = sc.nextInt();
        
        for(i = 0; i < q; i++) {
        	cmd = sc.next();
        	if(cmd.equals("replace")) {
        		a = sc.nextInt();
        		b = sc.nextInt();
        		p = sc.next();
        		
        		str1 = str0.substring(0, a);
        		str1 = str1.concat(p);
        		str0 = str1.concat(str0.substring(b + 1));
        	} else if (cmd.equals("reverse")) {
        		a = sc.nextInt();
        		b = sc.nextInt();
        		
        		StringBuffer strB = new StringBuffer(str0.substring(a, b+1));
        		str1 = strB.reverse().toString();
        		
        		str2 = str0.substring(0, a);
        		str2 = str2.concat(str1);
        		str2 = str2.concat(str0.substring(b + 1));
        		str0 = str2;
        	} else {
        		a = sc.nextInt();
        		b = sc.nextInt();
        		System.out.println(str0.substring(a, b+1));
        		
        	}
        }
        
    }
}


Measured memory_bytes: 29596
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, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	x, y := nextInt(), nextInt()
	if x%y == 0 {
		fmt.Println(-1)
		return
	}
	fmt.Println(x)
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main( void )
{
	int kotae = 0;
	string in;
	while ( cin >> in )
	{
		string l, r;
		int len = in.size()/2;
		for ( int i = 0; i < len; i++ )
		{
			l += in[i];
		}
		int c = (in.size()%2)?1:0;
		for ( int i = len+c; i < in.size(); i++ )
		{
			r += in[i];
		}

		reverse( r.begin(), r.end() );
		if ( r == l ) kotae++;
	}
	
	cout << kotae << endl;

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
public class  Main{
    public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	String input1 = scan.next();
	int inputTime = Integer.parseInt(input1);
	int numberCrack = 3600;
	int[] times = new int[3];
	for (int i = 0; i < 3; i++) {
	    times[i] = inputTime / numberCrack;
	    inputTime %= numberCrack;
	    numberCrack /= 60;
	}
	System.out.println(times[0] + ":" + times[1] + ":" + times[2]);
    }
}

Measured memory_bytes: 26212
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

string str;
signed main(){
	int ans = 0;
	cin >> str;
	int n = str.size();
	char c = str[0];
	rep(i,n){
		if(str[i] != c){
			c = str[i];
			ans++;
		}
	}
	printf("%lld\n", ans);
	return 0;
}




Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
ll sr[maxn];
ll sb[maxn];
ll sg[maxn];
int main() {
	int n;
	cin>>n;
	string s;
	cin>>s;
	if(s[0]=='R') sr[1] = 1;
	if(s[0]=='G') sg[1] = 1;
	if(s[0]=='B') sb[1] = 1;
	for(int i=1;i<s.length();i++){
		sr[i+1] = sr[i];
		sg[i+1] = sg[i];
		sb[i+1] = sb[i];
		if(s[i]=='R') sr[i+1]++;
		if(s[i]=='G') sg[i+1]++;
		if(s[i]=='B') sb[i+1]++;
	}
	ll ans = 0;
	for(int i=1;i<n;i++){
		if(s[i]=='G'){
			ll add = 0;
			for(int j=1;(i-j)>=0&&(i+j)<n;j++){
				if(s[i-j]=='R'&&s[i+j]=='B'){
					add++;
				}
				if(s[i-j]=='B'&&s[i+j]=='R'){
					add++;
				}
			}
			ll sum = (sr[i]*(sb[n]-sb[i]))+(sb[i]*(sr[n]-sr[i]));
			sum-=add;
			ans+=sum;
		}
		if(s[i]=='R'){
			ll 	add = 0;
			for(int j=1;(i-j)>=0&&(i+j)<n;j++){
				if(s[i-j]=='G'&&s[i+j]=='B'){
					add++;
				}
				if(s[i-j]=='B'&&s[i+j]=='G'){
					add++;
				}
			}
			ll sum = (sg[i]*(sb[n]-sb[i]))+(sb[i]*(sg[n]-sg[i]));
			sum-=add;
			ans+=sum;
		}
		if(s[i]=='B'){
			ll add = 0;
			for(int j=1;(i-j)>=0&&(i+j)<n;j++){
				if(s[i-j]=='G'&&s[i+j]=='R'){
					add++;
				}
				if(s[i-j]=='R'&&s[i+j]=='G'){
					add++;
				}
			}
			ll sum = (sg[i]*(sr[n]-sr[i]))+(sr[i]*(sg[n]-sg[i]));
			sum-=add;
			ans+=sum;
		}
	}
	cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3736
a, b, c, x = 4.times.map { gets.to_i }
cnt = 0
(0..a).each do |i|
    (0..b).each do |j|
        (0..c).each do |k|
            cnt += 1 if i * 500 + j * 100 + k * 50 == x
        end
    end
end

puts cnt

Measured memory_bytes: 14240
/*
author: atoiz
*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>

using namespace std;

#define LSB(i) ((i)&(-(i)))

const int MOD = 1e9 + 7;

struct BIT
{
    int n;
    vector<int> a;

    BIT(int _n) { n = _n; a.assign(n+1, 0); }
    void update(int x, int v) {
        while (x <= n) {
            a[x] = (a[x] + v) % MOD;
            x += LSB(x);
        }
    }
    int get(int x) {
        int ans = 0;
        while (x > 0) {
            ans = (ans + a[x]) % MOD;
            x -= LSB(x);
        }
        return ans;
    }
};

int main()
{
    int n, m; scanf("%d %d", &n, &m);
    vector<int> x(n), y(m);
    for (int i = 0; i < n; ++i) scanf("%d", &x[i]);
    for (int i = 0; i < m; ++i) scanf("%d", &y[i]);

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    // Initialize leftIdx + rightIdx
    vector<int> leftIdx(n), rightIdx(n);

    for (int i = 0; i < n; ++i) {
		leftIdx[i] = (i == 0) ? -1 : leftIdx[i-1];
        while (leftIdx[i]+1 < m && y[leftIdx[i]+1] < x[i]) ++leftIdx[i];
    }
    for (int i = n-1; i >= 0; --i) {
        rightIdx[i] = (i == n-1) ? m : rightIdx[i+1];
        while (rightIdx[i]-1 >= 0 && y[rightIdx[i]-1] > x[i]) --rightIdx[i];
    }

    // dists <- distance to left, right
    vector< pair<int, int> > dists;
    dists.reserve(n);
    for (int i = 0; i < n; ++i) {
        if (leftIdx[i] == -1 || rightIdx[i] == m) continue;
        dists.push_back({x[i] - y[leftIdx[i]], y[rightIdx[i]] - x[i]});
//        cerr << x[i] - y[leftIdx[i]] << ' ' << y[rightIdx[i]] - x[i] << endl;
    }
//    cerr << endl;
    sort(dists.begin(), dists.end());

    map<int, int> indexed;
    map<int, vector<int> > queries;

    indexed[-1] = 1;
    for (pair<int, int> p : dists) {
        indexed[p.second] = 1;
    }
    int tmp = 1;
    for (map<int, int>::iterator it = indexed.begin(); it != indexed.end(); ++it) {
        it->second = tmp++;
    }

    for (pair<int, int> p : dists) {
        queries[p.first].push_back(indexed[p.second]);
    }

    BIT bit(tmp);
    bit.update(1, 1);
    for (pair< int, vector<int> > p : queries) {
        vector<int> v = p.second;
        sort(v.begin(), v.end());
        v.erase(unique(v.begin(), v.end()), v.end());
//        for (int i : v) cerr << i << ' '; cerr << endl;
        for (int i = v.size() - 1; i >= 0; --i) {
            bit.update(v[i], bit.get(v[i]-1));
        }
//		for (int i = 1; i <= tmp; ++i) cerr << bit.get(i) - bit.get(i-1) << ' '; cerr << endl;
//		for (int i : v) bit.update(i, bit.get(i-1));
//        cerr << "ans: " << bit.get(tmp) << endl;
    }

    cout << bit.get(tmp) << endl;
}


Measured memory_bytes: 18048
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define mp make_pair
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;
vector<vector<int>> v;

pair<int,int> dfs(int x,int par){
	vector<pair<int,int>> vec;
	pii p={1,1};
	for(auto y:v[x]){
		if(y==par) continue;
		pii temp=dfs(y,x);
		p.ss=(p.ss*temp.ff)%M;
		p.ff=(p.ff*(temp.ff+temp.ss)%M)%M;
	}
	return(p);
}

int32_t main(){
    IOS;
    int n;
    cin>>n;
    v.resize(n);
    for(int i=0;i<n-1;i++){
    	int x,y;
    	cin>>x>>y;
    	x--,y--;
    	v[x].pb(y);
    	v[y].pb(x);
    }   
    pii p=dfs(0,-1);
    cout<<(p.ff+p.ss)%M<<endl;
}

Measured memory_bytes: 12672
s = input()
sa = int(s[:2])
sb = int(s[2:])

if sa >= 1 and sa <= 12 and sb >= 1 and  sb <= 12:
    print('AMBIGUOUS')
    exit()
else:
    if sa >= 1 and sa <= 12:
        print('MMYY')
        exit()
    if sb >= 1 and sb <= 12:
        print('YYMM')
        exit()

print('NA')

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

typedef long long ll;
typedef double ld;
typedef pair <ll, ll> pll;

#define pb push_back
#define mp make_pair
#define all(_c) _c.begin(), _c.end()

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

    int n;
    cin >> n;

    vector <pll> p(n);
    for (int i = 0; i < n; i++) { 
        cin >> p[i].first >> p[i].second;
    }

    sort(all(p), [] (const pll& a, const pll& b) {
        return a.first + a.second > b.first + b.second;
    });

    ll ans = 0;
    for (ll i = 0; i < n; i++)
        ans += (i & 1 ? -p[i].second : p[i].first);
    cout << ans << '\n';
    return 0;
}


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

int main(){
    int n; cin >> n;
    if(n%2 == 0){
        cout << n/2 << endl;
    }
    else{
        cout << (n+1)/2 << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int map[10][10];

int main(void) {
	int input,max;
	int casenum=1;
	int now;
	int x,y;
	int up;
	while(1) {
		scanf("%d",&input);
		if(input==0)break;
		x=y=0;
		now=0;
		up=1;
		max=input*input;
		while(now<max) {
			map[y][x]=++now;
			if(up) {
				if(x==input-1) {
					y++;up=0;
				} else if(y==0) {
					x++;up=0;
				} else {
					x++;y--;
				}
			} else {
				if(y==input-1) {
					x++;up=1;
				} else if(x==0) {
					y++;up=1;
				} else {
					x--;y++;
				}
			}
		}
		printf("Case %d:\n",casenum++);
		for(y=0;y<input;y++) {
			for(x=0;x<input;x++)printf("%3d",map[y][x]);
			putchar('\n');
		}
	}
	return 0;
}

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

int n,m,ans=0;
int a[2005][2005],a1[2005][2005],a2[2005][2005],a3[2005][2005],a4[2005][2005];

signed main()
{
	cin>>n>>m;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			char temp;
			cin>>temp;
			
			if (temp=='#')  a[i][j]=0;
			else a[i][j]=1;
		}
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			if (!a[i][j])  a1[i][j]=0;
			else a1[i][j]=a1[i][j-1]+1;
		}
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=m;j>=1;j--)
		{
			if (!a[i][j])  a2[i][j]=0;
			else a2[i][j]=a2[i][j+1]+1;
		}
	}
	for (int j=1;j<=m;j++)
	{
		for (int i=1;i<=n;i++)
		{
			if (!a[i][j])  a3[i][j]=0;
			else a3[i][j]=a3[i-1][j]+1;
		}
	}
	for (int j=1;j<=m;j++)
	{
		for (int i=n;i>=1;i--)
		{
			if (!a[i][j])  a4[i][j]=0;
			else a4[i][j]=a4[i+1][j]+1;
		}
 	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			if ((a1[i][j]+a2[i][j]+a3[i][j]+a4[i][j]-3)>ans)
				ans=a1[i][j]+a2[i][j]+a3[i][j]+a4[i][j]-3;
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 157184
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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 main () {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int ma = max({a,b,c});
  int rem = a+b+c - ma;
  rep(_,k) {
    ma *= 2;
  }
  cout << rem + ma << endl;
  return 0;
}

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

int N,M;
int a[28],b[28];

int main(){
  scanf("%d %d",&N,&M);
  rep(i,M){
    scanf("%d %d",&a[i],&b[i]);
  }
  vector<int> v(N);
  rep(i,N){
    v[i]=i+1;
  }
  ll count=0;
  do{
    if(v[0]==2)break;
    int vcount=0;
    rep(i,N-1){
      rep(j,M){
        if((v[i]==a[j]&&v[i+1]==b[j])||(v[i]==b[j]&&v[i+1]==a[j])){
          vcount++;
          if(vcount==N-1){
            count++;
          }
        }
      }
    }
  
  }while(next_permutation(v.begin(),v.end()));
  printf("%lld",count);
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>

using namespace std;

int main()
{
long i, j, k, l;
	long n;
	cin >> n;
	vector<long long> a;
	a.resize(n);

	for (i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	long long small = 10000000001;
	long long befS = -1;
	long temp = -1;

	while (small != 1)
	{
		small = 10000000001;

		for (i = 0; i < n; i++)
		{
			if (a[i] < small && a[i] > 0)
			{
				small = a[i];
				temp = i;
			}
		}

		if (befS == small)
		{
			break;
		}

		for (i = 0; i < n; i++)
		{
			if (a[i] > 0 && i != temp) 
			{
				a[i] =  a[i] % small;
			}
		}

		befS = small;
	}

	cout << small;

	return 0;
}


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

int main(){
  
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  
  int x = k - a - b;
  int ans = a - x;
  
  if(k <= a){
    cout << k << endl;
  }else if(k > a){
    if(k - a <= b){
      cout << a << endl;
    }else if(k - a > b){
      cout << ans << endl;
    }
  }
  
}


Measured memory_bytes: 3676
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Int32;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            label:
            var sp = ReadLine().Split();
            int n = Parse(sp[0]);
            int m = Parse(sp[1]);
            var sort = new SortedList<int, int>();
            for (int i = 0; i < n; ++i)
            {
                sp = ReadLine().Split();
                int a = Parse(sp[0]);
                int b = Parse(sp[1]);
                int val;
                if (sort.TryGetValue(a, out val))
                {
                    sort[a] = val + b;
                }
                else
                {
                    sort[a] = b;
                }
            }
            long result = 0;
            foreach (var pair in sort)
            {
                if (pair.Value < m)
                {
                    m -= pair.Value;
                    result += (long)(pair.Key) * pair.Value;
                }
                else
                {
                    result += (long)(pair.Key) * m;
                    break;
                }
            }
            WriteLine(result);
            //goto label;
        }
    }
}


Measured memory_bytes: 17364
a,b,c = map(int, input().split())
if a==b==c:
  if a%2:
    print(0)
  else:
    print(-1)
else:
  cnt = 0
  while a%2 == b%2 == c%2 == 0:
    a,b,c = (b+c)//2,(a+c)//2,(a+b)//2
    cnt += 1
  print(cnt)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        int a = reader.nextInt();
        int b = reader.nextInt();
        int c = reader.nextInt();
        reader.close();
        System.out.println(a > b ? (b + (a > c ? (10 * a + c) : (10 * c + a))) : (a + (b > c ? (10 * b + c) : (10 * c + b))));
    }
}

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

#define REP(i, n) for(int i = 0; i < (int) (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 1e9

using namespace std;

char alphabet[52];

int main(){
  int n;
  REP(i, 26){ alphabet[i] = char('A' + i); }
  REP(i, 26){ alphabet[i+26] = char('a' + i); }
  while(cin >> n and n){
    int keys[100];
    REP(i, n) cin >> keys[i];
    for(int i = n; i < 100; i++) keys[i] = keys[i-n];
    string list;
    cin >> list;
    REP(i, list.size()){
      int target;
      if(list[i] < 'a') target = list[i]-'A';
      else target = list[i]-'a'+26;
      cout << alphabet[(target - keys[i] + 52) % 52];
    }
    cout << endl;
  }
  return 0;
}

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

int main() {
  int a, b;
  
  cin >> a >> b;
  if (a % 2 == 0 && b % 2 == 0){
    cout << "Even" << endl;
  }
  else if (a % 2 == 0 && b % 2 >= 0){
    cout << "Even" << endl;
  }
  else if (a % 2 >= 0 && b % 2 == 0){
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

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

int main() {
    int N;;
    cin >> N;
    int cnt = 0;
    int flag = 0;
    rep(i,N){
        int d1,d2;
        cin >> d1;
        cin >> d2;
        if(d1 == d2){
            cnt++;
        }else{
            cnt = 0;
        }
        if(cnt > 2){
            flag = 1;
        }
    }

   	if(flag==1){
       cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
    return 0;
}

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

typedef struct{
    int a;
    int b;
}TEST;

int comp( const void *c1, const void *c2 )
{
  TEST test1 = *(TEST *)c1;
  TEST test2 = *(TEST *)c2;

  int tmp1 = test1.b;   /* b を基準とする */
  int tmp2 = test2.b;

  return tmp1 - tmp2;
}
int main(){
    int N;
    TEST base[210000];
    int ans = 0;
    int timenow=0;
    int i;

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

    qsort( base, N, sizeof(TEST), comp );

    for(i=0; i<N; i++){
        
        timenow += base[i].a;
        //printf("%d %d %d\n", base[i].a, base[i].b, timenow);
        if(base[i].b < timenow){
            ans =1;
        }
    }

    if(ans == 0){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 3324
N,K=map(int,input().strip().split())
A=list(map(int,input().strip().split()))

i=A.index(1)+1
if i<=K or i>=N-K:
    ans=(N-K)//(K-1)+1 if (N-K)%(K-1)==0 else (N-K)//(K-1)+2
else:
    for a in range(K):
        b=0 if (i-a)%(K-1)==0 and (N-(i+(K-a)))%(K-1)==0 else 1
    front=i//(K-1)
    back=(N-(i+K))//(K-1)
    ans=front+back+1+b
print(ans)

Measured memory_bytes: 20592
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <algorithm>
#include <stdio.h>
using namespace std;

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

	int ary[3] = {a, b, c};
	sort(ary, ary + 3);

	cout << ary[0] << " " << ary[1] << " " << ary[2] << endl;
	return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long n,x,i,j,k,y,z,g,mx;
    g=0;
    cin>>n>>x;
    mx=0;
    for (i=0;i<n;i++)
    {
    	cin>>arr[i];
    	mx=max(mx,arr[i]);
    	g=__gcd(g,arr[i]);
	}
	if (mx<x || (x%g)!=0)
	{
		cout<<"IMPOSSIBLE"<<endl;
	}
	else
	{
		cout<<"POSSIBLE"<<endl;
	}
}

Measured memory_bytes: 1024
import scala.math._

object Main extends App {
  val sc = new java.util.Scanner(System.in)
//  val list = List.fill(3)(sc.nextInt)
  val n = sc.next

  val ans = if (n == n.reverse) "Yes" else "No"

  println(ans)

  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 27312
fun main(args: Array<String>) {
    var (a,b) = readLine()!!.split(" ").map(String::toInt)
    var S = readLine()!!
    if(S[a] == '-' && S.length == a+b+1 && S.filter{it == '-'}.length == 1) println("Yes")
    else println("No")
}


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

typedef long long int int64;
int64 arr[100003];
int n;
int64 a,b;
int main()
{
	scanf("%d",&n);
	for(int i = 0;i < n;++i) {
		scanf("%lld",&arr[i]);
	}
	a = 2,b = 2;
	for(int i = n - 1;i >= 0;--i) {
		int64 cur = arr[i];
		a = ((a - 1) / cur + 1) * cur,b = (b / cur + 1) * cur - 1;
		if(a > b) {
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld %lld\n",a,b);
	return 0;
}

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

// マクロ
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) x * x

// 型エイリアス
using lint = long long;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;

int main() {

	lint N, A, B;
	cin >> N >> A >> B;

	if ((A - B) % 2 == 0) {
		cou((A - B > 0 ? (A - B) / 2 : (B - A) / 2));
	}
	else {
		cout << ((min(A, B) - 1) > (N - max(A, B)) ? (2 * N - A - B) / 2 + 1 : (A + B) / 2) << endl;
	}
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<algorithm>
#include<bits/stdc++.h>
#define l(i,a,b) for(auto i=a;i<b;i++)
#define lr(i,a,b) for(auto i=a;i>=b;i--)
#define ll long long 
#define lli long long int
#define ld long double
#define vec vector<int>
#define mii map<ll,ll>
#define vl vector<long long>
#define se set <long long int>
#define pi pair<long long,long long>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define all(v) v.begin(), v.end()
#define in(x) cin>>x
#define o(x) cout<<x
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    SYNC
    int n,k;
    in(n)>>k;
    int dp[n+1],ar[n+1];
    l(i,1,n+1)
    {
        in(ar[i]);
        dp[i]=100001;
    }
    dp[1]=0;
    l(i,2,n+1)
    {
        dp[i]=dp[i-1]+abs(ar[i]-ar[i-1]);
        l(j,1,k+1)
        {
            if((i-j)<1)
            break;
            dp[i]=min(dp[i-j]+abs(ar[i]-ar[i-j]),dp[i]);
        }
    }
    o(dp[n]);
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k - 1] += 'a' - 'A';
    cout << s << endl;

    return 0;
}



Measured memory_bytes: 892
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))


index = 0
index2 = 0
stackedTime = 0

while(index<N and stackedTime + A[index] <= K):
  stackedTime += A[index]
  index += 1

while(index2 < M and stackedTime + B[index2] <= K):
  stackedTime += B[index2]
  index2 += 1

maxBook = index + index2
for i in range(N):
  if(index == 0 or index2 == M):
    break
  index -= 1
  stackedTime -= A[index]
  while(index2 < M and stackedTime + B[index2] <= K):
    stackedTime += B[index2]
    index2 += 1

  maxBook = max(maxBook, index + index2)

print(maxBook)


Measured memory_bytes: 110856
#include<cstdio>
#define pritnf printf
#define scnaf scanf
#define retrun return
#define sizoef sizeof
#define inl inline
#define br break
#define con continue
#define mst(mst_a,mst_b) memset(mst_a,mst_b,sizeof(mst_a))
#define fora(fora_x,fora_a,fora_b) for(re nti (fora_x)=(fora_a);(fora_x)<=(fora_b);++(fora_x))
#define forb(forb_x,forb_a,forb_b) for(re nit (forb_x)=(forb_a);(forb_x)>=(forb_b);--(forb_x))
#define foral(foral_x,foral_a,foral_b) for(re ll (foral_x)=(foral_a);(foral_x)<=(foral_b);++(foral_x))
#define forbl(forbl_x,forbl_a,forbl_b) for(re ll (forbl_x)=(forbl_a);(forbl_x)>=(forbl_b);--(forbl_x))
#define re register
#define stt struct
#define nms namespace
#define gc getchar
#define sl(sl_a) strlen(sl_a)
#define gt(gt_a) goto gt_a
#define rt return
#define infa (0x3f3f3f3f)
#define infb (0x7fffffff)
#define infd (0x7f)
#define abss(abss_x) ((abss_x)>(0)?(abss_x):(-1)*(abss_x))
#define maxx(maxx_a,maxx_b) ((maxx_a)>(maxx_b)?(maxx_a):(maxx_b))
#define minn(a,b) ((a)<(b)?(a):(b))
#define in(in_a) freopen("F:/""/in"in_a".in","r",stdin)
#define out(out_a) freopen("F:/""/out"out_a".out","w",stdout)
#define filein(a) freopen(a,"r",stdin)
typedef long long ll;
typedef int itn,nti,tin,tni,nit;
using namespace std;
const nit maxa=100004;
const nit maxb=104;
const nit maxc=4;
const tni maxd=10004;

tni n;

tni main()
{
	scanf("%d",&n);
	//
	printf("%d\n",(n>>1)-(n+1)%2);
	//
	rt 0;
}

Measured memory_bytes: 888
#include<stdio.h>

int main()
{
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	if (a + b > c + d)
		printf("Left");
	else if (a + b < c + d)
		printf("Right");
	else
		printf("Balanced");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, a[200100], b[200100], i, alxor=1;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
        alxor=alxor^a[i];
    }
    alxor=alxor^1;
    for(i=0;i<n;i++){
        b[i]=alxor^a[i];
    }
    for(i=0;i<n;i++){
        cout << b[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 6648
N = int(input())
P = list(map(int, input().split()))
count = 0
for n in range(1, N - 1):
  if (P[n] > P[n - 1] and P[n] < P[n + 1]) or (P[n] < P[n - 1] and P[n] > P[n + 1]):
    count += 1
print(count)

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
#include <string.h>
int abs(int n){
    if(n > 0){
        return n;
    } else {
        return -n;
    }
}

int min(int a, int b){
    if(a > b){
        return b;
    } else {
        return a;
    }
}


int main(){
  int n, m;
  scanf("%d  %d", &n, &m);
  int k;
  int count[30] = {};
  for(int i = 0; i< n; i++){
      scanf("%d", &k);
      for(int j = 0; j < k; j++){
          int a;
          scanf("%d", &a);
          count[a-1]++;
      }
  }
  
  int ans = 0;
  for(int i = 0; i < m; i++){
      if(count[i]==n){
          ans++;
      }
  }
  printf("%d", ans);
  return 0;
}




Measured memory_bytes: 128
#!/usr/bin/env python3


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    # Failed to predict input format
    N, M, X = list(map(int, input().split()))
    C = []
    A = [[] for i in range(N)]
    for n in range(N):
        row = list(map(int, input().split()))
        C.append(row[0])
        for m in range(M):
            A[n].append(row[m+1])

    smallest = 10**9
    for i in range(2 ** 12):
        binary = bin(i)[2:]
        if len(binary) > N:
            break
        head = N - len(binary)
        pattern = list('0'*head + binary)

        M_satisfy = [0 for i in range(M)]
        for idx, p in enumerate(pattern):
            if p == '1':
                for m in range(M):
                    M_satisfy[m] += A[idx][m]
        flag = True
        for m in range(M):
            if M_satisfy[m] < X:
                flag = False
        if flag == True:
            tmp = sum([int(pattern[i]) * C[i] for i in range(len(pattern))])
            if tmp < smallest:
                smallest = tmp
    if smallest == 10**9:
        print(-1)
    else:
        print(smallest)

    pass

if __name__ == '__main__':
    main()


Measured memory_bytes: 9304
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    string s;
    cin >> s;
    cout << count(begin(s), end(s), '1') << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull uint64_t
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mx5 100005
#define mx6 1000005
#define mod 1000000007
#define nfs ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

double dp[301][301][301] = {};
double gedit(int c1, int c2, int c3, int n) {
    if (c1 < 0 || c2 < 0 || c3 < 0)
        return 0;
    if ((c1 == 0 and c2 == 0 and c3 == 0) || dp[c1][c2][c3] != 0)
        return dp[c1][c2][c3];
    dp[c1][c2][c3] += ((double)c1/(c1+c2+c3))*(gedit(c1-1, c2, c3, n));
    dp[c1][c2][c3] += ((double)c2/(c1+c2+c3))*(gedit(c1+1, c2-1, c3, n));
    dp[c1][c2][c3] += ((double)c3/(c1+c2+c3))*(gedit(c1, c2+1, c3-1, n));
    dp[c1][c2][c3] += (double)n/(c1 + c2 + c3);
    return dp[c1][c2][c3];
}

int main() {
    nfs
    int i, j, k, n, c[4] = {}, a;
    cin >> n;
    for (i = 0; i < n; i++) {
        cin >> a;
        c[a]++;
    }
    printf("%.9f", gedit(c[1], c[2], c[3], n));
}

Measured memory_bytes: 111160