akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<ll, ll>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

/* -- template -- */

int main() {
    ll X;
    cin >> X;
    vector<pair<ll, int>>ans;

    for(ll i = 0; i * i * i * i * i <= 1e14; ++i) {
        ans.pb(mp(i * i * i * i * i, i));
        ans.pb(mp(-1 * i * i * i * i * i, -1 * i));
    }
    rep(i, ans.size()) {
        rep(j, ans.size()) {
            if(ans[i].first - ans[j].first == X) {
                cout << ans[i].second << ' ' << ans[j].second << endl;
                return 0;
            }
        }
    }
    cout << ans.size() << endl;
}


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

int descending_compare(const void *a, const void *b){
    if (*(long long*)a > *(long long*)b){
        return -1;
    }else if (*(long long*)a == *(long long*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}

unsigned long lcm(unsigned long x, unsigned long y){
    unsigned long g = gcd(x, y);
    return x*y/g;

}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/

/*unsigned long long pascal[100][100] = {0};
void make_pascal(void){
    for (int i = 0; i < 100; i++){
        pascal[i][0] = 1;
    }
    pascal[1][1] = 1;
    for (int i = 2; i < 100; i++){
        for (int j = 1; j < 100; j++){
           pascal[i][j] = (pascal[i-1][j-1]+pascal[i-1][j]);
        }
    }
}*/
long long mod = 1000000007;

long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % mod;
        x = x * x % mod;
    }
    return res;
}

int c[3][3];
int dx[2];
int dy[2];

int main(void){
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
            scanf("%d", &c[j][i]);
        }
    }

    for (int i = 0; i < 3; i++){
        for (int j = 1; j < 3; j++){
            if (i == 0) dx[j-1] = c[j][i] - c[j-1][i];
            else{
                if (dx[j-1] != c[j][i] - c[j-1][i]){
                    printf("No");
                    return 0;
                }
            }
        }
    }
    for (int i = 0; i < 3; i++){
        for (int j = 1; j < 3; j++){
            if (i == 0) dy[j-1] = c[i][j] - c[i][j-1];
            else{
                if (dy[j-1] != c[i][j] - c[i][j-1]){
                    printf("No\n");
                    return 0;
                }
            }
        }
    }
    printf("Yes\n");
    return 0;

}

Measured memory_bytes: 888
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define SIZE 262144
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
ll po(ll a, ll b)
{
	if (b == 0)return 1;
	ll z = po(a, b / 2);
	z = z*z%mod;
	if (b & 1)z = z*a%mod;
	return z;
}
ll getinv(ll a)
{
	return po(a, mod - 2);
}
class BIT
{
public:
	ll bit[SIZE + 1];
	void add(int a, ll b)
	{
		a++;
		for (;;)
		{
			bit[a] = (bit[a] + b) % mod;
			a += a&-a;
			if (a > SIZE)return;
		}
	}
	ll get(int a)
	{
		a++;
		ll ret = 0;
		for (;;)
		{
			ret += bit[a];
			a -= a&-a;
			if (a == 0)return ret%mod;
		}
	}
};
BIT glo, bi1, bi2;
typedef pair<ll, ll>pii;
int dat[202020];
ll tim[202020], rui[202020], gg[202020];
int main()
{
	int num;
	scanf("%d", &num);
	vector<pii>zv;
	invinit();
	for (int i = 0; i < num; i++)
	{
		scanf("%d", &dat[i]);
		zv.push_back(make_pair(dat[i], i));
	}
	sort(zv.begin(), zv.end());
	int now = 0, st = 0;
	ll ans = 0, cnt = 1;
	for (int i = 0; i < num; i++)
	{
		int k = zv[i].second;
		if (dat[k] <= i)
		{
			printf("0\n");
			return 0;
		}
		cnt = cnt*(dat[k] - i) % mod;
		ll pr;
		if (now - i == 0)
		{
			pr = inv[dat[k] - now];
			tim[k] = 1;
		}
		else
		{
			pr = (rui[now] + mod - rui[st])*inv[now - i] % mod;
			tim[k] = getinv(pr)*inv[dat[k] - i] % mod;
		}
		for (int j = now + 1; j <= dat[k]; j++)rui[j] = (rui[j - 1] + pr) % mod;
		now = dat[k];
		if (dat[k] == i + 1)
		{
			ll sum = 0;
			for (int j = i; j >= st; j--)
			{
				int x = zv[j].second;
				ll kak = (rui[dat[x]] + mod - rui[st]) % mod;
				ll s1 = bi1.get(x), s2 = bi1.get(num) + mod - bi1.get(x);
				ll n1 = bi2.get(x);
				ll r1 = n1 + mod - s1*kak%mod*((mod + 1) / 2) % mod;
				ll r2 = s2*kak%mod*((mod + 1) / 2) % mod;
				sum += r1 + r2;
				bi1.add(x, tim[x]);
				bi2.add(x, 1);
			}
			ans = (ans + sum) % mod;
			for (int j = i; j >= st; j--)
			{
				ll x = zv[j].second;
				bi1.add(x, mod - tim[x]);
				bi2.add(x, mod - 1);
				gg[x] = st;
			}
			st = now;
		}
	}
	ll bas = 0;
	for (int i = 0; i < num; i++)
	{
		bas += glo.get(num) + mod - glo.get(gg[i]);
		glo.add(gg[i], 1);
	}
	printf("%lld\n", (bas + ans) % mod*cnt%mod);
}

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

