akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define REP(i, a, n) for(int i = 0;)
#define ll long long

#define MAX_N 1000
#define MAX_M 1000

int nCr(int n, int r){
    int ans = 1;
    for(int i = n; i > n - r; i--){
        ans = ans*i;
    }
    for(int i = 1; i < r + 1; i++){
        ans = ans / i;
    }
    return ans;
}

int main(){
    int n, m; cin >> n >> m;
    int ans = 0;
    if(m >= 2){
        ans = nCr(n, 2) + nCr(m, 2);
    }else{
        ans = nCr(n, 2);
    }
    cout << ans << endl;

}




Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int q;
    double[] xp0, yp0, xp1, yp1, xp2, yp2, xp3, yp3;
    int i;
    double s1x, s1y, s2x, s2y;

    q = sc.nextInt();
    xp0 = new double[q];
    yp0 = new double[q];
    xp1 = new double[q];
    yp1 = new double[q];
    xp2 = new double[q];
    yp2 = new double[q];
    xp3 = new double[q];
    yp3 = new double[q];

    for(i = 0;i < q;i++){
      xp0[i] = sc.nextDouble();
      yp0[i] = sc.nextDouble();
      xp1[i] = sc.nextDouble();
      yp1[i] = sc.nextDouble();
      xp2[i] = sc.nextDouble();
      yp2[i] = sc.nextDouble();
      xp3[i] = sc.nextDouble();
      yp3[i] = sc.nextDouble();
    }

    for(i = 0;i < q;i++){
      s1x = xp1[i] - xp0[i];
      s1y = yp1[i] - yp0[i];
      s2x = xp3[i] - xp2[i];
      s2y = yp3[i] - yp2[i];

      if((s1y * s2x) == (s2y * s1x)){
        System.out.println("2");
      }else if((s1x * s2x + s1y * s2y) == 0.0){
        System.out.println("1");
      }else{
        System.out.println("0");
      }
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 48388
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long int n,m;
    cin>>n>>m;
    long long int ans1=n%m;
    long long int ans2=abs(ans1-m);
    cout<<min(ans1,ans2)<<endl;

    return 0;
}


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

int main(){
    int N;
    cin >> N;
    unsigned long long K;
    // int K;
    cin >> K;
    vector<int> A(N+1);
    A[0] = 0;
    rep(i, N) cin >> A[i+1];
    vector<int> when(N+1, -1);
    int pos = 1;
    int cnt = 0;
    // when[pos] = cnt;

    while(when[pos] == -1){
        when[pos] = cnt;
        cnt++;
        pos = A[pos];
        // cout << pos << endl;
    }

    // cout << cnt << " " << when[pos] << endl;

    if (when[pos] < K){
        int T = cnt - when[pos];
        // cout << T<< endl;
        int res = (K - when[pos]) % T;

        rep(i, res){
            pos = A[pos];
        }
    }else{
        pos = 1;
        rep(i, K){
            pos = A[pos];
        }
    }
    
    cout << pos << endl;
    
    return 0;
}

Measured memory_bytes: 4844
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define INF 2000000000
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int n, m, x, y, a, b,c,d;
	cin >> n >> m >> x >> y;
	a = x;
	b = y;
	rep(i, n) {
		cin >> c;
		a = max(a, c);
	}
	rep(i, m) {
		cin >> d;
		b = min(b, d);
	}
	if (a >= b) {
		cout << "War" << endl;
	}
	else {
		cout << "No War" << endl;
	}

}

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

int main(){
    int x;
    cin >> x;
    int b,p;
    int h=1;
    for(b=1;b<x;b++){
        for(p=2;(pow(b,p)<=x);p++){
            if(pow(b,p)>h){
                h=pow(b,p);
            }
            if(b==1)break;
        }
    }
    cout << h << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
	int i,n,t;
	t=0;
	char a[100];
	scanf("%s",a);
  
	for(i=0;i<strlen(a);i++)
	{
		if(i%2==0)
		{
			if(a[i]=='R'|| a[i]=='U' || a[i]=='D')
				t++;
		}
		else
		{
			if(a[i]=='L'||a[i]=='U'||a[i]=='D')
				t++;
		}
	}
	if(t==strlen(a))
		printf("Yes");
	else
		printf("No");
	
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int R[][][] = new int[4][3][10];
        for (int i = 0; i < a; i++) {
            int b = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            int v = sc.nextInt();
 
            R[b-1][f-1][r-1] += v;
 
        }
 
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 10; k++) {
                    System.out.print(" "+R[i][j][k]);
                }
                System.out.println();
            }
            if (i == 3)
                break;
            for (int l = 0; l < 20; l++) {
                System.out.print("#");
            }
            System.out.println();
        }
        sc.close();
 
    }
 
}


Measured memory_bytes: 29984
#include <bits/stdc++.h>
using namespace std;
#define surfaces 6

class Dice{
private:
    int surface[6];
    int tmp[6];
public:
    Dice();
    void setVal(vector<int>);
    void initTmp();
    void rotate(int, int, int, int);
    void rollN();
    void rollE();
    void rollS();
    void rollW();
    int printTop();
};


Dice::Dice(){
}

void Dice::setVal(vector<int> data){
    for (int i = 0; i < surfaces; i++){
        surface[i] = data.at(i);
    }
}

void Dice::rollN(){
    rotate(0, 4, 5, 1);
}

