akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String data = sc.nextLine();
        
        String[] array = data.split(" ");
        int n = Integer.parseInt(array[0]);
        int r = Integer.parseInt(array[1]);
        
        int result = 0;
        
        if(n >= 10)
        {
            result = r;
        }
        else
        {
            result = r + 100 * (10 - n);
        }
        System.out.println(result);
    }
}


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

long double foreach_permutation(int n, std::function<long double(int *)> f)
{
    long double sum = 0;
    int indexes[n];
    for (int i = 0; i < n; i++)
        indexes[i] = i;
    do
    {
        sum += f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
    return sum;
}

int main()
{
    cout << std::fixed << std::setprecision(10);
    ll N;
    cin >> N;
    vector<long double> x(N), y(N);
    rep(i, N) cin >> x[i] >> y[i];
    long double n = 1;
    rep(i, N) n *= (i + 1);
    auto dist = [&](int i, int j) {
        return sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
    };
    long double s;
    s = foreach_permutation(N, [&](int *indexes) {
        long double sum = 0.;
        rep(i, N - 1)
        {
            sum += dist(indexes[i], indexes[i + 1]);
        }
        return sum;
    });
    cout << s / n << endl;
    return 0;
}


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

int main()
{
  string s;
  cin >> s;
  if(s.at(0) == s.at(1) || s.at(1) == s.at(2) || s.at(2) == s.at(3))
  {
    cout << "Bad" << endl;
  }
  else
  {
    cout << "Good" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, M;
    cin >> N >> M;
    int p[M], y[M];
    vector<pii> vec[N];
    rep(i, M){
        cin >> p[i] >> y[i];
        vec[p[i]-1].pb(pii(y[i], i));
    }
    rep(i, N){
        sort(vec[i].begin(), vec[i].end());
    }
    string s[M];
    rep(i, N) rep(j, vec[i].size()){
        int k = vec[i][j].second;
        s[k] = "";
        string a = to_string(i+1);
        string b = to_string(j+1);
        rep(l, 6-a.size()){
            s[k] += '0';
        }
        s[k] += a;
        rep(l, 6-b.size()){
            s[k] += '0';
        }
        s[k] += b;
    }
    rep(i, M) cout << s[i] << endl;
}

Measured memory_bytes: 13184
#include <stdio.h>

int main(void)
{
    char buf[1001] = {'\0'};
    int sum;
    int i = 0;

    do {
        buf[0] = '\0';
        scanf("%s", buf);
        if (buf[0] == '0') break;
        sum = 0;
        i = 0;
        while(buf[i] != '\0')
        {
            sum += buf[i++] - '0';
        }
        printf("%d\n", sum);
    } while (buf[0] != '0');  

    return 0;
}


Measured memory_bytes: 2112
#include <stdio.h>

int main(void){
	int S,h,x,m,s;
	scanf("%d", &S);
	h = S/3600;
	x = S%3600;
	m = x/60;
	s = x%60;
	printf("%d:%d:%d\n", h,m,s);
	
	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<vector<int>> x(n, vector<int>(n, -1)), y(n, vector<int>(n, -1));
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        for (int j = 0; j < a[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for (int b = 0; b < (1<<n); b++) {
        bitset<15> honest(b);
        bool ok = true;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < a[i]; j++) {
                if (honest[i] == 1 && honest[x[i][j]-1] != y[i][j]) {
                    ok = false;
                    break;
                }
            }
        }
        if (ok) ans = max(ans, (int)honest.count()); 
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define FLOAT setprecision(16)
#define SPEEDUP {cin.tie(0); ios::sync_with_stdio(false);}
#define INSIDE(i,j,H,W) ((i) >= 0 && (i) < (H) && (j) >= 0 && (j) < (W))
#define YesNo(b) (b ? "Yes" : "No")
#define YESNO(b) (b ? "YES" : "NO")
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const double EPS = 1.0e-9;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }

// all_of
// partial_sum, adjacent_difference

#if _DEBUG
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#endif

#if 1234567891
#include <array>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

int N,K;
int main() {
	int ans = 1;
	cin >> N >> K;
	REP(i, 0, N) {
		if (ans < K) {
			ans *= 2;
		} else {
			ans += K;
		}

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


Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
#include<stdlib.h>
 
int main(void){
 
	long long int a, b, v, w, t;
	bool f = false;
 
	scanf("%lld %lld", &a, &v);
	scanf("%lld %lld", &b, &w);
	scanf("%lld", &t);
 
	

	if(abs(a-b) <= v*t - w*t){
			f = true;
	}
	
 
	if(f){
		printf("YES");
	}
 
	else{
		printf("NO");
	}
 
	return 0;
}

Measured memory_bytes: 1696
N,A,B=map(int,input().split())
count=(N//(A+B))*A
if (N//(A+B))*(A+B)+A>=N:
    count+=N-(N//(A+B))*(A+B)
elif ((N//(A+B))*(A+B)+A<N):
    count+=A
print(count)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
#define N 30020
#define M 10
using namespace std;

char a[N];
set<int> f[M];

bool Calc(int x, int y, int z)
{
    set<int>::iterator t;

    t = f[x].begin();
    if(t == f[x].end())
        return false;

    t = f[y].upper_bound(*t);
    if(t == f[y].end())
        return false;

    t = f[z].upper_bound(*t);

    return t != f[z].end();
}

int main(void)
{
    int n;
    int i, j, k, o;

    scanf("%d %s", &n, a);
    for(i = 0; i < n; i ++)
        f[a[i] - 48].insert(i);

    for(i = o = 0; i < M; i ++)
        for(j = 0; j < M; j ++)
            for(k = 0; k < M; k ++)
                o += Calc(i, j, k);
    printf("%d\n", o);

    return 0;
}


Measured memory_bytes: 1664
def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return False
    return True

s=input()
n=(len(s))
left=s[0:(n-1)//2]
right=s[((n+3)//2-1):]

if is_kaibun(s):
  if is_kaibun(left):
    if is_kaibun(right):
      print('Yes')
    else:
      print('No')
  else:
     print('No')
else:
  print('No')      
    

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
	int n;
	int d[100];
	d[0]=1;
	d[1]=1;
	d[2]=2;
	for(int i=3;i<100;i++){
		d[i]=d[i-1]+d[i-2]+d[i-3];
	}
	while(1){
		cin>>n;
		if(n==0)
		break;
		cout<<d[n]/365/10+1<<endl;
	}
return 0;
}

Measured memory_bytes: 1160
import Data.Array (Array, (!), listArray)
import qualified Data.Map as M
import Data.Foldable (maximumBy)

import Control.Monad.Trans.State (State, execState, modify, get)
import Control.Monad (forM_)
import Data.Maybe (catMaybes, fromJust)

type StrL = (String,Int)
headL (x:xs, _) = xs
tailL (x:xs, n) = (xs, n-1)
cons x (xs, n) = (x:xs, n+1)

cmp (s1,l1) (s2,l2)
  | l1 < l2 = LT
  | l1 > l2 = GT
  | otherwise = compare s1 s2

main :: IO ()
main = do
  n <- read . head . words <$> getLine
  as <- map head . words <$> getLine
  let result = mm as n
  putStrLn . fst . fromJust . M.lookup n $ result

match = listArray ('1','9') [2,5,5,4,5,6,3,7,6]

mm :: [Char] -> Int -> M.Map Int StrL
mm as n = flip execState (M.fromList []) $ do
    forM_ [0..n] $ \i -> do
      tab <- get
      case nth tab i of
        Nothing -> return ()
        Just s -> modify $ M.insert i s
  where
    nth :: M.Map Int StrL -> Int -> Maybe StrL
    nth _ 0 = Just ("", 0)
    nth tab n =
      let cands = catMaybes [(cons a)<$>M.lookup (n-m) tab |a<-as, let m=match!a] in
      case cands of
        [] -> Nothing
        xs -> Just $ maximumBy cmp xs


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

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    ll n;
    cin>>n;
    cout<<n+(n*n)+(n*n*n)<<nl;


    return 0;
}



Measured memory_bytes: 3620
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

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

int main()
{
    vector<ll> num(3);
    for (ll i = 0; i < 3; i++)
    {
        cin >> num[i];
    }
    sort(num.begin(), num.end());

    ll ans = num[2] * 10 + num[1] + num[0];
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    K = int(input())
    A, B = [int(x) for x in input().split()]

    for i in range(A, B + 1):
        if i % K == 0:
            print("OK")
            return
    print("NG")

    

if __name__ == '__main__':
    main()



Measured memory_bytes: 9168
#include <iostream>
#include <vector>
using namespace std;
typedef long long int ll;
int main(void)
{
	int n,b;
	cin >> n;
	vector<int> a(n);

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> b;
		a[i]-=b;
	}
	int t=0;
ll p=0,m=0;
for(int i=0;i<n;i++){
	if(a[i]>0){
		p+=a[i];

	}else{
		m-=a[i]/2;
		if(a[i]!=0){
		t-=(a[i]-1)/2;
		}
	}
}
if(p>m){
	cout<<"No"<<endl;
}else{
	cout<<"Yes"<<endl;
}

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define REP(i, s, n) for (signed i = (s); i < signed(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(c) (c).begin(), (c).end()


const int INF = 1 << 29;

using namespace std;

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

int dr[] = { -1, 0, 1, 0 };
int dc[] = { 0, -1, 0, 1 };
const int MOD = 1000000007;

signed main() {

	int w, h;
	while (cin >> w >> h && w)
	{
		vector<VV> stage(h, VV(w, V(4)));
		rep(i, h) {
			stage[i][w - 1][3] = stage[i][0][1] = 1;
		}
		rep(j, w) {
			stage[h - 1][j][2] = stage[0][j][0] = 1;
		}
		rep(i, h * 2 - 1) rep(j, w - (i % 2 == 0)) {
			int b; cin >> b;
			if (i % 2 == 0) {
				stage[i / 2][j][3] = stage[i / 2][j + 1][1] = b;
			}
			else {
				stage[i / 2][j][2] = stage[i / 2 + 1][j][0] = b;
			}
		}

		queue<IP> que;
		vector<vector<bool>> memo(h, vector<bool>(w));
		que.push(IP(1, P(0, 0)));
		memo[0][0] = true;
		int ans = 0;
		while (!que.empty() && ans == 0) {
			IP ip = que.front(); que.pop();
			int step = ip.first;
			int pr = ip.second.first, pc = ip.second.second;

			rep(i, 4) if (stage[pr][pc][i] == 0) {
				int nr = pr + dr[i], nc = pc + dc[i];
				if (nr == h - 1 && nc == w - 1) {
					ans = step + 1;
					break;
				}
				if (!memo[nr][nc]) {
					que.push(IP(step + 1, P(nr, nc)));
					memo[nr][nc] = true;
				}
			}
		}
		cout << ans << endl;
	}

}

Measured memory_bytes: 3220
import math
from fractions import gcd
a,b,c,d = map(int,input().split())
x = b//c - (a-1)//c
y = b//d - (a-1)//d
l = c * d // gcd(c,d)
z = b//l - (a-1)//l
print(b-a+1-x-y+z)

Measured memory_bytes: 64492
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7


def main():
    n = int(input())
    s = list(input())
    ansl = []
    c = True
    k = ""
    for i in range(n):
        if c:
            k = s[i]
            ansl.append(s[i])
            c = False
        elif not c and k != s[i]:
            k = s[i]
            ansl.append(s[i])
    
    print(len(ansl))




    
            
    

    

    

if __name__ == '__main__':
    main()


Measured memory_bytes: 7136
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define CLR(a) memset((a), 0, sizeof(a))
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

//using LL = long long;
using namespace std;

const int dy[] = {0, 0, 1, -1};
const int dx[] = {1, -1, 0, 0};
const double EPS = 1e-10;
const double PI = acos(-1.0);

struct Queue{
    Queue(){}

    list< pair<string, int> > v;

    void processing(int q){
        v.front().second -= q;
    }

    pair<string, int> front(){
        return v.front();
    }

    bool empty(){
        if(v.empty()) return true;
        else return false;
    }

    void enqueue(pair<string, int> p){
        v.push_back(p);
    }

    pair<string, int> dequeue(){
        pair<string, int> p = v.front();
        v.pop_front();
        return p;
    }
};

Queue solve(Queue queue, int q){
    Queue res;
    int count = 0;
    while(!queue.empty()){
        queue.processing(q);
        
        pair<string, int> p = queue.dequeue();
        if(p.second <= 0){
            count += p.second + q;
            p.second = count;
            res.enqueue(p);
            //debug(count)
        }else{
            count += q;
            queue.enqueue(p);
            //debug(count)
        }
        
    }
    return res;
}



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

    int n, q;
    cin >> n >> q;

    Queue queue;
    REP(_, n)
    {
        string tempStr;
        int tempInt;
        cin >> tempStr >> tempInt;
        queue.enqueue(make_pair(tempStr, tempInt));
    }

    Queue res = solve(queue, q);
    REP(_, n)
    {
        pair<string, int> p = res.dequeue();
        cout << p.first << " " << p.second << endl;
    }

   
}


Measured memory_bytes: 10192
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    long double a,b,c;
    cin>>a>>b>>c;
    
    long double hoge=c-a-b;
    
    long double root=pow(a*b,0.5)*2;
    
    if(root<hoge) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    char ch;
    cin >> ch;
    a[i] = ch - '1';
  }
  bool ones = false;
  for (auto& i : a) if (i == 1) ones = true;
  if (ones) {
    for (auto& i : a) if (i == 2) i = 0;
  } else {
    for (auto& i : a) if (i == 2) i = 1;
  }
  auto doit = [] (int n, const vector<int>& a) {
    int res = 0;
    for (int i = 0; i < n; i++) {
      if (((n - 1) & i) == i) res ^= a[i];
    }
    return res;
  };
  cout << (ones ? doit(n, a) : 2 * doit(n, a)) << endl;
  return 0;
}

Measured memory_bytes: 7112
N = int(input())
b = list(map(int,input().split()))
can = True
for i in range(N):
    if i+1 < b[i]:
        can = False
if not can:
    print(-1)
else:
    ans = []
    while b:
        for i in list(reversed(range(len(b)))):
            if i+1 == b[i]:
                ans.append(b[i])
                b.pop(i)    
                break
    for i in reversed(ans):
        print(i)

Measured memory_bytes: 39536
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[][] cum = new int[2][w];
		int ans = 0;
		for (int i = 0; i < h; ++i) {
			if(i%100==0)
			System.gc();
			for (int j = 0; j < w; ++j) {
				int c = sc.nextInt();
				if (c == 0) {
					cum[i % 2][j] = (i > 0 ? cum[(i - 1) % 2][j] : 0) + 1;
				} else {
					cum[i % 2][j] = 0;
				}
			}
			ans = Math.max(ans, solve(cum[i % 2], w));
			
		}

		System.out.println(ans);

	}

	int solve(int[] cum, int w) {
		int ans = 0;
		ArrayDeque<List<Integer>> stack = new ArrayDeque<>();
		for (int j = 0; j < w; ++j) {
			ans = Math.max(ans, cum[j]);
			int d = j;
			while (!stack.isEmpty() && (cum[j] == 0 || stack.peekLast().get(0) > cum[j])) {
				List<Integer> pair = stack.pollLast();
				ans = Math.max(ans, pair.get(0) * (j - pair.get(1)));
				d = Math.min(d, pair.get(1));
			}
			if (cum[j] == 0)
				continue;
			stack.addLast(Arrays.asList(cum[j], d));
		}
		while (!stack.isEmpty()) {
			List<Integer> pair = stack.pollLast();
			ans = Math.max(ans, pair.get(0) * (w - pair.get(1)));
		}
		return ans;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 128832
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

struct mint {

  ll x; 

  mint(ll x=0):x((x%mod+mod)%mod){} //コンストラクタを呼んで自動的にmodを取っている。

  mint operator-() const { return mint(-x);}

  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    //メンバ関数にはthisポインタがある。メンバ変数の値を返す。
    return *this;
  }

  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }

  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }

  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }

  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }

  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }

  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1); //a=x/2
    a *= a; //繰り返し二乗法
    if (t&1) a *= *this; //tが奇数のときはxを1回かける
    return a;
  }



  // for prime mod

  mint inv() const {
    return pow(mod-2);
  }

  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }

  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
    
};

struct combination{
  vector<mint> fact, ifact; //ifactはinverse factorial
  combination(ll n):fact(n+1), ifact(n+1){
    assert(n<mod);
    fact[0]=1;
    for(ll i=1;i<=n;i++) fact[i]=fact[i-1]*i;
    ifact[n]=fact[n].inv();
    for(ll i=n;i>=1;--i) ifact[i-1]=ifact[i]*i; // 1/(i-1)!=(1/i!)*i
  }
  mint operator()(ll n,ll k){
    if(k<0 || k>n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
    ll k;
    cin >> k;
    string s;
    cin >> s;
    ll n=s.length();
    vector<ll> cur(k+1),pre(k+1),p(n+k+1);
    ll v=1;
    for(ll i=0;i<=n+k;i++){
        p[i]=v;
        v*=25;
        v%=mod;
    }
    mint ans=0;
    pre[0]=1;
    combination c=combination(2000000);
    for(ll i=n;i<=n+k;i++){
        mint comb=c(n+k,i);
        comb*=p[n+k-i];
        ans+=comb;
    }
    cout << ans.x << endl;
} 

Measured memory_bytes: 66692
#include<iostream>

using namespace std;

int main(void)
{
  int l,r,d; cin>>l>>r>>d;
  int c=0;
  
  for(int i=l;i<=r;i++){
    if(i%d==0){c++;}
  }
  
  cout<<c<<endl;
  
  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    int N; cin >> N;
    vec A(N), B(N);
    readv(A);
    readv(B);
    int sA = 0, sB = 0;
    REP(i, N){
        sA += A[i];
        sB += B[i];
    }
    if(sA < sB){
        cout << -1;
        return 0;
    }

    vec dif(N);
    REP(i, N) dif[i] = A[i] - B[i];
    SORT(dif);
    REVERSE(dif);
    int n0 = 0, ms = 0, n2 = 0;
    REP(i, N){
        if(dif[i] > 0) n0++;
        else ms += dif[i];
        if(dif[i] < 0) n2++;
    }
    int a1 = -1, a2 = n0;
    //cout << n0 << endl;
    while(a2 - a1 > 1){
        int a = (a1 + a2 + 1) / 2;
        int p = 0;
        REP(i, a) p += dif[i];
        if(p >= -ms) a2 = a;
        else a1 = a;
    } 
    cout << n2 + a2;
    
    return 0;
}

Measured memory_bytes: 2560
n, y = map(int, input().split())
for i in range(n + 1):
  for j in range(n + 1 -i):
    if 10000*i + 5000*j + 1000*(n - i -j) == y:
      print(i, j, n - i -j)
      break
  else:
    continue
  break
else:
  print('-1 -1 -1')


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

#define OnlineJudge1

#define loop(a,n) for(int i = a;i<n;i++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)


typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
    #ifdef OnlineJudge
        freopen("in.in","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
}
int main(){
    init();
ll n,k;
cin >> n >> k;
int arr[n];
for(int i =0;i < n;i++){
cin >> arr[i];
}
sort(arr,arr+n);
int ans = INT_MAX;
for(int i = 0;i + k - 1 < n;i++){
ans = min(ans, arr[i+k-1]-arr[i]);
}
cout << ans;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,num=1,ans=0;
    cin>>n;
    while(num*num<n){
        num++;
    }
    for(ll i=1;i<=num;i++){
        ll niko=(n-i)/i;
        if(niko){
        if(n%niko==i){
            ans+=niko;
        }
    }
    }
    cout << ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

int n,h[99][99],m[99],M[99];

int main(){
	while(cin>>n){
		if(n==0)return 0;
		for(int i=0;i<n;i++){m[i]=99999999;M[i]=0;}
		for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>h[i][j];
		for(int i=0;i<n;i++){
			m[i]=h[i][0];M[i]=h[0][i];
			for(int j=1;j<n;j++){
				m[i]=min(m[i],h[i][j]);M[i]=max(M[i],h[j][i]);
			}
		}
		int f=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(h[i][j]==m[i]&&h[i][j]==M[j]){cout<<h[i][j]<<endl;f=1;break;}
			}
			if(f==1)break;
		}
		if(f==0)cout<<0<<endl;
	}
}

Measured memory_bytes: 0
c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))
if not c1[0]-c1[1] == c2[0]-c2[1] == c3[0]-c3[1]:
    print('No')
    exit()
if not c1[2]-c1[1] == c2[2]-c2[1] == c3[2]-c3[1]:
    print('No')
    exit()
if not c1[0]-c2[0] == c1[1]-c2[1] == c1[2]-c2[2]:
    print('No')
    exit()
if not c3[0]-c2[0] == c3[1]-c2[1] == c3[2]-c2[2]:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#define LL long long

int main(){
	int n,m,i,j,s,PossibleMaxScore=0;
	bool found;
	std::cin >> n;
	std::vector<std::string> positiveCards;
	std::vector<int> positiveCards_score;
	std::string currentCard;
	for(i=0;i<n;i++){
		std::cin >> currentCard;
		s = positiveCards.size();
		found = false;
		for(j=0;j<s;j++){
			if(positiveCards[j]==currentCard){
				positiveCards_score[j]++;
				found = true;
				break;
			}
		}
		if(!found){
			positiveCards.push_back(currentCard);
			positiveCards_score.push_back(1);
		}
	}

	std::cin >> m;
	for(i=0;i<m;i++){
		std::cin >> currentCard;
		for(j=0;j<s;j++){
			if(positiveCards[j]==currentCard)positiveCards_score[j]--;
		}
	}

	for(j=0;j<s;j++){
		if(positiveCards_score[j]>PossibleMaxScore)PossibleMaxScore=positiveCards_score[j];
	}

	std::cout << PossibleMaxScore << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(string, S);
  each(x, S) {
    if (x == ',') {
      cout << " ";
    } else {
      cout << x;
    }
  }
}


Measured memory_bytes: 256
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

int main() {
	int a, b, c; cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << " " << b <<" " << c << endl;
}

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

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

    vector<int> cnt(n + 10, 1);
    int repCnt = min(n, 5000001);
    for (int i = 2; i <= repCnt; i++)
        for (int j = i; j <= n; j += i)
            cnt[j]++;

    ll ans = 0;
    for (int i = 1; i <= repCnt; i++)
        ans += (ll)i * (ll)cnt[i];
    if (repCnt == 5000001)
        for (int i = repCnt + 1; i <= n; i++)
            ans += (ll)i * (ll)(cnt[i] + 1);

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


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define Matrix vector< vector<int> >

Matrix operator * (Matrix a,Matrix b)
{
    Matrix ans;
    int r1=a.size(),c1=a[0].size();
    int r2=b.size(),c2=b[0].size();
    if(c1!=r2)
        return ans;
    for(int i=0;i<r1;i++)
    {
        ans.push_back({});
        for(int j=0;j<c2;j++)
        {
            ans[i].push_back(0);
            for(int k=0;k<c1;k++)
            {
                long long F=a[i][k];
                long long S=b[k][j];
                long long sum=(F*S+ans[i][j])%1000000007;
                ans[i][j]=sum;
            }
        }
    }
    return ans;
}

Matrix Power(Matrix a,ll b)
{
    Matrix ans;
    int r=a.size(),c=a[0].size();
    if(r!=c)
        return ans;
    for(int i=0;i<r;i++)
    {
        ans.push_back({});
        for(int j=0;j<c;j++)
            ans[i].push_back((i==j));
    }
    while(b)
    {
        if(b%2)
            ans=ans*a;
        a=a*a;
        b/=2;
    }
    return ans;
}

int n;
ll k;

Matrix kek;
Matrix a;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>k;
    kek.resize(n);
    for(int i=0;i<n;i++)
    {
        kek[i].resize(n);
        for(int j=0;j<n;j++)
        {
            cin>>kek[i][j];
        }
    }
    a.resize(1);
    a[0].resize(n);
    for(int i=0;i<n;i++)
    {
        a[0][i]=1;
    }
    kek=Power(kek,k);
    a=a*kek;
    ll res=0LL;
    for(auto &it:a[0])
    {
        res+=it;
        res%=1000000007;
    }
    cout<<res<<"\n";
    return 0;
}
/**



**/


Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int n,k;
    cin>>n>>k;
    double ans = 0;
    for (int i = 1; i <= n; ++i) {

        for (int j = 0; i * pow(2,j) < INF ; ++j) {
            if(i * pow(2,j) >= k){
                ans +=  1 / (n * (pow(2,j)));
                break;
            }
        }
    }

    printf("%.10f\n", ans);


    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 typedef long long ll;
 