int main() {
    long long n, d;
    cin >> n >>d;
    int ans = 0;
    d *= d;
    for(int i = 1; i <= n; ++i)
    {
        long long  x, y;
        cin >> x >> y;
        if(x * x + y * y <= d)
            ans ++;
    }

    cout << ans << endl;

    return 0;
}


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

#define endl "\n"
#define int long long

signed main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int a;
	cin >> a;
	if (a >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3612
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<functional>
using namespace std;
int main(void)
{
	long long int i,n,paipu,p,joi[65000],honsuu,max,m;
	while(1){
		scanf("%lld",&n);
		if(n==0)break;
		honsuu=n;
		paipu=0;
		for(i=0;i<n;i++){
			scanf("%lld",&p);
			paipu+=p;
		}
		for(i=0;i<n-1;i++) scanf("%lld",&joi[i]);
		sort(joi,joi+n-1,greater<int>());
		max=paipu*honsuu;
		for(i=0;i<n-1;i++){
			paipu+=joi[i];
			honsuu--;
			m=paipu*honsuu;
			if(max<m) max=m;
		}
		printf("%lld\n",max);
	}
	return 0;
}

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

int main (void){
  int a = 0,b = 0,c = 0,d = 0;

  cin >> a >> b >> c >> d;

  do{
    c = c - b;
    if(c <= 0){
      cout << "Yes\n";
      return 0;
    }
    a = a - d;
    if(a <= 0){
      cout << "No\n";
      return 0;
    }
  }while(a > 0 && c > 0);

}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

string smap[110];

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

	int A, B;
	int H = 100, W = 100;
	cin >> A >> B;

	rep(i, 0, H)rep(j, 0, W)
	{
		if (i < H / 2)
		{
			smap[i] += '#';
		}
		else
		{
			smap[i] += '.';
		}
	}

	rep(i, 1, A)
	{
		int y = 2 * (i / (W/2));
		int x = (i % (W / 2)) * 2;
		smap[y][x] = '.';
	}

	rep(i, 1, B)
	{
		int y = H - 1 - 2 * (i / (W / 2));
		int x = (i % (W / 2)) * 2;
		smap[y][x] = '#';
	}

	cout << H << " " << W << endl;
	rep(i, 0, H)
	{
		cout << smap[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections import deque


def solve(K: int):
    G = []
    m = {
        '0': [0, 1],
        '1': [0, 1, 2],
        '2': [1, 2, 3],
        '3': [2, 3, 4],
        '4': [3, 4, 5],
        '5': [4, 5, 6],
        '6': [5, 6, 7],
        '7': [6, 7, 8],
        '8': [7, 8, 9],
        '9': [8, 9],
    }
    q = deque([])
    for i in list(range(1, 10)):
        q.appendleft(i)
    while(len(G) <= 100000):
        v = str(q.pop())
        G.append(v)
        for nv in m[v[-1]]:
            q.appendleft(v + str(nv)) 
    print(G[K-1])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    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: 24048
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int main(){
    lli n;
    cin >> n;
    lli num[7], minimum = 1e+16;
    for(int i = 0; i < 5; ++i){
        cin >> num[i];
        minimum = min(minimum, num[i]);
    }

    lli ans = (n % minimum == 0)? n / minimum + 4 : n / minimum + 1 + 4;
    cout << ans << endl;
    return 0;
}

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

int main(){
    int h, c, w, space;
    while(scanf("%d\n", &h), h){
        scanf("%d\n%d\n%d\n", &c, &w, &space);
        
        string in = "";
        while(space--)  in += ".";

        string line;
        vector<string> v;
        while(getline(cin, line), line != "?"){
            int pos = 0;
            while(pos < line.length()){
                v.push_back(line.substr(pos, min((int)line.length()-pos, w)));
                pos += min((int)line.length()-pos, w);
            }
            if(pos == 0)    v.push_back("");
        }
        while(v.size()%(h*c))   v.push_back("");
        int pos = 0;
        while(pos < v.size()){
            for(int i = 0; i < h; i++){
                for(int j = 0; j < c; j++){
                    if(j)   cout << in;
                    cout << v[pos+j*h+i];
                    for(int k = 0; k < w-v[pos+j*h+i].length(); k++)    cout << ".";
                }
                cout << endl;
            }
            pos += h*c;
            cout << "#" << endl;
        }
        cout << "?" << endl;
    }
    return 0;
}


Measured memory_bytes: 3248
#include <iostream>

using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  int a[110];
  for(int i=0; i<N; i++) cin >> a[i];
  bool dp[100010];
  for(int i=0; i<=K; i++) dp[i]=false;
  for(int i=1; i<=K; i++){
    for(int j=0; j<N; j++){
      if(i>=a[j]){
        if(dp[i-a[j]]==false){
          dp[i]=true;
          break;
        }
      }
    }
  }
  if(dp[K]==true) cout << "First" << endl;
  else cout << "Second" << endl;
  
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
using namespace std;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size()-2;i++){
		if(s[i]==s[i+1] && s[i+1]==s[i+2]){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n;
int x[10], y[10];
double ans = 0;
//順列列挙
void permut(vector<int> v){
	do {
		for(int i = 1; i < v.size(); i++){
			ans += sqrt(pow(x[v[i]]-x[v[i-1]],2)+pow(y[v[i]]-y[v[i-1]],2));
		}
	} while (std::next_permutation(v.begin(), v.end()));
}
i64 kai(int a){
	i64 c = a;
	while(--a) c*=a;
	return c;
}
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> x[i] >> y[i];
	}
	vector<int> v;
	for(int i = 0; i < n; i++) v.push_back(i);
	permut(v);
	
	printf("%.10f\n",ans/kai(n));
}

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#define N 100005
using namespace std;
typedef long long ll;
const ll mod = 1000000007LL;
int n, m;
string a,b,c;
int main() {
  cin>>a>>b>>c;
  if (a.back() == b[0] && b.back() == c[0]) {
  	cout<<"YES"<<endl;
  } else {
  	cout<<"NO"<<endl;
  }
	return 0;
}

Measured memory_bytes: 256
A = []
min_1 = 9
min_index = 0
for i in range(5):
    a = int(input())
    A.append(a)
    if (a%10 == 0):
        continue
    if (a%10 <= min_1):
        min_1 = a%10
        min_index = i

t = A.pop(min_index)
for a in A:
    if a%10 == 0:
        t += a
    else:
        t += ((a//10)+1)*10
print(t)


Measured memory_bytes: 3060
H,W=map(int,input().split())
S=[['$']*(W+2)]+list(['$']+list(input())+ ['$'] for _ in range(H)) +[['$']*(W+2)]
ans=list([0]*W for _ in range(H))
c=0
for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j]=='.':
            c=0
            for x in [-1,1,0]:
                for y in [-1,1,0]:
                    if S[i+x][j+y]=='#':
                        c+=1
            ans[i-1][j-1]=c
        else:
            ans[i-1][j-1]=S[i][j]
for p in range(H):
    for q in range(W):
        print(ans[p][q],end='')
    else:
        print('')

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 112345
#define M 18
int n, u, v;
vi g[N];
int d[N] = {}, p[M][N];
int q[N];

void dfs(int a, int b){
	p[0][a] = b;
	FOR(i, 1, M) p[i][a] = p[i-1][ p[i-1][a] ];
	for(auto &i : g[a]){
		if(i == b) continue;
		d[i] = d[a] + 1;
		dfs(i, a);
	}
}
int lca(int a, int b){
	if(d[a] > d[b]) swap(a, b);
	DEBUG("lca(%d, %d)\n", a, b);
	for(int i = M-1; i >= 0; i--){
		if(d[b] - (1<<i) >= d[a]) {
			b = p[i][b];
		}
	}
	DEBUG(" => (%d, %d) ( d = %d, %d )\n", a, b, d[a], d[b]);
	if(a==b) return a;
	for(int i = M-1; i >= 0; i--){
		if(p[i][a] != p[i][b]){
			a = p[i][a];
			b = p[i][b];
			DEBUG(" => (%d, %d)\n", a, b);
		}
	}
	DEBUG(" => %d\n", p[0][a]);
	return p[0][a];
}

int main(){
	scanf("%d%d%d", &n, &u, &v);
	REP(i, n) {
		int a, b; scanf("%d%d", &a, &b);
		g[a].EB(b);
		g[b].EB(a);
	}
	dfs(v, v);
	iota(q, q+n, 1);
	sort(q, q+n, [](auto &x, auto &y){ return d[x] > d[y]; });
	REP(i, n){
		int s = q[i];
		int t = lca(u, s);
		DEBUG("s=%d, t=%d\n", s, t);
		if(t == v) continue;
		if(d[u]-d[t] >= d[t]) continue;
		printf("%d\n", d[s]-1);
		return 0;
	}
}





Measured memory_bytes: 18432
#include <iostream>

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

using namespace std;

string s;

int k(long long int l){
	long long int ret;
	ret = (l+1)/2;
	//printf("ret = %lld\n",ret);
	
	long long int i = l/2-1;
	long long int j = l%2==0 ? i+1 : i+2;
	//printf("i = %lld, j = %lld\n",i,j);
	//printf("s[i] = %c, s[j] = %c\n",s[i],s[j]);
	
	if (l%2!=0 && s[i]!=s[i+1]) return ret;
	if (s[i]!=s[j]) return ret;
	
	REP(m,l/2){
		if ((s[i]!=s[i-1])||(s[j]!=s[j+1])){
			ret += m+1;
			return ret;
		}else{
			i--; j++;
		}
	}
	return l;
}

int main(){
	cin >> s;
	long long int l = s.length();
	
	cout << k(l) << endl;
	
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int X, t;
    cin >> X >> t;
    cout << max(X - t, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <stack>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef pair<int,int> P;
typedef pair<P,int> Q;
#define fi first
#define sc second

string str;
int n,nn;
pair<int,int>rec(int L,int R){
	//cout << L << "  "<< R << endl;
	if(str[L+1]!='['){
		int ret = 0;
		for(int x=L+1;x<R;x++) ret = ret*10+(str[x]-'0');
		return make_pair((ret+1)/2,0);
	}
	else{
		vector<P>need;
		stack<int>que;
		for(int i=L+1;i<R;i++){
			if(str[i] == '[') que.push(i);
			else if(str[i] == ']'){
				int q = que.top(); que.pop();
				if(que.size() == 0) need.push_back(rec(q,i));
			}
		}
		//cout << str << " " << need.size() << endl;
		//cout << need[0].fi << " " <<  need[0].sc << endl;
		sort(need.begin(),need.end());
		int ans = 0;
		for(int i=0;i<(need.size()+1)/2;i++) ans+=need[i].fi;
		return P(ans,0);
	}
}
int main(){
	cin>>nn;
	while(nn--){
		cin>>str;
		n = str.size();
		cout << rec(0,n-1).first << endl;
	}
}



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

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;

    vector<int> a(n);
    for(int i = 1; i <= n; ++i)
    {
        int x; cin >> x;
        x -= i;
        a[i - 1] = x;
    }

    nth_element(a.begin(), a.begin() + a.size() / 2, a.end());
    int median = a[a.size()/2];
    long long s = 0;
    for(int x : a)
        s += abs(x - median);
    cout << s << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const ll MOD = (ll)1e9 + 7LL;

const int MAX_P=101;
int fact[MAX_P];

void init (void){
	fact[0] = 1;
	for (int i = 1; i < MAX_P; ++i){
		fact[i] = ((ll)fact[i-1]*i)%MOD;
	} // end for
}

ll dp[105][205][256];

int main()
{
	memset(dp, 0LL, sizeof(dp));
	init();
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, K; cin >> N >> K;
	vector<int> a(N, 0);
	rep (i, N) cin >> a[i];
	
	dp[0][0][0] = 1LL;	
	for (int i = 0; i < N; ++i){
		for (int j = 0; j <= i; ++j){
			for (int k = 0; k < 256; ++k){
				ll & ans = dp[i+1][j+1][k ^ a[i]];
				ans = (ans + dp[i][j][k]) % MOD;
				dp[i+1][j][k] = (dp[i+1][j][k] + dp[i][j][k]) % MOD;
			} // end for
		} // end for
	} // end for

	ll res = 0LL;
	for (int i = 1; i <= N; ++i) res = (res + dp[N][i][K] * fact[i]) % MOD;
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 43264
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")

#include <bits/stdc++.h>
using namespace std;
 
#define len(x) (int)((x).size())
#define endl '\n'
#define int long long
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(9);
    solve();
    return 0;
}
 
const int MOD = 998244353, MAXN = 3e5 + 10, INF = 1e18 + 10;

void solve() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);

    for (int i = 0; i < a; ++i) {
        cin >> p[i];
    }
    for (int i = 0; i < b; ++i) {
        cin >> q[i];
    }
    for (int i = 0; i < c; ++i) {
        cin >> r[i];
    }

    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());

    vector<int> v;
    for (int i = 0; i < x; ++i) {
        v.push_back(p[i]);
    }
    for (int i = 0; i < y; ++i) {
        v.push_back(q[i]);
    }
    for (int i = 0; i < c; ++i) {
        v.push_back(r[i]);
    }

    sort(v.rbegin(), v.rend());

    int ans = 0;
    for (int i = 0; i < x + y; ++i) {
        ans += v[i];
    }

    cout << ans << endl;
}   



Measured memory_bytes: 8688
use proconio::input;

fn main() {
    input! {
        text: String
    }

    let sum: i32 = text
        .chars()
        .map(|x: char| x.to_string())
        .map(|x: String| x.parse::<i32>().unwrap())
        .sum();

    if sum % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2412
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

N, K = i_l()
x = i_l()

ans = 1 << 31
for i in range(N-K+1):
    if x[i] >= 0:
        ans = min(ans, x[i+K-1])
    elif x[i+K-1] <= 0:
        ans = min(ans, abs(x[i]))
    elif x[i] <= 0 and 0 <= x[i+K-1]:
        ans = min(ans, x[i+K-1] - x[i] + min(abs(x[i+K-1]), abs(x[i])))

print(ans)

Measured memory_bytes: 14656
import heapq

N,M=map(int,input().split())
pq=list(map(lambda x:-1*int(x),input().split()))
heapq.heapify(pq)

for i in range(M):
    item=heapq.heappop(pq)
    heapq.heappush(pq,item/2)

ans=0
for i in range(N):
    item=heapq.heappop(pq)
    ans+=int(abs(item))

print(ans)

Measured memory_bytes: 104728
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){
  int A,B,C;
  scanf("%d %d %d",&A,&B,&C);
  for(int i=0;i<B;i++){
    if(A*i%B==C){
      printf("YES\n");
      return 0;
    }
  }
  printf("NO\n");
  return 0;
}

Measured memory_bytes: 256
//Author: Suifeng0214
//2020.7.26 8.40
#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<int>arr;
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, d, ans=0;
	cin >>  n >> d;
	for (int i = 0; i < n; i++){
		int x, y;
		cin >> x >> y;
		int z = x*x + y*y;
		if (z <= d*d) ans++;
	}
	cout << ans << "\n";
}



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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  set<char> ss;
  for (int i = 0; i < (int) s.size(); i++) {
    ss.insert(s[i]);
  }
  cout << (ss.size() == s.size() ? "yes" : "no") << '\n';
  return 0;
}