void Dice::rollE(){
    rotate(0, 2, 5, 3);
}

void Dice::rollS(){
    rotate(0, 1, 5, 4);
}

void Dice::rollW(){
    rotate(0, 3, 5, 2);
}

int Dice::printTop(){
    return surface[0];
}

void Dice::initTmp(){
    for (int i = 0; i < surfaces; i++){
        tmp[i] = Dice::surface[i];
    }
}

void Dice::rotate(int a, int b, int c, int d){
    Dice::initTmp();
    surface[b] = tmp[a];
    surface[c] = tmp[b];
    surface[d] = tmp[c];
    surface[a] = tmp[d];
}


int main(){
    int num;
    vector<int> data;
    string str;
    
    for(int i = 0; i < 6; i++){
        cin >> num;
        data.push_back(num);
    }
    cin >> str;
    Dice dice;
    dice.setVal(data);
    
    for (int i = 0; i < str.size(); i++){
        if(str[i] == 'N') dice.rollN();
        if(str[i] == 'E') dice.rollE();
        if(str[i] == 'S') dice.rollS();
        if(str[i] == 'W') dice.rollW();
    }
    cout << dice.printTop() << endl;
}



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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define MP make_pair
#define PB push_back
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int INF = 1e9 + 7;
const int maxn = 15;

int n, used;
int a[maxn];

inline void dfs(int dep){
	if(dep == n){
		FOR(i, 0, n)
			putchar(a[i] + 'a');
		puts("");
		return;
	}
	FOR(i, 0, used){
		a[dep] = i;
		dfs(dep + 1);
	}
	if(used < 26){
		a[dep] = used;
		++used;
		dfs(dep + 1);
		--used;
	}
	return;
}

int main(){
	scanf("%d", &n);
	dfs(0);
	return 0;
}


Measured memory_bytes: 1536
#pragma GCC optimize ("O3")
#define _CRT_DISABLE_PERFCRIT_LOCKS
#include <bits/stdc++.h>

using namespace std;
#define BOOST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define fileIn freopen("1.txt", "r", stdin)
#define fileOut freopen("output.txt", "w", stdout)
#define dbg(n) cout << n <<"\n"
#define dbg2(n) cout << n <<" "
#define all(a) a.begin(), a.end()
#define cinArr(arr) for(auto &v : arr) cin>>v
#define coutArr(arr) for(auto &v : arr) cout<<v<<" "
#define FOR(i, a, b) for(int i = a; i < b; i++)
typedef int64_t ll;
typedef uint64_t ull;
typedef vector<int> vi;
typedef vector<vi > vii;


int main()
{
    BOOST;
    string s, s2;
    cin>>s;
    s2 = s;
    int ans1 = 0, ans2 = 0;
    FOR(i, 1, s.size()){
        if(s[i] == s[i - 1]) {s[i] = ((s[i] == '0') ? '1' : '0'); ans1++;}
    }

    FOR(i, 0, s.size() - 1){
        if(s2[i] == s2[i + 1]) {s2[i + 1] = ((s2[i] == '0') ? '1' : '0'); ans2++;}
    }
    cout<<min(ans1, ans2);


    return 0;
}





















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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/02/27  Problem: ABC 115 B / Link: http://abc115.contest.atcoder.jp/tasks/abc115_b  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	LL N; 
	cin >> N;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}

	ans = accumulate(ALL(a), 0) - (*max_element(ALL(a))) / 2;
	
	
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
import numpy as np
def evaluate(A, ti):
    return np.sum(A[0, :ti+1]) + np.sum(A[1, ti:])

def solve():
    N = input()
    A = np.array([map(int, raw_input().split()) for i in range(2)])
    return max([evaluate(A, i) for i in range(N)])
print solve()

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

using namespace std;
#define ll long long
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main()
{
  IOS;
  int ans=0;
  string s;
  cin >> s;
  //char c='R';
  if (s[0]=='R' && s[1]=='R')
    ans=2;
  else if (s[0]=='R' && s[1]!='R')
    ans=1;
  if (s[2]=='R' && s[1]=='R')
    ans+=1;
  if (s[2]=='R'&& s[1]=='R')
    ans=2;
  if (s[0]=='R'&& s[1]=='R' && s[2]=='R')
    ans=3;
  if (s[0]=='R'&& s[1]!='R'&& s[2]!='R'|| s[0]!='R'&& s[1]=='R'&& s[2]!='R'||            s[0]!='R'&& s[1]!='R'&& s[2]=='R')
    ans=1;
  cout << ans << endl;
  return 0;
}


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

int tab[110];
bool DP[100010];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,k;
	cin >> n >> k;
	for (int i = 1 ; i <= n ; i++)
	{
		cin >> tab[i];
		DP[tab[i]] = 1;
	}
	for (int i = tab[1] + 1 ; i <= k ; i++)
	{
		// DP[i] = 1;
		for (int j = 1 ; j <= n ; j++)
		{
			if (tab[j] > i) break;
			DP[i] |= !DP[i - tab[j]];
		}
	}
	// for (int i = 1 ; i <= k ; i++)
	// 	cout << DP[i] << " ";
	// cout << endl;
	cout << (DP[k] ? "First" : "Second") << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
