akhauriyash/Code-Regression huggingface dataset:
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

#include <iostream>
#include <string>
#include <algorithm>
#include<vector>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> vmin,vmax;
    rep(i,n){
        int a;
        int b;
        cin >> a >> b;
        vmin.push_back(a);
        vmax.push_back(b);
    }
    sort(vmin.begin(),vmin.end());
    sort(vmax.begin(),vmax.end());
    if (n%2 == 1){
        cout << vmax[n/2]-vmin[n/2]+1 << endl;
    }else{
        cout << (vmax[n/2]+vmax[n/2-1])-(vmin[n/2]+vmin[n/2-1])+1 << endl;
    }

}

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

#define pb push_back
#define mp make_pair
#define inside sl<=l&&r<=sr
#define outside r<sl||sr<l
#define INF 1000000000000000009
#define mod 1000000007
using namespace std;
typedef long long ll;

ll inf = 1000000000000000000;

ll n;
ll mat[17][17];
ll dp[16][(1<<16)];
ll dp2[(1<<16)];

ll getsum(ll mask){
	if (dp2[mask] != -1) return dp2[mask];
	ll ans = 0;
	for (ll j = 0; j < n; j++){
		if ((mask & (1<<j)) == 0) continue;
		for (ll k = 0; k < j; k++){
			if ((mask & (1<<k)) == 0) continue;
			ans += mat[j][k];
		}
	}
	return dp2[mask] = ans;
}

ll f(ll i, ll mask){
	//cout << "f(" << i << ", " << mask << ")" << endl;
	if (i == -1){
		return 0;
	}
	if (dp[i][mask] != -1) return dp[i][mask]; 
	if ((mask & (1<<i)) != 0) return dp[i][mask] = f(i-1, mask);
	ll ans = 0;
	for (ll mask2 = 0; mask2 < (1<<(i)); mask2++){
		if ((mask & mask2) == 0){
			//cout << "mask: " << (mask2|(1<<i)) << endl;
			//cout << "getsum: " << getsum(mask2|(1<<i)) << endl;
			//cout << "f(" << i-1 << ", " << (mask|mask2) << "): " << f(i-1, mask|mask2) << endl;
			ans = max(ans, getsum(mask2|(1<<i)) + f(i-1, mask|mask2));
			//cout << "ans: " << ans << endl;
		}
	}
	return dp[i][mask] = ans;
}

int main(){
	//freopen("stl.gir", "r", stdin);
	
	cin >> n;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			cin >> mat[i][j];
		}
	}
	
	for (int i = 0; i < n; i++){
		for (int j = 0; j < (1<<n); j++){
			dp[i][j] =-1;
		}
	}
	
	for (int j = 0; j < (1<<n); j++){
		dp2[j] = -1;
	}
	
	//clock_t begin = clock();
	
	
	cout << f(n-1, 0) << endl;
	
	//cout << (clock()-begin)/(double)(CLOCKS_PER_SEC) << endl;
}

Measured memory_bytes: 9088
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        ArrayList<Integer> arrayList = new ArrayList<>();

        for(int i=0; i<3; i++){
            arrayList.add(scanner.nextInt());
        }

        Collections.sort(arrayList, Collections.reverseOrder());

        System.out.println(arrayList.get(0)*10 + arrayList.get(1) + arrayList.get(2));

    }
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long[] T = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long M = long.Parse(Console.ReadLine());
            long[] result = new long[M];
            for(int j = 0; j < M; j++)
            {
                long[] PX = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
                result[j] = T.Sum() - T[(PX[0] - 1)] + PX[1];
            }
            for(int z = 0; z < M; z++)
            {
                Console.WriteLine(result[z]);
            }
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


//Console.WriteLine(ans);


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

int vis[110];
void dfs(int now)
{
	if(now>100) return ; 
	vis[now]=1;
	dfs(now+4);
	dfs(now+7);
}

int main()
{
	int n;
	dfs(0);
	cin>>n;
	if(vis[n]) puts("Yes");
	else puts("No");
}

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

using namespace std;
using i64 = int64_t;
i64 MOD = 1e9 + 7;

i64 solve(){
    
    int n;
    cin >> n;
    if(n == 0)
        return MOD;
    vector<int> a(n), b(n - 1);
    for(auto& x : a)
        cin >> x;
    for(auto& x : b)
        cin >> x;
    sort(b.begin(), b.end());
    i64 sum = accumulate(a.begin(), a.end(), 0LL) + accumulate(b.begin(), b.end(), 0LL);
    i64 ans = 0;
    for(int i = 0; i < n; ++i){
        i64 val = (i + 1) * sum;
        if(val > ans)
            ans = val;
        sum -= b[i];
    }
    cout << ans << endl;
    
    return true;
}

signed main(){
    while(solve() != MOD);
}


Measured memory_bytes: 3344
#include <iostream>
#include <queue>
#include <vector>
#include <utility>
using namespace std;
typedef pair<int, int> P;
struct edge {int to, cost;};
const int INF = 2100000000;
int n;
vector<edge> G[10010];