Measured memory_bytes: 3636
/*  ex9_2
    Y_Aizaki  */

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

#define SIZE 100000

typedef struct node{
    char elem;
    struct node *next;
}stack;

void push(stack **first, char elem);
char pop(stack **first);

int main(void){
    stack *stk;
    char input[SIZE];
    char *input_p = input;
    int removed = 0; // 除かれたキューブの数

    scanf("%s", input);
    stk = NULL; // stkの初期化

    while (*input_p != '\0'){ // inputを前から見ていくループ
        if (stk == NULL){ // stkが空の時
            push(&stk, *input_p);
        }
        else{ // stkに要素があるとき
            if (stk->elem != *input_p){ // inputで見ている要素と、stkの中身が違う時
                pop(&stk); // stkから消去
                removed += 2;
            }
            else{ // inputで見ている要素と、stkの中身が同じ時
                push(&stk, *input_p); // stkに追加
            }
        }
        input_p++;
    }

    printf("%d\n", removed);

    return 0;
}

void push(stack **first, char elem){
    stack *new = calloc(1, sizeof(stack));
    if (new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}


char pop(stack **first){
    char elem;
    stack *tmp = *first;
    if (tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;

    free(tmp);
    return elem;
}

Measured memory_bytes: 4920
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
typedef long long ll;

using namespace std;

int main(){
  int N;
  string s;
  cin >> N >> s;
  int r = 0;
  for (int i = 0; i < N; i++) {
    if (s[i] == 'R') r++;
  }
  if (N - r < r) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 256
n = input()

x = len(n)

if n == n[::-1]:

    if n[:((x-1)//2)] == n[:((x-1)//2)][::-1]:

        if n[((x+3)//2)-1:] == n[((x+3)//2)-1:][::-1]:

            print('Yes')

        else:

            print('No')

    else:

        print('No')

else:

    print('No')

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll ans = 0;
    ll tmp = 0;
    char acgt[4] = {'A', 'C', 'G', 'T'};
    REP(i, 0, S.size()) {
        char c = S[i];
        bool ok = false;
        REP(j, 0, 4) {
            if (c == acgt[j]) {
                ok = true;
            }
        }
        if (ok) {
            tmp++;
        } else {
            ans = max(ans, tmp);
            tmp = 0;
        }
    }
    ans = max(ans, tmp);
    cout << ans << endl;
}


Measured memory_bytes: 256
// Aizu Vol-5 0518: The Oldest Site
// 2017.9.1 bal4u@uu

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

typedef struct { int x, y; } T;
T p[3003]; int n;
char mk[5003][5003];

int search(int x1, int y1, int x2, int y2)
{
	int x3, y3, x4, y4;

	x3 = x2+y1-y2, y3 = y2+x2-x1;
	x4 = x1+y1-y2, y4 = y1+x2-x1;
	if (x3 >= 0 && x3 <= 5000 && y3 >= 0 && y3 <= 5000 &&
		x4 >= 0 && x4 <= 5000 && y4 >= 0 && y4 <= 5000) {
		if (mk[x3][y3] && mk[x4][y4]) return (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
	}

	x3 = x2+y2-y1, y3 = y2+x1-x2;
	x4 = x1+y2-y1, y4 = y1+x1-x2;
	if (x3 >= 0 && x3 <= 5000 && y3 >= 0 && y3 <= 5000 &&
		x4 >= 0 && x4 <= 5000 && y4 >= 0 && y4 <= 5000) {
		if (mk[x3][y3] && mk[x4][y4]) return (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
	}
	return -1;
}

int main()
{
	int i, j, k, x, y, ans;

	while (scanf("%d", &n) && n) {
		memset(mk, 0, sizeof(mk));
		for (i = 0; i < n; i++) {
			scanf("%d%d", &x, &y);
			p[i].x = x, p[i].y = y, mk[x][y] = 1; 
		}
		for (ans = 0, i = 0; i < n; i++) {
			for (j = i+1; j < n; j++) {
				if ((k = search(p[i].x, p[i].y, p[j].x, p[j].y)) > ans) ans = k;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 25072
N,K = map(int,input().split())
data = []
nolist = list(range(1,N+1))
for i in range(K):
  number = int(input())
  data = input().split()
  for j in range(number):
    nolist[int(data[j])-1] = 0
try:
  for i in range(N):
  	nolist.remove(0)
except:
  pass
print(len(nolist))

Measured memory_bytes: 9152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

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

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    a--;
    ll e = c/gcd(c,d)*d;
    ll ans = 0;
    ans = b-(b/c)-(b/d)+(b/e);
    //cout << ans << endl;
    ans -= a-a/c-a/d+a/e;
    cout << ans << endl;

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  string s, t;
  cin >> s >> t;
  unordered_map<char, char> mp;
  for (int i = 0; i < s.length(); ++i) {
    if (mp.find(s[i]) == mp.end()) {
      mp[s[i]] = t[i];
    } else if (mp[s[i]] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  unordered_map<char, int> mp2;

  for (auto c : mp) {
    if (++mp2[c.second] > 1) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


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

using namespace std;

int main(){ string s; cin >> s; int mina = s.size() + 1
  ; int maxz = 0;
           for(int i = 0; i < s.size(); i++){
             if(s[i] == 'A'){ mina = min(mina,i);}
             else if(s[i] == 'Z'){maxz = max(maxz,i);}}
             
             cout << maxz - mina + 1 << endl;
             
             return 0;}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>

using namespace std;

const int N = 100;
const int M = 51;
const double EPS = 1e-9;

int n, m, L, t[N], v[N];
double p[N], C[M+1][M+1], ps[N][N], s_ps[N][N], ts[N][N];

main(){
  for(int i=0;i<=M;i++) C[i][0] = 1.0;
  for(int i=1;i<=M;i++) for(int j=1;j<=i;j++) C[i][j] = C[i-1][j-1] + C[i-1][j];
  cin >> n >> m >> L;
  for(int i=0;i<n;i++) cin >> p[i] >> t[i] >> v[i];
  bool f = true;
  for(int i=0;i<n;i++) if(v[i]) f = false;
  if(f){
    for(int i=0;i<n;i++) printf("%.8f\n", 0+EPS);
    return 0;
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<=m;j++){
      ps[i][j] = C[m][j] * pow(p[i]/100.0, j) * pow((100 - p[i])/100.0, m - j);
      if(j == 0) s_ps[i][j] = ps[i][j];
      else s_ps[i][j] = s_ps[i][j-1] + ps[i][j];
      ts[i][j] = (double)L / v[i] + t[i] * j;
    }
  }
  for(int i=0;i<n;i++){
    double ans = 0.0;
    for(int j=0;j<=m;j++){
      double tmp = 1.0;
      for(int k=0;k<n;k++){
        if(k == i) continue;
        int l = lower_bound(ts[k], ts[k]+m+1, ts[i][j]+EPS) - ts[k];
        if(l != 0) tmp *= (1.0 - s_ps[k][l-1]);
      }
      ans += ps[i][j] * tmp;
    }
    printf("%.8f\n", ans+EPS);
  }
}

Measured memory_bytes: 1500
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  cout << (b-a)*(2*(k%2)-1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <sstream>
#include <cstdio>
#include <stack>
using namespace std;

// Switching Railroad Cars(0013)
int main()
{
	int n;
	stack<int> train;
	while (cin >> n) {
		if (n == 0) {
			cout << train.top() << endl;
			train.pop();
		} else {
			train.push(n);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int n,h[100005],m;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>h[i];
		if(h[i]<m)cout<<"No",exit(0);
		m=max(m,h[i]-1);
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 640
while True :
    try :
        s = list(input())
    except EOFError :
        break
    
    i = 0
    while i < len(s) :
        if s[i] == "@" :
            for j in range(int(s[i+1])) :
                print(s[i+2], end="")
            i += 3
        else :
            print(s[i], end="")
            i += 1
    print()


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

using namespace std;

int main(){
	int snum, tnum;
	cin >> snum;

	vector<int> s;
	vector<int> t;

	for(int i = 0; i < snum; i++){
		int x;
		cin >> x;
		s.push_back(x);
	}

	cin >> tnum;

	for(int i = 0; i < tnum; i++){
		int x;
		cin >> x;
		t.push_back(x);
	}

	sort(s.begin(), s.end());
	sort(t.begin(), t.end());

	int ans = 0;
	static int j = 0;

	for(int i = 0; i < tnum; i++){
		for(j = 0; j < snum; j++){
			if(t[i] == s[j]){
				while(t[i] == s[j]) j++;
				ans++;
			}
			else continue;
		}
		if(j < tnum) break;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <cstdio>

using namespace std;

#define M 800005
#define ll long long

int n, q, tot;
int fa[M];
ll ans, d[M];

struct Edge
{ int u, v; ll w; } e[M];

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { (x *= 10) += ch - '0'; ch = getchar(); }
	return x * f;
}

inline int findf(int x)
{ return fa[x] == x ? x : fa[x] = findf(fa[x]); }

inline bool cmp1(Edge a, Edge b)
{ return a.w < b.w; }

inline void kruscal()
{
	sort(e + 1, e + 1 + tot, cmp1);
	for (int i = 1; i <= tot; i++)
	{
		int uf = findf(e[i].u), vf = findf(e[i].v);
		if (uf == vf) continue;
		fa[uf] = vf; ans += e[i].w;
	}
}

int main()
{
	n = read(), q = read(); tot = q;
	for (int i = 0; i < n; i++) fa[i] = i;
	memset(d, 0x3f3f3f3f, sizeof(d));
	for (int i = 1; i <= q; i++)
	{
		e[i].u = read(), e[i].v = read(); e[i].w = read();
		d[e[i].u] = min(d[e[i].u], e[i].w + 1);
		d[e[i].v] = min(d[e[i].v], e[i].w + 2);
	}

	for (int i = 0; i < n; i++)
		d[i] = min(d[i], d[(i-1+n)%n] + 2);
	for (int i = 0; i < n; i++)
		d[i] = min(d[i], d[(i-1+n)%n] + 2);

	for (int i = 0; i < n; i++)
		e[++tot].u = i, e[tot].v = (i+1)%n, e[tot].w = d[i];

	kruscal();

	cout << ans<<endl;
	return 0;
}

Measured memory_bytes: 23056
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <functional>
 
using namespace std;
 
std::vector<int> TECC(const std::vector<std::vector<int>> &g) {
  const int n = g.size();
  std::vector<int> ord(n, -1);
  std::vector<int> low(n);
  std::vector<int> cid(n);
  std::vector<int> s;
  int k = 0;
  int c = 0;
  std::function<void(int, int)> dfs = [&](int u, int p) {
    low[u] = ord[u] = k++;
    s.push_back(u);
    for (int v : g[u]) {
      if (ord[v] == -1) {
        dfs(v, u);
        low[u] = std::min(low[u], low[v]);
      } else if (v != p) {
        low[u] = std::min(low[u], ord[v]);
      }
    }
    if (p == -1 || ord[p] < low[u]) {
      while (true) {
        int v = s.back();
        s.pop_back();
        cid[v] = c;
        if (v == u) break;
      }
      c++;
    }
  };
  for (int i = 0; i < n; i++) {
    if (ord[i] == -1) dfs(i, -1);
  }
  return cid;
}
 
int main() {
  int n, m;
  cin >> n >> m;
 
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
 
  set<int> st;
  for (int i : TECC(g)) {
    st.insert(i);
  }
 
  cout << st.size() - 1 << endl;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
if a < 0:
  if b >= 0:
    print('Zero')
  else:
    if (b - a) % 2 == 0:
      print('Negative')
    else:
      print('Positive')
elif a == 0:
  print('Zero')
else:
  print('Positive')


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

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string str;
    cin>>str;
    for(int i=0;i<str.size();i++)
    {
        if((i==5)||(i==13))
        {
            cout<<" ";
        }
        else
        {
            cout<<str[i];
        }
    }
    cout<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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



int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,k;
    cin>>n>>k;
    vl v(n);
    REP(i,n)
        cin>>v[i];

    ll ans = 0;
    REP(l, min(n+1, k+1)){
        REP(r, min(n+1, k+1-l)){
            ll tmp = 0;
            priority_queue<ll, vector<ll>, greater<ll>> minus;

            //DEBUG2(l,r);

            //左からL個
            REP(i,l){
                tmp += v[i];
                if(v[i]<0)
                    minus.emplace(v[i]);
            }
            //右からR個
            REP(i,r){
                if(n-i==l){
                    break;
                }
                tmp += v[n-1-i];
                //DEBUG(v[n-1-i]);
                if(v[n-1-i]<0)
                    minus.emplace(v[n-1-i]);
            }
            //DEBUG(tmp);
            int remain = k-l-r;

            while(!minus.empty() && remain>0){
                auto e = minus.top();
                minus.pop();
                //DEBUG(e);
                tmp -= e;
                remain--;
            }

            chmax(ans, tmp);
        }
    }


    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
import numpy as np

N = int(input())
arr = [list(map(int, input().split())) for _ in range(N)]
arr = np.array(arr)

if N % 2 == 1:
    a = np.sort(arr[:, 0])
    b = np.sort(arr[:, 1])
    print(b[N // 2] - a[N // 2] + 1)

else:
    a = np.sort(arr[:, 0])
    b = np.sort(arr[:, 1])
    print((b[N // 2] + b[N // 2 - 1]) - (a[N // 2 - 1] + a[N // 2]) + 1)


Measured memory_bytes: 66444
#include<stdio.h>
	int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);
	if(a == b)
		printf("a == b\n");
	else if(a > b)
		printf("a > b\n");
	else
		printf("a < b\n");
	return 0;
}

Measured memory_bytes: 580
#include <iostream>

using namespace std;

int main() {
	int A, B;
	int A1, A2, A3, A4;
	int B1, B2, B3, B4;
	cin >> A1 >> A2 >> A3 >> A4;
	A = A1 + A2 + A3 + A4;
	cin >> B1 >> B2 >> B3 >> B4;
	B = B1 + B2 + B3 + B4;

	cout << (A>B?A:B) << endl;
	return 0;
}

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

int main() {
  int K;
  string S;
  cin >> K >> S;
  
 int M = S.size();
  
  if(M > K){
  	cout << S.substr(0,K) << "..." << endl;
  }else{
    cout << S.substr(0,K) << endl;
  }
}




Measured memory_bytes: 3628
#include <iostream>
#include <stack>
#include <cstdlib>
#include <cstring>

using namespace std;

int main() {
  stack<int> s;
  char f[7];
  while(cin >> f) {
    if(atoi(f)) {
      s.push(atoi(f));
    } else if(!strcmp(f,"+")) {
      int p = s.top();
      s.pop();
      p += s.top();
      s.pop();
      s.push(p);
    } else if(!strcmp(f, "-")) {
      int m2 = s.top();
      s.pop();
      int m1 = s.top();
      s.pop();
      s.push(m1 - m2);
    } else if(!strcmp(f, "*")) {
      int t = s.top();
      s.pop();
      t *= s.top();
      s.pop();
      s.push(t);
    }
  }

  cout << s.top() << endl;

  return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

lli n, m;

int main(void){
    cin >> n >> m;
    UnionFind u(n);
    rep(i, m){
        lli a, b;
        cin >> a >> b;
        a--;
        b--;
        u.unite(a, b);
    }
    vector<lli> c(n);
    rep(i, n) c[u.root(i)]++;
    lli ans = 0;
    sort(c.begin(), c.end());
    rep(i, n){
        ans += c[i]-ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11712
#include<stdio.h>

const int N = 105;

int main()
{
	int n, a[N] = {0};

	scanf("%d", &n);
	for(int i = 0;i < n;i++)
	{
		scanf("%d", &a[i]);
	}
	for(int j = n-1;j > 0;j--)
	{
		printf("%d ", a[j]);
	}
	printf("%d\n", a[0]);
} 


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll INF=100000000000;

vector<ll> par1(200001);//親
vector<ll> Rank1(200001);//木の深さ
vector<ll> par2(200001);//親
vector<ll> Rank2(200001);//木の深さ

void init(ll n){//初期化
	rep1(i,n){
		par1[i]=i;
		Rank1[i]=0;
		par2[i]=i;
		Rank2[i]=0;
	}
}

ll find1(ll x){
	if(par1[x]==x){
		return x;
	}
	else {
		return  par1[x]=find1(par1[x]);
	}
}
ll find2(ll x){
	if(par2[x]==x){
		return x;
	}
	else {
		return  par2[x]=find2(par2[x]);
	}
}
void unite1(ll x,ll y){
	x=find1(x);
	y=find1(y);
	if(x==y) return;

	if(Rank1[x]<Rank1[y]){
		par1[x]=y;
	}
	else{
		par1[y]=x;
		if(Rank1[x]==Rank1[y]) Rank1[x]++;
	}
}
void unite2(ll x,ll y){
	x=find2(x);
	y=find2(y);
	if(x==y) return;

	if(Rank2[x]<Rank2[y]){
		par2[x]=y;
	}
	else{
		par2[y]=x;
		if(Rank2[x]==Rank2[y]) Rank2[x]++;
	}
}
bool same1(ll x,ll y){
	return find1(x)==find1(y);
}
bool same2(ll x,ll y){
	return find2(x)==find2(y);
}

//a,b x
int main(){
	ll N,K,L; cin>>N>>K>>L;
	
	init(N);//N個初期化

	rep(i,K){
		ll x,y; cin>>x>>y;
		if(!same1(x,y)) unite1(x,y);//元々違う属だったが、ここで併合
	}

	rep(i,L){
		ll x,y; cin>>x>>y;
		if(!same2(x,y)) unite2(x,y);//元々違う属だったが、ここで併合
	}

	map<P,ll> m;
	rep1(i,N){
		m[mp(find1(i),find2(i))]++;
	}
	rep1(i,N){
		cout<<m[mp(find1(i),find2(i))]<<" ";
	}
}

Measured memory_bytes: 18304
#include <stdio.h>

int main(void) {
  /* code */
  int n, m, i;
  scanf("%d %d", &n, &m);
  if(n<m) {
    for ( i = 0; i < m; i++) {
      printf("%d", n);
    }
  }
  else{
    for ( i = 0; i < n; i++) {
      printf("%d", m);
    }
  }
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
int main(){
   int n,l;
   scanf("%d%d",&n,&l);
   char s[n][l+1];
   char temp[l+1];
   int i,j;
   for(i=0;i<n;++i)
       scanf("%s",&s[i]);
       
   for(i=0;i<n;++i)
      {
          for(j=i+1;j<n;++j)
             {
                 if(strcmp(s[i],s[j])>0)
                   {
                       strcpy(temp,s[i]);
                       strcpy(s[i],s[j]);
                       strcpy(s[j],temp);
                   }
             }
      }
      for(i=0;i<n;++i)
         {
             printf("%s",s[i]);
         }
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
	int n,q,i,j,c=0,left,right,mid=0;
	int s[100000],t[50000];
	scanf("%d",&n);
	for(i=0; i<n  ; i=i+1 ){
		scanf("%d", &s[i] );
	}
	scanf("%d",&q);
	for(i=0;i<q ; i=i+1){
		scanf("%d",&t[i]);
	}//??¢?´¢
	for(i=0;i<q;i=i+1){
		left=0,right=n;
		while(left<right){
			mid=(left+right)/2;
			if(s[mid]==t[i]){
				c=c+1;
				break;
			}
			else if(t[i]<s[mid]){
				right=mid;
			}
			else{
			left=mid+1;
			}
		}
	}
	
	
	
	
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 1184
#include <stdio.h>

int main(void) {
    int n, x, l;
    int d = 0, ans = 1;

    scanf("%d %d",&n,&x);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &l);
        if (d + l <= x) {
            ans += 1;
        }
        d = d + l;
    }
    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 128