akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;

ll N;
// vector<ll> u, v, w;

vector<P> g[100100];
vector<ll> ans;

void dfs(int cur, int par = -1) {
    for (int j = 0; j < g[cur].size(); j++) {
        if (g[cur][j].first == par) continue;
        if (ans[g[cur][j].first] != -1) continue;

        ans[g[cur][j].first] = (ans[cur] + g[cur][j].second) % 2;
        dfs(g[cur][j].first, cur);
    }
}

int main() {
    cin >> N;
    rep(i, N - 1) {
        ll u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        g[u].push_back(P(v, w));
        g[v].push_back(P(u, w));
    }

    ans.resize(N, -1);

    ans[0] = 0;
    dfs(0);

    rep(i, ans.size()) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 9472
fun main(args : Array<String>) {
    val (n, p) = readLine()!!.split(" ").map { it.toLong() }
    val divisors = decom(p)

    var current = p
    var factors = mutableMapOf<Long, Long>()
    divisors.forEach {
        while (current != 1L && current % it == 0L) {
            current /= it
            factors[it] = (factors[it] ?: 0L) + 1L
        }
    }
    factors[current] = 1L

    var ans = 1L
    factors.forEach {
        if (it.value >= n) {
            ans *= Math.pow(it.key.toDouble(), (it.value / n).toDouble()).toLong()
        }
    }

    println(ans)
}

fun prime(from : Long, to : Long = from) : List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j ->  i % j != 0L }
    }
}

fun decom(value : Long) : List<Long>{
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}


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

