akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

long long int diffsum(vector<int> &a, int b){
    long long int sum = 0;
    for(int i=0; i<(int)a.size(); i++){
        sum += abs(a[i] -(b +i +1));
    }
    return sum;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        a[i] += 2e5;
    }
    int lb=0, ub=1e9;
    while(lb<ub){
        int m[2] = {(lb+ub)/2, (lb+ub)/2+1};
        long long int sum[2] = {diffsum(a, m[0]), diffsum(a, m[1])};
        if(sum[0] < sum[1]){
            ub = m[0];
        }else{
            lb = m[1];
        }
    }
    cout << diffsum(a, lb) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pb       push_back
#define mp       make_pair
#define mod      1000000007
#define pi       acos(-1.0)
typedef long long ll;
using namespace std;
int main()
{      


     ios::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     

     int n;
     cin>>n;
     int  x,y;
     vector<pair<int,int>>p,q,r;
    for(int i=0;i<n;i++)
    {
         cin>>x>>y;
         p.push_back(make_pair(x,y));
         q.push_back(make_pair(x+y,i));
         r.push_back(make_pair(x-y,i));
    }
    sort(q.begin(),q.end());
    sort(r.begin(),r.end());

    ll ans1=abs(p[q[0].second].first-p[q[n-1].second].first)+abs((p[q[0].second].second-p[q[n-1].second].second));
    ll ans2=abs(p[r[0].second].first-p[r[n-1].second].first)+abs((p[r[0].second].second-p[r[n-1].second].second));
    cout<<max(ans1,ans2)<<endl;


     

      return 0;
 }       


Measured memory_bytes: 8148
import re

N, Q = map(int, input().split())
S = input()
lr_list = [map(int, input().split()) for _ in range(Q)]

count_array = []

count = 0
is_first = True
for index in range(N):
    if index == 0:
        pass
    elif S[index - 1] == 'A' and S[index] == 'C':
        count += 1
    count_array.append(count)


for l, r in lr_list:
    right_count = count_array[r-1]
    left_count = count_array[l-1]
    print(right_count - left_count)


Measured memory_bytes: 52280
#include<iostream>
using namespace std;
int main() {
	int A, B;
	int l;
	cin >> A >> B;
	if (A - 2 * B > 0) {
		l = A - 2 * B;
	}
	else {
		l = 0;
	}
	cout << l;
	return 0;
}



Measured memory_bytes: 256
s = input()
num = len(s)
a = [0]*(num+1)

for i in range(num):
    if s[i] == '<':
        a[i+1] = max(a[i+1], a[i]+1)

for i in range(1, num+1):
    if s[-i] == '>':
        a[-(i+1)] = max(a[-(i+1)], a[-i]+1)
print(sum(a))


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

int n, r;

ll solve() {
    if (n >= 10) return r;
    return r + 100 * (10 - n);
}

int main() {
    cin >> n >> r;
    cout << solve() << endl;
}

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

string reverse(const string& str) {
	string ret;
	string::const_reverse_iterator it = str.rbegin();
	for (; it != str.rend(); it++) {
		ret.push_back(*it);
	}
	return ret;
}

int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		string S1;
		string S2;
		int overflow = 0;
		cin >> S1 >> S2;
		if (S1.size() > 80 || S2.size() > 80) {
			cout << "overflow";
			overflow++;
		}
		S1 = reverse(S1);
		S2 = reverse(S2);
		S1.resize(80, '0');
		S2.resize(80, '0');
		int a = 0;
		for (int i = 0; i < 80; i++) {
			S1[i] += S2[i] - '0';
			if (S1[i] > '9') {
				if (i + 1 > 79) {
					cout << "overflow";
					overflow++;
				}
				S1[i + 1] += 1;
				S1[i] -= 10;
			}
			if (S1[i] != '0')
				a = i;
		}
		S1 = reverse(S1);
		if (overflow == 0)
			for (int i = 79 - a; i < 80; i++) {
				cout << S1[i];
			}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
//たくさんの人をチームに入れればよいな。
//そういえば、すべてのチームにはコーダーがいるなあ。CCC以外のチームは、コーダーとほかの種類を交換してるよな。
//交換しても、チーム数は変わらないし…。むしろ、再結成によってチーム数が増えるかも…
//ナビゲーターは入れるだけ入ればよい。アルゴリズマーも入れるだけ入ればよい。気がする。(コーダーも入れるｄ(とはならない希ガス))
//CANを作れるだけ作る→CCAを作れるだけ作る→CCCを作れるだけ作る.(勘アルゴリズム)
#include<iostream>
#include<math.h>
using namespace std;

int Q;
int C,A,N;
int ans[100];

int main(){
	int i,j;
	cin >> Q;
	for(i = 0;i < Q;i++){
		int team;
		cin >> C >> A >> N;
		team = min(C,min(A,N));
		C -= team;
		A -= team;
		N -= team;
		ans[i] += team;
		team = min(C >> 1,A);
		C -= team * 2;
		A -= team;
		ans[i] += team;
		team = C / 3;
		C -= team * 3;
		ans[i] += team;
	}
	for(i = 0;i < Q;i++){
		cout << ans[i] << endl;
	}
	return 0;
}
	

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	ll sum = 0, n, k;
	cin>>n>>k;
	for(ll i=k;i<=n+1;i++)
	{
		sum+=i*(n-i+1)+1;
	}
	cout<<sum%(1000000007);
}

Measured memory_bytes: 3644
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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; }

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};



