akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

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

const int L=5001;
const LL M=1e9+7;
vector<int> dp[L][2];
vector<int> es[L];

LL g[L];
vector<LL> buf[2];
void f(int r, int p, vector<LL> u[2])
{
	u[0].push_back(0);
	u[0].push_back(1);
	u[1].push_back(0);
	u[1].push_back(0);
	for(auto c:es[r]){
		if(c==p)continue;
		vector<LL> v[2];
		f(c,r,v);
		for(int i=0;i<2;i++){
			buf[i].clear();
			buf[i].resize(u[i].size()+v[i].size()-1);
		}
		for(int i=0;i<2;i++){
			for(int j=0;j<2;j++){
				for(int k=1;k<u[i].size();k++){
					for(int l=1;l<v[j].size();l++){
						(buf[(i+j)%2][k+l]+=u[i][k]*v[j][l]%M)%=M;
						(buf[(i+j+1)%2][k]+=u[i][k]*v[j][l]%M*g[l]%M)%=M;
					}
				}
			}
		}
		for(int i=0;i<2;i++){
			buf[i].swap(u[i]);
		}
	}
}
int main() {
	int N;
	cin >> N;
	for(int i=1;i<N;i++){
		int x,y;
		cin >> x >> y;
		es[x].push_back(y);
		es[y].push_back(x);
	}
	g[0]=1;
	for(int i=2;i<=N;i+=2){
		g[i]=g[i-2]*(i-1)%M;
	}
	vector<LL> u[2];
	f(1,0,u);
	LL ret=0;
	for(int i=1;i<u[0].size();i++){
		(ret+=u[0][i]*g[i]%M)%=M;
	}
	for(int i=1;i<u[1].size();i++){
		(ret+=M-u[1][i]*g[i]%M)%=M;
	}
	cout << ret << endl;
	//cout << f(es[s][0].first,s,0,1) << endl;

	return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}

const int INF = 100000; 

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

    int y1 = abs(x - a);
    int y2 = abs(x - b);

    if(y1 > y2){
        cout << 'B' << endl;
    }else{
        cout << 'A' << endl;
    }
    
    return 0;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    string s;
    cin >> s;

    int64_t m = s.size();

    vector a(1, 0L);
    int64_t t = 0;
    for (auto c : s) {
        if (c == '0') {
            a.push_back(t);
        } else {
            ++t;
        }
    }
    a.push_back(t);

    int64_t k;
    cin >> k;
    k = min(k, a.back());

    int64_t n = a.size();

    constexpr auto M = 998244353L;

    vector dp(vector(k + 1, vector(a.back() + 1, 0L)));
    int64_t mk = 0;
    dp[0][0] = 1;
    for (auto i : irange(0L, n - 1)) {
        for (auto j : irange(mk, -1L, -1L)) {
            auto r = min(k - j, a[i + 1] - a[i]);
            auto mc = a.back()  - a[i + 1];
            for (auto b : irange(1L, mc + r + 1)) {
                for (auto c : irange(max(0L, b - r), min(b, mc + 1))) {
                    auto w = j + b - c;
                    dp[w][c] += dp[j][b];
                    if (dp[w][c] >= M) {
                        dp[w][c] -= M;
                    }
                }
            }

            for (auto c : irange(1L, a.back() - a[i + 1] + 1)) {
                dp[j][c] += dp[j][c - 1];
                if (dp[j][c] >= M) {
                    dp[j][c] -= M;
                }
            }
        }
        mk = min(k, mk + a[i + 1] - a[i]);
    }

    int64_t ans = 0;
    for (auto i : irange(0L, mk + 1)) {
        ans += dp[i][0];
    }

    cout << ans % M << "\n";
}


Measured memory_bytes: 3924
import numpy as np

grid = np.array([])
for _ in range(3):
    list1 = list(map(int, input().split()))
    grid = np.append(grid, list1)

grid = grid.reshape(3, 3)
grid2 = np.vstack((grid[1:3, :], grid[0, :]))
judge = grid - grid2
judge = judge.transpose()
judge2 = np.copy(judge)
judge2 = np.vstack((judge2[1:3, :], judge2[0, :]))
new_judge = judge - judge2

if np.allclose(new_judge, np.zeros_like(new_judge)):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 12500
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;

#define SORT(v) std::sort(v.begin(), v.end())
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(N+1);
    a[0]=0;
    for(int i=1;i<=N;++i){
        cin >> a[i];
    }
    vector<int> dp(N+1);
    dp[0]=0;
    dp[1]=0;
    for(int i=2;i<=N;++i){
        if(i==2){
            dp[i]=abs(a[i]-a[i-1]);    
        }else{
            dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
        }
        
    }
    cout << dp[N] <<endl;
    return 0;
}