int main() {
int a,b,c,d;
cin>>a>>b>>c>>d;
int ans=0;
for(int i=0;i<3001;i++){
for(int j=0;j<3001;j++){
if((d-a*i-b*j)%c==0 && (d-a*i-b*j)>=0){
    ans++;
}
    
}

}
cout<<ans<<endl;
}

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

#define N 100000

int main()
{
    int n = 0, i, key, ans;
    string s;
    
    cin >> s;
    n = s.size();
    ans = n;
    
    for(i = 0; i < n; i++) {
        
        if(s[i] != s[i+1]) {
            
            if((i+1) >= (n-(i+1))) {
                key = i+1;
            } else {
                key = n-(i+1);
            }
            
            if(ans > key) {
                ans = key;
            }
        }
    }
    
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 512
def main():
    N,M=map(int,input().split())
    s=[list(map(int,input().split()))[1:] for i in range(M)]
    p=list(map(int,input().split()))
    
    ans=0
    for i in range(2**N):
        flag=True
        for j in range(M):
            if not ([(i>>k-1)&1 for k in s[j]].count(1)%2==p[j]):
                flag=False
                
        if flag:
            ans+=1
            
    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>	
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());

using namespace std;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}
 
const int mod = (int)1e9 + 7;
 
int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();   
	int x, a;
	cin >> x >> a;
	if(x < a) cout << 0;
	else cout << 10;
}                                