void solve(){
    ll n;
    ll a[1010];
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    ll cnt[1010]={};
    rep(i,n){
        ll c=0;
        while(a[i]%2==0){
            c++;
            a[i]/=2;
        }
        cnt[i]=c;
    }
    ll ans=LLINF;
    rep(i,n) chmin(ans,cnt[i]);
    cout<<ans<<endl;

}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


Measured memory_bytes: 256
let [| N; M |] = stdin.ReadLine().Split() |> Array.map int
let H = stdin.ReadLine().Split() |> Array.map int

let AB = Array.zeroCreate<int> N

for _ in [ 1..M ] do
    let ab = stdin.ReadLine().Split() |> Array.map int
    AB.[ab.[0] - 1] <- max AB.[ab.[0] - 1] H.[ab.[1] - 1]
    AB.[ab.[1] - 1] <- max AB.[ab.[1] - 1] H.[ab.[0] - 1]

AB
|> Array.indexed
|> Array.filter (fun x -> H.[fst x] > snd x)
|> Array.length
|> stdout.WriteLine


Measured memory_bytes: 52860
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define PB push_back
#define SZ size()
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define GET(a) cin >> (a)
#define GET2(a, b) cin >> a >> b
#define GET3(a, b, c) cin >> a >> b >> c
#define SHOW(v) cout << v << endl
#define MOD 1000000007
typedef long long ll;

using namespace std;

struct xyz {
	int a;
	int b;
};

int main()
{
	int n, t;
	GET2(n, t);
	
	vector<xyz> v(n);
	REP(i, n) {
		GET2(v[i].a, v[i].b);
	}
	
	int ans = 100000;
	REP(i, n) {
		if(v[i].b <= t && ans > v[i].a) {
			ans = v[i].a;
		}
	}
	
	if(ans != 100000) {
		SHOW(ans);
	}
	else {
		SHOW("TLE");
	}
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Integer[] a = new Integer[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    Arrays.sort(a, Comparator.reverseOrder());
    int alice = 0;
    int bob = 0;
    for (int i = 0; i < n; i++) {
      if (i % 2 == 0) {
        alice += a[i];
      } else {
        bob += a[i];
      }
    }
    System.out.println(alice - bob);
  }
}

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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"
#define all(x) x.begin(),x.end()
#define sz(x) x.size()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int n,q;
vector<int> v;
vector<pair<int,int>> queries;
int block_size;
map<pair<int,int>,int> mp;

void solve()
{
    cin>>n>>q;
    v.resize(n);
    for(auto &x:v)cin>>x;
    queries.resize(q);
    for(auto &P:queries)cin>>P.first>>P.second;
    vector<pair<int,int>> dummy(queries);
    block_size=int(sqrt(n));
    sort(all(queries),[&](pair<int,int> a,pair<int,int> b){
        if((a.first/block_size)!=(b.first/block_size))return (a.first/block_size)<(b.first/block_size);
        return a.second<b.second;
    });
    int curL=0,curR=-1;
    vector<int> cur(n+1);
    int ans=0;
    for(auto P:queries){
        int l=P.first-1,r=P.second-1;
        while(curL<l){
            cur[v[curL]]--;
            ans-=(cur[v[curL]]==0);
            curL++;
        }
        while(curL>l){
            cur[v[curL-1]]++;
            ans+=(cur[v[curL-1]]==1);
            --curL;
        }
        while(curR<r){
            cur[v[curR+1]]++;
            ans+=(cur[v[curR+1]]==1);
            ++curR;
        }
        while(curR>r){
            cur[v[curR]]--;
            ans-=(cur[v[curR]]==0);
            --curR;
        }
        mp[P]=ans;
    }
    for(auto P:dummy)cout<<mp[P]<<"\n";
}

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

Measured memory_bytes: 46840
N=int(input())
p=list(map(float,input().split()))
dp=[[0 for _ in range(N+1)] for _ in range(N+1)]
dp[0][0]=1
for i in range(N):
    for j in range(N):
        dp[i+1][j]+=dp[i][j]*(1-p[i])
        dp[i+1][j+1]+=dp[i][j]*p[i]
print(sum(dp[-1][N//2+1:]))

Measured memory_bytes: 223912
#include <iostream>
#include <cstdio>
#include <cassert>
using namespace std;
typedef long long LL;
const int MAXN=3000;
int n;
LL mods;
struct M{
	LL x;
	M (){
		x=0;
	}
	M (LL angka){
		if(angka>=mods||angka<=-mods)
			angka%=mods;
		if(angka<0)
			angka+=mods;
		x=angka;
	}
	
	M operator + (const M &other) const{
		return M(x+other.x);
	}
	M operator - (const M &other) const{
		return M(x-other.x);
	}
	M operator * (const M &other) const{
		return M(x*other.x);
	}
	M operator - () const{
		return M (-x);
	}
	bool operator == (const M &other) const{
		return x==other.x;
	}
};
M dp[MAXN+5],dp2[MAXN+5][MAXN+5],dp3[MAXN+5][MAXN+5],fakt[MAXN+5],pangpang[MAXN+5],ans;
M DnC(M angka,LL pangkat){
	if(pangkat==0)
		return 1;
	M ret=DnC(angka,pangkat>>1);
	ret=ret*ret;
	if(pangkat&1LL)
		ret=ret*angka;
	return ret;
}
M inv(M angka){
	M ret=DnC(angka,mods-2);
	assert(ret*angka==1);
	return ret;
}
M kombin(int N,int K){
	if(K>N)
		return 0;
	return fakt[N]*inv(fakt[K])*inv(fakt[N-K]);
}
void isipangpang(){
	pangpang[0]=2;
	for(int i=1;i<=n;i++)
		pangpang[i]=pangpang[i-1]*pangpang[i-1];
}
void isifakt(){
	fakt[0]=1;
	for(int i=1;i<=n;i++)
		fakt[i]=fakt[i-1]*i;
}
void isidp3(){
	//basecase
	dp3[0][0]=1;
	for(int i=1;i<=n;i++)
		dp3[0][i]=0;
	
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
			dp3[i][j]=((j)?dp3[i-1][j-1]:0)+dp3[i-1][j]*(j+1);
	}
}
void isidp2(){
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			dp2[i][j]=dp3[i][j]*DnC(2,(n-i)*j)*(pangpang[n-i]);
		}
	}
}
void isidp(){
	for(int i=1;i<=n;i++)
	{
		dp[i]=0;
		for(int j=0;j<=i;j++)
			dp[i]=dp[i]+dp2[i][j];
	}
}
void isians(){
	ans=pangpang[n];
	for(int i=1,status=-1;i<=n;i++,status=-status)
		ans=ans+kombin(n,i)*dp[i]*status;
}
int main()
{
	cin>>n>>mods;
	isipangpang();
	isifakt();
	isidp3();
	isidp2();
	isidp();
	isians();
	cout<<ans.x<<endl;
}