Measured memory_bytes: 1024
N, A, B = map(int, input().split())
S = input()

total = A + B
domestic = 0
overseas = 0

for i in S:
    if i == 'a':
        if domestic + overseas < total:
            print('Yes')
            domestic += 1
            continue
    elif i == 'b':
        if domestic + overseas < total and overseas < B:
            print('Yes')
            overseas += 1
            continue

    print('No')

Measured memory_bytes: 4016
S = list(input())
N = len(S)
flag = 1

S1 = S[0:int((N-1)/2)]
S2 = S[int((N+1)/2):N]


for i in range(int((N-1)/2)):
  if S1[i] != S1[len(S1)-i-1]:
    flag = 0
  if S2[i] != S2[len(S2)-i-1]:
    flag = 0
  if S[i] != S[len(S)-i-1]:
    flag = 0
    
if flag == 1:
  print('Yes')
else:
  print('No')
  
  

Measured memory_bytes: 3064
loop do
  n, x = gets.split.map(&:to_i)
  break if n == 0 && x == 0

  count = 0
  (1..n).each do |i|
    ((i+1)..n).each do |j|
      ((j+1)..n).each do |k|
        break if x < i + j + k
        count += 1 if i + j + k == x
      end
    end
  end
  puts count
end

Measured memory_bytes: 8764
a = gets.to_i
henkan = "abcdefghijklmnopqrstuvwxyz"
aans = []
 
loop {
  a = a - 1
  amari = a % 26
  shou = a / 26
  ans = henkan[amari]
  aans.push(ans)
  a = shou
  if a == 0
    break
  end
}
  
puts aans.reverse.join

Measured memory_bytes: 14424
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define ar array

bool check(const vector<int> &a) {
    for (int i = 0; i < (int) a.size() - 1; i++) {
        if (a[i] > a[i + 1]) return false;
    }
    return true;
}
 
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
 
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];
    int cnt = 0;
    if (check(p)) {
        cout << "YES\n";
        return 0;
    }
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            if (p[i] > p[j]) {
                swap(p[i], p[j]);
                if (check(p)) {
                    cout << "YES\n";
                    return 0;
                }
                swap(p[i], p[j]);
            }
        }
    }
    cout << "NO\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vb vector<bool>
#define mod 1000000007
#define pii pair<int,int>
const int inf = 0x3f3f3f3f3f3f3f3f;
int fun(int i , vi &a , vi &dp , int k)
{
    int j , t ;
    
    if(i<0) return inf;
    if(i == 0) return 0;
    if(dp[i]!=-1) return dp[i];
    dp[i]=inf;
    for(j = 0 ; j  <  k ; j++)
    {
        t = fun(i-1-j , a, dp , k) + abs(a[i] - a[i-1-j]);
        dp[i] = min(dp[i] , t);
    }
   
    return dp[i]; 
}
int32_t main(){
    
    int n , i , k , t; 
    cin >> n >> k;
    
    vi a(n);
    for(i = 0 ; i <  n ; i++) cin >> a[i];
   
    vi dp(n,-1);
    
    
    
    cout << fun(n-1 , a , dp , k);
    
    return 0;
}

Measured memory_bytes: 11264
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/*Used path compression technique*/
/*-------------------------------------*/
//ll finds(ll a)
//{
//    vector<ll>vec;
//    while(parent[a]>0){
//        vec.pb(a);
//        a=parent[a];
//    }
//    for(int i=0;i<vec.size();i++)parent[vec[i]]=a;
//    return a;
//}
//void unions(ll a,ll b)
//{
//    parent[a]+=parent[b];
//    parent[b]=a;
//}
/*------------------------------*/
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
void Dufaux()
{
    ll a,b,c;
    cin>>a>>b;
    if(a%3==0 || b%3==0 || (a+b)%3==0){
        cout<<"Possible"<<endl;
    }
    else{
        cout<<"Impossible"<<endl;
    }
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






Measured memory_bytes: 3608
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

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

const int INF = 1001001001;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		int dp[10][10];
		memset(dp, INF, sizeof(dp));
		int V = 0;
		rep(i, n){
			int a, b, c;
			scanf("%d%d%d", &a, &b, &c);
			dp[a][b] = dp[b][a] = c;
			V = max(V, max(a, b)+1);
		}
		rep(i, V)
			dp[i][i] = 0;
		rep(k, V) rep(i, V) rep(j, V)
			dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
		
		int best = INF;
		int ansi = -1;
		rep(i, V){
			int sum = accumulate(dp[i], dp[i]+V, 0);
			if(sum < best){
				best = sum;
				ansi = i;
			}
		}
		printf("%d %d\n", ansi, best);
	}
	return 0;
}