const ll mod = 7*17*(1<<23) + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main()
{
//	ios::sync_with_stdio(0);
//	cin.tie(0);
//	cout.tie(0);
	int n, a[200100], b[200100];
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cin >> b[i];
	priority_queue<pair<int, int>> q;
	for(int i = 1; i <= n; i++) {
		if(b[i]<a[i])return cout << -1, 0;
		if(b[i]>a[i]) q.push({b[i], i});
	}
	b[0]=b[n], b[n+1]=b[1];
	ll ans = 0;
	while(!q.empty()) {
		int i, v;
		tie(v,i) = q.top(), q.pop();
//		cout << i << " " << v << "\n";
		int t = b[i]%(b[i-1]+b[i+1]);
//		cout << i << " " << t << "\n";
		ans += b[i]/(b[i-1]+b[i+1]);
		if(t < a[i]) {
			if((a[i]-t)%(b[i-1]+b[i+1])) return cout << -1, 0;
			ans -= (a[i]-t)/(b[i-1]+b[i+1]);
			t = a[i];
		} else if(b[i]/(b[i-1]+b[i+1]) == 0)
			return cout << -1, 0;
		b[i] =t;
		if(i==1)b[n+1]=b[1];
		if(i==n)b[0]=b[n];
//		cout << i << " " << t << "\n";
		if(t>a[i])
			q.push({b[i], i});
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3956
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
using namespace std;
const int MAX = 1e5 + 10;
const int MOD = 1e9 + 7;
int N, M, K, Q;
int cnt[60][30];

int main()
{
	int i, j, k;
	string str;

	scanf("%d", &N);
	for (i = 0; i < N; ++i) {
		cin >> str;
		for (j = 0; j < str.size(); ++j) cnt[i][str[j] - 'a']++;
	}
	str.clear();
	for (i = 0; i < 26; ++i) {
		int mini = INF;
		for (j = 0; j < N; ++j) {
			mini = min(mini, cnt[j][i]);
		}
		for (j = 0; j < mini; ++j) str.push_back('a' + i);
	}
	sort(str.begin(), str.end());
	if (str.size() == 0) cout << "\n";
	else cout << str;
}



Measured memory_bytes: 256
fun main(args:Array<String>):Unit {
    while (true) {
        val (n, m) = readLine()!!.trim().split(' ').map(String::toInt)
        if (n == 0 && m == 0) return
        val stone = Array(n) { UnionFindTree() }
        val edgeCount = Array(n){0}
        var canMake = true
        repeat(m) {
            val (u, v) = readLine()!!.trim().split(' ').map(String::toInt)
            canMake = canMake && !stone[u - 1].isSameUnion(stone[v - 1])
            stone[u - 1].merge(stone[v - 1])
            edgeCount[u - 1]++
            edgeCount[v - 1]++
        }
        println(if (canMake && edgeCount.none{it > 2}) "yes" else "no")
    }
}
class UnionFindTree{
    private var mParent:UnionFindTree? = null
    private fun parent():UnionFindTree {
        return when(mParent){
            null -> this
            else -> {
                mParent = mParent?.parent()
                mParent !!
            }
        }
    }
    fun isSameUnion(other:UnionFindTree):Boolean {
        return parent() == other.parent()
    }
    fun merge(other:UnionFindTree):Unit {
        if (!isSameUnion(other)){
            parent().mParent = other.parent()
        }
    }
}


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

using namespace std;

int main() {

	int x1, x2, x3, x4, x5;
	cin >> x1 >> x2 >> x3 >> x4 >> x5;
	if (x1 == 0) { cout << 1 << endl; return 0; }
	if (x2 == 0) { cout << 2 << endl; return 0; }
	if (x3 == 0) { cout << 3 << endl; return 0; }
	if (x4 == 0) { cout << 4 << endl; return 0; }
	if (x5 == 0) { cout << 5 << endl; return 0; }

}

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

const int MOD = 1e9 + 7;
int memo[200][200];
map<string, int> mp;
int mpidx = 0;

bool ok(string last4) {
  for (int i = 0; i < 4; i++) {
    string t = last4;
    if (i >= 1) {
      swap(t.at(i-1), t.at(i));
    }
    if (t.find("AGC") != string::npos) {
      return false;
    }
  }
  return true;
}

int dfs(int cur, string last3, int N) {
  if (mp.count(last3) == 0) {
    mp[last3] = mpidx;
    mpidx++;
  }
  if (memo[cur][mp[last3]] != 0) {
    return memo[cur][mp[last3]];
  }
  if (cur == N) {
    return 1;
  }
  int cnt = 0;
  for (int i = 0; i < 4; i++) {
    string acgt = "ACGT";
    char c = acgt.at(i);
    if (ok(last3 + c)) {
      cnt += dfs(cur + 1, last3.substr(1,2) + c, N);
      cnt %= MOD;
    }
  }
  memo[cur][mp[last3]] = cnt;
  return cnt;
}

int main() {
  int N;
  cin >> N;
  cout << dfs(0, "___", N) << endl;;
}

Measured memory_bytes: 384
s = input()
up_ctr = 0
if s[0] != 'A':
    print('WA')
else:
    if s[2:len(s)-1].count('C') != 1:
        print('WA')
    else:
        for i in range(1, len(s)):
            if s[i].isupper():
                up_ctr += 1
        if up_ctr != 1:
            print('WA')
        else:
            print('AC')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }
#define ll long long

const long long mod = 1e+9 + 7; 

vector<long long>dp_table;

long long solve(long long remain){
    if(remain == 0)return 1;
    else if(remain < 0) return 0;
    if(dp_table[remain] > 0)return dp_table[remain];
    long long ans = 0;
    for(long long i = 3; i <= remain; i++){
        (ans += solve(remain - i)) %= mod;
    }
    
    return dp_table[remain] = ans;
}



void test_case(){
    int S;
    cin >> S;
    dp_table.resize(S + 1, -1);
    
    long long ans  = 0;
    for(int i = 3; i <= S; i++){
        (ans += solve(S - i)) %= mod;
    }
    
    cout << ans%mod << endl;
} 


int main(){
    
    int t = 1;
    //cin >> t;
    for(int i = 0; i < t; i++)
        test_case();
    
    return 0;
} 


 


Measured memory_bytes: 3652
#include<iostream>

long long f(long long n, long long x){
    if(n == -1){
        return 0;
    }else{
        return n / x + 1;
    }
}

int main(){
    
    long long a, b, x;

    std::cin >> a >> b >> x;

    std::cout << f(b, x) - f(a - 1, x)  << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int h, w;
	int d;
	while (cin >> h >> w) {
		if (h == 0 && w == 0) {
			break;
		}
		d = h*h + w*w;
		bool hantei = false;
		int i, j, k;
		k = 0;
		while (!hantei){
			if (k != 0) {
				h = 0;
			}
			for (i = h+1; i <= 150; i++) {
				for (j = i+1; j <= 150; j++) {
					if (i*i+j*j == d+k) {
						hantei = true;
						break;
						} else if (i*i+j*j > d+k) {
						break;
					}
				}
				if (hantei) {
					break;
				}
			}
			k++;
		}
		cout << i << ' ' << j << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
//Dice1
#include<iostream>
#include<string>
using namespace std;

class Dice{
	private:
		int men[6];
		int ue,sita,migi,hidari,mae,usiro,ho;
	public:
		void setmen(int n, int i);
		void set();
		void setue(string c);
		void stout();
};

void Dice::setmen(int n, int i){
	men[i] = n;
}

void Dice::set(){
	ue = men[0];
	sita = men[5];
	migi = men[2];
	hidari = men[3];
	mae = men[4];
	usiro = men[1];
}

void Dice::setue(string c){
	for(int i = 0; i < c.size(); i++){
		switch(c[i]){
			case 'W':
				ho = ue;
				ue = migi;
				migi = sita;
				sita = hidari;
				hidari = ho;
				break;
			case 'S':
				ho = ue;
				ue = mae;
				mae = sita;
				sita = usiro;
				usiro = ho;
				break;
			case 'N':
				ho = ue;
				ue = usiro;
				usiro = sita;
				sita = mae;
				mae = ho;
				break;
			case 'E':
				ho = ue;
				ue = hidari;
				hidari = sita;
				sita = migi;
				migi = ho;
				break;
		}
	}
}

void Dice::stout(){
	cout << ue << endl;
}



int main()
{
	Dice A;
	string c;
	int n;
	for(int i = 0; i < 6; i++){
		cin >> n;
		A.setmen(n, i);
	}
	A.set();
	
	cin >> c;
	A.setue(c);
	A.stout();
	return 0;
}


Measured memory_bytes: 3220
#include <iostream>
using namespace std;
int main()
{
	int a , b , c , d ,w=0;
	cin>>a>>b>>c>>d;
	for(int i=0;i<=100;i++)
	{
		if( a<i && b>=i && c<i && d>=i)
		{
			w++;
		}
	}
	cout<<w;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define emb emplace_back

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

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

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

  int res = 0;
  rep(i,n - 2) {
    if(s.substr(i,3) == "ABC") res++;
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
a,b = gets.split.map(&:to_i)
A = Array.new
A[0] = 1
A[1] = 2
A[2] = 3
A[3] = 4
A[4] = 5
A[5] = 6
A[6] = 7
A[7] = 8
A[8] = 9
A[9] = 10
A[10] = 11
A[11] = 12
for i  in 0..11
 if A[i] == a && A[i] > b
  puts(A[i-1])
  elsif A[i] == a && A[i] <= b
  puts(A[i])
 end
end

Measured memory_bytes: 1788
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,w;
int dp[103][100010];

signed main(){
    I(n); I(w);
    REP(i,103) REP(j,100010) dp[i][j] = 1LL << 60;
    dp[0][0] = 0;
    REPS(i,n){
        int wi,vi;
        I(wi); I(vi);
        REP(vt,100001){
            dp[i][vt] = vt < vi ? dp[i-1][vt] :
                min(dp[i-1][vt], dp[i-1][vt-vi] + wi);
        }
    }
    int ret = 0;
    REP(i,100001) if(dp[n][i] <= w) ret = i;
    cout << ret << endl;
}

Measured memory_bytes: 80768
import java.util.Scanner;
 
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    // 5つの調理時間の入力
    int[] arr = new int[5];
    for (int i=0; i<arr.length; i++) {
    	arr[i] = sc.nextInt();
    }
    
    // 一番最後に注文する料理を計算
    // 割り切れず、あまりが最小のもの
    int last_dish = 6;
    int amari_smallest = 11;
    int amari = 0;
    
    for (int i=0; i<arr.length; i++) {
    	if (arr[i] % 10 != 0) {
        	amari = arr[i] % 10;
            if (amari < amari_smallest) {
            	amari_smallest = amari;
                last_dish = i;
            }
        }
    }
    
    // 最後の料理以外は10で切り上げた後で10倍する
    int total = 0;
    for (int i=0; i<arr.length; i++) {
    	if (i==last_dish) {
        	total += arr[i];
        } else {
        	total += ((arr[i] + 10 - 1) / 10 ) * 10;
        }
    }
    
    // 出力
    System.out.println(total);
  }
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int test;
		test = scan.nextInt();
		String push;

		int onepush;
		String word;
		int samepushnumber;
		char preword = ' ';

		for (int i = 0; i < test; i++) {
			String result = new String();
			push = scan.next();

			samepushnumber = 0;
			word = "";

			for (int j = 0; j < push.length(); j++) {
				onepush = push.charAt(j) - '0';
				switch (onepush) {
				case 0:
					if (samepushnumber > 0)
						word += preword;
					samepushnumber = 0;

					break;
				case 1:
					samepushnumber++;
					if (samepushnumber % 5 == 1) {
						preword = '.';
					} else if (samepushnumber % 5 == 2) {
						preword = ',';
					} else if (samepushnumber % 5 == 3) {
						preword = '!';
					} else if (samepushnumber % 5 == 4) {
						preword = '?';
					} else if (samepushnumber % 5 == 0) {
						preword = ' ';
					}
					break;
				case 2:
					samepushnumber++;
					if (samepushnumber % 3 == 1) {
						preword = 'a';
					} else if (samepushnumber % 3 == 2) {
						preword = 'b';
					} else if (samepushnumber % 3 == 0) {
						preword = 'c';
					}
					break;
				case 3:
					samepushnumber++;
					if (samepushnumber % 3 == 1) {
						preword = 'd';
					} else if (samepushnumber % 3 == 2) {
						preword = 'e';
					} else if (samepushnumber % 3 == 0) {
						preword = 'f';
					}
					break;
				case 4:
					samepushnumber++;
					if (samepushnumber % 3 == 1) {
						preword = 'g';
					} else if (samepushnumber % 3 == 2) {
						preword = 'h';
					} else if (samepushnumber % 3 == 0) {
						preword = 'i';
					}
					break;
				case 5:
					samepushnumber++;
					if (samepushnumber % 3 == 1) {
						preword = 'j';
					} else if (samepushnumber % 3 == 2) {
						preword = 'k';
					} else if (samepushnumber % 3 == 0) {
						preword = 'l';
					}
					break;
				case 6:
					samepushnumber++;
					if (samepushnumber % 3 == 1) {
						preword = 'm';
					} else if (samepushnumber % 3 == 2) {
						preword = 'n';
					} else if (samepushnumber % 3 == 0) {
						preword = 'o';
					}
					break;
				case 7:
					samepushnumber++;
					if (samepushnumber % 4 == 1) {
						preword = 'p';
					} else if (samepushnumber % 4 == 2) {
						preword = 'q';
					} else if (samepushnumber % 4 == 3) {
						preword = 'r';
					} else if (samepushnumber % 4 == 0) {
						preword = 's';
					}

					break;
				case 8:
					samepushnumber++;
					if (samepushnumber % 3 == 1) {
						preword = 't';
					} else if (samepushnumber % 3 == 2) {
						preword = 'u';
					} else if (samepushnumber % 3 == 0) {
						preword = 'v';
					}

					break;
				case 9:
					samepushnumber++;
					if (samepushnumber % 4 == 1) {
						preword = 'w';
					} else if (samepushnumber % 4 == 2) {
						preword = 'x';
					} else if (samepushnumber % 4 == 3) {
						preword = 'y';
					} else if (samepushnumber % 4 == 0) {
						preword = 'z';
					}

					break;
				}
			}

			result = word;
			System.out.println(result);

		}

		scan.close();
	}
}

Measured memory_bytes: 24892
#include<bits/stdc++.h>
using namespace std;
int main(void){

  int a=0,b=0;
  cin >> a >> b;
  int num = 0;
  num = a*b;
  if(num%2 == 0){
  	cout << "Even" << endl;
  }else{
  	cout << "Odd" << endl;
  }
}

Measured memory_bytes: 3584
#include <stdio.h>

auto main(void) -> int {
    int rain = 0;
    char* in = new char[3];
    for (int i = 0; i <= 2; i++) {
        char temp;
        scanf("%c", &temp);
        in[i] = temp;
    }

    int* consec = new int[3];
    consec[0] = (in[0] == 'R') ? 1 : 0;
    for (int i = 1; i <= 2; i++) {
        if (in[i] == 'R')
            consec[i] = consec[i - 1] + 1;
        else
            consec[i] = 0;
    }

    delete[] in;

    int max = consec[0];
    for (int i = 1; i <= 2; i++) {
        max = (consec[i] > max) ? consec[i] : max;
    }
    delete[] consec;

    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 3136
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,p = LI()
    s = list(map(int, input()))
    if p in [2,5]:
        ans = 0
        for i in range(n):
            si = s[i]
            if si%p == 0:
                ans += i+1
        print(ans)
        return
    a = [0]
    k = pow(10,p-2,p)
    K = k
    for i in range(n):
        si = s[i]
        a.append((a[-1]+si*K)%p)
        K *= k
        K %= p
    ans = 0
    d = defaultdict(lambda : 0)
    for i in a:
        ans += d[i]
        d[i] += 1
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 59084
<?php
  list($a, $b) = explode(" ", trim(fgets(STDIN)));
  $ary = array();
  for($i=1; $i <= $a; $i++) {
    $line = explode(" ", trim(fgets(STDIN)));
    array_push($ary, $line);
  }
  foreach ($ary as $val) {
    print(join(" ", $val) . " " . array_sum($val) . "\n");
  }
  $aaa = array();
  for($x=0; $x <= ($b-1); $x++) {
    $s = 0;
    for($n = 0; $n <= ($a-1); $n++) {
      $s += $ary[$n][$x];
    }
    print($s . " ");
    array_push($aaa, $s);
  }
  print(array_sum($aaa));
?>

Measured memory_bytes: 8392
#include<iostream>
#include<cmath>
#include<float.h>
using namespace std;
double h[1005];
int main()
{
	int N;
	double T,A;
	cin>>N;
	cin>>T>>A;
	int flag=0;
	for(int i=1;i<=N;i++)
	{
		cin>>h[i];
	}
	double min=DBL_MAX;
	for(int i=1;i<=N;i++)
	{
		if(fabs(T-0.006*h[i]-A)<min)
		{
			min=fabs(T-0.006*h[i]-A);
			flag=i;
		}
	}
	cout<<flag;
	return 0;
}

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

int N, K;
vector<lint> a;

bitset<5000> bits;

bool nibu(int n)
{
    bits.reset();
    bits.set(0);
    for (int i = 0; i < N; i++)
    {
        if (i != n)
        {
            bits |= (bits << a[i]);
        }
    }
    for (int i = 0; i < min(a[n], (lint)K); i++)
    {
        if (bits[K-i-1]) return false;
    }
    return true; // 必要
}

int main()
{
    cin >> N >> K;
    a.resize(N);
    for (auto &v : a) cin >> v;
    sort(a.begin(), a.end());

    int l = 0, r = N;
    while(r - l > 0)
    {
        if (nibu((l+r)/2))
        {
            l = (l + r) / 2 + 1;
        }
        else
        {
            r = (l + r) / 2;
        }
    }
    cout << l << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int ans = (int)(Math.ceil((n-1.0)/(k-1.0)));
        System.out.println(ans);
    }    
}


Measured memory_bytes: 21716
from itertools import accumulate

n,t = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
dp1 = [[-(10 ** 18)] * t for i in range(n)]
dp2 = [[-(10 ** 18)] * t for i in range(n)]
dp1[0][0] = 0
dp2[0][0] = 0
for i,(a,b) in enumerate(ab[:-1]):
  for j in range(t):
    dp1[i+1][j] = max(dp1[i+1][j],dp1[i][j])
    if j < t-a:
      dp1[i+1][j+a] = max(dp1[i+1][j+a],dp1[i][j]+b)
for i,(a,b) in enumerate(ab[n-1:0:-1]):
  for j in range(t):
    dp2[i+1][j] = max(dp2[i+1][j],dp2[i][j])
    if j < t-a:
      dp2[i+1][j+a] = max(dp2[i+1][j+a],dp2[i][j]+b)
ans = 0
for key,(i,j,(a,b)) in enumerate(zip(dp1,dp2[::-1],ab)):
  nowi,nowj = 0,0
  I,J = [],[]
  for x,y in zip(i,j):
    nowi = max(nowi,x)
    nowj = max(nowj,y)
    I.append(nowi)
    J.append(nowj)
  J.reverse()
  tmp = 0
  for x,y in zip(I,J):
    tmp = max(tmp,x+y)
  tmp += b
  ans = max(ans,tmp)
print(ans)

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


int main() {
	int N;
	cin >> N;

	string S;
	cin >> S;

	int Q;
	cin >> Q;
	vector<int> k(Q);
	for(int i=0;i<Q;i++) {
		cin >> k[i];
	}

	vector<ll> ans(Q);
	vector<ll> cumsum(N);
	vector<ll> cumsum_a_cnt(N);
	ll b_cnt = 0;
	for(int i=0;i<N;i++) {
		if(S[i] == 'D') {
			cumsum[i] = b_cnt;
			cumsum_a_cnt[i]++;
		}else if(S[i] == 'M') {
			b_cnt++;
		}
	}
	b_cnt = 0;
	for(int i=0;i<N;i++) {
		if(i >= 1) {
			cumsum[i] += cumsum[i - 1];
			cumsum_a_cnt[i] += cumsum_a_cnt[i - 1];
		}
		if (S[i] == 'M') {
			b_cnt++;
		}else if (S[i] == 'C') {
			for (int j = 0; j<Q; j++) {
				ll a_cnt = cumsum_a_cnt[i];
				if(i - k[j] >= 0) a_cnt -= cumsum_a_cnt[i - k[j]];
				ans[j] += a_cnt * b_cnt - cumsum[i];
				if(i - k[j] >= 0) {
					ans[j] += cumsum[i - k[j]];
				}
			}
		}
	}

	for(ll a : ans) {
		cout << a << endl;
	}

	return 0;
}


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

int main(void) {
  int A, B, sum;
  cin >> A >> B;

  sum = A + B;
  if(sum%2==0) cout << sum/2 << endl;
  else cout << "IMPOSSIBLE" << endl;
  
  return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int A, B, A1, B1;
string S, T, U;

int main() {
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  
  A1 = A - 1;
  B1 = B - 1;
  
  if ( S == U ) {
    cout << A1 << " " << B << endl;
  }
  
  if ( T == U ) {
    cout << A << " " << B1 << endl;
  }
}

Measured memory_bytes: 256
K,N = map(int, input().split())
l = list(map(int,input().split()))


ans_list = []
flag = 0
num = 0
ans = 999999999999999
    
for i in range(N):
    if(l[i] == 0):
        flag =True
if(flag == True):
    
    for i in range(1,N):
          ans_list.append(l[i] - l[i-1])
    ans_list.append(K - l[N-1])
    
    for i in range(N):
        num = K - ans_list[i]
        ans = min(ans, num)
    print(ans)
    
else: 
    for i in range(1,N):
        ans_list.append(l[i] - l[i-1])
    ans_list.append(K-l[N-1] + l[0])
    max_length = max(ans_list)
    ans = K-max_length
    print(ans)

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

int main(){
    int N, K, R, S, P;
    std::string T;
    std::cin >> N >> K >> R >> S >> P >> T;
    
    long long score = 0;
    for(int i=0; i<K; i++){
        if(T[i] == 'r'){
            score += P;
        }else if(T[i] == 's'){
            score += R;
        }else{
            score += S;
        }
    }
    for(int i=K; i<N; i++){
        if(T[i] == T[i - K]){ T[i] = 'a'; continue; } 
        if(T[i] == 'r'){
            score += P;
        }else if(T[i] == 's'){
            score += R;
        }else{
            score += S;
        }
    }
    
    std::cout << score << std::endl;
    
    return 0;
}
    



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define re register
#define IL inline
using namespace std;
const int maxn=1e5+10;
template<typename T> void read(T &x){
	T f=1;x=0;
	char s=getchar();
	while(s<'0' || s>'9'){if(s=='-') f=-1;s=getchar();}
	while(s>='0' && s<='9'){x=(x<<3)+(x<<1)+s-48;s=getchar();}
	x*=f;
}
ll n,m;
vector<int> t[maxn];
ll f[maxn];
ll ans[maxn];
bool book[maxn];
void dfs(int st){
	f[st]=1;
	book[st]=1;
	for(re int i=0;i<t[st].size();i++){
		if(!book[t[st][i]]){
			book[t[st][i]]=1;
		//	fa[t[st][i]]=st;
			dfs(t[st][i]);
			f[st]=(f[st]%m*(f[t[st][i]]+1)%m)%m;
		}
	}
	return;
}
void huangen(int st){
	//cout<<1<<endl;
	int len=t[st].size();
	int pre[len+5],suf[len+5];
	pre[0]=suf[len+1]=1;
	for(re int i=1;i<=len;i++){
		pre[i]=(pre[i-1]%m*(f[t[st][i-1]]+1)%m)%m;	
		suf[len-i+1]=(suf[len-i+2]%m*(f[t[st][len-i]]+1)%m)%m;
	}
	for(re int i=0;i<t[st].size();i++){
		if(ans[t[st][i]]!=-1) continue;
		int tmp1=f[st],tmp2=f[t[st][i]];
		f[st]=(pre[i]%m*suf[i+2]%m)%m;
		f[t[st][i]]=(f[t[st][i]]%m*(f[st]+1)%m)%m;
		ans[t[st][i]]=f[t[st][i]];
		huangen(t[st][i]);
		f[st]=tmp1;f[t[st][i]]=tmp2;
	}
	return;
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	read(n);read(m);
	for(re int i=1;i<n;i++){
		int x,y;
		read(x);read(y);
		t[x].push_back(y);
		t[y].push_back(x);
	}
	dfs(1);
	memset(ans,-1,sizeof ans);
	ans[1]=f[1];
	huangen(1);
	for(re int i=1;i<=n;i++) cout<<ans[i]%m<<endl;
	return 0;
}

Measured memory_bytes: 21848
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}

void solve(){
  ll n;
  cin>>n;
  vector<ll> v1(n),v2(n);
  rep(i,0,n) cin>>v1[i]>>v2[i];
  sort(all(v1));
  sort(all(v2));
  if(n%2) cout<<v2[n/2]-v1[n/2]+1LL<<endl;
  else{
    double x = (v1[n/2LL]+v1[(n)/2LL-1]), zy= (v2[n/2]+v2[(n)/2LL-1]);
    double z=(zy-x)+1;
    cout<<(ll)z<<endl;
  }
}
int main(){
    optimizeIO();
    // tc
    {
      solve();
    }
}


Measured memory_bytes: 6340
#include <bits/stdc++.h>
#define int long long

#define mp make_pair
#define pb push_back

const int mod = (int)1e9+7;
using namespace std;

int fastp(int a, int b){
    int res = 1;
    a %= mod;
    while(b){
        if(b&1) res = (res * a) % mod;
        a *= a; a %= mod;
        b >>= 1;
    }
    return res%mod;
}
signed main(){
    int n,a;
    cin >> n >> a;
    int s = 0;
    int cnt[a];
    memset(cnt,0,sizeof cnt);
    for(int i = 1;i<=a;i++){
        int x = a/i;
        cnt[i-1] = fastp(x,n)%mod;
    }
    s = 0;
    for(int i = a;i>=1;i--){
        int cnn = cnt[i-1];
        cnn %= mod;
        for(int z = i+i;z <= a;z += i){
            cnn -= cnt[z-1];
            cnn += mod+mod;
            cnn %= mod;
        }
        cnt[i-1] = cnn;
        cnt[i-1] += mod;
        cnt[i-1] %= mod;
        s += cnn*(i)%mod;
        s %= mod;
    }
    cout << s;
}


Measured memory_bytes: 4304
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int a[3];
	int ans;

	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	ans=a[0]+a[1];
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    ll ans = 1;
    vector <ll> as;
    REP(i, n) {
        ll a;
        cin >> a;
        as.push_back(a);
    }
    ll ulimit = pow(ll(10), ll(18));
    sort(as.begin(), as.end());
    dumparr(as)
    dump(ulimit)
    REP(i, n){
        if ((as[i]!=0) && (ulimit/as[i] < ans)){
            cout << -1 << endl;
            return 0;
        }
        ans *= as[i];
        if (ans > ulimit){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4320
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
struct node {
    lli x, h;
};
lli getLargestHist(vector<lli> h)
{
    stack<node> st;
    lli m = 0;
    h.push_back(0);
    rep(i, h.size())
    {
        node a;
        a.h = h[i];
        a.x = i;
        if (st.empty()) {
            st.push(a);
        } else if (st.top().h < a.h) {
            st.push(a);
        } else if (st.top().h > a.h) {
            int tar = i;
            while (!st.empty() && st.top().h >= a.h) {
                node pre = st.top();
                st.pop();
                m = max(pre.h * (i - pre.x + 1), m);
                tar = pre.x;
            }
            a.x = tar;
            st.push(a);
        }
    }
    return m;
}
string s[2005];
int f[2005][2005];
int g[2005][2005] = {};

int v[2005][2005];

int main()
{
    lli h, w;
    cin >> h >> w;
    rep(i, h) cin >> s[i];
    rep(i, h) rep(j, w)
    {
        f[i][j] = (s[i][j] == '#' ? 1 : 2);
    }
    rep(i, h - 1) rep(j, w - 1)
    {
        g[i][j] = (f[i + 1][j + 1] ^ f[i][j] ^ f[i + 1][j] ^ f[i][j + 1]);
    }
    rep(i, h - 1)
    {
        int cnt = 1;
        rep(j, w - 1)
        {
            if (g[i][j] == 0) {
                cnt++;
                v[i][j] = cnt;
            } else {
                cnt = 1;
                v[i][j] = cnt;
            }
        }
    }
    lli ans = max(h, w);
    rep(j, w - 1)
    {
        vector<lli> hoge;
        rep(i, h - 1)
        {
            //cout << v[i][j] << " ";
            hoge.push_back(v[i][j]);
        }
        //    cout << endl;
        ans = max(getLargestHist(hoge), ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 51584
using System;
class test{
	static void Main(){
    	string[] tmp = Console.ReadLine().Split();
		Int64 num1 = Int64.Parse(tmp[0]);
		Int64 num2 = Int64.Parse(tmp[1]);
    	Int64 sum = num1+num2;
    	if(sum%2==0){
    	  Console.Write(sum/2);
    	}else{
    	  Console.Write("IMPOSSIBLE");
    	}
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<numeric>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

ll gcd(ll x, ll y) {
	if (x >= y) {
		ll q0 = x;
		ll q1 = y;
		while (q1 > 0) {
			ll tmp = q0;
			q0 = q1;
			q1 = tmp%q1;
		}
		return q0;
	}
	else gcd(y, x);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll x, y;
	cin >> x >> y;
	cout << gcd(x, y) << "\n";

	return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
	int N;
	cin >> N;

	int max = 0;
	int a = 0;
	long long sum = 0;

	for (int i = 0; i < N; i++) {
		cin >> a;
		if (a >= max) {
			max = a;
		}
		else {
			sum += (max - a);
		}
	}

	cout << sum << endl;

}

Measured memory_bytes: 3620
import math, operator
from collections import Counter
from itertools import chain, product, permutations, combinations
from functools import reduce, lru_cache
class PrimeUtils:
    @staticmethod
    def primes_sieve(n):
        sieve = [True] * (n + 1)
        for i in range(2, n + 1):
            if sieve[i]:
                for j in range(i + i, n + 1, i):
                    sieve[j] = False
        return [i for i, x in enumerate(sieve[2:], 2) if x]
    @classmethod
    # Prime Factor Decomposition
    def pfd(cls, n):
        rn = math.ceil(math.sqrt(n))
        primes = cls.primes_sieve(rn)

        factors = []
        cur = n
        for p in primes:
            while True:
                div, rem = divmod(cur, p)
                if rem == 0:
                    factors.append(p)
                    cur = div
                else:
                    break
        if cur != 1 or not factors:
            factors.append(cur)
        return factors
    @classmethod
    # List up aliquots
    def aliquots(cls, n):
        pf = cls.pfd(n)
        pfc = Counter(pf)
        ppv = [[pow(p, i) for i in range(n+1)] for p,n in pfc.items()]
        return map(lambda x: reduce(operator.imul, x), product(*ppv))

N, M = map(int, input().split())
for factor in sorted(PrimeUtils.aliquots(M)):
    if N <= factor:
        print(M // factor)
        break
else:
    print(1)

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

int main() {
	int N;
	cin >> N;
	cout << (N >= 1000 ? "ABD" : "ABC");
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

要はNが1000以上かどうかで分岐
*/

Measured memory_bytes: 256