Measured memory_bytes: 141440
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
typedef long long LL;
const LL mod = 1e9 + 7;
const int N = 3e5 + 5;

int n, m, fa[N], siz[N], ans;

int get(int x) {
	if(fa[x] == x) return x;
	return fa[x] = get(fa[x]);
}

int main() {
	cin>>n>>m;
	rep(i, 1, n) fa[i] = i, siz[i] = 1;
	rep(i, 1, m) {
		int u, v;
		cin>>u>>v;
		u = get(u), v = get(v);
		if(u == v) continue;
		fa[v] = u;
		siz[u] += siz[v];
	}
	rep(i, 1, n)
	    if(fa[i] == i) ans = max(ans, siz[i]);
	cout<<ans<<endl;
}

Measured memory_bytes: 5184
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

int n, d = 0;
int o[1000][1000];
int cp[1000];
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    memset(o, -1, sizeof(o));
    F0R(i, n) 
    {
        F0R(j, n - 1) 
        {
            cin >> o[i][j];
            o[i][j]--;
        }
    }
    // for(auto i : o) 
    // {
    //     for(auto j : i) cout << j << " ";
    //     cout << "\n";
    // }
    bool c = true;
    unordered_map<ll, int> m;
    stack<int> tc;
    F0R(i, n) tc.push(i);
    int tot = 0;
    while(c)
    {
        c = false;
        tot += sz(tc);
        vector<pair<int, int>> e;
        while(!tc.empty())
        {
            int j = tc.top();
            tc.pop();
            if(cp[j] < n - 1)
            {
                int a = o[j][cp[j]], b = j;
                if(a > b) swap(a, b);
                m[1005 * (a + 1) + (b + 1)]++;
                if(m[1005 * (a + 1) + (b + 1)] == 2) 
                {
                    // cout << a << " " << b << "\n";
                    c = true;
                    e.pb({a, b});
                }
            }
        }
        for(auto i : e) 
        {
            cp[i.f]++;
            cp[i.s]++;
            tc.push(i.f);
            tc.push(i.s);
            m.erase((i.f + 1) * 1005 + (i.s + 1));
        }
        // cout << "\n";
        d++;
        if(!c) break;
    }
    bool pos = true;
    F0R(i, n) if(cp[i] != n - 1) pos = false;
    cout << (pos ? d - 1 : -1);
    return 0;
}

Measured memory_bytes: 4224
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0
inf = float("inf")

a,v = I()
b,w = I()
t = k()
sa = v-w
if sa <= 0:
    print("NO")
    sys.exit()
kyori = abs(b-a)
if (kyori / sa)<=t:
    print("YES")
else:
    print("NO")


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

int main(){
    string s;
    cin >> s;
    int num1,num2,ans;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'){
            num1 = i;
            break;
        }
    }
    for(int j=s.size()-1;j>=0;j--){
        if(s[j]=='Z'){
            num2 = j;
            break;
        }
    }
    ans = num2-num1+1;
    cout << ans << '\n';
}

Measured memory_bytes: 640
#!/usr/bin/env python3
import sys


def solve(K: int):
    even = K//2
    odd = K-even
    print(even*odd)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)


if __name__ == '__main__':
    main()


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

const int MAXN = 5e5;

int n;
string s;
int seg[4*MAXN+20];
int q;
 
void build(int pos, int l, int r){
	if(l==r){
		seg[pos] = 1<<(s[l]-'a');
	} else {
		build(pos<<1, l, (l+r)>>1);
		build((pos<<1)+1, ((l+r)>>1)+1, r);
		seg[pos] = seg[pos<<1] | seg[(pos<<1)+1];
	}
}

void upd(int pos, int l, int r, int tar){
	if(l==r){
		seg[pos] = 1<<(s[l]-'a');
	} else {
		if(tar <= ((l+r)>>1)){
			upd(pos<<1, l, ((l+r)>>1), tar);
		} else {
			upd((pos<<1)+1, ((l+r)>>1)+1, r, tar);
		}
		seg[pos] = seg[pos<<1] | seg[(pos<<1)+1];
	}
}
 