Measured memory_bytes: 1028
#include<stdio.h>
int main()
{
        int high=0,low=0,n,nn,a[1000]={0};
        int i,j,k,l;
        scanf("%d",&n);
        for(i=0;i<n;i++)
        {
                scanf("%d",&nn);
                for(j=0;j<nn;j++)
                {
                        scanf("%d",&a[j]);
                }
                for(j=0;j<nn;j++)
                {
                        if(a[j+1]==0)break;
                        if(a[j+1]-a[j]>high)high=a[j+1]-a[j];
                        if(a[j]-a[j+1]>low)low=a[j]-a[j+1];
                }
                printf("%d %d\n",high,low);
                high=0;
                low=0;
                for(k=0;k<1000;k++)
                {
                        a[k]=0;
                }
        }
        return 0;
}

Measured memory_bytes: 600
int n=1<<18;
long dat[1<<20],lazy[1<<20],A[1<<18];
eval(i,l,r)
{
	if(lazy[i])
	{
		dat[i]+=lazy[i];
		lazy[2*i+1]+=lazy[i];
		lazy[2*i+2]+=lazy[i];
		lazy[i]=0;
	}
}
update(a,b,x,k,l,r)long x;
{
	eval(k,l,r);
	if(a<=l&&r<=b)
	{
		lazy[k]+=x;
		eval(k,l,r);
	}
	else if(l<b&&a<r)
	{
		update(a,b,x,2*k+1,l,(l+r)/2);
		update(a,b,x,2*k+2,(l+r)/2,r);
		dat[k]=fmax(dat[2*k+1],dat[2*k+2]);
	}
}
long query(a,b,k,l,r)
{
	eval(k,l,r);
	return b<=l||r<=a?0:a<=l&&r<=b?dat[k]:fmax(
		query(a,b,2*k+1,l,(l+r)/2),
		query(a,b,2*k+2,(l+r)/2,r)
	);
}
N,m;
L[1<<18],p;
first[1<<18],next[1<<18];
main(i)
{
	scanf("%d%d",&N,&m);
	for(;~scanf("%d%d%ld",L+i,&p,A+i);first[p]=i++)next[i]=first[p];
	for(i=1;i<=N;i++)
	{
		update(i,i+1,query(0,i,0,0,n),0,0,n);
		p=first[i];
		for(;p!=0;)
		{
			update(L[p],i+1,A[p],0,0,n);
			p=next[p];
		}
	}
	printf("%ld",query(0,N+1,0,0,n));
}

/*
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
*/


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

#define watch(x) cerr << (#x) << ": " << (x) << endl

typedef long long LL;

LL n, a, b, c, d;

map<LL, LL> f;
LL solve(LL m) {
    if(f.count(m)) {
        return f[m];
    }

    LL a2 = m/2*2, b2 = (m+1)/2*2;
    LL a3 = m/3*3, b3 = (m+2)/3*3;
    LL a5 = m/5*5, b5 = (m+4)/5*5;

    LL ans = 1000000000000000000LL;
    if(m < ans/d) {
        ans = m*d;
    }

    ans = min(ans, abs(a2-m)*d + a + solve(a2/2));
    if(b2 != a2)
        ans = min(ans, abs(b2-m)*d + a + solve(b2/2));
    ans = min(ans, abs(a3-m)*d + b + solve(a3/3));
    if(b3 != a3)
        ans = min(ans, abs(b3-m)*d + b + solve(b3/3));
    ans = min(ans, abs(a5-m)*d + c + solve(a5/5));
    if(b5 != a5)
        ans = min(ans, abs(b5-m)*d + c + solve(b5/5));

    f[m] = ans;
    return ans;
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t; cin >> t;
    while(t--) {
        cin >> n >> a >> b >> c >> d;
        f.clear();
        f[0] = 0;
        f[1] = d;
        LL ans = solve(n);
        cout << ans << '\n';
    }
    
    return 0;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif

    ll A, B;
    cin >> A >> B;

    int c1, c2;  // c1が下地の色
    if (A <= B) {
        c1 = 0, c2 = 1;
    }
    else {
        c1 = 1, c2 = 0;
    }

    if (A > B) {
        swap(A, B);
    }

    --A;

    vector<Vi> mas(100, Vi(100, c1));
    int pvi = 0, pvj = 0;
    while (A > 0) {
        if (pvj == 100) {
            pvi += 4;
            pvj = 0;
        }
        mas[pvi][pvj] = c2;
        mas[pvi][pvj + 1] = c2;
        mas[pvi][pvj + 2] = c2;

        mas[pvi + 1][pvj] = c2;
        mas[pvi + 1][pvj + 2] = c2;

        mas[pvi + 2][pvj] = c2;
        mas[pvi + 2][pvj + 1] = c2;
        mas[pvi + 2][pvj + 2] = c2;

        --A;
        --B;
        pvj += 4;
    }

    pvi = 99, pvj = 99;
    while (B > 0) {
        if (pvj < 0) {
            pvi -= 2;
            pvj = 99;
        }

        mas[pvi][pvj] = c2;

        --B;
        pvj -= 2;
    }

    cout << 100 << " " << 100 << "\n";

    for (ll i = 0; i < 100; i++) {
        for (ll j = 0; j < 100; j++) {
            cout << (mas[i][j] == 1 ? '#' : '.');
        }
        cout << " \n";
    }

    cout << flush;
    return 0;
}

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

