akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#define MAX 500100
#define NIL -1
using namespace std;

class Node{
  public:
    int location;
    int p,l,r;
    Node(){}
};

class Point{
  public:
    int id,x,y;
    Point(){}
    Point(int id,int x,int y): id(id),x(x),y(y){}
    bool operator < (const Point &p) const {
      return id<p.id;
    }
    
    void print(){
      printf("%d\n",id);
    }
};

Point P[MAX];
Node T[MAX];
int np=0,N;

bool lessX(const Point &a,const Point &b){ return a.x<b.x;}
bool lessY(const Point &a,const Point &b){ return a.y<b.y;}

int makeKDtree(int l,int r,int depth){
  if(!(l<r)) return NIL;
  int mid=(l+r)/2;
  int t=np++;
  if(depth%2 == 0){
    sort(P+l,P+r,lessX);
  }
  else{
    sort(P+l,P+r,lessY);
  }

  T[t].location=mid;
  T[t].l=makeKDtree(l,mid,depth+1);
  T[t].r=makeKDtree(mid+1,r,depth+1);

  return t;
}

void find(int v,int sx,int tx,int sy,int ty,int depth,vector<Point> &ans){
  int x=P[T[v].location].x;
  int y=P[T[v].location].y;

  if(sx<=x && x<=tx && sy<=y && y<=ty){
    ans.push_back(P[T[v].location]);
  }

  if(depth%2 == 0){
    if(T[v].l!=NIL && sx<=x) find(T[v].l,sx,tx,sy,ty,depth+1,ans);
    if(T[v].r!=NIL && tx>=x) find(T[v].r,sx,tx,sy,ty,depth+1,ans);
  }
  else{
    if(T[v].l!=NIL && sy<=y) find(T[v].l,sx,tx,sy,ty,depth+1,ans);
    if(T[v].r!=NIL && ty>=y) find(T[v].r,sx,tx,sy,ty,depth+1,ans);
  }
}

int main(){
  int x,y;
  scanf("%d",&N);
  for(int i=0;i<N;++i){
    scanf("%d %d",&x,&y);
    P[i]=Point(i,x,y);
    T[i].l=T[i].r=T[i].p=NIL;
  }

  np=0;

  int root=makeKDtree(0,N,0);

  int q;
  scanf("%d",&q);
  int sx,tx,sy,ty;
  vector<Point> ans;
  for(int i=0;i<q;++i){
    scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
    ans.clear();
    find(root,sx,tx,sy,ty,0,ans);
    sort(ans.begin(),ans.end());
    for(int j=0;j<ans.size();++j){
      ans[j].print();
    }
    printf("\n");
  }
}



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