int que(int pos, int l, int r, int ql, int qr){
	if(ql>qr) return 0;
	if(l==ql && r==qr){
		return seg[pos];
	} else {
		int m = (l+r)>>1;
		int a = que(pos<<1, l, m, ql, min(m,qr));
		int b = que((pos<<1)+1, m+1, r, max(ql,m+1), qr);
		return a | b;
	}
}

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

	cin >> n;
	cin >> s;
	cin >> q;

	build(1,0,n-1);

	while(q--){
		int type;
		cin >> type;
		if(type==1){
			int i;
			char c;
			cin >> i >> c;
			s[i-1]=c;
			upd(1,0,n-1,i-1);
		} else if(type==2){
			int l,r;
			cin >> l >> r;
			cout << __builtin_popcount(que(1,0,n-1,l-1,r-1)) << "\n";
		}
	}

}


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

#define int long long
const int MOD = 1000000007LL;

int dp[100010];
int a[110];
int minVal = MOD;
int n;

bool dfs(int k){

    //cout << k << endl;
    if(dp[k] != -1) return (bool)dp[k];
    if(k < minVal){
        dp[k] = 0;
        //cout << k << " " << dp[k] << endl;
        return dp[k];
    }
    //cout << "hoge" << endl;
    bool rec = true;
    for(int i = 0; i < n; i++){
        //cout << a[i] << endl;
        //cout << k - a[i] << endl;
        if(k >= a[i]) rec = rec && dfs(k - a[i]);
    }

    dp[k] = (int)(!rec);
    //cout << k << " " << !rec << endl;
    return !rec;
}

signed main(){

    int k; cin >> n >> k;
    //vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        minVal = min(minVal, a[i]);
    }

    //for(int i = 0; i < n; i++) cout << a[i] << endl;
    
    for(int i = 0; i < k + 1; i++) dp[i] = -1;
    
    
    if(dfs(k)) cout << "First" << endl;
    else cout << "Second" << endl;

    return 0;
}

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

class Main{
    public static void main(String[] args){
        solve();
    }

    public static void solve(){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length();
        int count0 = 0;
        int count1 = 0;
        for(int i=0;i<n;i++){
        	if(s.charAt(i)=='0'){
        		count0++;
        	}
        	else{
        		count1++;
        	}
        }
        System.out.println(2*(int)Math.min(count0, count1));
    }
}

Measured memory_bytes: 26788
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<cmath>
#include<set>
#include<stack>

using namespace std;