ll mod(ll x) {
    const ll d = 1e9 + 7;
    ll y = x % d;

    ll z = 0;
    if (y >= 0) {
        z = y -d;
    }
    if (y < 0) {
        z = y + d;
    }
    if (abs(y) > abs(z)) {
        return z;
    }
    else {
        return y;
    }
}

int main() {
    const ll d = 1e9 + 7;
    int N;
    cin >> N;
    vector<ll> A(N);
    for (ll& a : A) {
        cin >> a;
    }

    ll sum = 0;
    for (ll a : A) {
        sum += a;
        sum = mod(sum);
    }
    ll square = mod(sum * sum);
    ll diag = 0;
    for (auto i = 0; i < N; ++i) {
        diag += mod(A[i] * A[i]);
        diag = mod(diag);
    }
    ll y = square - diag >= 0 ? square -diag : square - diag + d;
    ll x = (y * (d+1) / 2) % d;
    cout << x << endl;

}

Measured memory_bytes: 4808
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
int main(void)
{
    long long A, B, C, ans=0;

    cin >> A >> B >> C;

    if(C < A+B+1){
        cout << B+C << endl;
    }

    else{ // C >= A+B+1
        cout << B+(A+B+1) << endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class  Main
{
     public static void main (String[] args)
    {
        Scanner sc=new Scanner(System.in);
        long x=sc.nextLong();
        long y=sc.nextLong();
        if( (x+y)%3==0)
            System.out.println("Possible");
        else     if( (y)%3==0)
            System.out.println("Possible");
        else     if( (x)%3==0)
            System.out.println("Possible");
        else
            System.out.println("Impossible");
    }
}

Measured memory_bytes: 25044
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int p,r,q;
  cin >> p >> r >> q;
  cout << (int)min(p+r,min(r+q,q+p)) << "\n";
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (a,b,c) = get!(usize, usize, usize);
    if (a==b && b != c) 
        || (a==c && b != c)
        || (b==c && a != c) {
            println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 8572
#include<stdio.h>
#include<cstdio>
#include<vector>
#include<list>
using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int a[n], res[n];
  for (int i=0 ; i<n ; i++) scanf("%d", &a[i]);
  int mid;
  if (n%2 == 0) {
    mid = n/2;
    for (int i=0 ; i<mid ; i++) {
      res[mid+i] = a[i*2];
      res[mid-i-1] = a[i*2+1];
    }
  } else {
    mid = (n-1)/2;
    res[mid] = a[0];
    for (int i=0 ; i<mid ; i++) {
      res[mid+(i+1)] = a[i*2+1];
      res[mid-(i+1)] = a[i*2+2];
    }
  }
  for (int i=0 ; i<n ; i++) {
    if (i == n-1) printf("%d\n", res[i]);
    else printf("%d ", res[i]);
  }
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

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

int main() {
    int n;cin >> n;
    vi a(n);rep(i,n)cin >> a[i];
    vi b(n);rep(i,n)cin >> b[i];

    vi lack;
    vi enough;

    for(int i=0;i<n;i++){
        int tmp = a[i] - b[i];
        if(tmp > 0)enough.push_back(tmp);
        else if(tmp < 0)lack.push_back(tmp);
    }

    sort(ALL(enough),greater<int>());
    sort(ALL(lack));
    
    if(lack.empty()){
        cout << 0 << endl;
        return 0;
    }else if(enough.empty()){
        cout << -1 << endl;
        return 0;
    }

    int i,j;i = j = 0;
    while(i < lack.size() && j < enough.size()){
        lack[i] += enough[j];
        enough[j] = 0;
        if(lack[i] < 0){
            j++;
        }else if(lack[i] > 0){
            enough[j] = lack[i];
            i++;
            if(i == lack.size())j++;
        }else{
            i++;
            j++;
        }
    }

    if(i == lack.size())cout << i+j << endl;
    else cout << -1 << endl;
    return 0;
}


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

int main() {
    ll N; cin >> N;
    ll n2 = sqrt(N);
    map<ll, ll> mp;
    ll n = N;
    for (int i = 2; i <= n2; i++){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1)mp[n]++;

    int counter = 0;
    for (auto p : mp){
        auto value = p.second;
        int i = 2;
        while(value > 0){
            value -= i;
            counter++;
            i++;
        }

    }
    cout << counter << endl;

    return 0;
}

Measured memory_bytes: 3624
import math

a=input().rstrip().split(" ")

sum=0
for i in range( int(a[0]) , int( a[1] ) + 1 ,1  ):
    if(math.floor(i/10000) == i%10 and math.floor(i/1000)%10 == math.floor(i%100/10)):
        sum=sum+1

print(sum)


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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); ++i)
#define REP(i,start,end) for(int i=(start);i<=(end);++i)
#define all(n) begin(n),end(n)

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	vector<string> s(n);
	vi cnt(n,0);
	rep(i,n) cin >> s[i];

	map<string, int> dic;

	rep(i,n)
	{
		dic[s[i]] += 1;
	}

	int max = 0;
	rep(i,n)
	{
		if(max < dic[s[i]]) max = dic[s[i]];
	}

	for(auto i = dic.begin(); i != dic.end(); ++i)
	{
		if((i -> second) == max)
		{
			cout << i -> first << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 26240
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

vector<int> primes;

void erathosthenes(int n) {
    bool primeFlags[n+1];
    for (int i = 0; i <= n; i++) {
        primeFlags[i] = true;
    }
    primeFlags[0] = primeFlags[1] = false;
    vector<int> sqrtprimes;
    for (int i = 2; i*i <= n; i++) {
        bool mod0 = false;
        for (int j = 2; j*j <= i; j++) {
            if (i%j == 0) mod0 = true;
        }
        if (!mod0) sqrtprimes.push_back(i);
    }
    for (int i = 0; i < sqrtprimes.size(); i++) {
        for (int j = 2; j <= n; j++) {
            if (j%sqrtprimes[i] == 0) primeFlags[j] = false;
        }
    }
    for (int i = 0; i < sqrtprimes.size(); i++) primeFlags[sqrtprimes[i]] = true;
    for (int i = 1; i <= n; i++) {
        if (primeFlags[i]) primes.push_back(i);
    }
    return;
}

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    int max = 55555;
    erathosthenes(max);
    vector<int> ans;
    for (auto x: primes) if (x%5 == 1) ans.push_back(x);
    REP(i,n) cout << ans[i] << " ";
    cout << "" << std::endl;
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>

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

    int saisyo = 1000000;
    int saidai = -1000000;
    long sum = 0;

    for (int i = 0;i < n;i++) {
        int k;
        std::scanf("%d",&k);
        if (k < saisyo) {
            saisyo = k;
        }
        if (saidai < k) {
            saidai = k;
        }
        sum += k;
    }

    std::printf("%d %d %ld\n",saisyo,saidai,sum);

}


Measured memory_bytes: 2740
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool neg=c=='-';
	neg?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return neg?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
template<class T>inline void mset(T a,int v,int n){memset(a,v,n*sizeof(a[0]));}
const int N=100010,INF=0x7f7f7f7f;
int f[N];
int main(){
	const int n=ni;
	f[0]=0;
	for(int i=1;i<=n;i++){
		f[i]=f[i/10]+i%10;
	}
	int mn=INF;
	for(int i=1;i<n;i++){
		apmin(mn,f[i]+f[n-i]);
	}
	printf("%d\n",mn);
	return 0;
}


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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

ll f (ll b, ll n) {
  ll ans = 0;
  while(n) {
    ans += n % b;
    n /= b;
  }
  return ans;
}
 
ll solve(ll n, ll s) {
  if (n < s) {
    return -1;
  }
  
  if (n == s) {
    return n + 1;
  }
  
  ll b = 2;
  for (; b * b <= n; b++) {
    if (f(b, n) == s) {
      return b;
    }
  }
  
  // √n < b になるので、pは√nより小さい
  for (ll p = b - 1; p >= 1; p--) {
    b = (n - s) / p + 1;
    if (b <= 1) {
      continue;
    }
    if (f(b, n) == s) {
      return b;
    }
  }
  return -1;
}

int main() {
    ll n, s;
    cin >> n >> s;
    cout << solve(n, s) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
#define rep(i,n) for (int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

int main(){
    int x;
    cin>>x;
    if (x==0) cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 3620
n,m,c = map(int, input().split())
b=list(map(int, input().split()))
a=[]
for _ in range(n):
  a.append(list(map(int, input().split())))

ans=0
for ai in a:
  score=c
  for aij, bj in zip(ai, b):
    score+=aij*bj
  if score>0:
    ans+=1
print(ans)

Measured memory_bytes: 3064
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)

def main():
	n = int(input())
	a = list(map(int,input().split()))
	b = deepcopy(a)
	b.sort()
	c = 0
	for i in range(n):
		if(b[i] != a[i]):
			c+=1
	if(c==2 or c==0):
		print('YES')
	else:
		print('NO')

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


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

int main(){
    ll d,t,s;
    cin >> d >> t >> s;
    if(d<=t*s) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3560
# -*- coding: utf-8 -*-
"""
Created on Tue Mar  3 23:56:09 2020

@author: Kanaru Sato
"""

H,N = list(map(int, input().split()))
A = list(map(int, input().split()))
sum = 0

for i in range(0,N):
    sum = sum + A[i]

if sum < H:
    print("No")
if sum >= H:
    print("Yes")

Measured memory_bytes: 13964
#include <iostream>
using namespace std;
int main()
{
    int d, n, x;
    cin >> n >> d;
    for(x=1; x<25; x++)
    {
        if((2*d+1)*x >= n)
        {
            cout << x << '\n';
            return 0;
        }
    }
    return 0;
}

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

// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

void solve(long long A, long long B){
    if (A >= 1 && A <= 9 && B >= 1 && B <= 9) print(A * B);
    else print(-1);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

int main() {
    int d, n, ans;
    cin >> d >> n;
    ans = pow(100, d);
    ans *= n;
    if(n == 100) ans += pow(100, d);
    cout << ans << endl;
}

Measured memory_bytes: 256
num1, num2 = map(int, input().split())
matrix = []

for i in range(num1):
    rows = list(map(int, input().split()))
    matrix.append(rows)

column = []
for j in range(num2):
    m = int(input())
    column.append(m)

for k in range(num1):
    a = 0
    for l in range(num2):
        a += matrix[k][l]*column[l]
    print(a)


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

#define mod 1000000007;
//vector<int> dp;
vector<vector<int>> dp;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int r,c,i,j;
    string st;
    cin >> r >> c;
    vector<string> s;
    for(i=0;i<r;i++){
        cin >> st;
        s.push_back(st);
    }
    dp.resize(r+1,vector<int> (c+1,0));

    dp[r][c]=1;
    for(i = r;i >= 1;i--){
        for(j = c;j >= 1;j--){
            if(s[i-1][j-1] == '#'){
                dp[i][j] = 0;
                continue;
            }
            if(i+1 <= r){
                dp[i][j] =(dp[i][j]+dp[i+1][j])%mod;
            }
            if(j+1 <= c){
                dp[i][j] = (dp[i][j]+dp[i][j+1])%mod;
            }
        }
    }
    // for(i = 0;i < r+1;i++){
    //     for(j = 0;j< c+1;j++){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout <<endl;
    // }
    cout << dp[1][1];
    dp.clear();

    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;


int main(){
  int a1, a2, a3; cin >> a1 >> a2 >> a3;

  int s = a1+a2+a3;
  if(s >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int X,Y,i,flag=0;
   cin >> X >> Y;
   if(X<=50){
       for(i=0;i<=X;i++){
            if(((X-i)*2+i*4)==Y){
                flag=1;
                break;
            }
        }
   }
   if(flag) cout << "Yes";
   else cout << "No";
   
   
   return 0;
}

Measured memory_bytes: 3676
#include <stdio.h>

int main(){
    long N,M;
    long ans;

    scanf("%ld %ld",&N,&M);
    if(N>=3&&M>=3){
        ans = (M-2)*(N-2);
    }
    if(N>=3&&M==2){
        ans = 0;
    }
    if(N>=3&&M==1){
        ans = N-2;
    }
    if(N==2&&M>=3){
        ans = 0;
    }
    if(N==1&&M>=3){
        ans = M-2;
    }
    if(N<3&&M<3){
        ans = 0;
        if(N==1&&M==1){
            ans = 1;
        }
    }
    printf("%ld",ans);
    return 0;
}

Measured memory_bytes: 128
n = int(input())
a = [list(map(int, input().split())) for _ in range(2)]
b = [[0]*n for _ in range(2)]
b[0][0], b[1][0] = a[0][0], a[0][0]+a[1][0]
for i in range(1, n):
  b[0][i] = b[0][i-1]+a[0][i]
for i in range(1, n):
  b[1][i] = max(b[0][i], b[1][i-1])+a[1][i]
print(b[1][n-1])

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long

static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const ll INF = 1e18;

int main() {

    int N, T;
    cin >> N >> T;
    vector<pair<int, int>> kitaku(N);
    // vector<int> c(N), t(N);
    REP(i, N){
        // cin >> c[i] >> t[i];
        int c, n; cin >> c >> n;
        kitaku[i] = {c, n};
    }
    sort(kitaku.begin(), kitaku.end());

    REP(i, N){
        if(kitaku[i].second <= T){
            cout << kitaku[i].first << endl;
            return 0;
        }
    }
    cout << "TLE" << endl;

}

/*
みんな、くるくるぱーにな〜れ
　∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();
		int K = scan.nextInt();
		int max;
		if(A <= B) {
			if(B <= C) {
				max = C;
			}else {
				max = B;
			}
		}else {
			if(A <= C) {
				max = C;
			}else {
				max = A;
			}
		}
		if(max == A) {
			for(int i = 0;i < K;i++) {
				max *= 2;
			}
			max = max + B + C;
		}else if(max == B) {
			for(int i = 0;i < K;i++) {
				max *= 2;
			}
			max = max + A + C;
		}else {
			for(int i = 0;i < K;i++) {
				max *= 2;
			}
			max = max + B + A;
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 21844
loop do
  n = gets.to_i
  break if n.zero?
  ps = n.times.map { x, y = gets.split(?,).map(&:to_f); x + y * 1i }
  p0 = ps.min_by(&:imag)
  p, u, c = p0, 1, 1
  loop do
    q = ps.reject {|q| p == q }.min_by {|q|
      v = q - p
      a = (v / u).arg
      a < 0 ? 2 * Math::PI + a : a
    }
    break if q == p0
    c += 1
    u = q - p
    u /= u.abs
    p = q
  end
  p ps.size - c
end

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

int query(string s) {
    cout<<"? "<<s<<endl;
    int ans;
    cin>>ans;
    return ans;
}

string alphabet;
int L = 128;

string join(const vector<string> &v, int l, int r, int n) {
    if (l == r) return v[l];
    int mid = (l+r)/2;

    string a = join(v, l, mid, n);
    string b = join(v, mid+1, r, n);

    string ans = a;
    for (int i=0, cur=0; i<b.size(); cur++) {
        string nw = ans;
        nw.insert(nw.begin()+cur, b[i]);
        if (query(nw) == n-nw.size())   ans = nw, i++;
    }
    return ans;
}

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

    for (char i='a'; i<='z'; i++)    alphabet += i;
    for (char i='A'; i<='Z'; i++)    alphabet += i;
    for (char i='0'; i<='9'; i++)    alphabet += i;

    vector<string> v;
    int sum = 0;
    for (char c: alphabet) {
        int x = query(string(L, c));
        if (x < L) v.push_back(string(L-x, c));
        sum += L-x;
    }

    string ans = join(v, 0, v.size()-1, sum);
    cout<<"! "<<ans<<endl;
}


Measured memory_bytes: 3808
#include <iostream>

using namespace std;

int main()
{
        double d;
        double max = -0.1, min = 1000000.1;

        while (cin >> d) {
                max = (max < d) ? d : max;
                min = (min > d) ? d : min;
        }

        cout << (max - min) << endl;

        return 0;
}

Measured memory_bytes: 3208
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto s = readln.chomp;

  auto i = 0, j = 0;
  foreach (c; s) {
    switch (c) {
    case '(':
      ++i;
      break;
    case ')':
      --i;
      if (i < 0) {
        i = 0;
        ++j;
      }
      break;
    default:
      assert(0);
    }
  }

  writeln('('.repeat.take(j), s, ')'.repeat.take(i));
}


Measured memory_bytes: 256
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0]); lines.shift();
    var txy = lines.map(i => i.split(" ").map(i => Number(i)));

    var t = txy[0][0], x = txy[0][1], y = txy[0][2]
    if (t < x + y || (t - (x + y)) % 2 !== 0) { console.log("No"); return (0); }

    for (var i = 1; i < N; i++) {
        t = Math.abs(t - txy[i][0]), x = Math.abs(x - txy[i][1]), y = Math.abs(y - txy[i][2]);

        if (t < x + y || (t - (x + y)) % 2 !== 0) { console.log("No"); return (0) }
    }

    console.log("Yes")
});


Measured memory_bytes: 57988
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <bitset>
#include <utility>
#include <assert.h>
using namespace std;
#define rank rankk
#define mp make_pair
#define pb push_back
#define xo(a,b) ((b)&1?(a):0)
#define tm tmp
//#pragma comment(linker, "/STACK:1024000000,1024000000") 
//#define LL ll
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const int INF=0x3f3f3f3f;
const ll INFF=0x3f3f3f3f3f3f3f3fll;
const int MAX=5e5+10;
//const ll MAXN=2e8;
//const int MAX_N=MAX;
const ll MOD=10007;
//const long double pi=acos(-1.0);
//const double eps=0.00000001;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
inline ll powMM(ll a,ll b,ll M){
    ll ret=1;
    a%=M;
//    b%=M;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
void open()
{
//    freopen("1009.in","r",stdin);
    freopen("out.txt","w",stdout);
}

int n;
char a[MAX];
int num[MAX],dp[MAX];
int an,tem;
int main()
{
    scanf("%d",&n);
    scanf("%s",a+1);
    for(int i=1;i<=n;i++)
    {
        if(a[i]=='1')
            num[i]=num[i-1]+1;
    }
    for(int i=n-1;i>=1;i--)
        if(a[i]=='1')
            num[i]=max(num[i],num[i+1]);
    for(int i=2;i<=n-1;i++)
    {
        if(a[i]=='0'&&a[i-1]=='1'&&a[i+1]=='1')
        {
            for(int j=1;j<=num[i+1];j++)
                dp[i+j]=max(dp[i-2]+j,dp[i+j]);
            for(int j=1;j<=num[i-1];j++)
                dp[i+1]=max(dp[i+1],dp[i-j-1]+j);
        }
        dp[i]=max(dp[i],dp[i-1]);
        an=max(an,dp[i]);
    }
    an=max(an,dp[n]);
    an=max(an,dp[n+1]);

    printf("%d\n",an);
}
/*
8
11011011
*/


Measured memory_bytes: 4608
// プリム法 最小全域木 Minimum Spanning Tree
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <vector>
using namespace std;
static const int MAX = 100;
static const int INF = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX]; //M:隣接行列

int prim() {
    int u, minv;
    int distance[MAX], parent[MAX], color[MAX];

    for(int i = 0; i < n; i++) {
        distance[i] = INF;
        parent[i] = -1;
        color[i] = WHITE;
    }

    distance[0] = 0;

    while (true) {
        minv = INF;
        u = -1;
        for(int i = 0; i < n; i++) {
            if (minv > distance[i] && color[i] != BLACK) {
                u = i;
                minv = distance[i];
            }
        }

        if (u == -1)
            break;

        color[u] = BLACK;
        for(int v = 0; v < n; v++) {
            if (color[v] != BLACK && M[u][v] != INF) {
                if (distance[v] > M[u][v]) {
                    distance[v] = M[u][v];
                    parent[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }

    int sum = 0;
    for(int i = 0; i < n; i++) {
        if (parent[i] != -1)
            sum  += M[i][parent[i]];
    }

    return sum;
}

int main() {

    cin >> n;

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            int e; cin >> e;
            M[i][j] = (e == -1) ? INF : e;
        }
    }

    cout << prim() << endl;
    
    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const int P=998244353;
const int N=2e6+11;
ll n,m,fac[N],inv[N];
ll quickmul(ll x,ll y){
	ll ans=1;
	for(;y;y>>=1,x=x*x%P)
		if(y&1) ans=ans*x%P; 
	return ans;
}
int main(){
	scanf("%lld%lld",&n,&m);
	ll ans=max(n,m);
	fac[0]=1;inv[0]=1;
	for(int i=1;i<=n+m;++i) fac[i]=fac[i-1]*i%P;
	inv[n+m]=quickmul(fac[n+m],P-2);
	for(int i=n+m;i;--i) inv[i-1]=inv[i]*i%P;
	ll k=inv[n+m]*fac[m]%P*fac[n]%P;
	for(int i=1;i<=min(n,m);++i){
		ans=(ans+inv[2]*k%P*fac[2*i]%P*inv[i]%P*inv[i]%P*fac[n+m-2*i]%P*inv[n-i]%P*inv[m-i]%P)%P; 
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 18688
using System;
using System.Collections.Generic;
using System.Linq;
class TEST
{
    public static void Main()
    {
        int num = int.Parse(Console.ReadLine());
        string str = Console.ReadLine();

        int a = num / 2;
        if (str.Substring(0, a) == str.Substring(a))
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }


}

Measured memory_bytes: 27488