vector<int> dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s));
    vector<int> d(n, INF);
    d[s] = 0;
    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (auto e: G[v]) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
    return d;
}

int main(void) {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int u, k, v, c;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v >> c;
            G[u].push_back(edge {v, c});
        }
    }
    vector<int> d = dijkstra(0);
    for (int i = 0; i < n; i++) {
        cout << i << " " << d[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 6308
//#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef vector< vector<ll> > mat;
const ll M = 10007;

int main(){
    string str;
    getline(cin,str);
    for(int i=0;i<str.size();i++){
	int n = (int)(str[i]);
	if(97 <= n && n <= 122) str[i] = (char)(n - 32);
    }
    cout << str << endl;


    return 0;
}

Measured memory_bytes: 1172
main(a,b,c,d,e,f,g,h,n){scanf("%d",&n);while(n--){scanf("%d%d%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f,&g,&h);if((c-a)*(g-e)==-(d-b)*(h-f)){printf("1\n");}else if((c-a)*(h-f)==(d-b)*(g-e)){printf("2\n");}else{printf("0\n");}}}

Measured memory_bytes: 584
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define N 100005
#define M 405
using namespace std;
bool bz[N];
int cd[M],rd[M],n,num,f[M],h,m,v1[M],v2[M];
int getf(int k)
{
	if(f[k]==k||!f[k]) return k;
	return (f[k]=getf(f[k]));
}
int main()
{
	cin>>n>>h;
	fo(i,1,n)
	{
		int a,b,c,d,x,y;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		x=(c>0)?c:(a+200);
		y=(d>0)?(d+200):b;
		cd[x]++,rd[y]++;
		int fx=getf(x),fy=getf(y);
		f[fx]=fy;
	}
	int w=0;
		bool pd=1;
		fo(i,1,400) 
		{
			if(rd[i]>0||cd[i]>0)
			{
				int fa=getf(i);
				if(rd[i]-cd[i]<0) 
				{
					v1[fa]++;
					if(i<=200)
					{
						pd=0;
						break;
					}
				}
				if(rd[i]-cd[i]>0) 
				{
					v2[fa]++;
					if(i>200)
					{
						pd=0;
						break;
					}
				}
			}
		}
		if(pd)
		fo(i,1,400)
		{
			if((rd[i]||cd[i])&&v1[getf(i)]==0&&i!=200+h) 
			{
				pd=0;
				break;
			}
		}
		if(pd) printf("YES\n");
		else printf("NO\n"); 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n,a,b,tmp[3] = {},mn;
    cin >> n >> a >> b;
    vector<int> p(n);
    for(int i = 0;i < n;i++) cin >> p[i];
    sort(p.begin(),p.end());
    for(int i = 0;i < n;i++){
        if(p[i] <= a) tmp[0]++;
        if(p[i] >= a+1 && p[i] <= b) tmp[1]++;
        if(p[i] >= b+1) tmp[2]++;
    }
    mn = min(tmp[0],tmp[1]);
    mn = min(mn,tmp[2]);
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

vector<vector<int>> to;
vector<int> dist;

vi dp;
vb finished;

int dfs(int v) {
    if (dp[v] != -1) {
        if (!finished[v]) return -1;
        return dp[v];
    }
    dp[v] = 1;
    for (auto u : to[v]) {
        int res = dfs(u);
        if (res == -1) return -1;
        chmax(dp[v], res+1);
    }
    finished[v] = true;
    return dp[v];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vvi toid(n, vi(n));
    int v = 0;
    rep(i, n) for (int j = i+1; j < n; ++j) toid[i][j] = v++;
    to.resize(v);
    dp.resize(v, -1);
    finished.resize(v, false);
    vvi a(n, vi(n-1));
    rep(i, n) rep(j, n-1) cin >> a[i][j];
    rep(i, n) {
        rep(j, n-1) {
            int x = i, y = --a[i][j];
            if (x > y) swap(x, y);
            a[i][j] = toid[x][y];
        }
        rep(j, n-2) {
            to[a[i][j]].pb(a[i][j+1]);
        }
    }
    int ans = 0;
    rep(i, v) {
        int res = dfs(i);
        if (res == -1) { puts("-1"); return 0;}
        chmax(ans, res);
    }
    cout << ans << endl;
}


Measured memory_bytes: 37632
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
 
 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;
 
using namespace std;


int main()   {
    cout.precision(17);
    ll modd = 1000 * 1000 * 1000 + 7;
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
    ll infinit = 10000000000000000;

//    auto start = chrono::steady_clock::now();

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
            readint(n);
            vector<int> data(1000001, 0);
            forr(i,0,n) {
                readint(kk); data[kk]++;
            }

            int ret = 0;
            forr(i,0,data.size()) {
                if (data[i]!=0) {
                    ret += (data[i]==1);
                    for(int k = 1; k*i < 1000001; ++k) {
                        data[k*i] = 0;
                    }
                }
            }

            cout << ret << endl;

    }

//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;

    return 0;
}

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

int main() {
    int t_hp,t_pow,a_hp,a_pow;
    cin >> t_hp >> t_pow >> a_hp >> a_pow;
    int t_ans, a_ans;
    
    t_ans = t_hp / a_pow;
    if(t_hp % a_pow > 0) t_ans++;
    
    a_ans = a_hp / t_pow;
    if(a_hp % t_pow > 0) a_ans++;
    
    if(a_ans > t_ans) std::cout << "No" << std::endl;
    else std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
 
using namespace std;
 
pair<int, int> segx[1 << 19], segy[1 << 19];
int sz = (1 << 18);
 
void update(pair<int, int> *seg, int pos, int val)
{
    pos += sz - 1;
    seg[pos] = make_pair(val, val);
 
    while (pos){
        pos = (pos - 1) / 2;
        seg[pos].first = max(seg[pos * 2 + 1].first, seg[pos * 2 + 2].first);
        seg[pos].second = min(seg[pos * 2 + 1].second, seg[pos * 2 + 2].second);
    }
}
 
pair<int, int> get(pair<int, int> *seg, int a, int b, int k = 0, int l = 0, int r = sz)
{
    if (b <= l || r <= a) return (make_pair(INT_MIN, INT_MAX));
    if (a <= l && r <= b){
        return (seg[k]);
    }
    pair<int, int> lf = get(seg, a, b, k * 2 + 1, l, (l + r) / 2);
    pair<int, int> rg = get(seg, a, b, k * 2 + 2, (l + r) / 2, r);
 
    return (make_pair(max(lf.first, rg.first), min(lf.second, rg.second)));
}
 
int main()
{
    int N, d;
 
    scanf("%d %d", &N, &d);
 
    vector<pair<int, int> > xs, ys;
    vector<int> xss, yss, bs;
 
    for (int i = 0; i < N; i++){
        int x, y, b;
        scanf("%d %d %d", &x, &y, &b);
        xs.push_back(make_pair(b, x));
        ys.push_back(make_pair(b, y));
        bs.push_back(b);
    }
 
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());
 
    for (int i = 0; i < N; i++){
        xss.push_back(xs[i].first);
        yss.push_back(ys[i].first);
        update(segx, i, xs[i].second);
        update(segy, i, ys[i].second);
    }
 
    long long ret = 0;
 
    for (int i = 0; i < N; i++){
        int xL = lower_bound(xss.begin(), xss.end(), bs[i])     - xss.begin(),
            xR = upper_bound(xss.begin(), xss.end(), bs[i] + d) - xss.begin();
        int yL = lower_bound(yss.begin(), yss.end(), bs[i])     - yss.begin(),
            yR = upper_bound(yss.begin(), yss.end(), bs[i] + d) - yss.begin();
 
        pair<int, int> posx = get(segx, xL, xR), posy = get(segy, yL, yR);
        ret = max(ret, (long long)(posx.second - posx.first) * (posy.second - posy.first));
    }
 
    printf("%lld\n", ret);
 
    return (0);
}

Measured memory_bytes: 16380
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

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

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
const ll MOD=1e9+7;

//last*other -> minCost
ll dp[2123][2123];
const ll INF=2e15;
vector<ll> a,sum;
int n,m,l;
ll cost(int L,int r){
  return (sum[a[r]+1]-sum[a[L]])/l;
}
int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  cin>>n>>m>>l;
  a.resize(n); sum.resize(m+1);
  rep(i,n){
    cin>>a[i]; --a[i];
  }
  sort(all(a));
  rep(i,m){
    cin>>sum[i+1];
    sum[i+1]+=sum[i];
  }
  //cout<<a<<sum;
  fill(dp[0],dp[0]+2123*2123,INF);
  dp[1][0]=cost(0,1);
  for(int i=2;i<n;++i){
    rep(j,i-1){
      dp[i][j]=min(dp[i][j],dp[i-1][j]+cost(i-1,i));
      dp[i][i-1]=min(dp[i][i-1],dp[i-1][j]+cost(j,i));
    }
  }
  ll re=INF;
  rep(i,n-1){
    re=min(re,dp[n-1][i]+cost(i,n-1));
  }
  cout<<re<<endl;
  return 0;
}

Measured memory_bytes: 37140
import numpy as np
N = int(input())
S = input()
pre_s = S[0]
sum1 = sum(s == 'E' for s in S)
res = sum1
if S[0] =='E':
    sum1-=1
    
for i in range(1,len(S)):
    if pre_s =='W':
        sum1 +=1
    if S[i]=='E':
        sum1 -=1
    if sum1 < res:
        res =sum1
    pre_s = S[i]
print(res)

Measured memory_bytes: 21264
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll  long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define bp __builtin_popcountll
#define MOD 1000000007
const int N = 55;
 
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll dp[N][N][2505];
ll a[N];
ll n,k;
ll solve(ll index,ll total,ll sum)
{
    if(index==n)
    {
        if(total!=0 && sum%total==0)
        {
            if(sum/total==k)  return 1;
            else return 0;
        }
        else   return 0;
    }
    ll ans = dp[index][total][sum];
    if(ans!=-1)   return ans;
    ans = 0;
    ans += solve(index+1,total+1,sum+a[index]);
    ans += solve(index+1,total,sum);
    return dp[index][total][sum] = ans;
}
int main() 
{
    FAST;
    cin >> n >> k;
    for(ll i=0;i<n;i++)   cin >> a[i];
    memset(dp,-1,sizeof(dp));
    ll ans = solve(0,0,0);
    cout<<ans;
    
}    

Measured memory_bytes: 59520
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
void vout(vl V) {
	for (ll i = 0; i < (ll)V.size(); i++) cout << V[i] << " ";
	cout << endl;
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color; vll path; vl A; vl dp; vl Ans;
int main(){
	cin >> N >> K;
	vl L, R;
	R.push_back(0);
	for (i = 0; i < N; i++) {
		ll x;
		cin >> x;
		if (x >= 0) R.push_back(x);
		else L.push_back(-x);
	}
	L.push_back(0);
	reverse(L.begin(), L.end());
	ans = INF;
	for (i = 0; i < L.size(); i++) {
		if(i>=0 && K-i>=0 && i<L.size() && K-i < R.size()) ans = min(ans, L[i] + R[K - i] + min(L[i], R[K - i]));
	}
	cout << ans;
}

Measured memory_bytes: 1656
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    in_arr(int, a, n);
    list<int> b;
    rep(i, n){
        if(i % 2 == 0){
            b.push_back(a[i]);
        }else {
            b.push_front(a[i]);
        }
    }
    if(n % 2 == 1){
        for(list<int>::reverse_iterator i = b.rbegin(); i != b.rend(); ++i){
            cout << *i;
            if(next(i) == b.rend()){
                cout << endl;
            }else{
                cout << " ";
            }
        }
    }else {
        for(list<int>::iterator i = b.begin(); i != b.end(); ++i){
            cout << *i;
            if(next(i) == b.end()){
                cout << endl;
            }else{
                cout << " ";
            }
        }
    }
    return 0;
}


Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
int h[100000];

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> h[i];
	
	int len = 0;
	int ans = 0;
	rep(i, n - 1) {
		if (h[i] >= h[i + 1]) {
			len++;
		}
		else {
			ans = max(ans, len);
			len = 0;
		}
	}
	ans = max(ans, len);
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>


int main(int argc, char const *argv[]) {

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

  if (a < 2*b){
      printf("%d\n", 0);
  }
  else {
      printf("%d\n", a - 2*b);
  }

  return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld EPS = 6e-11;
const int N = (int)1e5 + 10;
ld x[N];
ld y[N];
char dir[N];
int n;

ld fx(ld p){
  ld lx=(ld)1e9,rx=-(ld)1e9;
  ld cx;
  for(int i = 0 ; i < n; i ++ ){
    cx = x[i];
    if(dir[i]=='L')cx-=p;
    if(dir[i]=='R')cx+=p;
    lx=min(lx,cx);
    rx=max(rx,cx);
  }
  return (rx - lx);
}

ld fy(ld p){
  ld ly=(ld)1e9,ry=-(ld)1e9;
  ld cy;
  for(int i = 0 ; i < n; i ++ ){
    cy = y[i];
    if(dir[i]=='D')cy-=p;
    if(dir[i]=='U')cy+=p;
    ly=min(ly,cy);
    ry=max(ry,cy);
  }
  return (ry-ly);
}


int main(){
  fastIO;
  cin >> n;
  for(int i = 0; i < n; i ++ ){
    cin >> x[i] >> y[i] >> dir[i];
  }
  ld ans = fx(0)*fy(0);
  ld li = 0, ri = (ld)4e8;
  ld m1, m2;
  ld f1, f2;
  for(int it = 0; it < 300; it ++ ){
    m1 = (li + li + ri) / 3.0;
    m2 = (li + ri + ri) / 3.0;
    f1 = fx(m1)*fy(m1);
    f2 = fx(m2)*fy(m2);
    ans = min(ans, f1);
    ans = min(ans, f2);
    if(fx(m1)*fy(m1)>fx(m2)*fy(m2)){
      li = m1;
    }
    else{
      ri = m2;
    }
  }
  cout << fixed << setprecision(12) << ans << "\n";
  return 0;
}

Measured memory_bytes: 7020
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,i,c,f;
    deque<int > d;
    cin>>a;
    while(a--)
    {
        cin>>b;
        if(b==0)
        {
            cin>>c>>f;
            if(c==0)
            {
                d.push_front(f);
            }
            else if(c==1)
            {
                d.push_back(f);
            }
        }
        else if(b==1)
        {
            cin>>c;
            cout<<d[c]<<endl;
        }
        else if(b==2)
        {
            cin>>c;
            if(c==0)
            {
                d.pop_front();
            }
            else if(c==1)
            {
                d.pop_back();
            }
        }

    }
}



Measured memory_bytes: 4532
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;



signed main(){
	int N;
	cin>>N;
	vector<vector<int>>g(N);
	vector<int>a(N-1),b(N-1);
	REP(i,N-1){
		cin>>a[i]>>b[i];
		a[i]--;b[i]--;
		g[a[i]].push_back(b[i]);
		g[b[i]].push_back(a[i]);
	}
	map<pair<int,int>,int>mp;
	int nn = 0;
	REP(i,N)CHMAX(nn,(int)g[i].size());
	auto dfs = [&](auto&&f,int now,int par,int col)->void{
		int nuri = 0;
		for(auto&&e:g[now]){
			if(e==par)continue;
			if(nuri==col)nuri++;
			mp[{min(now,e),max(now,e)}]=nuri;
			f(f,e,now,nuri);
			nuri++;
		}
	};
	dfs(dfs,0,-1,-1);
	cout<<nn<<endl;
	REP(i,N-1){
		cout<<1+mp[{min(a[i],b[i]),max(a[i],b[i])}]<<endl;
	}
}

Measured memory_bytes: 14336
#include <iostream>
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
int cou;
int n,l;
struct ant{
  bool toRight;
  int position;
};
ant ants[20];
int main() {
  while(true){
    cin >> n >> l;
    if(n==0&&l==0) return 0;
    rep(i,n){
      ants[i] = ant();
      char c;
      cin >> c;
      if(c=='R'){
        ants[i].toRight = true;
      }else{
        ants[i].toRight = false;
      }
      cin >> ants[i].position;
    }
    cou = n;
    int leftout;
    int rightout;
    for(int t = 1;true;t++){
      leftout = -1;
      rightout = -1;
      rep(i,n){
        if(ants[i].position==0||ants[i].position==l) continue;
        if(ants[i].toRight){
          ants[i].position++;
        }else{
          ants[i].position--;
        }
        if(ants[i].position==0){
          cou--;
          leftout = i;
        }
        if(ants[i].position==l){
          cou--;
          rightout = i;
        }
      }
      if(cou==0){
        if(leftout!=-1){
          cout << t << " " << leftout+1 << endl;
        }else{
          cout << t << " " << rightout+1 << endl;
        }
        break;
      }
      rep(i,n){
        if(ants[i].position==0||ants[i].position==l) continue;
        REP(j,i+1,n){
          if(ants[i].position==ants[j].position){
            ants[i].toRight = !ants[i].toRight;
            ants[j].toRight = !ants[j].toRight;
          }
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    struct Point { internal double x, y; }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                double[] temp = Array.ConvertAll(input.Split(','), double.Parse);

                Point p1, p2, q;
                p1.x = temp[0];
                p1.y = temp[1];
                p2.x = temp[2];
                p2.y = temp[3];
                q.x = temp[4];
                q.y = temp[5];

                Point r = Reflect(p1, p2, q);

                sb.AppendLine(r.x + " " + r.y);
            }
            Console.Write(sb);
        }

        static Point Reflect(Point p1, Point p2, Point q)
        {
            Point project = Project(p1, p2, q);

            Point ret;
            ret.x = q.x + (project.x - q.x) * 2.0;
            ret.y = q.y + (project.y - q.y) * 2.0;

            return ret;
        }

        static Point Project(Point p1, Point p2, Point q)
        {
            Point vec1;
            vec1.x = p2.x - p1.x;
            vec1.y = p2.y - p1.y;

            Point vec2;
            vec2.x = q.x - p1.x;
            vec2.y = q.y - p1.y;

            double r = (vec1.x * vec2.x + vec1.y * vec2.y) / (vec1.x * vec1.x + vec1.y * vec1.y);

            Point ret;
            ret.x = p1.x + vec1.x * r;
            ret.y = p1.y + vec1.y * r;
            return ret;
        }
    }
}

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

using namespace std;

const int N = 205;
const double pi = acos(-1);

struct data {
    int x, y;
    double alp;

    bool operator < (const data &rhs) const {
        return alp < rhs.alp;
    }
} a[N];

int n;

int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d %d", &a[i].x, &a[i].y), a[i].alp = atan2(a[i].y, a[i].x);
    sort(a + 1, a + n + 1);

    for (int i = 1; i <= n; i++) {
        a[i + n].x = a[i].x;
        a[i + n].y = a[i].y;
        a[i + n].alp = a[i].alp + 2 * pi;
    }

    int ptr = 1;
    long long x = 0, y = 0, ans = 0;
    for (int i = 1; i <= n; i++) {
        while (ptr < i + n && a[ptr].alp - a[i].alp < pi) {
            x += a[ptr].x;
            y += a[ptr].y;
            ptr++;
            ans = max(ans, x * x + y * y);
        }

        x -= a[i].x;
        y -= a[i].y;
        ans = max(ans, x * x + y * y);
    }

    cout << fixed << setprecision(15) << (double)sqrt(ans);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

//数字を入れて場所を出力するようなvectorを作る。
//
int main() {
    ll n;
    cin>>n;
    vector<ll>a(n+1);
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        a.at(x)=i;//数字を入れたら何番目の値かわかるvectorを定義する。
    }
    set<ll>st;
    st.insert(-1);
    st.insert(n);
    ll ans=0;
    // cout<<"a.at(1) = "<<a.at(1)<<endl;
    // cout<<"*st.begin() = "<<*st.begin()<<endl;
    // auto itr = st.end();
    // itr--;
    // cout<<"*st.end() = "<<*itr<<endl;
    for(int i=0;i<n;i++){
        st.insert(a.at(i+1)); //i=0の時、1のindexがなんなのかがわかる。
        auto itr = st.find(a.at(i+1));
        auto itr1 = itr;
        auto itr2 = itr;
        itr1--;
        itr2++;
        ans+=(*(itr) - *(itr1))*(*(itr2) - *(itr)) * (i+1);
        // cout<<"AAA"<<*(itr)<<endl;
    }
    cout<<ans<<endl;



    return 0;
}



Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long n,i,j,ans=0;
   cin>>n;
   long long a[n+5];
   for(i=0;i<n;i++)
   {
       cin>>a[i];
   }
   vector<long long>v;
   for(i=0;i<n-2;i++)
   {
       //v.push_back(a[i]);
       for(j=i+1;j<n-1;j++)
       {
           //v.push_back(a[j]);
           for(int k=j+1;k<n;k++)
           {

               v.push_back(a[i]);
               v.push_back(a[j]);
               v.push_back(a[k]);
               sort(v.begin(),v.end());
               if(v[0]+v[1]>v[2]&&v[0]!=v[1]&&v[1]!=v[2]&&v[0]!=v[2])
                {
                    //cout<<a[i]<<" "<<a[j]<<" "<<a[k]<<endl;
                    ans++;
                }
               v.clear();
           }
       }
   }
   cout<<ans<<endl;
}


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

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int H,N;
  cin >> H >> N;
  vector<int> A(N),B(N);
  rep(i,N)  cin >> A.at(i) >> B.at(i);

  vector<int> dp(H+1,1e9);
  dp.at(0)=0;
  rep(i,N){
    rep(j,H+1){
      int tmp=max(0,j-A.at(i));
      chmin(dp.at(j),dp.at(tmp) + B.at(i));
    }
  }
  cout << dp.at(H) << endl;

  return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define USE1(T) template <typename T> inline
#define USE2(T, U) template <typename T, typename U> inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

template <typename T> using duo = std::pair<T, T>;
template <typename T> using vec = std::vector<T>;
using ll = long long;
using pii = duo<int>;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE1(T=int)vec<T>in(int n){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE1(T)vec<std::pair<T,int>>zipi(const vec<T>&x,int s=0){int N=x.size();vec<std::pair<T,int>>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  int a = in(), b = in(), h = in();
  pr((a + b) * h / 2);
  return 0;
}


Measured memory_bytes: 256
N = int(input())
X, U = [None]*N, [None]*N
for i in range(N):
    x, u = input().split()
    X[i], U[i] = float(x), u

s = 0
r = 380000.0
for x, u in zip(X, U):
    if u == 'JPY':
        s += x
    else:
        s+= x*r
print(s)

Measured memory_bytes: 3060
function readLines(): Promise<string[]> {
    return new Promise<string[]>((resolve) => {
        let inputBuffer = "";
        process.stdin.resume();
        process.stdin.setEncoding("utf8");
        process.stdin.on("data", (chunk) =>
            inputBuffer += chunk.toString()
        );
        process.stdin.on("end", () =>
            resolve(inputBuffer.split("\n"))
        );
    });
}

async function main() {
    const inputs: string[] = await readLines();
    const sp = inputs[0].split(" ");
    const a = parseInt(sp[0]);
    const b = parseInt(sp[1]);
    console.log((a-1)*(b-1));
}

main();


Measured memory_bytes: 11724
from time import time
import random


def main():
    random.seed(145)

    start = time()

    MAX = 26

    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(d)]

    t = []
    prev = [0] * MAX
    for day, row in enumerate(s, 1):
        mxi = 1
        mx = 0
        for i, (es, ec) in enumerate(zip(row, c), 1):
            point = es + ec * (day - prev[i-1])
            if point > mx:
                mx = point
                mxi = i

        prev[mxi-1] = day
        t.append(mxi)

    #print(t)

    last = [0] * MAX

    score = 0
    for day, e in enumerate(t, 1):
        score += s[day-1][e-1]
        last[e-1] = day

        for ec, elast in zip(c, last):
            score -= ec * (day - elast)

    d_li = []
    for i in range(1, d + 1):
        ln = max(1, (-(i - d // 2) ** 2 + d ** 2 // 4) // 500)
        d_li += [i] * ln

    di_max = len(d_li) - 1

    #c_sum = sum(c)
    #c_li = []
    #for i, e in enumerate(c, 1):
    #    c_li += [i] * e

    sc = []
    for row in s:
        app = []
        for i, (es, ec) in enumerate(zip(row, c), 1):
            app += [i] * max(1, (es + ec * d) // 20)
        sc.append(app)

    now = time()

    cnt = 0
    no_change = 0
    while now - start <= 1.85:
        prev_score = score
        cnt += 1

        di = random.randint(0, di_max)
        ed = d_li[di]
        qi = random.randint(0, len(sc[ed-1]) - 1)
        eq = sc[ed-1][qi]

        q_old = t[ed-1]
        d_prev = {q_old: 0, eq: 0}

        c_old = c[q_old-1]
        c_new = c[eq-1]

        for day, e in enumerate(t, 1):
            if e in d_prev.keys():
                d_prev[e] = day

            score += c_old * (day - d_prev[q_old])
            score += c_new * (day - d_prev[eq])

        score -= s[ed-1][q_old-1]
        score += s[ed-1][eq-1]

        t[ed-1] = eq

        d_prev = {q_old: 0, eq: 0}

        for day, e in enumerate(t, 1):
            if e in d_prev.keys():
                d_prev[e] = day

            score -= c_old * (day - d_prev[q_old])
            score -= c_new * (day - d_prev[eq])

        now = time()

        if (prev_score - score) * (2 - now) <= 10:
            #print(prev_score - score)
            continue

        no_change += 1
        t[ed-1] = q_old
        score = prev_score

    print(*t, sep="\n")
    #print(cnt, no_change)


if __name__ == "__main__":
    main()


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

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int L, R;
    L = A + B;
    R = C + D;

    if (L == R){
        cout << "Balanced" << endl;
    }
    else if (L > R){
        cout << "Left" << endl;
    }
    else
    {
        cout << "Right" << endl;
    }
    
}

Measured memory_bytes: 3620
#include<stdio.h>

int number_a[105][105],number_b[10050];

int main()
{
    int h1,m;
    while(scanf("%d %d",&h1,&m)!=EOF)
    {
        int i,j,t,k=0;
        scanf("%d",&t);
        for(i=0; i<t; i++)
            scanf("%d",&number_b[i]);
        for(i=0; i<h1; i++)
        {
            if(i%2==0)
                for(j=0; j<m; j++)
                {
                    number_a[i][j]=k+1;
                    number_b[k]--;
                    if(number_b[k]==0)
                        k++;
                }
            if(i%2==1)
                for(j=m-1; j>=0; j--)
                {
                    number_a[i][j]=k+1;
                    number_b[k]--;
                    if(number_b[k]==0)
                        k++;
                }
        }
        for(i=0; i<h1; i++)
        {
            for(j=0; j<m-1; j++)
                printf("%d ",number_a[i][j]);
            printf("%d\n",number_a[i][m-1]);
        }
    }
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <type_traits>
#include <vector>
using namespace std;
int main() {
  unsigned long long x;
  cin >> x;
  unsigned long long moto = 100;
  long double cut = 0;
  while (1) {
    cut++;
    moto = moto * 1.01;
    // cout << moto << endl;
    if (x <= moto) {
      cout << cut << endl;
      break;
    }
  }
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
#define all(x) x.begin(),x.end()
const int maxn = 705;

int mat[maxn][maxn];
vector <int> adjlist[maxn];
int n,m;

int clength[2];
int col[maxn];
bool visited[maxn];


void fail() {
	cout << "-1";
	exit(0);
}

void dfs(int x, int c) {
	clength[c]++;
	col[x] = c;
	visited[x] = true;
	
	for (auto i: adjlist[x]) {
		if (!visited[i])
			dfs(i,!c);
		else if (col[i] == c) {
			fail();
		}
	}
}

int dp[2][maxn]; //Size of T is size of S is i.

int32_t main() {
	cin >> n >> m;
	memset(mat,1,sizeof mat);
	for (int i =0;i<m;i++) {
		int a,b; cin >> a >> b;
		mat[a][b] = mat[b][a] = 0;
	}
	for (int i =1;i<=n;i++) {
		for (int j=1;j<=n;j++) {
			if (mat[i][j] and i != j) adjlist[i].push_back(j);
		}
	}
	memset(dp,-1,sizeof dp);
	dp[0][0] = 0;
	int pos = 1;
	
	for (int i =1;i<=n;i++) {
		if (visited[i]) continue;
		pos = !pos;
		clength[0] = clength[1] = 0;
		dfs(i,0);
		for (int j =0;j<=n - clength[0];j++) {
			if (dp[pos][j] == -1) continue;
			dp[!pos][j+clength[0]] = dp[pos][j] + clength[1];
		}	
		
		for (int j =0;j<=n - clength[1]; j++) {
			if (dp[pos][j] == -1) continue;
			dp[!pos][j + clength[1]] = dp[pos][j] + clength[0];
		}
		memset(dp[pos],-1,sizeof dp[pos]);
	}
	
	int ans = INT_MAX/2;
	for (int i = 0;i<=n;i++) {
		if (dp[!pos][i] + i == n) 
			ans = min(ans, (i)*(i-1)/2 + dp[!pos][i]*(dp[!pos][i]-1)/2);
	}
	cout << ans;
}









Measured memory_bytes: 4992
#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<stdlib.h>
#include<queue>
#include<utility>
#include<string>
using namespace std;
int main() {
	int n, memo, ans = 0, w = 0, r = 0;
	char str[200001];
	vector<int>index_W(200001, -1), index_R(200001, -1);
	scanf("%d%s", &n, &str);
	memo = n - 1;
	for (int i = 0; i < n; ++i) {
		if (str[i] == 'W') {
			index_W[w++] = i;
		}
		if (str[n - 1 - i] == 'R') {
			index_R[r++] = n - 1 - i;
		}

	}
	for (int i = 0; i < n; ++i) {
		if (index_W[i] == -1||index_R[i]==-1||(index_W[i]>index_R[i]))break;
		swap(str[index_W[i]], str[index_R[i]]);
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4720
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define PI 3.141592653589793
#define endl "\n"

struct UnionFind {
  vi par, count;

  UnionFind(int N) : par(N), count(N, 1){
    for(int i = 0; i < N; i++) par.at(i) = i;
  }

  int root(int x){
    if(par.at(x) == x) return x;
    return par.at(x) = root(par.at(x));
  }

  int unite(int x, int y){
    if(root(x) == root(y)) return 0;
    if(size(x) < size(y)){
      count.at(root(y)) += count.at(root(x));
      par.at(root(x)) = root(y);
    }
    else{
      count.at(root(x)) += count.at(root(y));
      par.at(root(y)) = root(x);
    }
    return 1;
  }

  bool same(int x, int y){
    return root(x) == root(y);
  }

  int size(int x){
    return count.at(root(x));
  }
};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, M;
  cin >> N >> M;
  UnionFind uf(N);
  for(int i = 0; i < M; i++){
    ll X, Y, Z;
    cin >> X >> Y >> Z;
    X--; Y--;
    uf.unite(X, Y);
  }
  set<ll> par;
  for(int i = 0; i < N; i++){
    par.insert(uf.root(i));
  }
  cout << par.size() << endl;
}

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

int main(){
	int a,b;
	int used[1000][2] = {};
	string s;
	bool flag = false,f = false;
	while(getline(cin,s)){
		if(s == "") flag = true;
		else{
			int tmp = 0;
			for(int i = 0;i < s.length();i++){
				if(s[i] == ',') {
					used[tmp - 1][flag]++;
					break;
				}else tmp = tmp * 10 + s[i] - '0';
			}
		}
	}
	for(int i = 0;i < 1000;i++){
		if(used[i][0] && used[i][1]) cout << i + 1 << " " << used[i][0] + used[i][1] << endl;
	}
	return 0;
}

Measured memory_bytes: 3004
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let n: usize = read();
    let a: Vec<u64> = (0..n).map(|_| read()).collect();
    let mut sort_a: Vec<_>= a.iter().cloned().collect();
    sort_a.sort();
    let left_mid = sort_a[n/2-1];
    let right_mid = sort_a[n/2];

    for i in a.iter(){
        if *i <= left_mid {
            println!("{}",right_mid);
        }else{
            println!("{}",left_mid);
        }
    }
}


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

int main() {
	int N;
  	cin >> N;
  
  	vector<int> vec(N);
  
  	for(int i = 0; i < N; i++) {
    	cin >> vec.at(i);
    }
  	
  	int sum = 0;
  
  	for(int i = 0; i < N;i++) {
      bool can = true;
    	for(int j = 0; j < i; j++) {
        	if(vec.at(j) > vec.at(i)) {
              can = false;
              break;
        	}
        }
      if(can)
      	sum++;
    }
  
  	cout << sum << endl;
}

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

int arr[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};


int main()
{
    int n;
    cin>>n;
    cout<<arr[n-1]<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count =0;
		int a[] = new int[9];
		int N = sc.nextInt();
		int temp =1;
		for (int i=0;i<a.length;i++) {
			a[i] = temp;
			temp *=2;
		}
		for (int i=a.length-1;i>=0;i--) {
			if (a[i]<=N) {
				System.out.println(a[i]);
				return;
			}
		}
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<iostream>
using namespace std;

string s;
int main (){
    cin >> s;
    for(int i=0; i<5; i++) cout << s[i] ;
    cout << " " ;
    for(int i=6; i<13; i++) cout << s[i] ;
    cout << " ";
    for(int i=14; i<19; i++) cout << s[i] ;
    cout << endl;
    return 0;

}


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

int main (void) {
    int n;
    cin >> n;
    vector<int> x(n);
    int sum = 0, max_x = 0, min_x = 0;
    for (int i = 0; i < n; i ++ ) {
        cin >> x.at(i);
        sum += x.at(i);
        max_x = max(max_x, x.at(i));
        min_x = min(min_x, x.at(i));
    }
    
    int32_t v_min = 0;
    for (int i = min_x; i < max_x + 1; i++) {
        int32_t v = 0;
        for (auto X : x) {
            v += pow(X - i, 2);
        }
        if (i == min_x) {
            v_min = v;
        } else {
            v_min = min(v, v_min);
        }
    }
    cout << v_min << endl;
}

Measured memory_bytes: 256