int main(){
    string s;
    cin >> s;
    int i;
    for(i=0;i<3;i++){
        if(s.at(i)=='1') cout << "9" ;
        else cout << "1" ;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

using ll = long long int;

int main(int argc, char *argv[])
{
	ll n,m;
	std::cin >> n >> m;

	std::vector<ll> h(n,0);
	std::vector<ll> s(n,0);
	for(ll i = 0;i < n;++i) { std::cin >> h[i]; }
	
	for(ll i = 0;i < m;++i)
	{
		ll a,b;
		std::cin >> a >> b;
		s[a-1] = std::max(s[a-1], h[b-1]);
		s[b-1] = std::max(s[b-1], h[a-1]);
	}

	int ans = 0;
	for (int i = 0;i < n;++i) { if (h[i] > s[i]) { ++ans; } }

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 4784
#include <stdio.h>
#define N 100000
main(){
	int i,str[N],ptr[N];
	scanf("%d",&i);
	int j;
	for(j=0; j<i; j++){
		scanf("%d",&str[j]);
		ptr[str[j]] = j+1;
	}
	for(j=1; j<=i; j++){
		printf("%d ",ptr[j]);
	}
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int a[110]= {0};
int main()
{
    int n,sum,x,ans=10000000;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=-100;i<=100;i++)
    {
        sum=0;
        for(int j=0;j<n;j++)
        {
            sum+=(a[j]-i)*(a[j]-i);
        }
        ans=min(ans,sum);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
from random import randint
import sys
M = 3 * (10**5)
def main(D, C, S):
    def evaluate(i, t, satisfaction, last):
        satisfaction += S[i][t]
        last[t] = i
        for j, c in enumerate(C):
            satisfaction -= c * (i - last[j])
        return (satisfaction, last)

    ans = []
    satisfaction = 0
    last = [-1] * 26
    count = [BinaryIndexedTree(D) for _ in range(26)]
    for i in range(D):
        tt = -1
        ts = -10**10
        tl = None
        ps = satisfaction
        pl = last[:]
        for t in range(26):
            s, l = evaluate(i, t, ps, pl[:])
            if ts < s:
                tt = t
                ts = s
                tl = l
        ans.append(tt + 1)
        satisfaction = ts
        last = tl
        count[tt].add(i, 1)

    for i in range(M):
        p = randint(0, 100)
        tmp_s = satisfaction
        d = randint(0, D - 1)
        new = randint(0, 25)
        old = ans[d] - 1
        tmp_s += S[d][new] - S[d][old]
        cnt_old = count[old].query(d)
        nxt_d_old = count[old].bisect(lambda x: x < cnt_old + 1)
        pre_d_old = count[old].bisect(lambda x: x < cnt_old - 1) if cnt_old > 1 else -1
        tmp_s -= C[old] * (nxt_d_old - d) * (d - pre_d_old)
        ans[d] = new + 1
        count[old].add(d, -1)
        count[new].add(d, 1)
        cnt_new = count[new].query(d)
        nxt_d_new = count[new].bisect(lambda x: x < cnt_new + 1)
        pre_d_new = count[new].bisect(lambda x: x < cnt_new - 1) if cnt_new > 1 else -1
        tmp_s += C[new] * (nxt_d_new - d) * (d - pre_d_new)
        if p > i * 200 // M or tmp_s < satisfaction:
            ans[d] = old + 1
            count[old].add(d, 1)
            count[new].add(d, -1)
        else:
            satisfaction = tmp_s

    return ans

class BinaryIndexedTree:
    def __init__(self, n=None, f=lambda x, y: x + y, identity=0, initial_values=None):
        assert(n or initial_values)
        self.__f, self.__id, = f, identity
        self.__n = len(initial_values) if initial_values else n
        self.__d = [identity] * (self.__n + 1)
        if initial_values:
            for i, v in enumerate(initial_values): self.add(i, v)

    def add(self, i, v):
        n, f, d = self.__n, self.__f, self.__d
        i += 1
        while i <= n:
            d[i] = f(d[i], v)
            i += -i & i

    def query(self, r):
        res, f, d = self.__id, self.__f, self.__d
        r += 1
        while r:
            res = f(res, d[r])
            r -= -r & r
        return res

    def bisect(self, func):
        n, f, d, v = self.__n, self.__f, self.__d, self.__id
        x, i = 0, 1 << (n.bit_length() - 1)
        while i > 0:
            if x + i <= n and func(f(v, d[x + i])): v, x = f(v, d[x + i]), x + i
            i >>= 1
        return x

if __name__ == '__main__':
    input = sys.stdin.readline
    D = int(input())
    *C, = map(int, input().split())
    S = [list(map(int, input().split())) for _ in range(D)]
    ans = main(D, C, S)
    for a in ans:
        print(a)


Measured memory_bytes: 98680
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    double* a=new double[n];
    for(int i=0;i<n;i++)cin>>a[i];
    double dp[n+1][n+1];
    ///row=>minreq,col=>atpres
    memset(dp,0.0,sizeof(dp));
    dp[0][0]=1.0;
    for(int i=0;i<=n;i++)
    {
        for(int j=i;j<=n;j++)
        {
            if(i==0 && j==0)dp[i][j]=1.0;
            else if(i==0)dp[i][j]=dp[i][j-1]*(1-a[j-1]);
            else dp[i][j]=dp[i-1][j-1]*a[j-1] + dp[i][j-1]*(1-a[j-1]);
        }
    }
    // for(int i=0;i<=n;i++)
    // {
    //     for(int j=0;j<=n;j++)
    //     cout<<dp[i][j]<<" \t\t";
    //     cout<<endl;
    // }
    double ans=0;
    for(int i=(n+1)/2;i<=n;i++)
    ans+=dp[i][n];
    // for(int i=(n+1)/2;i<=n;i++)
    // cout<<dp[i][n]<<" ";
    cout << fixed << setprecision(9);
    cout<<ans;
}

Measured memory_bytes: 70528
/* Author : Prasuk Jain */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int              long long int
#define ull              unsigned long long
#define ld               long double
#define fo(i, n)         for(int i=0; i<n; i++)
#define FOR(i, a, b)     for(int i=a; i<b; i++)
#define rfor(i, n)       for(int i=n-1; i>=0; i--)
#define RFOR(i, a, b)    for(int i=b-1; i>=a; i--)
#define tr(it, v)        for(auto it=a.begin(); it!=a.end(); it++)
#define vi               vector<int>
#define pii              pair<int,int>
#define mii              map<int,int>
#define pqb              priority_queue<int>
#define pqs              priority_queue<int,vi,greater<int>>
#define mp               make_pair
#define pb(x)            push_back(x)
#define hcf(x, y)        __gcd(x, y)
#define lcm(x, y)        boost::math::lcm(x,y)
#define setpre(x, y)     fixed << setprecision(y) << x
#define setbits(x)       __builtin_popcountll(x)
#define zerolead(x)      __builtin_clzll(x)
#define zerotrail(x)     __builtin_ctzll(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define PI               3.1415926535897932384626
const int mod = 1e9+7;
const int inf = 1e18;
int mpow(int base, int exp);
bool isprime(int num);
void prifact(int num);

//*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!//

void coderprasukj(){ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int32_t main() {
    //coderprasukj();
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]) cout << "Yes\n";
    else cout << "No\n";
    
    return 0;
}

//*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!//

int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
        if (exp & 1) result = ((int)result * base) % mod;
        base = ((int)base * base) % mod;
        exp >>= 1;
    }
  return result;
}

bool isprime(int num) {
    if(num <= 1) return false;
    for(int i=2; i*i <= num; i++)
        if(num%i == 0) return false;
    return true;
}

void prifact(int num){
    for(int i=2; i<=num; i++)
    if(num%i == 0){
        int cnt = 0;
        while(num%i == 0)
        cnt++ , num /= i;
        cout << i << "^" << cnt << " ";
    }
    if(num > 1)
    cout << num << "^" << "1" << " ";
}



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

int main(){
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;

        cin >> k;

        cout << a[k-1] << endl;
}

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

int main(){
    int N;
    cin >> N;

    int T, A;
    cin >> T >> A;

    int X;
    int flag = 999999;
    int flag_i = 0;
    rep(i,N+1){
        cin >> X;
        if(abs((1000*T-X*6)-A*1000) < flag){
            flag = abs((1000*T-X*6)-A*1000);
            flag_i = i;
        }
    }
    cout << flag_i << endl;
}

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

using namespace std;


int main() {
    int n;
    cin >> n;
    double x[10];
    string u[10];
    double y = 0.0;
    for (int i=0; i < n; i++){
        cin >> x[i];
        cin >> u[i];
        if (u[i] == "JPY"){
            y = y + x[i];
        }
        else if (u[i] == "BTC")
            y = y + x[i] * 380000.0;
    }
    cout << y << endl;
}

Measured memory_bytes: 256
def solve():
    N = int(input())
    A = [0]+list(map(int, input().split()))
    
    diff_A = [A[i+1]-A[i] for i in range(N)]
    diff_A.append(-A[-1])
    ret = sum(abs(a) for a in diff_A)
    for i in range(N):
        diff = abs(diff_A[i+1])+abs(diff_A[i])-abs(diff_A[i+1]+diff_A[i])
        print(ret-diff)
        
solve()

Measured memory_bytes: 14048
#include <bits/stdc++.h>
typedef long long intl;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define INF = 1e9;
using namespace std;
int main(){
    string s;
    cin >> s;
    rep(i,s.length()){
        s[i] = 'x';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define MAX(a, b) ((a) > (b) ? (a) : (b))

using namespace std;

vector<pair<int, int>> A;
vector<int> p;
vector<int> m;
int rp, rm;

int main(){
    int N;
    cin >> N;
    
    int x, y;
    for(int i = 0; i < N; ++i) {
        cin >> x >> y;
        A.push_back({x, y});
        p.push_back(x+y);
        m.push_back(x-y);
    }
    
    sort(p.begin(), p.end());
    sort(m.begin(), m.end());
    
    rp = p[N-1] - p[0];
    rm = m[N-1] - m[0];
    
    cout << MAX(rp, rm) << endl;
}


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

using namespace std;
using ll = long long;

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

    string s; cin >> s;
    for(int i=0; i<s.size()-1; i++)
        if(s[i]==s[i+1])
            return cout << i+1 << ' ' << i+2, 0;
    for(int i=0; i<s.size()-2; i++)
        if(s[i]==s[i+2])
            return cout << i+1 << ' ' << i+3, 0;

    cout << "-1 -1";
    return 0;
}


Measured memory_bytes: 512
n = int(input())
arr = [int(i) for i in input().split()]

diff = lambda x,y : abs(x-y)

dp = [0,diff(arr[0],arr[1])]

for i in range(2,n):
    cost1 = diff(arr[i-1],arr[i])+dp[i-1]
    cost2 = diff(arr[i-2],arr[i])+dp[i-2]
    dp.append(min(cost1,cost2))

print(dp[-1])


Measured memory_bytes: 13976
x,y=map(int,input().split())
a,b,c=map(int,input().split())
n=list(input())
s=0
for i in range(y):
    if n[i]=="r":
        s+=c
    elif n[i]=="s":
        s+=a
    else:
        s+=b
for i in range(y,x):
    if n[i-y]==n[i]:
        n[i]="!"
    else:
        if n[i]=="r":
            s+=c
        elif n[i]=="s":
            s+=a
        elif n[i]=="p":
            s+=b       
print(s) 

Measured memory_bytes: 49520
from collections import defaultdict
import heapq
def main():
    n,m = map(int,input().split())
    dc = defaultdict(list)
    for _ in range(n):
        a,b = map(int,input().split())
        dc[a].append(-b)
    a = []
    ans = 0
    for i in range(1,m+1):
        for j in dc[i]:
            heapq.heappush(a,j)
        if len(a)==0:
            pass
        else:
            ans += -1 * heapq.heappop(a)
    
    print(ans)
            
    


if __name__ == '__main__':
    main()

Measured memory_bytes: 77912
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;

#define ALL(a) (a).begin(),(a).end()
#define REP(i,x) for(int i = 0;i < x;++i)
#define debug(x) cerr << #x << "=" << x << endl

int n, m;
int col[123456];//-1:nobody else:d
int rem[123456];//remaining people

int bondnum;

using ll = long long;

ll buffer[234567];
bool cond(int x)
{
	int overnum = 0;
	REP(j, n - m)
	{
		if (rem[j] >= x)++overnum;
	}
	REP(i, n)
	{
		if (col[i] == -1)
		{
			buffer[i] = 1;
		}
		else if (col[i] >= x)
		{
			buffer[i] = 0;
		}
		else
		{
			buffer[i] = 123456789;
		}
	}
	REP(t, bondnum)
	{
		buffer[t + n] = buffer[t * 3] + buffer[t * 3 + 1] + buffer[t * 3 + 2] - max(max(buffer[t * 3], buffer[t * 3 + 1]), buffer[t * 3 + 2]);
	}
	return (buffer[bondnum + n - 1] <= overnum);
}

int main(void)
{
	scanf("%d %d", &n, &m);
	fill(col, col + n, -1);
	REP(i, m)
	{
		int d, p;
		scanf("%d %d", &d, &p);
		--p;
		col[p] = d;
	}
	REP(j, n - m)
	{
		scanf("%d", rem + j);
	}
	bondnum = (n - 1) / 2;
	int upper = 1000000001;
	int lower = 0;
	while (upper > lower + 1)
	{
		int middle = (upper + lower) / 2;
		if (cond(middle))
		{
			lower = middle;
		}
		else
		{
			upper = middle;
		}
	}
	printf("%d\n", lower);
	return 0;
}

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

int main(){
  int sankasya,point,num;
  int seikaisya;
  
  cin >> sankasya >> point >> num;
  
  vector<int> vec(sankasya,0);
  for(int i = 0; i < num; i++){
    cin >> seikaisya;
    vec.at(seikaisya-1) += 1;
  }
  
  for(int i = 0; i < sankasya; i++){
    if(point - (num - vec.at(i)) > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
const int N = 2e5+5;
const ll inf = 1e18;
int n,val[N];
ll f[N][3];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n);
	for(ri i=1;i<=n;++i) read(val[i]);
	for(ri i=0;i<=n;++i) for(ri j=0;j<=2;++j) f[i][j]=-inf;
	f[0][0]=0,f[1][0]=val[1];
	for(ri i=2;i<=n;++i){
		for(ri j=0;j<=2;++j){
			f[i][j]=f[i-2][j]+val[i];
			if(i-3>=0&&j) f[i][j]=max(f[i][j],f[i-3][j-1]+val[i]);
		}
	}
	if(n%2==1){
		ll ans=f[n-2][0];
		ans=max(ans,max(f[n-1][0],f[n-1][1]));
		ans=max(ans,max(f[n][1],f[n][2]));
		int mn=INF;
		for(ri i=1;i<=n;i+=2) mn=min(mn,val[i]);
		ans=max(ans,f[n][0]-mn);
		print(ans);
	}
	else{
		ll ans=f[n-1][0];
		ans=max(ans,max(f[n][0],f[n][1]));
		print(ans);
	}
	return 0;
}

Measured memory_bytes: 9068
#include <stdio.h>

int main(){

int a,b;

int n,m;

while(1){

scanf("%d %d",&a,&b);

if(a==0&&b==0)

break;

for(m=1;m<=a;m++){

for(n=1;n<=b;n++){

printf("#");

}

printf("\n");

}

printf("\n");

}

return 0;

}

Measured memory_bytes: 572
N,M,X=map(int,input().split())
li=[list(map(int,input().split())) for _ in range(N)]
ans=float("inf")
for i in range(2**N):
  PriceAbil=[0]*(M+1)
  for j in range(N):
    if (i>>j)&1:
      PriceAbil=[x+y for (x,y) in zip(PriceAbil,li[j])]
  if min(PriceAbil[1:])>=X:
    ans=min(ans,PriceAbil[0])
if ans==float("inf"):
  print(-1)
else:
  print(ans)

Measured memory_bytes: 9164
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
string s;
int d, ans;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  FOR(i, 0, sz(s)){
    if(s[i] == 'S'){
      d++;
    }else{
      if(d > 0){
        d--;
      }else{
        ans++;
      }
    }
  }
  cout << ans + d << endl;
  return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
#include <fstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;
//ll kai[3010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

vector<ll> dx = { 0, 1, 0, -1, 1, -1, 1, -1, 0};
vector<ll> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0};

void chmin(double& x, double y) {
	x = min(x, y);
}

void chmax(double& x, double y) {
	x = max(x, y);
}

ll pow_long(ll x, ll y) {
	ll res = 1;
	while (y > 0) {
		if (y % 2 == 1) res *= x;
		x *= x;
		y /= 2;
	}
	return res;
}

void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 1000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; 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] % mod * finv[n - k] % mod;
}