Measured memory_bytes: 764
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef long long  ll;

/** Problem0164 : Ohajiki Game **/
int main()
{
	int ohajiki=32;
	vector<int> take;
	int n;
	
	while (cin>>n, n) {
		ohajiki = 32;
		take.clear();
		
		rep(i, n) {
			int a;
			cin>>a; take.push_back(a);
		}
		
		for (int i=0; ; i++) {
			ohajiki -= (ohajiki-1)%5;
			if (ohajiki<=0) {
				ohajiki=0;
				break;
			}
			cout << ohajiki << endl;


			ohajiki -= take[i%take.size()];
			if (ohajiki<=0) {
				ohajiki=0;
				break;
			}
			cout << ohajiki << endl;
		}
		cout << ohajiki << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>

using namespace std;

int main(void) {
	int n, a = 0, i;
	cin >> n;
	while (n > 0) {
		a++;
		n -= a;
	}
	n *= -1;
	for (i = 1; i < n; i++)
		printf("%d\n", i);
	for (i = n + 1; i <= a; i++)
		printf("%d\n", i);
	return 0;
}

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

vector<int> edge[200001];
vector<bool> visited(200001, false);

pair<int, int> visit(int vertex)
{
  int d(0), v(vertex);
  visited[vertex] = true;
  for (auto&& vn : edge[vertex]) {
    if (!visited[vn]) {
      auto p = visit(vn);
      if (d <= p.first) {
        d = p.first + 1;
        v = p.second;
      }
    }
  }
  visited[vertex] = false;
  return {d, v};
}

int main()
{
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    edge[v1].push_back(v2);
    edge[v2].push_back(v1);
  }
  cout << (visit(visit(1).second).first % 3 == 1 ? "Second" : "First") << endl;
}


Measured memory_bytes: 26880
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int w[] = new int[10];
		int k[] = new int[10];
		int first, second, third;
		int sumW, sumK;

		for (int i = 0; i < 10; i++) {
			w[i] = scanner.nextInt();
		}
		for (int i = 0; i < 10; i++) {
			k[i] = scanner.nextInt();
		}
		
		first  = -1;
		second = -1;
		third  = -1;
		for (int i = 0; i < 10; i++) {
			if (first < 0 || w[first] < w[i]) {
				first = i;
			}
		}
		for (int i = 0; i < 10; i++) {
			if (i != first && (second < 0 || (0 <= second && w[second] < w[i]))) {
				second = i;
			}
		}
		for (int i = 0; i < 10; i++) {
			if (i != first && i != second && (third < 0 || (0 <= third && w[third] < w[i]))) {
				third = i;
			}
		}
		sumW = w[first] + w[second] + w[third];
		first  = -1;
		second = -1;
		third  = -1;
		for (int i = 0; i < 10; i++) {
			if (first < 0 || k[first] < k[i]) {
				first = i;
			}
		}
		for (int i = 0; i < 10; i++) {
			if (i != first && (second < 0 || (0 <= second && k[second] < k[i]))) {
				second = i;
			}
		}
		for (int i = 0; i < 10; i++) {
			if (i != first && i != second && (third < 0 || (0 <= third && k[third] < k[i]))) {
				third = i;
			}
		}
		sumK = k[first] + k[second] + k[third];
		System.out.println(sumW + " " + sumK);
	}
}