int main()
{
    ll L,R;
    cin >> L >> R;

    ll min2019 = 2020;

    if(R-L >= 2018)
    {
        cout << 0 << endl;
        return 0;
    }
    else
    {
        for(ll i = L; i < R; i++)
        {
            for(ll j = i+1; j <= R; j++)
            {
                if((i * j) % 2019 < min2019)
                {
                    min2019 = (i*j)%2019;
                }
            }
        }
    }
    cout << min2019 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <climits>
#include <cstring>


using namespace std;

const int N_MAX = 1000000;

int main(){
  string T;
  string P;
  cin >> T;
  cin >> P;

  int t_ix = 0;
  int p_ix = 0;

  vector<int> ans;
  
  while(t_ix < T.length()){
    // cout << "t_ix: " << t_ix << endl;
    if(T[t_ix] == P[p_ix]){
      
      int tmp_t_ix = t_ix;
      while(T[tmp_t_ix] == P[p_ix] && tmp_t_ix < T.length() && p_ix < P.length()){
	// cout << "tmp_t_ix: " << tmp_t_ix << endl;
	tmp_t_ix++;
	p_ix++;
      }
      if(p_ix == P.length()) ans.push_back(t_ix);
      p_ix = 0;
    }
    t_ix++;
  }

  for(int i=0; i<ans.size(); i++){
    cout << ans[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3176
//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 1000000007LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto& v : vs)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" << " " << __FILE__ << endl

#define MAX_VALUE 9223372036854775807

vector<vector<ll>> dps;

ll calc_dps(ll idx, ll t, const vector<pair<ll, ll>>& ABs) {
	if (idx < 0) return 0;
	if (t < 0) return 0;
	if (dps[idx][t] != -1) return dps[idx][t];

	ll res = calc_dps(idx - 1, t, ABs);
	if (t >= ABs[idx].first) {
		res = max(res, calc_dps(idx - 1, t - ABs[idx].first, ABs) + ABs[idx].second);
	}

	dps[idx][t] = res;
	return dps[idx][t];
}

int solve() {
	ll N, T;
	cin >> N >> T;

	vector<pair<ll, ll>> ABs(N);
	ll A, B;
	REPD(i, 0, N) {
		cin >> A >> B;
		ABs[i] = {A, B};
	}
	sort(ABs.begin(), ABs.end());

	dps = vector<vector<ll>>(N, vector<ll>(T, -1));
	ll res = ABs[0].second;
	REPD(i, 0, N) res = max(res, ABs[i].second + calc_dps(i - 1, T - 1, ABs));

	RET(res);
}

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

	solve();
	// ll t;
	// cin >> t;
	// REPD(i, 0, t) solve();

	return 0;
}


Measured memory_bytes: 73932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,w;
	cin >> n >> w;
	int mx = 100005;
	ll inf = 1e15;
	vector<vector<ll>> dp(n, vector<ll>(mx+1));
	for (int q = 0; q < n; q++)
	{
		ll weight, value;
		cin >> weight >> value;
		if (q == 0)
		{
			for (int e = 1; e <= value; e++)
			{
				dp[0][e] = weight;
			}
			for (int e = value+1; e <= mx; e++)
			{
				dp[0][e] = inf;
			}
		}
		else
		{
			for (int e = 0; e <= mx; e++)
			{
				dp[q][e] = dp[q-1][e];
			}
			for (int e = value; e <= mx; e++)
			{
				dp[q][e] = min(dp[q][e], weight + dp[q-1][e-value]);
			}
		}
	}
	for (int q = mx; q >= 0; q--)
	{
		if (dp[n-1][q] <= w)
		{
			cout << q << "\n";
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 79488
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

const int MAX = 510000;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / ll(i)) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

ll mod(ll i, ll j) {
    return (i % j) < 0 ? (i % j) + 0 + (j < 0 ? -j : j) : (i % j + 0);
}

int main() {
    int N;
    ll K;
    cin >> N >> K;
    unordered_map<int, unordered_set<int>> graph;
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        graph[a].insert(b);
        graph[b].insert(a);
    }
    COMinit();

    ll ans = 1;
    
    int nd = 1;
    deque<int> que;
    que.push_back(nd);
    unordered_set<int> visited;
    visited.insert(nd);
    ans = COM(K, graph[nd].size() + 1);
    while (1) {
        if (que.size() <= 0) break;
        nd = que.front();
        que.pop_front();
        for (auto& adj : graph[nd]) {
            if (visited.count(adj) >= 1) continue;

            ans *= COM(K - 2, graph[adj].size() - 1);
            ans %= MOD;
            visited.insert(adj);
            que.push_back(adj);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 36132
n, u, v = map(int, input().split())
edges = [[] for i in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

aolevel = [-1] * n
aolevel[v - 1] = 0
q = [v - 1]
while len(q) > 0:
    i = q.pop(0)
    for j in edges[i]:
        if aolevel[j] < 0:
            aolevel[j] = aolevel[i] + 1
            q.append(j)

ret = 0
takalevel = [-1] * n
takalevel[u - 1] = 0
q = [u - 1]
while len(q) > 0:
    i = q.pop(0)
    ret = max(ret, aolevel[i] - 1)
    if takalevel[i] < aolevel[i]:
        for j in edges[i]:
            if takalevel[j] < 0:
                takalevel[j] = takalevel[i] + 1
                q.append(j)

print(ret)


Measured memory_bytes: 92944
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

// sum[p] = 0..p の中から n 個の要素を選び、最大の和を格納
long[] calcLeft(int[] xs) {
    long[] sum = new long[xs.length];
    long s = 0;
    int d = cast(int)xs.length / 3;
    auto q = new BinaryHeap!(Array!long, "a > b"); // 小さい順から取り出せる
    for (int i = 0; i < d * 2; i++) {
        q.insert(xs[i]);
        s += xs[i];
        if (q.length > d) {
            s -= q.front;
            q.popFront;
        }
        sum[i] = s;
    }
    return sum;
}

// sum[p] = p..$ の中から n 個の要素を選び、最小の和を格納
long[] calcRight(int[] xs) {
    long[] sum = new long[xs.length];
    long s = 0;
    int d = cast(int)xs.length / 3;
    auto q = new BinaryHeap!(Array!long, "a < b"); // 大きい順から取り出す
    for (int i = cast(int)xs.length-1; i >= d; i--) {
        q.insert(xs[i]);
        s += xs[i];
        if (q.length > d) {
            s -= q.front;
            q.popFront;
        }
        sum[i] = s;
    }
    return sum;
}

long calc(int[] xs) {
    auto lefts  = calcLeft(xs);
    auto rights = calcRight(xs);

    auto n = xs.length;
    auto d = cast(int)xs.length / 3;
    long ans = long.min;
    for (int i = d - 1; i < 2 * d; i++) {
        long diff = lefts[i] - rights[i + 1];
        ans = max(ans, diff);
    }
    return ans;
}

void main() {
    readint;
    auto xs = readints;
    auto ans = calc(xs);
    writeln(ans);
}

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

using LL = long long;

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

    LL h, w;
    cin >> h >> w;

    int i, j;

    vector<vector<char>> arr;
    arr.resize(h); 
    for (i = 0; i < h; i++)
    {
        arr[i].resize(w);
    }
    vector<vector<int>> arr2;
    arr2.resize(h); 
    for (i = 0; i < h; i++)
    {
        arr2[i].resize(w);
    }

    for(i = 0; i < h; i++){
        for(j = 0; j < w; j++){
            cin >> arr[i][j];
            if(arr[i][j] == '#'){
                arr2[i][j] = -2500;
             }else{
                arr2[i][j] = 0;
             }
        }
    }

    for(i = 0; i < h; i++){
        for(j = 0; j < w; j++){
            if(arr2[i][j] < 0){
                if(i > 0){
                    arr2[i - 1][j]++;
                }
                if(i < h-1){
                    arr2[i + 1][j]++;
                }
                if(j > 0){
                    arr2[i][j - 1]++;
                }
                if(j < w-1){
                    arr2[i][j + 1]++;
                }
                if(i > 0 && j > 0){
                    arr2[i - 1][j - 1]++;
                }
                if(i < h-1 && j > 0) {
                    arr2[i + 1][j - 1]++;
                }
                if(i > 0 && j < w-1){
                    arr2[i - 1][j + 1]++;
                }
                if(i < h-1 && j < w-1){
                    arr2[i + 1][j + 1]++;
                }
            }
        }
    }

    for(i = 0; i < h; i++){
        for(j = 0; j < w; j++){
            if(arr2[i][j] < 0){
                cout << "#";
            }else{
                cout << arr2[i][j];
            }
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import bisect

sys.setrecursionlimit(10**7)
n = int(input())
l = list(map(int,input().split()))
e = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    e[a].append(b)
    e[b].append(a)


ans = [0]*n
ans[0] = 1
dp = [l[0]]

def dfs(now,bef):
    
    change = True
    if l[now] > dp[-1]:
        dp.append(l[now])
    else:
        index = bisect.bisect_left(dp,l[now])
        change = False
        s = dp[index]
        dp[index] = l[now] 
    ans[now] = len(dp)
    
    for nex in e[now]:
        if nex != bef:
            dfs(nex,now)
    if change:
        dp.pop()
    else:
        dp[index] = s 

for i in e[0]:
    dfs(i,0)

for i in ans:
    print(i)



Measured memory_bytes: 345304
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var s = cin.next();
            var ss = cin.next();
            var sss = cin.next();
            Console.WriteLine(""+s[0]+ss[0]+sss[0]);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

int main() {
	string S;cin>>S;


	int ans1=0,ans2=0;
	for (int i = 0; i < S.size(); i++)
	{
		if (S[i] != (i % 2 ? '1' : '0'))
		{
			ans1++;
		}
		if (S[i] != (i % 2 ? '0' : '1'))
		{
			ans2++;
		}
	}

	cout<<min(ans1, ans2)<<endl;

	return 0;
}

Measured memory_bytes: 512
/*****************************************************
 *     created by: nayakashutosh9
 * "Winners Never Quit and Quitters Never Win".
*****************************************************/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define endl '\n'
#define mod 1000000007
#define inf 1e18
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
const int N = 300005;
/**********************************************************************************************/


void solve() {
	int n; cin >> n;
	cout << ((n >= 30) ? "Yes\n" : "No\n");
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1, z = 1;
	// cin >> t; cin.ignore();
	while (t--) {
		// cout << "Case #" << (z++) << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
		//print execution time in ms
	}

	return 0;
}

Measured memory_bytes: 3524
#include <iostream>
#include <cmath>

using namespace std;




int main(){
	
	int n;
	double xa,xb,ya,yb,ra,rb;
	double d;
	
	cin >> n;
	for (int i=0; i<n; i++) {
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		d=sqrt((xb-xa)*(xb-xa)+(yb-ya)*(yb-ya));
		if (d>ra+rb) {
			cout << 0 <<endl;
		}
		else if(ra<rb&&d<rb-ra){
			cout << -2 << endl;
		}
		else if(ra>rb&&d<ra-rb){
			cout << 2 << endl;
		}
		else {
			cout << 1 << endl;
		}
	}
		
	return 0;
}
 

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 1200000000

using namespace std;

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

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

    int lw = 0, le = 0, rw = 0, re = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'W') rw++;
        else re++;
    }

    int mn = INF;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'W') rw--;
        else re--;
        mn = min(mn, re + lw);
        if (s[i] == 'W') {
            lw++;
        } else {
            le++;
        }
    }

    cout << mn << endl;

    return 0;
}


Measured memory_bytes: 900
#include <stdio.h>

int main(void)
{
	long long int num;
	long long int sum;
	long long int fizz;
	long long int buzz;
	long long int fizzbuzz;

	//Junretu Sum.
	scanf("%lld", &num);
	sum = (num * (2 + (num - 1))) / 2;

	//fizz sum.
	fizz = num / 3;
	fizz = (fizz * (2 * 3 + (fizz * 3 - 3))) / 2;

	//buzz sum.
	buzz = num / 5;
	buzz = (buzz * (2 * 5 + (buzz * 5 - 5))) / 2;

	//fizz buzz sum.
	fizzbuzz = num / 15;
	fizzbuzz = (fizzbuzz * (2 * 15 + (fizzbuzz * 15 - 15))) / 2;

	sum = sum - fizz - buzz + fizzbuzz;

	printf("%lld\n", sum);
	return (0);
}


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

int main(){
  int N;
  cin >> N;
  float price = N / 1.08;
  if (int(int(price)*1.08) == N) cout << int(price) << endl;
  else if (int((int(price)+1)*1.08) == N) cout << int(price)+1 << endl;
  else  cout << ":(" << endl;
  return 0;
}

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

using namespace std;

const int inf = 2e9;

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

    int n;
    cin >> n;
    vector<int> dp(n, inf);
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for (int i = 2; i < n; i++) {
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << dp[n - 1] << "\n";

    return 0;
}


Measured memory_bytes: 1024
s = int(input())
mod = 10**9 + 7
n = s // 3
if n == 0:
    print(0)
    exit()
amari = [0]*(n+1)
for i in range(1, n+1):
    amari[i] = s - 3*i
#print(amari)

fac = [1] * (s + 1)
inv = [1] * (s + 1)
def COMinit():
    for j in range(1, s + 1):
        fac[j] = fac[j - 1] * j % mod

    inv[s] = pow(fac[s], mod - 2, mod)
    for j in range(s - 1, -1, -1):
        inv[j] = inv[j + 1] * (j + 1) % mod

def comb2(n, r):
    if r > n or n < 0 or r < 0:
        return 0
    return fac[n] * inv[n - r] * inv[r] % mod

ans = 0
COMinit()
for i in range(1, n+1):
    ans += comb2(amari[i]+i-1, amari[i])
    ans %= mod
print(ans % mod)

Measured memory_bytes: 64516
import java.util.Arrays;
import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner in = new Scanner(System.in);
		while(in.hasNext())
		{
			int n= in.nextInt();
			int a[] = new int[n];
			int ans = 0;
			for(int i=0; i<n; i++)
				a[i]=in.nextInt();
			Arrays.sort(a);
			int sum[]= new int [n];
			sum[0]=a[0];
			for(int i=1; i<n; i++)
				sum[i]=a[i]+sum[i-1];
			for(int i=0; i<n ;i++)
			ans+=sum[i];
			System.out.println(ans);
		}

	}

}

Measured memory_bytes: 12000
# もらうDPをメモ化再帰にしました的な実装
t = int(input())
for _ in range(t):
    n, a, b, c, d = map(int, input().split())
    memo = {0: 0, 1: d}

    def dfs(n):
        if n in memo.keys():
            return memo[n]

        res1 = n*d
        r = n % 2
        res2 = a+r*d+dfs((n-r)//2)
        if r != 0:
            tmp = a+(2-r)*d+dfs((n+(2-r))//2)
            if tmp < res2:
                res2 = tmp

        r = n % 3
        res3 = b+r*d+dfs((n-r)//3)
        if r != 0:
            tmp = b+(3-r)*d+dfs((n+(3-r))//3)
            if tmp < res3:
                res3 = tmp

        r = n % 5
        res5 = c+r*d+dfs((n-r)//5)
        if r != 0:
            tmp = c+(5-r)*d+dfs((n+(5-r))//5)
            if tmp < res5:
                res5 = tmp

        memo[n] = min(res1, res2, res3, res5)
        return memo[n]

    print(dfs(n))

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


int main() {
  int n;
  cin >> n;
  
  double odd = n%2 == 1 ? (n+1)/2 : n/2;
  double ans = odd /n;
  cout << fixed << setprecision(10);
  cout << ans << endl;
}

Measured memory_bytes: 256
# B問題
O = input()
E = input()
ans = ''
if len(O) == len(E):
    for i in range(len(O)):
        ans += O[i]
        ans += E[i]
else:
    for i in range(len(E)):
        ans += O[i]
        ans += E[i]
    ans += O[len(O) - 1]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
int ret[1000000];

int main(){
  int n;
  cin>>n;
  int a[1000000],num=0;
  lp(i,n){
    cin>>a[i];
    num=max(a[i],num);
  }
  int ans=0,memo,count;
  lp(i,n){
    count=0;
    memo=a[i];
    while(1){
      if(num%a[i]==0){
	ret[memo]=count;
	break;
      }
      if(ret[memo]!=0){
	ans+=ret[memo];
	break;
      }
      a[i]++;
      ans++;
      count++;
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3532
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

ll n,m,v,p;
vector<ll> a;

bool C(ll x){
    if(x < p) return true;
    ll now = a[x] + m;
    if(a[p-1] > now) return false;
    ll score = 0;
    score += (p-1) * m;
    score += (n-x) * m;
    for(ll i = p-1;i < x; i++){
        score += min(m,max(0ll, now - a[i]));
    }
    return score >= m * v;
}

int main(){
    cin >> n >> m >> v >> p;
    a.resize(n,0);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end(),greater<int>());
    
    ll ok = -1;
    ll ng = n;

    while(abs(ng-ok) > 1){
        ll mid = (ok+ng)/2;
        if(C(mid)) ok = mid;
        else ng = mid;
    }

    cout << ok + 1 << endl;
    return 0;
}

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

#define MOD 1000000007
#define MAX_P 500005
Int fact[MAX_P],inv[MAX_P],finv[MAX_P];;

Int extgcd(Int a,Int b,Int& x,Int& y){
  Int d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;y=0;
  }
  return d;
}
Int mod_inverse(Int a,Int mod){
  Int x,y;
  extgcd(a,mod,x,y);
  return (mod+x%mod)%mod;
}

Int mod_pow(Int x,Int n,Int mod){
  Int res=1;
  while(n){
    if(n&1) (res*=x)%=mod;
    (x*=x)%=mod;
    n>>=1;
  }
  return res;
}

Int mod_inverse2(Int a,Int mod){
  return mod_pow(a,mod-2,mod);
}

void init(Int mod){
  fact[0]=1;
  for(Int i=1;i<MAX_P;i++)
    fact[i]=(fact[i-1]*i)%mod;

  inv[1]=1;
  for(Int i=2;i<MAX_P;i++)
    inv[i]=inv[mod%i]*(mod-mod/i)%mod;
  
  finv[0]=1;
  for(Int i=1;i<MAX_P;i++)
    finv[i]=finv[i-1]*inv[i]%mod;
}

//only for prime mod
Int mod_comb3(Int n,Int k,Int mod){
  if(k<0||k>n) return 0;
  return fact[n]*finv[k]%mod*finv[n-k]%mod;
}


template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> a(m);
  for(Int i=0;i<m;i++) cin>>a[i];

  init(MOD);
  Int s=1<<n;
  assert(is_sorted(a.begin(),a.end()));
  reverse(a.begin(),a.end());

  
  auto dp=make_v<Int>(m+1,s);
  fill_v(dp,0);
  dp[0][0]=1;
  for(Int i=0;i<m;i++){
    for(Int j=i;j<m;j++){
      for(Int b=0;b<s;b++){
	for(Int k=0;k<n;k++){
	  if((b>>k)&1) continue;
	  Int nb=b|(1<<k);
	  Int rs=(s-a[j])-b;
	  Int cb=mod_comb3(rs,(1<<k)-1,MOD);
	  Int res=dp[i][b]*cb%MOD;
	  res=res*fact[1<<k]%MOD;
	  dp[j+1][nb]+=res;
	  dp[j+1][nb]%=MOD;
	}
      }
    }
  }
  
  vector<Int> dp2(s,0);
  for(Int i=0;i<=m;i++)
    for(Int j=0;j<s;j++)
      (dp2[j]+=dp[i][j])%=MOD;

  Int ans=0;
  for(Int i=0;i<s;i++){
    if(__builtin_popcount(i)&1) ans-=dp2[i]*fact[s-(i+1)]%MOD;
    else ans+=dp2[i]*fact[s-(i+1)]%MOD;
    ans+=MOD;
    ans%=MOD;
  }
  ans=ans*s%MOD;
  assert(0<=ans&&ans<MOD);
  //if(m==0) assert(ans==fact[s]);
  //else if(a.back()==2) assert(ans==0);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 22780
import math

while True:
	d =0
	n = int(input())
	if n == 0:
		break
	s = list(map(int, input().split()))
	avg = sum(s) / len(s)
	for i in s:
		c = (i - avg) ** 2
		d += c
	a2 = d / len(s)
	print(math.sqrt(a2))



Measured memory_bytes: 5692
n = int(input())
a = [int(input()) for i in range(n)]

count = 0
for i in range(n - 1):
    if a[i] > 0:
        tmp = a[i] // 2
        count += tmp
        a[i] -= tmp * 2
    if a[i] > 0 and a[i + 1] > 0:
        tmp = min(a[i], a[i + 1])
        a[i + 1] -= tmp
        count += tmp

if a[-1] > 1:
    count += a[-1] // 2
print(count)


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

int w[10];

void a(int x, int y){
  if(x==0)return;
  if(x%2==1){
    w[y]=1;
  }
  else{
    w[y]=0;
  }
  a(x/2, y+1);
}

int main(){
  int n;
  while(cin>>n){
    bool flag=false;
    for(int i=0; i<10; i++)w[i]=0;
    a(n, 0);
    for(int i=0; i<10; i++){
      if(w[i]==1){
        if(flag)cout << ' ';
        cout << (int)pow(2.0, i);
        flag=true;
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>


#define ll long long
//#define int ll
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 2e5 + 1;
int n , m, k , q;
int a[N];
void upd(int l , int r){
	if(l > r)return;
	a[l]--; a[r + 1]++;
}
main(){
	cin >> n >> k >> q;
	for(;q--;){
		int x;
		cin >> x;
		upd(1 , x - 1);
		upd(x +1 ,n);
	}
	for(int i = 1 ; i <= n; i++){
		a[i] += a[i - 1];

		if(a[i] + k <= 0)
			cout << "No\n";
		else cout << "Yes\n"; 
	}
		
}

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

int main()
{
	static int p[10 * 100 * 1000] = {};
	int index = 0;
	int a, d, n;
	while (cin >> a >> d >> n && a != 0 && d != 0 && n != 0)
	{
		index = 0;
		for (int i = a; i < 1000000; i += d)
		{
			bool f = true;
			if (i < 2)continue;
			for (int j = 2; j * j <= i; j++)
			{
				if (i % j == 0)
				{
					f = false;
					break;
				}
			}

			if (f)
			{
				p[index] = i;
				index++;
				if (index >= n)break;
			}
		}
		cout << p[n - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
program atcoder
implicit none
integer :: n,m,c,i,j,check
integer, allocatable :: a(:,:),b(:),ans(:)

read(*,*) n,m,c
allocate(a(n,m),b(m),ans(m))
ans = c

read(*,*) (b(i), i=1,m)

do i = 1,n
	read(*,*) (a(i,j), j=1,m)
end do

check = 0
do i = 1,n
	do j = 1,m
    	ans(i) = ans(i) + a(i,j)*b(j)
    end do
    if(ans(i)>0)then
    	check = check + 1
    end if
end do

write(*,'(i0)') check

end program atcoder

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0); 
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}
int main()
{
  //flash;
  set<ll>x;
  for (int i = -100; i <= 200; ++i)
  {
    x.insert(i);
  }
  ll y;
  cin>>y;
  int n;
  cin>>n;
  for (int i = 0; i < n; ++i)
  {
    ll yo;
    cin>>yo;
    x.erase(yo);
  }
  auto v=x.lower_bound(y);
  ll ans=(*v);
  if(v!=x.begin())v--;
  if(abs(y-(*v))<=abs(ans-y)){
    ans=(*v);
  }
  cout<<ans;
  return 0;
}
//code the AC sol !
// BS/queue/map

Measured memory_bytes: 3644
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

// rep(i, 100) { cout << i << endl; } => 0 1 2 ... 99
#define rep(i, n) for(int i = 0, i##_len = (n); i < (int)n; i++)

// std::sort(all(v));
#define all(x) (x).begin(), (x).end()

// long long int
using ll = long long;

// utility to cast return value of size function to int
#define SZ(x) ((int)(x).size())

// VS defines "_DEBUG" macro when debug configuration.
#if _DEBUG
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define dump(x)
#define debug(x)
#endif

// update max
template<class T>bool chmax(T & prov, const T & cur)
{
	if (cur > prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

// update min
template<class T>bool chmin(T & prov, const T & cur)
{
	if (cur < prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

int main()
{
	int N, K;
	cin >> N >> K;
	int ans = 0;
	rep(i, N)
	{
		int h;
		cin >> h;
		if (h >= K)
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
n = int(input())
s = sorted(list(int(input()) for hoge in range(n)))
if sum(s) % 10 != 0:
         print(sum(s))
         exit()
else:
         for i in range(n):
                  if s[i] % 10 != 0:
                           print(sum(s) - s[i])
                           exit()
print(0)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;



int main() {
  string s; cin >> s;
  if(s == "ABC") puts("ARC");
  if(s == "ARC") puts("ABC");

  return 0;
}


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

using namespace std;

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

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

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

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

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

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

template<typename T>
void DEBUG_VEC2(vector<vector<T>> &v, int ilen, int jlen){
    REP(i,ilen){
        REP(j,jlen) if(v[i][j] != -1){ printf("[% 4d]", v[i][j]); }else{ printf("[    ]"); }
        puts("");
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,m,q;
    cin>>n>>m>>q;

    vector<vi> imos(n+2, vi(n+2,0));
    vector<vi> cs(n+2, vi(n+2,0));

    REP(i,m){
        int a,b;
        cin>>a>>b;

        imos[a][b]++;
    }

    FOR(i,1,n+1) FOR(j,1,n+1){
        cs[i][j] += cs[i-1][j]+cs[i][j-1]-cs[i-1][j-1];
        cs[i][j] += imos[i][j];
    }
    //DEBUG_VEC2<int>(cs,n+1,n+1);

    ll ans;

    REP(lp,q){
        int a,b;
        cin>>a>>b;

        ans = (cs[b][b]-cs[b][a-1])-(cs[a-1][b]-cs[a-1][a-1]);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2944
class MyDictionary
  def initialize(size)
    @m = size
    @t = {}
  end

  def insert(key)
    i = 0
    while true
      j = h(convert(key), i)
      if @t[j].nil?
        @t[j] = key
        return
      else
        i += 1
      end
    end
  end

  def search(key)
    i = 0
    while true
      j = h(convert(key), i)
      if @t[j] == key
        return true
      elsif @t[j].nil? || i >= @m
        return false
      else
        i += 1
      end
    end
  end

  def convert(key)
    # key.chars { |ch| ch.ord[0] }
    # key.split('').map{ |s| s.ord[0] }.join('').to_i
    # key.chars.to_a.map{ |s| s.ord[0] }.join('').to_i
    key.tr("ACGT", "1234").to_i
  end

  # def code2num(s)
  #   case s
  #   when "A"
  #     return 1
  #   when "C"
  #     return 2
  #   when "G"
  #     return 3
  #   when "T"
  #     return 4
  #   end
  # end

  def h(key, i)
    (h1(key) + i * h2(key)) % @m
  end

  def h1(key)
    key % @m
  end

  def h2(key)
    1 + (key % (@m -1))
  end

  def exec(order, key)
    case order
    when "insert"
      insert(key)
    when "find"
      if search(key)
        puts "yes"
      else
        puts "no"
      end
    end
  end
end

n = gets.to_i
dict = MyDictionary.new(2079403)
n.times do
  order, key = gets.split
  dict.exec(order, key)
end

# start_time = Time.now
# n = 13
# "insert AAA
# insert AAC
# insert AGA
# insert AGG
# insert TTT
# find AAA
# find CCC
# find CCC
# insert CCC
# find CCC
# insert T
# find TTT
# find T
# ".split("\n").each do | o | 
#   order, key = o.split
#   dict.exec(order, key)
# end

# p "処理概要 #{Time.now - start_time}s"



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

// ----本問について----
// 問題：編集距離
// 問題文URL：https://onlinejudge.u-aizu.ac.jp/problems/DPL_1_E
// 所要時間：1時間
// 学んだこと：
// ------------------

// ----ここから本問のソースコード----

const int N = 1010;

// グローバル変数（入力）
ll dp[N][N];
string s1, s2;

ll solve(ll i, ll j) {                     // メモ化再帰（？）
  if (dp[i][j] != -1) { return dp[i][j]; } // 計算済みならその値を返す

  //置換が必要か否かを示す変数
  ll cost = 1;
  if (i > 0 && j > 0 && s1[i - 1] == s2[j - 1]) { cost = 0; }

  // 場合に応じて計算
  if (i == 0 || j == 0) {
    dp[i][j] = i + j;
  } else {
    dp[i][j] = min(solve(i - 1, j) + 1,
                   min(solve(i, j - 1) + 1, solve(i - 1, j - 1) + cost));
  }

  return dp[i][j];
}

int main() {
  // cout << fixed << setprecision(10);
  cin >> s1;
  cin >> s2;
  ll l1 = s1.size();
  ll l2 = s2.size();
  rep(i, N) {
    rep(j, N) {
      dp[i][j] = -1; // dpを全部未計算(-1)に初期化
    }
  }
  cout << solve(l1, l2) << endl;

  return 0;
}



Measured memory_bytes: 11216
n=gets.to_i
f=->b,i,m{
  if i==n
    puts b
    return
  end
  0.upto(m){|j| f[b+(97+j).chr,i+1,m] }
  f[b+(97+m+1).chr,i+1,m+1]
}
f["a",1,0]


Measured memory_bytes: 3068
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())

def main():
    N = ii()
    A = lmis()
    x = sum(A[::2]) - sum(A[1::2])
    for i in range(N):
        print(x)
        x = 2 * A[i] - x
        

main()


Measured memory_bytes: 14032
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Collections;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ir = new Resolver(new ConsoleReader());
            Console.WriteLine(ir.Resolve());
        }
    }

    public class Resolver
    {
        IInputReader InputReader { get; }
        public List<string> Messages { get; set; } = new List<string>();

        int n;
        List<long[]> ls = new List<long[]>();

        public void ParseLines() {
            n = int.Parse(InputReader.ReadLine());
            foreach (var i in Enumerable.Range(0, n))
            {
                ls.Add(InputReader.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray());
            }

        }

        public class Table
        {
            public long PointA { get; set; } = 0;
            Person A { get; }
            Person B { get; }
            int[] _dishes;

            public Table(Person a, Person b, int ndish)
            {
                this.A = a;
                this.B = b;
                this._dishes = Enumerable.Range(0, ndish).ToArray();
            }

            public long CalculatePoint()
            {
                PointA = _dishes
                .Select(x => A.Taste[x] + B.Taste[x])
                .OrderBy(x => -x)
                .Where((x, i)=> i % 2 == 0 ).Sum();

                PointA -= B.Taste.Values.Sum(x => x);
                return PointA;
            }


        }


    public class Person{
            public Dictionary<int, long> Taste { get; }
            public long HappyScore { get; set; } = 0;

            public Person(Dictionary<int, long> taste)
            {
                Taste = taste;
            }

        }


        public string Resolve()
        {
            var range = Enumerable.Range(0, n);

            var a = new Person(range.ToDictionary(i => i, i => ls[i][0]));
            var b = new Person(range.ToDictionary(i => i, i => ls[i][1]));

            var table = new Table(a, b, n);

            return table.CalculatePoint().ToString();
        }


        public Resolver(IInputReader inputReader)
        {
            InputReader = inputReader;
            ParseLines();
        }

    }

    public interface IInputReader
    {
        string ReadLine();
    }

    class ConsoleReader : IInputReader
    {
        string IInputReader.ReadLine()
        {
            return Console.ReadLine();
        }
    }
}


Measured memory_bytes: 40776
import sys
dataset = sys.stdin.readlines()

seq = 0

while dataset[seq] != '-\n':
 s = dataset[seq]
 l = len(s) - 1
 s = s[:l]
 seq += 1
 n = dataset[seq]
 l = len(n) - 1
 n = int(n[:l])
 seq += 1
 for i in range(seq, seq + n):
  h = dataset[i]
  l = len(h) - 1
  h = int(h[:l])
  s = s[h:] + s[0:h]
 print(s)
 seq += n

Measured memory_bytes: 7612
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define INF 100000005
#define MAX 131072
#define ll long long
#define dmp make_pair
#define dpb push_back
#define P pair<int,int>
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);
const int inf = 2147483647;

int n, dat[2*MAX];
void init(int m){
	n = 1;
	while(n < m)n *= 2;
	for(int i = 0;i < 2*n;i++)dat[i] = 0;
}

/*void change(int x, int y){
	x += n-1;
	dat[x] += y;
	while(x > 0){
		x = (x-1)/2;
		dat[x] += y;
	}
}

int query(int a, int b, int k, int l, int r){
	if(b <= l || r <= a)return 0;
	if(a <= l && r <= b)return dat[k];
	int vl = query(a, b, 2*k+1, l, (l+r)/2);
	int vr = query(a, b, 2*k+2, (l+r)/2, r);
	return vl+vr;
}*/

int add(int a, int b, int x,  int k, int l, int r){
	if(b <= l || r <= a)return 0;
	if(a <= l && r <= b){
		dat[k] += x;
		return 0;
	}
	add(a, b, x, k*2+1, l, (l+r)/2);
	add(a, b, x, k*2+2, (l+r)/2, r);
	return 0;
}

int get(int k){
	int ans = 0;
	k += n-1;
	ans += dat[k];
	while(k > 0){
		k = (k-1)/2;
		ans += dat[k];
	}
	return ans;
}

int main(){
	int m, q, c, s, t, x, ans;
	scanf("%d%d", &m, &q);
	init(m);
	while(q--){
		scanf("%d", &c);
		if(!c){
			scanf("%d%d%d", &s, &t, &x);
			add(s-1, t, x, 0, 0, n);
		}else{
			scanf("%d", &x);
			printf("%d\n", get(x-1));
			//printf("%d\n", get(x-1, y, 0, 0, n));
		}
	}
	//for(int i = 0;i < 2*n-1;i++)printf("%d ", dat[i]);
	return 0;
}

Measured memory_bytes: 4228
#include <bits/stdc++.h>
#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,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    int a,b;
    cin>>a>>b;
    if(a+b==15)  cout<<"+"<<endl;
    else if(a*b==15) cout<<"*"<<endl;
    else cout<<"x"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    string s, t; cin >> s >> t;

    int ssize = s.size();
    int tsize = t.size();

    bool possible = false;
    string ans;
    for(int i=ssize - tsize; i>=0; i--){
        for(int j=0; j<tsize; j++){
            if(s[i+j] != '?' && s[i+j] != t[j]){
                break;
            }
            if(j == tsize - 1){
                possible = true;
                for(int k=0; k<tsize; k++){
                    s[i+k] = t[k];
                }
                for(int k=0; k<ssize; k++){
                    if(s[k] == '?'){
                        s[k] = 'a';
                    }
                }
                break;
            }
        }
        if(possible) break;
    }

    cout << (possible ? s : "UNRESTORABLE");

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plll pair<pll,ll>
#define ff first
#define ss second
#define sfi(a) scanf("%d",&a)
#define sfi2(a,b) scanf("%d %d",&a,&b)
#define sfi3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfll(a) scanf("%lld",&a)
#define all(a) a.begin(),a.end()
#define inf 1e7
#define m_p make_pair
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define mem(x,val) memset(x,val,sizeof(x))
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)
#define sqr(x) ((x)*(x))

using ll = long long int;
const ll sz = 2005;
const ll mod = 1000000007;

int main()
{
    //write;
    //read;
    string s,t; cin >> s >> t;
    t.erase(t.size()-1,1);
    if(s==t) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>(b);i--)
using namespace std;
 
int main(void) {
	string s,t;
	char a;
	cin >> s;
	FOR(i, 0, s.size()) {
		if (i % 2 == 0) {
			a = s[i];
			t += a;
		}
	}
 
	cout << t << endl;
 
 
	return 0;
}

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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a <= c && c <= b) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]
 
use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;
 
use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;

    input!{ a: isize, b: isize, c: isize, d: isize, }

    let flag = if (a - c).abs() <= d {
        true
    } else if (a - b).abs() <= d && (b - c).abs() <= d {
        true
    } else {
        false
    };

    if flag {
        println!("Yes");
    } else {
        println!("No");
    }
    
}

fn main() {
    solve();
}


Measured memory_bytes: 2172
unittest
{
	assert( [ "90" ].solve == 4 );
	assert( [ "1" ].solve == 360 );
}



import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto x = input.front.to!( long );
	
	return lcm( x, 360 ) / x;
}

// 最小公倍数
auto lcm( long x, long y )
{
	import std.numeric;
	return x * y / x.gcd( y );
}


Measured memory_bytes: 2800