ll N, X[101];
ll ans;

void solve() {
	ans = INF;
	cin >> N;
	rep(i, N) cin >> X[i];
	for (ll i = 1; i <= 100; i++) {
		ll sum = 0;
		rep(j, N) {
			sum += (X[j] - i) * (X[j] - i);
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll T = 1;
	//cin >> T;
	rep(i, T) solve();
}


Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    let c: i64 = read();
    println!(
        "{}",
        if a % 2 == 0 || b % 2 == 0 || c % 2 == 0 {
            0
        } else {
            *[a * b, b * c, c * a].iter().min().unwrap()
        }
    );
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
N, M = map(int, input().split())
dic ={}

ac = 0
wa = 0

for m in range(M):
    p, S = input().split()
    if p not in dic and S == 'WA':
        dic[p] = {'AC' : 0, 'WA' : 1}
    elif p not in dic and S == 'AC':
        dic[p] = {'AC' : 1, 'WA' : 0}
    elif p in dic and dic[p]['AC'] == 1:
        continue
    elif p in dic and dic[p]['AC'] != 1:
        if S == 'AC':
            dic[p]['AC'] += 1
        else :
            dic[p]['WA'] += 1 

for i in dic:
    if dic[i]["AC"] != 0:
        ac += dic[i]["AC"]
        wa += dic[i]["WA"] 


print('{0} {1}'.format(ac, wa))


Measured memory_bytes: 44512
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
ll gcd(ll a, ll b)
{
	for (;;)
	{
		if (a < b)swap(a, b);
		a %= b;
		if (a == 0)return b;
	}
}
int d[2000];
int get(ll t)
{
	int r = 0;
	for (;;)
	{
		if (t == 0)return r;
		r++;
		t /= 10;
	}
}
int main()
{
	ll n;
	scanf("%lld", &n);
	int mini = 1000000;
	for (ll i = 1; i*i <= n; i++)
	{
		if (n%i == 0)
		{
			mini = min(mini, max(get(i), get(n / i)));
		}
	}
	printf("%d\n", mini);
}

Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int main() {

	string S;
	long long K;
	cin >> S >> K;

	/*
	long long pos = 0;
	while (K >= 1) {

		if (pos == S.length() - 1) {
			S[pos] = ((S[pos] - 'a') + K) % 26 + 'a';
			K = 0;
		}

		if (('z' - S[pos] + 1) <= K) {
			K = K - ('z' - S[pos] + 1);
			S[pos] = 'a';
		}

		pos++;
	}
	*/

	for (int i = 0; i < S.size(); i++) {
		if (i == S.size() - 1) {
			S[i] = ((S[i] - 'a') + K) % 26 + 'a';
			K = 0;
			break;
		}else if ('z' - S[i] + 1 <= K && S[i] != 'a') {
			K -= ('z' - S[i] + 1);
			S[i] = 'a';
		}
	}

	cout << S << endl;

	return 0;
}

Measured memory_bytes: 640
#include<cmath>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;

const int inf = 0x3f3f3f3f;
typedef long long ll;
const double pi=4*atan(1.0);

ll a[200005];
int main()
{    int n,k;
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        a[i]=i;a[i]+=a[i-1];
    }
    ll ans=1;
    if(k>n)printf("1\n");
    else
    {
        for(int i=k;i<=n;i++)
        {
            ans+=a[n]-a[n-i]-a[i-1]+1;
            ans%=1000000007;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 5216
#include "bits/stdc++.h"

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

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int UI;

using namespace std;

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

    int x, a, b;
    cin >> x >> a >> b;

    if (abs(a - x) < abs(b - x))
    {
        cout << "A" << endl;
    }
    else
    {
        cout << "B" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1061109567;
const ll LINF = 4557430888798830399ll;

/*---*/

int n, a[105];

void TestCase() {
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    ll ans = LINF;
    for(int d = -100; d <= 100; ++d) {
        ll sum = 0;
        for(int i = 1; i <= n; ++i) {
            sum += 1ll * abs(a[i] - d) * abs(a[i] - d);
        }
        ans = min(ans, sum);
    }
    printf("%lld\n", ans);
}

int main() {
#ifdef KisekiPurin
    freopen("KisekiPurin.in", "r", stdin);
    //freopen("KisekiPurin.out", "w", stdout);
#endif // KisekiPurin
    //InitCase();
    int t = 1;
    //scanf("%d", &t);
    for(int i = 1; i <= t; ++i) {
        //printf("Case #%d:", i);
        TestCase();
    }
    return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  vector<int> freq(10);
  int n1,n2,n3,n4;
  cin>>n1>>n2>>n3>>n4;
  freq[n1]++;
  freq[n2]++;
  freq[n3]++;
  freq[n4]++;
  rep(i,10) {
    if(i==1||i==9||i==7||i==4) {
      if(freq[i]!=1) {
        cout << "NO" << endl;
        return 0;
      }
    } else {
      if(freq[i]!=0) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner (System.in);

        int K = sc.nextInt();

        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(1);
        list.add(1);
        list.add(2);
        list.add(1);
        list.add(2);
        list.add(1);
        list.add(5);
        list.add(2);
        list.add(2);
        list.add(1);
        list.add(5);
        list.add(1);
        list.add(2);
        list.add(1);
        list.add(14);
        list.add(1);
        list.add(5);
        list.add(1);
        list.add(5);
        list.add(2);
        list.add(2);
        list.add(1);
        list.add(15);
        list.add(2);
        list.add(2);
        list.add(5);
        list.add(4);
        list.add(1);
        list.add(4);
        list.add(1);
        list.add(51);


        System.out.println(list.get(K-1));

    }
}

Measured memory_bytes: 21716
SA = list(input())
SB = list(input())
SC = list(input())

tmp = SA[0]
SA.remove(tmp)
for i in range(1000):
    if tmp == 'a':
        try:
            tmp = SA[0]
            SA.remove(SA[0])
        except:
            print('A')
            break
    elif tmp == 'b':
        try:
            tmp = SB[0]
            SB.remove(SB[0])
        except:
            print('B')
            break
    else:
        try:
            tmp = SC[0]
            SC.remove(SC[0])
        except:
            print('C')
            break

Measured memory_bytes: 9024
#include <bits/stdc++.h>
using namespace std;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;

static Graph graph;
static vector<int> retList;
static vector<bool> seen;

void dfs(int start, int length) {
  for (auto edge: graph[start]) {
    if (seen[edge.first])continue;
    seen[edge.first] = true;
    retList[edge.first]=(length+edge.second)%2;
    dfs(edge.first, (length+edge.second)%2);
  }
}

int main()
{
  // 入力受け取り
  int N, u,v;
  long w;
  cin >> N;
  graph.assign(N, vector<Edge>());
  seen.assign(N, false);
  retList.resize(N);
  
  for(int i=0; i<N-1; i++) {
    cin >> u >> v >> w;
    u--, v--;
    graph[u].push_back(Edge(v,(int)(w%2)));
    graph[v].push_back(Edge(u,(int)(w%2)));
  }
  
  seen[0] = true;
  retList[0]=0;
  dfs(0,0);
  
  for (auto ret: retList) {
    cout << ret << endl;
  }
  
  return 0;
}

Measured memory_bytes: 8192
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vl vector<long long>
#define vll vector<pair<long long, long long>>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define fori(i, n) for(ll i = 0; i < n; i++)
#define foris(i, a, b) for(ll i = a; i < b; i++)
#define forise(i, a, b) for(ll i = a; i <= b; i++)
#define ford(i, n) for(ll i = n; i >= 0; i--)
#define fords(i, a, b) for(ll i = a; i >= b; i--)
#define fordse(i, a, b) for(ll i = a; i > b; i--)
#define forr(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;

ll x, y, N;

int main() {
  io();
  cin >> N;
  
  double mmm = sqrt(N);
  int mm = sqrt(N);
  if((double)mm == mmm) {
    cout << mm + mm - 2;
    return 0;
  }
  else {
    while(N % mm != 0) {
      --mm;
    }
    cout << (mm + (N / mm)) - 2;
  }

  
  
  return 0;
}

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

int main()
{
	int a;
	int b;

	cin >> a;
	cin >> b;

	
	if(a%500<=b)
	{
		cout << "Yes" << endl;
	}

	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;
const int N = 1e6 + 5;
const int mod = 1e9 + 7;
ll qmi(ll a, ll b)
{
    ll res = 1;
    while (b)
    {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

ll fact[N], infact[N];
ll C(ll a, ll b)
{
    if (a < b) return 0;
    return fact[a] * infact[a - b] % mod * infact[b] % mod;
}

int main()
{
    fact[0] = infact[0] = 1;
    for (int i = 1; i < N; ++i)
    {
        fact[i] = fact[i - 1] * i % mod;
        infact[i] = infact[i - 1] * qmi(i, mod - 2) % mod;
    }
    int n;
    scanf("%d", &n);

    ll res = 0;

    res = qmi(10, n);

    ll diff = 0;

    for (int i = 1; i <= n; ++i)
    {
        diff = (diff + C(n, i) * (qmi(8, n - i) % mod) % mod) % mod;
    }

    res = ((res - diff * 2) % mod + mod) % mod;

    res = ((res - qmi(8, n)) % mod + mod) % mod;

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


    return 0;
}

Measured memory_bytes: 19452
//
//AtCoder Beginner Contest 132
//C - Divide the Problems
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int n;
    cin >> n;

    vector<int> d(n);
    REP(i, n) cin >> d[i];

    sort(ALL(d));
    cout << d[n/2] - d[n/2-1] << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <deque>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,n) loop(i,0,n)

using namespace std;

typedef vector<int> vi;
int const inf = 1 << 28;
int main(){
    vi q, r;
    for (int i = 1;; i++){
        int pq = i*(i + 1)*(i + 2) / 6;
        q.push_back(pq);
        if (pq & 1) r.push_back(pq);

        if (pq > 1e6 + 100) break;
    }

    int n = 1000000;

    vi dp(n + 1, inf);
    dp[0] = 0;
    rep(i, q.size()){
        rep(j, n + 1){
            if (j - q[i] >= 0){
                dp[j] = min(dp[j], dp[j - q[i]] + 1);
            }
        }
    }

    vi dp2(n + 1, inf);
    dp2[0] = 0;
    rep(i, r.size()){
        rep(j, n + 1){
            if (j - r[i] >= 0){
                dp2[j] = min(dp2[j], dp2[j - r[i]] + 1);
            }
        }
    }

    int t;
    while (cin >> t && t){
        cout << dp[t] << " " << dp2[t] << endl;
    }
}

Measured memory_bytes: 8792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,mn=INT_MAX;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    int dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(i=2;i<n;i++)
    {
        mn=INT_MAX;
        for(j=1;j<=2;j++)
        mn=min(mn,dp[i-j]+abs(a[i]-a[i-j]));
        dp[i]=mn;
    }
    cout<<dp[n-1];
    return 0;
}


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

main(){
	double p,q ;
	int cnt[4][2] = {} ;
	while( cin >> p ){
		if( cin.eof() ) break ;
		cin >> q ;
		
		if( p >= 1.1 ) cnt[0][0]++ ;
		else if( p >= 0.6 ) cnt[1][0]++ ;
		else if( p >= 0.2 ) cnt[2][0]++ ;
		else cnt[3][0]++ ;
		
		if( q >= 1.1 ) cnt[0][1]++ ;
		else if( q >= 0.6 ) cnt[1][1]++ ;
		else if( q >= 0.2 ) cnt[2][1]++ ;
		else cnt[3][1]++ ;
	}
	
	for( int i=0 ; i<4 ; i++ ){
		cout << cnt[i][0] << " " << cnt[i][1] << endl ;
	}
}

Measured memory_bytes: 1224
#すぬけくんの塗り絵
h,w,n=map(int,input().split())
dic={}
for  _ in range(n):
    a,b=map(int,input().split())
    for i in range(a-1,a+2):
        for j in range(b-1,b+2):
            if (i,j) in dic.keys():
                dic[(i,j)]+=1
            else:
                dic[(i,j)]=1
              
howmany=[0 for i in range(10)]
for some in dic.keys():
    a,b=some[0],some[1]
    if 2<=a<=h-1 and 2<=b<=w-1:
        howmany[dic[some]]+=1
J=(h-2)*(w-2)-sum(howmany)
print(J)
for i in range(1,10):
    print(howmany[i])


Measured memory_bytes: 151724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int inf=1e9;
int main(void)
{
    int N;
    cin >> N;
    int ans=0;
    for(int i=1;i<=N;i++)
    {
        string s=to_string(i);
        if(int(s.size())%2!=0) ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;



/* Name of the class has to be "Main" only if the class is public. */



public class Main
{
     
     
     
   
    
public static void main (String[] args) throws java.lang.Exception
{Scanner scn = new Scanner(System.in) ;
  int n = scn.nextInt() ;
 if(n % 1000==0)
 {
   System.out.println(0) ;
 }
 
 else{
   
    System.out.println(1000*((n/1000) + 1 ) -n) ;
 }
 
}
}

Measured memory_bytes: 35708
#include<iostream>

using namespace std;

int main(){

    int N,M,dy=0; cin >> N >> M;
    char A[N][N],B[M][M];
    if(N < M){
      cout <<"No"<<endl;
      return 0;
    }
//画像A,Bの入力
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    for(int i=0; i<M; i++){
        cin >> B[i];
    }

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

        int Tcon = 0;
      //Bに合致するか比較
        for(int k=0; k<M; k++){

            for(int l=0; l<M; l++){

                if(A[k+dx][l+dy] == B[k][l]){
                  Tcon += 1;

                  if(Tcon == M*M){
                    cout << "Yes" << endl;
                    return 0;
                  }
                }
            }

        }

        dx +=1;
    }

      dy += 1;
  }

  cout <<"No" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int Flag0,n;
inline int query(vector<int> V)
{
	cout<<"? ";
	for(int i=0;i<(int)V.size();i++) cout<<V[i]<<' ';
	cout<<endl;fflush(stdout);
	string ans;cin>>ans;return ans=="Red";
}
inline vector<int> getvector(int l,int r)
{
	vector<int> ans;
	for(int i=l;i<=r;i++) ans.push_back(i);
	return ans;
}
inline vector<int> merge(vector<int> a,vector<int> b)
{
	for(int i=0;i<(int)b.size();i++) a.push_back(b[i]);
	return a;
}
string ans;
int main()
{
	scanf("%d",&n);
	Flag0=query(getvector(1,n));
	int L=1,R=n,Pos=0;
	while(L<R)
	{
		int mid=(L+R+1)>>1,flagmid=query(getvector(mid,mid+n-1));
		if(flagmid==Flag0) L=mid;else R=mid-1;
	}
	vector<int> t=getvector(L+1,L+n-1),tt=merge(getvector(1,L-1),getvector(L+n+1,n+n));
	for(int i=1;i<=n+n;i++)
	{
		vector<int> v=t;
		v.push_back(i);
		if(i>=L&&i<=L+n) v=tt,v.push_back(i);
		if(query(v)) ans+="R";else ans+="B";
	}
	cout<<"! "<<ans<<endl;
	fflush(stdout);
}

Measured memory_bytes: 3776
#include <iostream>
#include <vector>
using namespace std;
const int MAX = 255;
const unsigned int INF = 1<< 29;
int cal(int f,int s){
  return (f-s)*(f-s);
}
int solve(vector<vector<int> > dp){
  int ans = INF;
  for(int i = 0;i < dp.size();i++){
    ans = min(ans,dp[i][dp[0].size()-1]);
  }
  return ans;   
}
int main(){
  int n,m;
  while(cin >> n >> m,n && m){
    vector<int> c(m,0);
    vector<int> x(n,0);
    for(int i = 0;i < m;i++){
      cin >> c[i];
    }
    for(int i = 0;i < n;i++){
      cin >> x[i];
    }
    vector<vector<int> > dp(MAX+1,vector<int>(n+1,INF));
    dp[128][0] = 0;
    for(int i = 0;i < n;i++){
      for(int j = 0;j <= 255;j++){
	for(int k = 0;k < m;k++){
	  int plus = j+c[k];
	  if(plus < 0)plus = 0;
	  else if(plus > 255)plus = 255;
	  dp[plus][i+1] = min(dp[plus][i+1],dp[j][i]+cal(plus,x[i]));
	}
      }
    }
    /*    for(int j = 0;j <= n;j++){
      for(int i = 118;i <= 136;i++){
	cout << dp[i][j] << " ";
      }
      cout << endl;
      }*/
    cout << solve(dp) << endl;
    
  }
  return 0;
}

Measured memory_bytes: 41200
#include <cstdio>

#define NR 5001000

typedef long long ll;

int p[NR], n, q, len, top;
ll stk[NR];
ll size[NR], sum[NR], cnt[NR];


void add(ll m) {
	if (len == 0 || m <= sum[1]) {
		++len;
		p[len] = 0;
		//size[len] = 1;
		sum[len] = sum[len - 1] + m;
		return;
	}
	int l = 1, r = len;
	for (; l < r;) {
		int mid = (l + r + 1) / 2;
		if (sum[mid] < m ) l = mid;
		else r = mid - 1;
	}
	++len;
	p[len] = l;
	//size[len] = 1;
	sum[len] = sum[len - 1] + sum[l];
	if (sum[l] != m) add(m - sum[l]);
}

int main() {
	scanf("%d%d", &n, &q);

	stk[top = 1] = n;
	for (int i = 1; i <= q; ++i) {
		ll tmp;
		scanf("%lld", &tmp);

		while (top > 0 && stk[top] > tmp) {
			--top;
		}
		stk[++top] = tmp;
	}

	for (int i = 1; i <= top; ++i) {
		add(stk[i] - stk[i - 1]);
		
		//if (i % 5000 == 0) printf("!!%d %lld\n", len, sum[1]);
		//if (i > 80000) return 0;
	}

	
	size[len] = 1;
	
	for (int i = len; i >= 1; --i) {
		size[i - 1] += size[i];
		//printf("!%d %d\n", i, sum[i] - sum[i - 1]);
		if (p[i] == 0) {
		
			cnt[sum[i] - sum[i - 1]] += size[i];
		} else {
			size[p[i]] += size[i];
		}
	}

	for (int i = n; i >= 1; --i) {
		cnt[i - 1] += cnt[i];
	}

	for (int i = 1; i <= n; ++i) {
		printf("%lld\n", cnt[i]);

	}
	return 0;
}

Measured memory_bytes: 31104
#include<iostream>
using namespace std;
int main()
{
long long a,b,x,sum=0;
cin>>a>>b>>x;
if(x>0&&a<=b)
{
if(a%x==0)
sum=(b/x)-(a/x)+1;
else
sum=(b/x)-(a/x);
}
cout<<sum;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
	"sort"
)

type byMod []int
type byZeroMod []int

func (s byMod) Len() int {
	return len(s)
}
func (s byMod) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}
func (s byMod) Less(i, j int) bool {
	return s[i]%10 > s[j]%10
}

func (s byZeroMod) Len() int {
	return len(s)
}
func (s byZeroMod) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}
func (s byZeroMod) Less(i, j int) bool {
	return s[i]%10 == 0
}

func main() {
	var intArray []int

	intArray = make([]int, 5)
	i := 0
	for i = 0; i < 5; i++ {
		fmt.Scanf("%d", &intArray[i])
	}
	sort.Sort(byMod(intArray))
	sort.Sort(byZeroMod(intArray))
	res := 0
	l := i - 1
	for p, v := range intArray {
		if p == l {
			res += v
		} else {
			res += int(10 * math.Ceil(float64(v)/float64(10)))
		}
	}
	fmt.Println(res)
}


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

using namespace std;

#define N 120000
#define LL long long

LL n,mn,mx,a[N];

int main(){
	scanf("%lld",&n);
	for (LL i=1;i<=n;i++) scanf("%lld",&a[i]);
	mn=mx=2;
	for (LL i=n;i>=1;i--){
		mx=mx/a[i]*a[i];
		mx+=a[i]-1;
		mn=(mn+a[i]-1)/a[i]*a[i];
	}
	if (mx<mn) puts("-1");
	else printf("%lld %lld\n",mn,mx);
	
	return 0;
}
			

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,k,q;
    cin >> n >> k >> q;
    vector<int32> cnt(n, 0);
    REP(i,q){
        int32 a;
        cin >> a;
        a--;
        cnt[a]++;
    }
    REP(i,n){
        Yes(k - q + cnt[i] > 0);
    }
    return 0;
}

Measured memory_bytes: 1408
#! /usr/bin/env python
# -*- coding: utf-8 -*-

def main():
	n,m = map(int,input().split())
	m_list = list(map(int,input().split()))
	sum = 0
	for i in m_list:
		sum += i
	
	if n < sum:
		print ("-1")
	else:
		print (n-sum)

if __name__ == '__main__':
	main()


Measured memory_bytes: 10000
#include <stdio.h>
#include <string.h>

int checkSolve(char str[]){
	if(strstr(str, "the") != NULL ||
	   strstr(str, "this") != NULL ||
	   strstr(str, "that") != NULL){
			return 1;
	}
	return 0;
}

int main(){
	int i;
	int find = 0;
	char str[100];

	while(fgets(str,99,stdin) != NULL){
		while(checkSolve(str)==0 && str[0]>='a'){
			i = 0;
			while(i < strlen(str)){
					if(str[i]!=' ' && str[i]!='.' && str[i]!='\n'){
						if(str[i]=='a'){
							str[i] = 'z';
						}else{
							str[i] = str[i] - 1;
						}
					}
					i++;
			}
		}
		if(checkSolve(str)==1){
				printf("%s",str);
		}
	}
	return 0;
};

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=100100100100;
const int Inf=1001001001;
const int mod=1000000007;
const double pi=3.141592653589793;

int main(){
  ll n,d,ans=0;
  cin>>n>>d;
  vvi v(n,vi(d));
  rep(i,n)rep(j,d)cin>>v[i][j];
  rep(i,n){
    REP(j,i+1,n){
      int a=0;
      double b=0;
      ll sum=0;
      rep(k,d)sum+=(v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
      a=sqrt(sum);
      b=sqrt(sum);
      if(a==b)ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    s = input()
    q = int(input())
    for i in range(q):
        code = input().split()
        op, a, b = code[0], int(code[1]), int(code[2])
        if op == 'print':
            print(s[a:b+1])
        elif op == 'reverse':
            s = s[:a] + s[a:b+1][::-1] + s[b+1:]
        elif op == 'replace':
            s = s[:a] + code[3] + s[b+1:]

Measured memory_bytes: 6724
<?php
fscanf(STDIN, "%d", $N);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
$tmp = 0;
for ($i = 0; $i < $N; $i++) {
    $tmp ^= $a[$i];
}
$ans = [];
for ($i = 0; $i < $N; $i++) {
    $ans[] = $tmp ^ $a[$i];
}
echo implode(' ', $ans);


Measured memory_bytes: 43016
#include<stdio.h>
int main(void){
	int a, b, d, r;
	double f;
	scanf("%d %d",&a,&b);
	d = a/b;
	r=a%b;
	f=1.0*a/b;
	printf("%d %d %lf\n",d,r,f);
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 998244353;



int main(void){
    int N,K;
    string S;
    cin >> N >> S >> K;
    char a;
    a = S.at(K-1);
    
    
    for(int i = 0; i < N; i++){
        if(S.at(i) == a){
            cout << a;
        }
        else{
            cout << '*';
        }
    }
    cout << endl;
}


Measured memory_bytes: 256