Measured memory_bytes: 12000
S=[];R=[]
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))
m=10**5
for i in range(N):
  R.append(i)
for i in H:
  S.append(abs(T-i*0.006-A))
F=list(zip(R,S))
F.sort(key=lambda x: x[1])
#print(F)
print(F[0][0]+1)

Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

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

typedef long long ll;

ll Q, H, S, D, N;
ll ans = 0;

int main() {
  cin >> Q >> H >> S >> D;
  cin >> N;

  ll l = min(4*Q, min(2*H, S));
  ll l2 = min(2*l, D);

  ans += l2 * (N/2);
  ans += l * (N%2);

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


Measured memory_bytes: 256
import sys
from itertools import accumulate

inf = 1<<60
ans = 0

def solve():
    n, k = map(int, sys.stdin.readline().split())
    a = [int(sys.stdin.readline().rstrip()) - k for i in range(n)]
    s = [0] + list(accumulate(a))

    MergeSort(s)

    print(ans)

def MergeSort(a):
    if len(a) == 1:
        return a

    apre = MergeSort(a[:len(a)//2])
    asuf = MergeSort(a[len(a)//2:])

    res = merge(apre, asuf)

    return res

def merge(a, b):
    global ans
    na = len(a)
    nb = len(b)

    a.append(-inf)
    b.append(-inf)

    la = 0
    lb = 0

    res = []

    for i in range(na + nb):
        if a[la] <= b[lb]:
            ans += na - la
            res.append(b[lb])
            lb += 1
        else:
            res.append(a[la])
            la += 1

    return res

if __name__ == '__main__':
    solve()

Measured memory_bytes: 24548
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int n;
    cin >> n;
    int a[4]={};
    rep(i,n){
        string s;
        cin >> s;
        if(s[0]=='A') a[0]++;
        if(s[0]=='W') a[1]++;
        if(s[0]=='T') a[2]++;
        if(s[0]=='R') a[3]++;
    }
    cout << "AC x " << a[0] << endl;
    cout << "WA x " << a[1] << endl;
    cout << "TLE x " << a[2] << endl;
    cout << "RE x " << a[3] << endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//-----CODE------//
void solve(void)
{
  int N,M;
  cin>>N>>M;
  double ANS = 0;
  double TIME = 1900*M + 100*(N-M);
  double dM = M;
  double P = pow(0.5,M);
  double rP = 1 - P;
  double sP = 1;
  for (int i = 1; i < 10000; i++)
  {
    ANS += TIME*(i)*P*sP;
    sP *= rP;
  }
  cout<<(int)round(ANS)<<endl;
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>

#define F_OR(i, a, b, s) for (ll i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 
int n,m,k;
vector<pair<int,int>> points;

const int nax = 1e6 + 50, mod = 1e9+7;
ll fac[nax*2], fin[nax*2];

ll power(ll a, ll b){
	ll result = 1;
	while(b>0){
		if(b&1) result = (result*a)%mod;
		(a*=a)%=mod;
		b/=2;
	}
	return result;
}

ll inv(ll x){
	ll e = mod -2, r = 1;
	while(e){
		if(e&1) r=r*x%mod;
		x = x*x %mod;
		e>>=1;
	}
	return r;
}

ll ncr(ll a, ll b){
	if(b<0 || b > a) return 0;
	return fac[a] * fin[b] % mod * fin[a-b] % mod;
}




// finding the distance between all pair of points in O(nlogn)
ll dist(){
	ll ans = 0;
	vector<int> x,y;
	FOR(i,1,n+1) FOR(j,1,m+1) x.pb(i);
	FOR(i,1,m+1) FOR(j,1,n+1) y.pb(i);
	
	ll prev_sum = 0;
	FOR(i,1,x.size()){
		ans += ((x[i]-x[i-1])*i + prev_sum)%mod;
		ans %= mod;
		prev_sum += ((x[i]-x[i-1])*i)%mod;
		prev_sum %= mod;
	}

	prev_sum = 0;
	FOR(i,1,y.size()){
		ans += ((y[i]-y[i-1])*i + prev_sum)%mod;
		ans %= mod;
		prev_sum += (y[i]-y[i-1])*i;
		prev_sum %= mod;
	}
	
	return ans;
}
 
// for any pair we can choose the other k-2 points in nm-2 nCr k-2 ways
// meaning this pair occurs in nm-2 nCr k-2 arrangements
// in manhattan x and y are independent
void solve(){
	cin >> n >> m >> k;
	
	//setting up ncr
	fac[0] = 1;
	FOR(i,1,nax*2) fac[i] = fac[i-1] * i % mod;
	fin[nax*2-1] = inv(fac[nax*2-1]);
	for(int i = nax*2-2; i>=0; --i) fin[i] = fin[i+1]*(i+1)%mod;
	
	cout << (dist() * ncr(n*m-2,k-2))%mod;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 36836
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define F(i,a,b) for(int i=a;i<b;i++)
#define RF(i,a,b) for(int i=a;i>b;i--)
#define mp(a,b) make_pair(int a,int b)
#define ll long long
const int mxn=1e3+10,mxm=4e5+10,modl=1e9+7;
int nm,n,m,p,t,ans,sum;
int a[mxn],b[mxn],h[mxn];
//string s[mxn];
//bool in[mxn][mxn];
//int tr[][2]={{0,-1},{-1,0},{0,+1}};
//struct pos{
//    int x,y;
//    bool operator < (const pos b)const{
//        return h[x][y]>h[b.x][b.y];
//    }
//};
bool cmp(string a,string b){
    return a+b<b+a;
}
int main(){
    ios_base::sync_with_stdio(false);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
//    cin>>nm;
    string s,s2;
    while(cin>>s){
//        priority_queue<int,vector<int>,greater<int>>q;
        if(s=="AAA"||s=="BBB") cout<<"No";
        else cout<<"Yes";
        //cout<<t;
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll ans = 0;
  ll sum = 0, res = 0;
  rep(i, k) sum += a[i];
  FOR(i, k, n) if (a[i] > 0) res += a[i];
  rep(i, n - k + 1) {
    chmax(ans, sum + res);
    chmax(ans, res);
    if (i == n - k) break;
    sum += a[i + k];
    sum -= a[i];
    if (a[i + k] > 0) res -= a[i + k];
    if (a[i] > 0) res += a[i];
  }
  cout << ans << '\n';




  
  return 0;
}

Measured memory_bytes: 1024