int main(){
    int x,y,m,n;
    while(cin>>m>>n,m){
        x=0,y=n-1;
        int dir=1;
        int dx[4]={1,0,-1,0};
        int dy[4]={0,-1,0,1};
        string s;
        while(cin>>s){
            if(s=="STOP")break;
            if(s[0]=='R'){
                dir=(dir+3)%4; continue;
            } else if(s[0]=='L'){
                dir=(dir+1)%4; continue;
            }
            int st;
            cin>>st;
            int td=dir;
            if(s[0]=='B')td=(td+2)%4;
            while(x+dx[td]<m&&x+dx[td]>=0&&y+dy[td]>=0&&y+dy[td]<n&&st--){
                x=x+dx[td];
                y=y+dy[td];
            }
            //cout<<x<<" "<<y<<endl;
        }
        cout<<x+1<<" "<<(n-y)<<endl;
    }
    return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define SCANF(i) int i;scanf("%d",&i)
typedef long long ll;
using namespace std;
using P = pair<int,int>;
const long long INF = 1LL << 60;
const int IINF=100000000;
const int MOD = (int)1e9 + 7;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

signed main () {
    int n,k;cin >> n >> k;
    vector<ll> price(n);
    REP(i,n)cin >> price[i];
    sort(ALL(price));
    ll ans = 0;
    for(ll a : price){
        ans+=a;
        k--;
        if(k==0)break;
    }
    cout << ans << endl;
}//https://atcoder.jp/contests/abc171/tasks/abc171_b

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

int main(){
    int N,P;
    long long ans=0;
    char c;
    cin >> N >> P;
    int S[N];
    for(int i=N-1; i>=0; i--){
        cin >> c;
        S[i]=(c-'0');
    }
    if(P==2 || P==5){
        for(int i=0; i<N; i++){
            if(S[i]%P==0){
                ans+=N-i;
            }
        }
    }else{
        long long R[P]={0};
        R[0]=1;
        int base=1;
        int sModP=0;
        for(int i=0; i<N; i++){
            sModP+=(base*S[i]);
            sModP%=P;
            R[sModP]++;
            base*=10;
            base%=P;
        }
        for(int i=0; i<P; i++){
            if(R[i]>1) ans+=(R[i]*(R[i]-1))/2;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1152
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
    string s; cin >> s;

    A--; B--; C--; D--;
    bool ok = true;
    {
        // A -> C
        int cons = 0, max_cons = 0;
        for(int i=A; i<=C; i++) {
            if(s[i] == '.') {
                max_cons = max(max_cons, cons);
                cons = 0;
            }
            else {
                cons++;
            }
        }

        ok &= (max_cons < 2);
        fprintf(stderr, "ok1 = %d\n", max_cons < 2);
    }
    {
        // B -> D
        int cons = 0, max_cons = 0;
        for(int i=B; i<=D; i++) {
            if(s[i] == '.') {
                max_cons = max(max_cons, cons);
                cons = 0;
            }
            else cons++;
        }
        ok &= (max_cons < 2);
        fprintf(stderr, "ok2 = %d\n", max_cons < 2);
    }

    if(C > D) {
        bool can = false;
        can |= (0 < B and B < N - 1 and s[B-1] == '.' and s[B+1] == '.');
        can |= (0 < D and D < N - 1 and s[D-1] == '.' and s[D+1] == '.');
        
        // 追い越す場合は 3 マス以上の空きがどこかに必要
        int cons = 0, max_cons = 0;
        for(int i=B; i<=D; i++) {
            if(s[i] == '#') {
                max_cons = max(max_cons, cons);
                cons = 0;
            }
            else cons++;
        }
      	max_cons = max(max_cons, cons);
        can |= (max_cons >= 3);
        // fprintf(stderr, "max_cons = %lld, can = %d\n", max_cons, can);

        ok &= can;
    }

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 640
module IntSet = Set.Make (struct
  type t = int
  let compare = compare
end)

let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let as_ = Array.init n (fun _ -> Scanf.scanf "%d\n" (fun a -> a)) in
  Array.fold_left (fun s a ->
    if IntSet.mem a s then IntSet.remove a s
    else IntSet.add a s) IntSet.empty as_
  |> IntSet.cardinal
  |> Printf.printf "%d\n"

Measured memory_bytes: 10752
fn main() {
    let mut buf = String::new();
    
    std::io::stdin().read_line(&mut buf).unwrap();
    
    let mut iter = buf.split_whitespace();
    
    let a: f64 = iter.next().unwrap().parse().unwrap();
    let b: f64 = iter.next().unwrap().parse().unwrap();
    let h: f64 = iter.next().unwrap().parse().unwrap();
    let m: f64 = iter.next().unwrap().parse().unwrap();

    let rad: f64 = std::f64::consts::PI * 2.0 * (h / 12.0 + m / 60.0 / 12.0 - m / 60.0);
    
    let rsq: f64 = (a * a + b * b) - (2.0 * a * b * rad.cos());
    
    println!("{:.20}", rsq.sqrt());
}

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

const int maxn = 1e6+10;
const int mod = 998244353;
int add(int a,int b){
    a+=b;
    if(a>=mod)  return a-mod;
    return a;
}
int sub(int a,int b){
    a-=b;
    if(a<0) return a+mod;
    return a;
}
int mul(int a,int b){
    long long t = 1ll*a*b;
    return t-t/mod*mod;
}
int qp(int a,int b){
    int ans=1;
    while(b){
        if(b&1) ans = mul(ans,a);
        a=mul(a,a);
        b>>=1;
    }
    return ans;
}

namespace NumberTheory{
    int prime[maxn],ptot,sm[maxn];
    void eulerseive(const int n){
        for(int i=2;i<=n;++i){
            if(!sm[i])  prime[sm[i]=++ptot]=i;
            for(int j=1;j<=sm[i];++j){
                if((long long)i*prime[j]>n) break;
                sm[i*prime[j]]=j;
            }
        }
        for(int i=2;i<=n;++i)   sm[i]=prime[sm[i]];
        sm[1]=1;
    }
    int mu[maxn];
    void getmu(const int n){
        mu[1]=1;
        for(int i=2;i<=n;++i){
            if(sm[i/sm[i]]==sm[i])    mu[i]=0;
            else mu[i]=-mu[i/sm[i]];
        }
    }
    int inv[maxn];
    void getinv(int n,const int mod){
        inv[1]=1;
        for(int i=2;i<=n;++i)
            inv[i]=mod-mul(mod/i,inv[mod%i]);
    }
}

int ddiv(int a,int b)
{
    return mul(a,NumberTheory::inv[b]);
}
int a[maxn],F[maxn];
int cnt[maxn];
int s2[maxn],s1[maxn];
const int maxN = 1000000;
int main()
{
    ios::sync_with_stdio(false);
    NumberTheory::eulerseive(1000000);
    NumberTheory::getmu(1000000);
    NumberTheory::getinv(1000000,mod);
    int N;
    cin>>N;
    for(int i=1;i<=N;++i)   cin>>a[i];
    for(int i=1;i<=N;++i)
        cnt[a[i]]++;
    for(int i=1;i<=maxN;++i)
        for(int j=i;j<=maxN;j+=i)
            if(cnt[j])
                s1[i]=add(s1[i],mul(cnt[j],j));
    for(int i=1;i<=maxN;++i)
        for(int j=i;j<=maxN;j+=i)
            if(cnt[j])
                s2[i]=add(s2[i],mul(cnt[j],mul(j,j)));
    for(int i=1;i<=maxN;++i){
        F[i]=ddiv(sub(mul(s1[i],s1[i]),s2[i]),2);
    }
    int ans=0;
    for(int i=1;i<=maxN;++i)
        if(NumberTheory::mu[i]<0)
            NumberTheory::mu[i]+=mod;
    for(int i=1;i<=maxN;++i){
        int tmp=0;
        for(int j=i;j<=maxN;j+=i)
            tmp = add(tmp,mul(NumberTheory::mu[j/i],F[j]));
        ans=add(ans,ddiv(tmp,i));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 33024
#include <iostream>
using namespace std;
int main(void){
        int a,b;
        char op;
        
        cin>>a>>op>>b;
        
        while(true){
            
            if(op=='?') {
            break;
            }
            
            if(op=='+'){
                cout<<(a+b)<<endl;
            }
            else if(op=='-'){
                cout<<(a-b)<<endl;
            }
            else if(op=='*'){
                cout<<(a*b)<<endl;
            }
            else if(op=='/'){
                cout<<(a/b)<<endl;
            }
         
        cin >> a >> op >> b;
        }
    }


Measured memory_bytes: 3100
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int main(void)
{
    int N, x[8], y[8];
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i];
    }
    vector<vector<int>> root;
    for(int i = 0; i < N; i++){
        root.push_back({i});
    }
    double sum = 0;
    int count = 0;
    while(root.size() > 0){
        vector<int> a = root[root.size() - 1];
        root.pop_back();
        for(int i = 0; i < N; i++){
            bool flag = 1;
            for(int j = 0; j < a.size(); j++){
                if(i == a[j]){
                    flag = 0;
                    break;
                }
            }
            if(flag){
               vector<int> copy = a;
               copy.push_back(i);
               if(copy.size() == N){
                   for(int k = 0; k < N - 1; k++){
                       sum += sqrt(pow(x[copy[k]] - x[copy[k + 1]], 2) + pow(y[copy[k]] - y[copy[k + 1]], 2));
                   }
                   count++;
               }
               else{
                   root.push_back(copy);
               }
            }
        }
    }
    printf("%lf\n", sum / (double)count);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<int, int> P;


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

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; 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 COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


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

int main() {

ll n;
cin>>n;

ll a[n+1];
ll b[n+1];
rep(i, n){
	cin>>a[i];
}


rep(i, n){
	cin>>b[i];
}


ll cnt=0;
queue<ll> que{};

while(1){
	ll co=1;
rep(i, n){
if(i==1){
	if(b[i]>=b[2]+b[n]+a[1])
{
	que.push(i);
}
if(b[i]!=a[i]) co=0;
}

if(i==n){
	if(b[n]>=b[n-1]+b[1]+a[n]){
		que.push(i);
	}
	if(b[i]!=a[i]) co=0;
}
if(2<=i && i<=n-1){
	if(b[i]>=b[i-1]+b[i+1]+a[i]){
		que.push(i);
	}
	if(b[i]!=a[i]) co=0;
}
}

if(que.size()==0 && co==0){
	cout<<-1<<endl;
	return 0;
}
if(que.size()==0 && co==1){
	cout<<cnt<<endl;
	return 0;
}



for(int t=0;t<que.size();t++){
	ll l=que.front();
	ll k;
	if(l==1){
	 k= (b[l]-a[l])/(b[n]+b[l+1]);
b[l]-=k*(b[n]+b[l+1]);
	}
if(l==n){
	 k= (b[l]-a[l])/(b[l-1]+b[1]);
b[l]-=k*(b[l-1]+b[1]);
}
if(l>=2 && l<=n-1){
k= (b[l]-a[l])/(b[l-1]+b[l+1]);
b[l]-=k*(b[l-1]+b[l+1]);
}

que.pop();
cnt+=k;

}


}






return 0;
}




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


int main(){
  vector<vector<int>> c(3,vector<int>(3));
  int i,j;
  for(i=0;i<3;++i){
    for(j=0;j<3;++j){
      cin >> c[i][j];
    }
  }
  vector<int>a(3,0),b(3,0);
  int loop=c[0][0];
  a[0]=0;
  int h=1;
    for(i=0;i<3;++i){
      b[i]=c[0][i]-a[0];
    }
    for(i=0;i<3;++i){
      a[1]=c[1][i]-b[i];
    }
    for(i=0;i<3;++i){
      a[2]=c[2][i]-b[i];
    }

    for(i=0;i<3;++i){
      for(j=0;j<3;++j){
        if(c[i][j]!=a[i]+b[j]){
          h=0;
        }
      }
  }
  if(h==1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
from collections import deque

l = deque([])
n = int(input())
for i in range(n):
    com = input()
    if com == "deleteFirst":
        a = l.popleft()
    elif com == "deleteLast":
        a = l.pop()
    else:
        m = com.split()
        if m[0] == "insert":
            l.appendleft(m[1])
        else:
            try:
                l.remove(m[1])
            except:
                a = 1
print(" ".join(l))

Measured memory_bytes: 71928
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#define SIZE 100005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll A[SIZE];
int sgn[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%lld",&A[i]);
	int mn=0,pl=0;
	for(int i=0;i<n;i++)
	{
		if(A[i]>=0) pl++;
		if(A[i]<=0) mn++;
	}
	if(pl==0)
	{
		ll mx=A[0];
		for(int i=0;i<n;i++) mx=max(mx,A[i]);
		for(int i=0;i<n;i++)
		{
			if(mx==A[i])
			{
				sgn[i]=1;
				mx=0;
			}
			else sgn[i]=-1;
		}
	}
	else if(mn==0)
	{
		ll mn=A[0];
		for(int i=0;i<n;i++) mn=min(mn,A[i]);
		for(int i=0;i<n;i++)
		{
			if(mn==A[i])
			{
				sgn[i]=-1;
				mn=0;
			}
			else sgn[i]=1;
		}
	}
	else
	{
		pl=mn=0;
		for(int i=0;i<n;i++)
		{
			if(A[i]>0)
			{
				sgn[i]=1;
				pl++;
			}
			else if(A[i]<0)
			{
				sgn[i]=-1;
				mn++;
			}
		}
		for(int i=0;i<n;i++)
		{
			if(A[i]==0)
			{
				if(pl==0)
				{
					sgn[i]=1;
					pl++;
				}
				else sgn[i]=-1;
			}
		}
	}
	ll ret=0;
	queue <int> vp,vm;
	for(int i=0;i<n;i++)
	{
		if(sgn[i]==1)
		{
			ret+=A[i];
			vp.push(i);
		}
		else
		{
			ret-=A[i];
			vm.push(i);
		}
	}
	printf("%lld\n",ret);
	while(vp.size()>=2)
	{
		int v=vp.front();vp.pop();
		int u=vm.front();vm.pop();
		printf("%lld %lld\n",A[u],A[v]);
		A[u]-=A[v];
		vm.push(u);
	}
	while(vm.size()>=1)
	{
		int v=vp.front();vp.pop();
		int u=vm.front();vm.pop();
		printf("%lld %lld\n",A[v],A[u]);
		A[v]-=A[u];
		vp.push(v);
	}
	return 0;
}


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

const int MOD = 1000000007;
template<class T> inline void add_mod(T &a, const T b) {
	a += b;
	if(a >= MOD) a -= MOD;
}

bool a[100010];
long dp[100010];

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		a[x] = true;
	}
	dp[0] = 1;
	for(int i = 1; i <= n; i++) {
		if(a[i]) continue;
		if(i - 1 >= 0) add_mod(dp[i], dp[i-1]);
		if(i - 2 >= 0) add_mod(dp[i], dp[i-2]);
	}
	printf("%ld\n", dp[n]);
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	string S;
	int A[4];
	cin>>S;
	A[0]=S[0]-'0';
	A[1]=S[1]-'0';
	A[2]=S[2]-'0';
	A[3]=S[3]-'0';
	int ct=0;
	int i;
	for(i=0;i<8;i++){
		switch(i){
			case 0: ct=A[0]+A[1]+A[2]+A[3]; break;
			case 1: ct=A[0]+A[1]+A[2]-A[3]; break;
			case 2: ct=A[0]+A[1]-A[2]+A[3]; break;
			case 3: ct=A[0]+A[1]-A[2]-A[3]; break;
			case 4: ct=A[0]-A[1]+A[2]+A[3]; break;
			case 5: ct=A[0]-A[1]+A[2]-A[3]; break;
			case 6: ct=A[0]-A[1]-A[2]+A[3]; break;
			case 7: ct=A[0]-A[1]-A[2]-A[3]; break;
		}
		if(ct==7) break;
	}
	switch(i){
		case 0: cout<<A[0]<<"+"<<A[1]<<"+"<<A[2]<<"+"<<A[3]<<"=7"; break;
		case 1:cout<<A[0]<<"+"<<A[1]<<"+"<<A[2]<<"-"<<A[3]<<"=7"; break;
		case 2:cout<<A[0]<<"+"<<A[1]<<"-"<<A[2]<<"+"<<A[3]<<"=7"; break;
		case 3: cout<<A[0]<<"+"<<A[1]<<"-"<<A[2]<<"-"<<A[3]<<"=7"; break;
		case 4:cout<<A[0]<<"-"<<A[1]<<"+"<<A[2]<<"+"<<A[3]<<"=7"; break;
		case 5:cout<<A[0]<<"-"<<A[1]<<"+"<<A[2]<<"-"<<A[3]<<"=7"; break;
		case 6: cout<<A[0]<<"-"<<A[1]<<"-"<<A[2]<<"+"<<A[3]<<"=7"; break;
		case 7:cout<<A[0]<<"-"<<A[1]<<"-"<<A[2]<<"-"<<A[3]<<"=7"; break;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100+7]; 
int main()
{
	int n;
	cin>>n;
	int maxn=-101;
	int minn=101; 
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]; 
		if(a[i]>=maxn)
		maxn=a[i];
		if(a[i]<=minn) 
 		minn=a[i];
	}
	int ans=0x3f3f3f3f; 
	for(int i=minn;i<=maxn;i++)
	{
		int sum=0; 
		for(int j=1;j<=n;j++)
		{
			sum+=(a[j]-i)*(a[j]-i);
		}
		if(sum<=ans)
		ans=sum;
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
using namespace std;
typedef pair<ll, ll> P;

ll dp[50][2] = { 0 };
int main(void) {
	int n, k;
	string s;
	cin >> n >> s >> k;
	for (int i = 0;i < n;i++) {
		if (s[k - 1] != s[i]) {
			s[i] = '*';
		}
	}
	cout << s << endl;
}

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

#define PI 3.14159265358979323846

int main()
{
	int		n;
	double	t;

	while(cin >> t, t)
	{
		for(int i=1; true; i++)
		{
			n = (int)(PI*i + 0.5);

			if(fabs((double)n/i -PI) <= t)
			{
				cout << n << "/" << i << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	H,W = MI()
	W1 = (W+1)//2
	W2 = W//2
	H1 = (H+1)//2
	H2 = H//2
	if(H==1 or W==1):
		print(1)
	else:
		print(H1*W1+H2*W2)

if __name__ == '__main__':
	main()

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  int x,i=0,store[100];
  char s[100];

  for(i=0;scanf("%s", s) != EOF;i++){
    if ( s[0] == '+' ){
      store[i-2]=store[i-2]+store[i-1];
     
     i=i-2;
 
    } else if ( s[0] == '-' ){
      store[i-2]=store[i-2]-store[i-1];
      
      i=i-2;

    } else if ( s[0] == '*' ){
      store[i-2]=store[i-2]*store[i-1];
     
    i=i-2;
 
    } else {
      x = atoi(s);
      store[i]=x;
    
    }
   
  }
  printf("%d\n",store[0]);
 
  return 0;
}

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

int main() {
    int sum = 0, max = 0, n = 3, a;
    while (n--) {
        scanf("%d", &a);
        if (a > max) max = a;
        sum += a;
    }
    puts(sum - max == max ? "Yes" : "No");
}


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

int main(){
    int n,d[100][2],flag=0;
    
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>d[i][0]>>d[i][1];
        
    for(int i=0;i<n-2;i++){
        if(d[i][0]==d[i][1]&&d[i+1][0]==d[i+1][1]&&d[i+2][0]==d[i+2][1]){
            flag=1;
            break;
        }
    }
    if(flag==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3636
#include <stdio.h>
int binary(int n,int *s,int t){
  int mid,right,left;
  right = n;
  left = 0;
  mid = (right + left)/2;
  while(left != mid){
    mid = (left + right)/2;
    if(s[mid] < t) left = mid+1;
    else if(s[mid] > t) right = mid;
    else if(s[mid] == t) return 1;
  }
  return 0;
}

int main(){
  int n,q;
  int s[100000],t[50000];
  scanf("%d",&n);
  int i;
  for (i=0;i<n;i++) scanf("%d",&s[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++) scanf("%d",&t[i]);
  int count=0;
  for (i=0;i<q;i++){
    if(binary(n,s,t[i])) count++;
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 1184
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<cmath>
#include<iomanip>
using namespace std;

int main(void){
	double a,c,d,e,f,dod,ret[1001],it[1000],w;
	cin>>f;
	d=0.333333333333;
	for(int b=0;f>b;b++){
		cin>>a;
		ret[b]=a;
	}
	for(int b=0;f>b;b++){
		cin>>a;
		it[b]=a;
	}
	for(int b=0;f>b;b++){
		c=ret[b]-it[b];
		if(c<0){
			c=c*-1;
		}
		dod+=c;
	}
	printf("%.8lf\n",dod);
	dod=0;
	for(int b=0;f>b;b++){
		c=ret[b]-it[b];
		dod+=c*c;
	}
	printf("%.8lf\n",sqrt(dod));
	dod=0;
	for(int b=0;f>b;b++){
		c=ret[b]-it[b];
		if(c<0){
			c=c*-1;
		}
		dod+=c*c*c;
	}
	printf("%.8lf\n",pow(dod,d));
	dod=0;
	for(int b=0;f>b;b++){
		c=ret[b]-it[b];
		if(c<0){
			c=c*-1;
		}
		if(dod<c){
			dod=c;
		}
	}
printf("%.8lf\n",dod);
	return 0;
}


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

using namespace std;

class Node {
public:
    Node(int key, Node* parent = nullptr) : key_(key), parent_(parent), leftChild_(nullptr), rightChild_(nullptr) {}
    void insert(int key) {
        Node* y = nullptr;  // x の親
        Node* x = this;
        while (x != nullptr) {
            y = x;  // 親を設定
            if (key < x->key_) {
                x = x->leftChild_;  // 左の子へ移動
            }
            else {
                x = x->rightChild_; // 右の子へ移動
            }
        }
        Node* z = new Node(key, this);
        if (key < y->key_) {
            y->leftChild_ = z;
        }
        else {
            y->rightChild_ = z;
        }
    }
    bool find(int key) {
        Node* x = this;
        while (x != nullptr) {
            if (key == x->key_) {
                return true;
            }
            else if (key < x->key_) {
                x = x->leftChild_;  // 左の子へ移動
            }
            else {
                x = x->rightChild_; // 右の子へ移動
            }
        }
        return false;
    }
    void printInorder() {
        if (leftChild_ != nullptr) {
            leftChild_->printInorder();
        }
        cout << " " << key_;
        if (rightChild_ != nullptr) {
            rightChild_->printInorder();
        }
    }
    void printPreorder() {
        cout << " " << key_;
        if (leftChild_ != nullptr) {
            leftChild_->printPreorder();
        }
        if (rightChild_ != nullptr) {
            rightChild_->printPreorder();
        }
    }
private:
    int key_;
    Node* parent_;
    Node* leftChild_;
    Node* rightChild_;
};

class Tree {
public:
    Tree() : root_(nullptr) {}
    void insert(int key) {
        if (root_ != nullptr) {
            root_->insert(key);
        }
        else {
            root_ = new Node(key);
        }
    }
    bool find(int key) {
        if (root_ != nullptr) {
            return root_->find(key);
        }
        else {
            return false;
        }
    }
    void print() {
        if (root_ != nullptr) {
            root_->printInorder();
            cout << endl;
            root_->printPreorder();
            cout << endl;
        }
    }
private:
    Node* root_;
};

int main()
{
    int n;
    cin >> n;
    string operation;
    Tree tree;
    for (int i = 0; i < n; ++i) {
        cin >> operation;
        if (operation == "insert") {
            int x;
            cin >> x;
            tree.insert(x);
        }
        else if (operation == "find") {
            int x;
            cin >> x;
            if (tree.find(x)) {
                cout << "yes" << endl;
            }
            else {
                cout << "no" << endl;
            }
        }
        else {
            tree.print();
        }

    }
}



Measured memory_bytes: 21856
# -*- coding: utf-8 -*-

def main():
	s = input()
	first = int(s[:2])
	second = int(s[2:])

	if (first >= 13 or first == 00) and (second >= 13 or second == 00):
		print("NA")
	elif first >= 13 or first == 00:
		print("YYMM")
	elif second >= 13 or second == 00:
		print("MMYY")
	else:
		print("AMBIGUOUS")


if __name__ == "__main__":
	main()


Measured memory_bytes: 3060
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd
#define mod 100000007
#define INF 1e9
/****************************/
int a[110];
int main()
{
	int n;
	cin>>n;
	rep(i,n)
	{
		cin>>a[i];
	}
	ll ans=1e18;
	sort(a,a+n);
	rep3(j,0,a[n-1]+1)
	{
		int num=j;
		ll ans2=0;
		rep(i,n)
		{
			ans2+=(ll)((a[i]-num)*(a[i]-num));
		}
		ans=min(ans,ans2);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
#define LAST(X) X[X.size()-1]
#define MOD 1000000007
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	vector <int> A(3);
	rep(i,3)
	cin >> A[i];
	sort(all(A));
	if (A[0] + A[1] == A[2])
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;

int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
  int n,k;
  cin >> n >> k;
  if(n*500>=k)cout << "Yes";
  else cout << "No";

        

}

Measured memory_bytes: 256