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

public class Main {
	public static void main(String[] args) {

		try {
			Scanner scanner = new Scanner(System.in);

			int n = scanner.nextInt();

			int [] h = new int [n];
			for(int i=0; i<n; i++) {
				h[i] = scanner.nextInt();
			}

			Main testC = new Main();
			System.out.println(testC.buildStairs(n, h));

			scanner.close();

		} catch (InputMismatchException e) {
			// TODO: handle exception
			System.out.println("整数を入力してください");
		}
	}


	public String buildStairs(int n, int[] h) {
//		for(int i=1; i<n; i++){
//			if(h[i-1] > h[i]) {
//				if(h[i-1] - 1 > h[i]) {
//					return "No";
//				} else if (i != 1 && h[i-2] > h[i-1] - 1){ //1つ目はi-2が-1でエラーになるので弾く
//					return "No";
//				} else {
//					h[i-1] = h[i-1] - 1;
//				}
//			}
//		}

		for(int i=n-1; i>0; i--) {
			if(h[i-1] > h[i]) {
				if(h[i-1] - 1 > h[i]) {
					return "No";
				} else if (i != 1 && h[i-2] > h[i-1]){ //1つ目はi-2が-1でエラーになるので弾く
					return "No";
				} else {
					h[i-1]--;
				}
			}
		}

		return "Yes";
	}

}



Measured memory_bytes: 48856
#include<iostream>
#include <string>
#include<vector>
#include<algorithm>
#include <cstdlib>
#include<cmath>
using namespace std;

int main(){
    string a,b;
    cin>>a>>b;
    a+=b;
    int n=stoi(a);
    int m=sqrt(n);
    cout<<(m*m==n?"Yes":"No")<<endl;
 
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
using namespace std;
#define ll long long int
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;
using namespace std;

int main() {
	ll r, l,c=0,y=-1,a,b;
	cin >> l >> r;
	for (ll i = l; i < r; i++) {
		if (c > 2030)break;
		ll d = 0;
		for (ll j = i + 1; j <= r; j++) {
			if (d > 2030)break;
			a = i % 2019;
			b = j % 2019;
			if (y != -1) {
				y = min(y, a*b % 2019);
			}
			else y = a * b % 2019;
			d++;
		}
		c++;
	}
	cout << y << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>

#define loop(n) for(ll i=0;i<n;i++)

using namespace std;

typedef long long int ll;

int main() {
    ll n,x[200000],y[200000];
    cin >> n;
    loop(n) cin >> x[i];
    memcpy(y,x,sizeof(ll[200000]));
    sort(y,y+n);
    ll a[2] = {y[n/2-1],y[n/2]};
    loop(n) if(x[i] <= a[0]) cout << a[1] << endl; else cout << a[0] << endl;
}

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

using P = pair<int,int>;
using P3 = pair<P, int>;
using ll = long long int;
constexpr int INF = 1<<30;

ll len[51], cnt[51];

ll rec(ll n, ll x){
    if(n==0){
        return x > 0;
    }else if(x == 0){
        return 0;
    }else{
        x--;
        if(x <= len[n-1]){
            return rec(n-1, x);
        }else{
            x -= len[n-1]+1;
            return rec(n-1, x) + cnt[n-1] + 1;
        }
    }
}

int main() {
    ll n, x;
    cin >> n >> x;
    len[0] = 1;
    cnt[0] = 1;
    for(int i=1;i<=50;i++){
        len[i] = len[i-1]*2+3;
        cnt[i] = cnt[i-1]*2+1;
    }
    cout << rec(n, x) << endl;
    return 0;
}


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

int main(){
    int N, D;
    cin >> N >> D;
    vector<int> X[N];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < D; j++){
            int x; cin >> x;
            X[i].push_back(x);
        }
    }
    int cnt = 0;
    for(int i = 0; i < N - 1; i++){
        for(int j = i + 1; j < N; j++){
            int sum = 0;
            for(int k = 0; k < D; k++){
                sum += pow(X[i][k] - X[j][k], 2);
            }
            if( (int)sqrt(sum) * (int)sqrt(sum) == sum) cnt++;
        }
    }
    cout <<cnt << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        int s = scanner.nextInt();
        int w = scanner.nextInt();
        if(w >= s){System.out.println("unsafe");}
        else{System.out.println("safe");}

        return;
    }
}

Measured memory_bytes: 35760
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;
const int mod = 1000000007;

int main() {

  int64_t N,ans=0;
  cin>>N;
  ans=N/500;
  ans*=1000;
  ans+=((N%500)/5)*5;
  //vector<int> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int>> A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{   
    string s;
    cin >> s;
    bool is_good = s[1]==s[2];
    is_good &= (s[1]==s[0]) || (s[2]==s[3]);
    cout << (is_good ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	long long n,k;
	cin>>n>>k;
	long double temp1=n/(long double)k;
	long long a=ceil(temp1);
	long long b=floor(temp1);
	ll c=abs(n-a*k);
	ll d=abs(n-b*k);
	cout<<std::min(c,d)<<endl;
	
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		long w = sc.nextInt();
		long h = sc.nextInt();
		long x = sc.nextInt();
		long y = sc.nextInt();
		int out = 0;

		if (w%2 == 0 && h%2 == 0 && x*2 == w && y*2 == h ) {
			out = 1;
		}

		double s = w * h / 2.0;
		System.out.print(BigDecimal.valueOf(s).toPlainString());
		System.out.print(" ");
		System.out.print(out);


	}

}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 21204
def main():
    n, m = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]
    
    ans = 0
    i = m
    for a, b in  sorted(ab):
        if i >= 0:
            ans += a * min(i, b)
            i -= min(i, b)
    
    print(ans)
            

if __name__ == '__main__':
    main()

Measured memory_bytes: 28652
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

def main():
    N,M=mis()
    sc = [lmis() for _ in range(M)]
    for i in map(str, range(10**(N-1) if N>1 else 0, 10**N)):
        if all(len(i) >= s and i[s-1] == str(c) for s, c in sc):
            print(i)
            return
    print(-1)


main()







Measured memory_bytes: 5300
sx, sy, tx, ty = map(int, input().split())

go = 'U' * (ty - sy) + 'R' * (tx - sx)
back = 'D' * (ty - sy) + 'L' * (tx - sx)
ans = go + back + 'LU' + go + 'RDRD' + back + 'LU'

print(ans)

Measured memory_bytes: 9168
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=998244353;
int a[500010],n,you[500010],que[500010];
char s[500010];
LL ans;
int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	FOR(i,1,n*3) if (s[i]=='R') a[i]=1; else if (s[i]=='G') a[i]=2; else a[i]=3;
	ans=1;
	FOR(i,2,n) ans=ans*i%MO;
	FOR(i,1,n*3){
		if (que[a[i]]){
			ans=ans*que[a[i]]%MO;
			--que[a[i]];
			continue;
		}
		bool flag=0;
		FOR(j,1,3) if (j!=a[i] && you[j]){
			flag=1;
			++que[6-j-a[i]];
			ans=ans*you[j]%MO;
			--you[j];
			
		}
		if (flag) continue;
		++you[a[i]];
	}
	ans=(ans%MO+MO)%MO;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4608
def rle(t):
    tmp2, num, ans = t[0], 1, []
    for i in range(1, len(t)):
        if tmp2 == t[i]:
            num += 1
        else:
            ans.append([tmp2, num])
            tmp2 = t[i]
            num = 1
    ans.append([tmp2, num])
    return ans


S = input()

s = list(map(str, S))
l = rle(S)
now = [[], [], []]
for i in range(len(S)):
    if S[i] == 'B':
        now[0].append(i)
for j in range(len(now[0])):
    now[1].append(len(S) - len(now[0]) + j)
    now[2].append(now[1][j] - now[0][j])
print(sum(now[2]))


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

void solve(long long N, std::vector<long long> a) {
  int as = 0, bs = 0;
  sort(a.begin(), a.end());
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0)
      as += a.at(i);
    else
      bs += a.at(i);
  }
  cout << abs(bs - as) << '\n';
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, std::move(a));
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define tests(i) cout<<"i: "<<i<<endl;
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}
bool sortdes(const pair<int,int> &a, const pair<int,int> &b){return a.ss<b.ss;}
bool sortasc(const pair<int,int> &a, const pair<int,int> &b){return a.ss>b.ss;} 
int gcd(int x,int y){return __gcd(x,y);}
lld fact(lld n);
lld nCr(lld n,lld r){return fact(n) / (fact(r) * fact(n - r));}
lld fact(lld n){ lld res = 1; for(lld i = 2; i <= n; i++){res = res * i;}return res;} 
const int maxi = 1e6+10;
vector<int> v[maxi];
long long a[maxi];
void dfs(int x,int y){
    a[x]+=a[y];
    for(int i:v[x]){
        if(i!=y){
            dfs(i,x);
        }
    }
}

void test_case(){
    int a,b,c;
    cin>>a>>b>>c;
    int sum=c-(a-b);
    if(sum<0){
        cout<<"0";
    }
    else{
        cout<<sum;
    }
    
}

int main(){
    fastio;
    file();
    int T=1;
    // int T;
    // cin>>T;
    for(int nr=1;nr<=T;++nr) {
        // cout<<"Case #"<<nr<<": ";
		test_case();
    }
}

Measured memory_bytes: 25344
n = int(input())
a_lst = list(map(int, input().split()))
b_lst = list(map(int, input().split()))
c_lst = list(map(int, input().split()))

res = sum(b_lst)
for i in range(n-1):
    if a_lst[i] + 1 == a_lst[i+1]:
        res += c_lst[a_lst[i]-1]
print(res)

Measured memory_bytes: 3064
from heapq import heapify, heappush, heappop
N,M = map(int,input().split())
AB = [[] for i in range(M+1)]
for i in range(N):
    a,b = map(int,input().split())
    if a <= M:
        AB[a].append(-b)
AB2 = []
work = 0
heapify(AB2)
for i in range(1,M+1):
    for j in AB[i]:
        heappush(AB2,j)
    if len(AB2):
        b = heappop(AB2)
        work -= b
print(work)

Measured memory_bytes: 17600
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debugg cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans,n,t;
void solve()
{
    cin>>n>>t;
    set<ll>st;
    for(int i=0;i<n;i++)
    {
        ll a,b;
        cin>>a>>b;
        if(b<=t)
            st.insert(a);
    }
    if(st.size())
        cout<<*st.begin();
    else
        cout<<"TLE";
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定 setprecision()
#include <list> //前後に数値を入れれる配列
#include <map> //map
#include <vector> //vecror

#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = acos(-1); //円周率
ll mod = 1e9 + 7;


//提出コード↓

ll r;



int main() {
	cin >> r;

	cout << r * r * 3 << endl;
	return 0;
}



Measured memory_bytes: 256
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end


n,k = inp
p ov = small(n%k,k-n%k)

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a == b && b == c){
    cout << "1" << endl;
  }
  
  else if(a == b && b != c){
    cout << "2" << endl;
  }
  
  else if(a != b && b == c){
    cout << "2" << endl;
  }
  
  else if(a == c && a != b){
    cout << "2" << endl;
  }
  
  else{
    cout << "3" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scnr = new Scanner(System.in);
		int n = scnr.nextInt();
		int max = Integer.MIN_VALUE;
		int min = Integer.MAX_VALUE;
		for(int i = 0; i < n; i++) {
			int num = scnr.nextInt();
			if (num > max) {
				max = num;
			}
			if (num < min) {
				min = num;
			}
		}
		System.out.println(max - min);
	}
}

Measured memory_bytes: 22612
#include <stdio.h>
int main(void)
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if((a==b&&b==c)||(a!=c&&a!=b&&b!=c)){
        printf("No");
    }
    else
        printf("Yes");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
string s;
cin>>n>>s;
int ans=0;
for(int i=1;i<=n-1;i++)
{
set<char> x(s.begin(),s.begin()+i),y(s.begin()+i,s.end());
int t=0;
for(char c='a';c<='z';c++)
if(x.count(c)&&y.count(c))t++;
ans=max(ans,t);
}
cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;
static const int MAX = 200000;

int main(void) {
	
	int R[MAX],N = 0;

	cin >> N;

	for (int i = 0; i < N; i++) cin >> R[i];

	int maxv = -2000000000;
	int minv = R[0];

	for (int i = 1; i < N; i++) {
		maxv = max(maxv, R[i]-minv);
		minv = min(minv, R[i]);
	}

	cout << maxv << endl;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	long long int h[n];
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	sort(h, h+n);
	long long int ans = 0;
	for (int i = 0; i < n-k; i++) {
		ans += h[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
/*
	0533:Contest
*/
#include	<iostream>
#include	<queue>

using namespace std;

int main(void) {
	priority_queue<int> W;
	priority_queue<int> K;
	int WP, KP, tops[2][3];
	
	for(int i = 0; i < 10; i++) {
		int p;
		cin >> p;
		W.push( p );
	}
	for(int j = 0; j < 3; j++) {
		tops[0][j] = W.top();
		W.pop();
	}
	WP = tops[0][0] + tops[0][1] + tops[0][2];
	
	for(int i = 0; i < 10; i++) {
		int p;
		cin >> p;
		K.push( p );
	}
	for(int j = 0; j < 3; j++) {
		tops[1][j] = K.top();
		K.pop();
	}
	KP = tops[1][0] + tops[1][1] + tops[1][2];
	
	cout << WP << ' ' << KP << endl;
	
	return 0;
}

Measured memory_bytes: 1216
#include <cstdio>

using namespace std;

int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<=0&&b>=0)
        printf("Zero\n");
    else if(a>0)
        printf("Positive\n");
    else if(b<0)
    {
        int difference=b-a;
        if(difference%2==1)
            printf("Positive\n");
        else
            printf("Negative\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//解答例写し 
const int mod = 1000000007;
struct mint {
  long long x; // typedef long long ll;
  mint(long long x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint c(int n,int k){
  mint a=1,b=1;
  for(int i=0;i<k;i++){
    a*=n-i;
    b*=i+1;
  }
  return a/b;
}
void solve(){
  int n;
  cin>>n;
  n-=5;
  mint ans;
  for (int o=0;o<=11;o++){
    int m=n-o;
    if(m<0||m%2!=0)continue;
    ans+=c(m/2+15,15)*c(11,o);
  }
  cout<<ans<<endl;
}
int main(){
  int ts;
  cin>>ts;
  for(int ti=0;ti<ts;ti++){
    solve();
  }
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" << v[0]; FOR(i_debug, 1, v.size()){ cout << "," << v[i_debug]; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#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 Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

int main()
{
	ll a;
	string s;
	cin >> a >> s;
	if(a>=3200) cout<<s<<endl;
	else cout<<"red"<<endl;
	
	return 0;
}

Measured memory_bytes: 764
#include <stdio.h>
#include <stdlib.h>

int	compar(const void *a, const void *b)
{
	return *(int*)b - *(int*)a;
}

int main ()
{
	long N;
	long ans = 0;
	scanf("%ld", &N);
	long *A = malloc((1 + N) * sizeof(long));
	for (int i = 0; i < N; i++)
	{
		scanf("%ld", &A[i]);
	}
	qsort(A, N, sizeof(long), compar);

	ans = A[0];
	for (int i = 1; i < N - 1; i++)
	{
		if (i % 2 == 1)
			ans += A[i / 2 + 1];
		else
			ans += A[i / 2];
	}

	printf("%ld\n", ans);
	return (0);
}


Measured memory_bytes: 4640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int x, y, z, k;
    ll a[1003] = {}, b[1003] = {}, c[1003] = {}, l = 0, r = mod * 328ll;
    cin >> x >> y >> z >> k;
    for (int i = 0; i < x; i++) cin >> a[i];
    for (int i = 0; i < y; i++) cin >> b[i];
    for (int i = 0; i < z; i++) cin >> c[i];
    sort(a, a + x); sort(b, b + y); sort(c, c + z);
    a[x] = b[y] = c[z] = mod * 328ll;
    while (l + 1 < r) {
        ll m = (l + r) >> 1;
        int w = 0;
        for (int i = 0; i < x; i++) for (int j = 0; j < y; j++) if (a[i] + b[j] <= m) w += (int)(lower_bound(c, c + z + 1, m - a[i] - b[j] + 1) - c);
        if (x * y * z - w >= k) l = m;
        else r = m;
    }
    vector<ll> v;
    for (int i = 0; i < x; i++) for (int j = 0; j < y; j++) {
        int w = (int)(lower_bound(c, c + z + 1, r - a[i] - b[j]) - c);
        for (int k = w; k < z; k++) v.push_back(a[i] + b[j] + c[k]);
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    for (int i = 0; i < k; i++) cout << v[i] << '\n';
    return 0;
    int T;
    cin >> T;
    for (int U = 1; U <= T; U++) {
        cout << "Case #" << U << ": ";
        
    }
}


Measured memory_bytes: 133084
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline 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);
  // ABC068 C = Cat Snuke and a Voyage
  // N個の島、M種類の定期船、島aとbを行き来することが可能
  // 島Nへ定期船2つで移動したい（直接の定期船は存在しない）
  int N, M; cin >> N >> M;
  vector<vector<int> > I(N+1, vector<int>());
  REP(i, M){
    int a, b; cin >> a >> b;
    I[a].push_back(b);
    I[b].push_back(a);
  }
  REP(i, I[1].size()){
    REP(j, I[I[1][i]].size()){
      if(I[I[1][i]][j] == N){
        cout << "POSSIBLE" << endl;
        return 0;
      }
    }
  }
  cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 12016
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

#define forin(i, f, t) for(auto i = f; i < t; i++)

using namespace std;
using ll = long long;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (auto i = 0; i < n; i++)
        cin >> a[i];
    for (auto i = 0; i < n; i++)
        cin >> b[i];
    ll ans = 0;
    for (auto i = 0; i < 30; i++) {
        vector<ll> c(n), d(n);
        auto t = (1 << i);
        for (auto j = 0; j < n; j++) {
            c[j] = a[j] % (t * 2);
            d[j] = b[j] % (t * 2);
        }
        sort(d.begin(), d.end());
        ll num = 0;
        for (auto j = 0; j < n; j++) {
            if ((c[j] & t) == 0) {
                num += lower_bound(d.begin(), d.end(), (t * 2) - c[j]) - lower_bound(d.begin(), d.end(), t - c[j]);
            } else {
                num += n - (lower_bound(d.begin(), d.end(), (t * 2) - c[j]) - lower_bound(d.begin(), d.end(), (t * 3) - c[j]));
            }
        }
        ans += (num % 2) << i;
        cerr << ans << endl;
    }
    cout << ans;
}


Measured memory_bytes: 6552
#include<bits/stdc++.h>
using namespace std;
long long x,cnt=1;
map<long long,int>mp;
long long poww(long long x1)
{
	long long cn=1ll;
	for(int i=1;i<=5;i++)
		cn*=x1;
	return cn;
}
int main()
{
	cin>>x;
	for(long long i=-3000;i<=3000;i++)
	{
		mp[poww(i)]=i;
		if(poww(i)==x)
		{
			cout<<i<<" "<<0;
			return 0;
		}
	}
	for(long long i=-3000;i<=3000;i++)
		if(mp[x+poww(i)]!=0)
		{
			cout<<mp[x+poww(i)]<<" "<<i;
			return 0;
		}
	cout<<-1;
	return 0;
}


Measured memory_bytes: 4164
#include <iostream>
#include <vector>

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

int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n + 1);
  rep(i, n) std::cin >> a[i + 1];

  for (int i = 1; i <= n; ++i) {
    printf("node %d: key = %d, ", i, a[i]);
    int left = 2 * i;
    int right = left + 1;
    int parent = i / 2;
    if (parent >= 1) printf("parent key = %d, ", a[parent]);
    if (left <= n) printf("left key = %d, ", a[left]);
    if (right <= n) printf("right key = %d, ", a[right]);
    std::cout << '\n';
  }
  return 0;
}



Measured memory_bytes: 3120
#include<iostream>
main()
{
    int m1,m2,d1,d2,res[1];
    std::cin >> m1 >>d1;
    std::cin >> m2 >>d2;
    if(m1<=7 && m1!=2){
        if(m1%2==0){
            if(d1==30){
                res[0]=1;
            }
            else{res[0]=0;}
        }
        else{
            if(d1==31){
                res[0]=1;
            }
            else{res[0]=0;
            }
        }
    }
    else if(m1==2 && d1==28)
    {res[0]=1;}
    else if(m1>=8 && m1%2==0)
    {if(d1==31)
    {res[0]=1;
    }
    else{res[0]=0;}
    }
    else if(m1>=8 && m1%2!=0){
        if(d1==30){res[0]=1;}
        else{res[0]=0;}
    }
    std::cout << res[0];
}

Measured memory_bytes: 256
import numpy as np

def gcd(m,n):
    while (m % n != 0):
        n,m = m%n,n
    return(n)



n, X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x = np.array(x)
x = np.sort(x)
d = x[1:] - x[:-1]

g = d[0]
for i in range(1,n):
    g = gcd(g,d[i])
print(g)

Measured memory_bytes: 23092
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

#define MOD 1000000007LL

struct Combinations {

    long long mod;
    vector< long long > inv;
    vector< long long > fact;
    vector< long long > inv_fact;

    Combinations (int n, int m) : inv(n), fact(n), inv_fact(n), mod(m) {
        inv[1] = 1;
        for (long long i = 2; i < n; i++) {
            inv[i] = inv[mod%i] * (mod - mod / i) % mod;
        }
        fact[0] = inv_fact[0] = 1;
        for (long long i = 1; i < n; i++) {
            fact[i] = (fact[i-1] * i) % mod;
            inv_fact[i] = (inv_fact[i-1] * inv[i]) % mod;
        }
    }

    long long nPr(long long n, long long r) {
        if (n < r) return 0;
        return fact[n] * inv_fact[n-r] % mod;
    }

    long long nCr(long long n, long long r) {
        if (n < r) return 0;
        return nPr(n,r) * inv_fact[r] % mod;
    }

    long long nHr(long long n, long long r) {
        return nCr(n+r-1,r);
    }

};


int main() {

    Combinations inst(200010,MOD);

    ll n; cin >> n;
    vector<ll> a(n+1);
    REP(i,n+1) cin >> a[i];

    ll d = -1;
    set<ll> used;
    REP(i,a.size()) {
        if(used.find(a[i]) != used.end()) d = a[i];
        used.insert(a[i]);
    }

    ll l = -1, r = -1;
    REP(i,a.size()) {
        if(a[i] == d && l == -1) l = i;
        else if(a[i] == d && l != -1) r = i; 
    }

   // cout << l << " " << r << endl;

    for (ll i = 1; i <= n + 1; i++) {
        ll ans = inst.nCr(n+1,i) - inst.nCr(n-r+l,i-1) + MOD;
        ans %= MOD;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 11392
//#pragma comment(linker, "/STACK:102400000,102400000") 
#pragma warning(disable:4996)
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x33ffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 15;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);
ll po(ll a, ll b) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }

int f[maxn];
int idx(char x)
{
	if (x == 'N')
	{
		return 0;
	}
	else if (x == 'S')
	{
		return 1;
	}
	else if (x == 'W')
	{
		return 2;
	}
	else
	{
		return 3;
	}
}

int main()
{
	string res;
	cin >> res;
	memset(f, 0, sizeof(f));
	rep(i, 0, res.length())
	{
		f[idx(res[i])] = 1;
	}
	if (f[0] == f[1] && f[2] == f[3])
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
}


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

int main()
{
  int N,M,X,m[100],array[100];
  cin >> N >> M >> X;
  for(int i = 0;i < N;i++) array[i] = 0;
  for(int i = 0;i < M;i++){
    cin >> m[i];
    array[m[i]] = 1;
  }
  int sum1,sum2;
  sum1 = 0;
  sum2 = 0;

  for(int i = 0;i < X;i++){
    sum1 += array[i];
  }
  for(int i = X;i < N;i++){
    sum2 += array[i];
  }
  if(sum1 < sum2) cout << sum1 << endl;
  else cout << sum2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pii pair<ll,ll>
#define F first
#define S second
#define pb push_back
ll mod1=998244353;
ll mod2=(ll)1e9+7;
ll power(ll n,ll k,ll mod){ll ans=1; n=n%mod;while(k>0){if(k&1)ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans;}
struct triplet{ll a,b,c;};
bool operator < (const triplet &t1,const triplet &t2){if(t1.a<t2.a)return true;if(t1.a==t2.a && t1.b <t2.b)return true;if(t1.a==t2.a && t1.b ==t2.b && t1.c<t2.c)return true;return false;}

ll f[2002],invf[2002];
void fact()
{
    int n=2000;
    f[0]=1;invf[n+1]=1;
    for(int i=1;i<=n+1;i++)
        f[i]=(f[i-1]*i)%mod2;
    for(int i=n+1;i>=1;i--)
    {
        ll v=power(i,mod2-2,mod2);
        invf[n+1]=(v*invf[n+1])%mod2;
    }
    for(int i=n;i>=0;i--)
        invf[i]=(invf[i+1]*(i+1))%mod2;
}

long long C(ll n, ll k)
{
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return (f[n] * ((invf[k] * invf[n - k]) % mod2) )% mod2;
}
int main()
{
    fio;
    ll n,k;
    cin>>n>>k;
     ll x=n-k;
     fact();

    ll r=n-k;
    ll b=k;
    for(int i=1;i<=k;i++)
    {

        cout<<(C(r+1,i)*C(b-1,i-1))%mod2<<"\n";
    }
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){

    string a, b;
    cin >> a >> b;

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    
    if(string(a).compare(b) < 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;

}

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

int main()
{
    long int h;
    cin >> h;
    long int x=1;
    long int ans=0;
    while(x<=h){
        ans+=x;
        x*=2;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

struct Prime {
    int N;
    vector<bool> is_p;

    Prime(int _N) : N(_N), is_p(N + 1, true) {
        is_p[0] = is_p[1] = false;
        for (long long i = 2; i <= N; ++i) {
            if (is_p[i])
                for (long long j = i * i; j <= N; j += i)
                    is_p[j] = false;
        }
    }
    bool operator[](const int idx) const { return is_p[idx]; }
};

template<class T>
std::vector<std::pair<T, T>> PrimeFactorization(T n) {
    std::vector<std::pair<T, T>> pf;
    T m = n;
    for (T i = 2; i * i <= n; ++i) {
        if (m % i != 0) continue;
        T cnt = 0;
        while (m % i == 0) { ++cnt; m /= i; }
        pf.emplace_back(std::make_pair(i, cnt));
    }
    if (1 < m) pf.emplace_back(std::make_pair(m, 1));

    return pf;
}

inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

bool Check(const ll p, const ll n, const vector<ll> &a) {
    if (a[0] % p != 0) return false;
    for (ll s = 0; s <= min(n, p - 2); ++s) {
        ll sum = 0;
        for (ll x = s; x <= n; x += p - 1) sum += a[x];
        if (sum % p != 0) return false;
    }
    return true;
}

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

    ll n;
    cin >> n;

    vector<ll> a(n + 1);
    for (int i = n; 0 <= i; --i) cin >> a[i];

    Prime primes(n);
    set<ll> ans_p;
    for (ll p = 2; p <= n; ++p) {
        if (primes[p] && Check(p, n, a)) ans_p.insert(p);
    }

    auto pf = PrimeFactorization<ll>(abs(a[n]));
    for (auto it : pf) if (Check(it.first, n, a)) ans_p.insert(it.first);

    for (auto p : ans_p) cout << p << '\n';

    return 0;
}


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

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

ll dp[51][51][51 * 51];

int main() {
    int n, a;
    cin >> n >> a;
    int x[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> x[i];

    }
    dp[0][0][0] = 1;
    for (int i = 1; i <= n; i++) {
        dp[i][0][0] = 1;
        for (int j = 1; j <= i; j++) {
            for (int k = 0; k <= 50 * 50; k++) {
                if (k < x[i]) {
                    dp[i][j][k] = dp[i - 1][j][k];
                } else {
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]];
                }
            }
        }
    }
    
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += dp[n][i][i * a];
    }
    
    cout << ans << endl;
    
    
    return 0;
}

Measured memory_bytes: 51072
#include <bits/stdc++.h>
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << n / 2 + (n % 2 != 0) << endl;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "(";
  each (i, v) os << i << ",";
  os << ")";
  return os;
}

struct Acc {
  vector<lli> sum;
  Acc(vector<lli> v) {
    sum.push_back(0);
    each (i, v) {
      sum.push_back(sum.back() + i);
    }
  }
  lli query(lli begin, lli end) {
    return sum[end] - sum[begin];
  }
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m, q;
  while (cin >> n >> m >> q) {
    vector<lli> g[n];
    fill(g, g + n, vector<lli>(n, 0));

    for (int i = 0; i < m; ++i) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      ++g[a][b];
    }

    vector<Acc> v;
    for (int i = 0; i < n; ++i) {
      v.push_back(Acc(g[i]));
    }

    while (q--) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      lli sum = 0;
      for (int i = a; i <= b; ++i) {
        sum += v[i].query(a, b + 1);
      }
      cout << sum << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = acos(-1.0);
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define SORT(v) sort(ALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;

#define HOGE COUT("HOGE")

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
int main() {
    IN(int, n);
    VIN(int, a, n);
    SORT(a);
    int aja = (a[n-1]-a[0]+1)/2;
    COUT(aja);
}



Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define FORD(i,a,b) for(int i=(a);i>=b;i--)
#define FOR(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
using namespace std;
int main() {
	int a,b,c;
	cin>>a>>b>>c;
	c-=a-b;
	if(c>=0)cout<<c;
	else cout<<0;
	return 0;
}


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

int N;
long long A[100001], K;

int main(){
	long long cnt = 0;
	cin >> N >> K;
	for(int i = 0; i < N; i++){
		int a, b;
		cin >> a >> b;
		A[a] += b;
	}
	for(int i = 1; i < 100001; i++){
		cnt += A[i];
		if(cnt >= K){
			printf("%d\n", i);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 1024
#
# 8c
#
import sys


def main():
    A = "abcdefghijklmnopqrstuvwxyz"
    r = [0 for _ in range(26)]
    S = sys.stdin.read()

    for i in range(len(S)):
        for j in range(len(A)):
            if S[i].lower() == A[j]:
                r[j] += 1
                break
    for i in range(26):
        print(f"{A[i]} : {r[i]}")


if __name__ == '__main__':
    main()



Measured memory_bytes: 5580
#include<map>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int ln;
  string s[256],t,u;
  map<string,char> v;
  s['A']="00000";
  s['B']="00001";
  s['C']="00010";
  s['D']="00011";
  s['E']="00100";
  s['F']="00101";
  s['G']="00110";
  s['H']="00111";
  s['I']="01000";
  s['J']="01001";
  s['K']="01010";
  s['L']="01011";
  s['M']="01100";
  s['N']="01101";
  s['O']="01110";
  s['P']="01111";
  s['Q']="10000";
  s['R']="10001";
  s['S']="10010";
  s['T']="10011";
  s['U']="10100";
  s['V']="10101";
  s['W']="10110";
  s['X']="10111";
  s['Y']="11000";
  s['Z']="11001";
  s[' ']="11010";
  s['.']="11011";
  s[',']="11100";
  s['-']="11101";
  s['\'']="11110";
  s['?']="11111";
  v["101"]=' ';
  v["000000"]='\'';
  v["000011"]=',';
  v["10010001"]='-';
  v["010001"]='.';
  v["000001"]='?';
  v["100101"]='A';
  v["10011010"]='B';
  v["0101"]='C';
  v["0001"]='D';
  v["110"]='E';
  v["01001"]='F';
  v["10011011"]='G';
  v["010000"]='H';
  v["0111"]='I';
  v["10011000"]='J';
  v["0110"]='K';
  v["00100"]='L';
  v["10011001"]='M';
  v["10011110"]='N';
  v["00101"]='O';
  v["111"]='P';
  v["10011111"]='Q';
  v["1000"]='R';
  v["00110"]='S';
  v["00111"]='T';
  v["10011100"]='U';
  v["10011101"]='V';
  v["000010"]='W';
  v["10010010"]='X';
  v["10010011"]='Y';
  v["10010000"]='Z';
  while(getline(cin,t)){
    ln=t.length();
    u="";
    for(i=0;i<ln;i++)
      u+=s[(int)t[i]];
    ln=u.length();
    t="";
    for(i=0;i<ln;i=j){
      for(j=i+1;j<ln+1;j++){
	if(v.count(u.substr(i,j-i))){
	  t+=v[u.substr(i,j-i)];
	  break;
	}
      }
    }
    cout<<t<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);
 
 		long n =fr.nextLong() ,k =fr.nextLong() ,md =1000000007l ,i ,j ,ans =0l ;
 		for (; k<=n+1 ; ++k) {
 			i =(k*(k-1))/2l ;	j =k*(n + (n-k+1))/2l ;	j-=i ;	++j ;	j%=md ;
 			ans =(ans + j)%md ;
 		}
 		op.println(ans) ;
		op.flush();	op.close();
	}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br =new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st==null || (!st.hasMoreElements())) 
			{
				try
				{
					st =new StringTokenizer(br.readLine());
				}
				catch(IOException e)
				{
					e.printStackTrace();
				}
				
			}
			return st.nextToken();
		}

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next()) ;
		}
	}
}

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

using namespace std;
using ll = long long;

int INF = numeric_limits<int>::max() / 2;

vector<vector<pair<int, int> > > edge;//edge[i][j] firstがiからj番目のノード、secondがその重み
vector<int> d(100010,INF);
vector<int> go(100010, -1);

void dijkstra(int start){
    priority_queue<int, vector<int>, greater<int> > q;

    d[start] = 0;
    q.push(start);

    while(!q.empty()){
        int now = q.top();
        q.pop();
        for(int j = 0; j < edge[now].size(); j++){
            int next = edge[now][j].first;
            int nextd = d[now] + edge[now][j].second;
            if(nextd < d[next]){
                d[next] = nextd;
                q.push(next);
                go[next] = now;
            }
        }
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--;b--;
        edge.resize(n);
        edge[a].push_back(make_pair(b, 1));
        edge[b].push_back(make_pair(a, 1));
    }

    dijkstra(0);

    cout << "Yes" << endl;
    for(int i = 1; i < n; i++){
        cout << go[i]+1 << endl;
    }
}

Measured memory_bytes: 14376
// ------------------------------------
// Date:2018/ 3/11
// Problem:ABC 074 BichromeCells a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

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

  int N, A;
  cin >> N >> A;
  int ans = N * N - A;
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define ll long long 
# define skorost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 

using namespace std ;
 
ll z , o , ans ;

ll N = 1e4 + 15820 ;

int main(){ skorost ;

	int n , m ;

	cin >> n >> m ;

	for( int i = 0 ; i< n ; i ++ ){

		string s ;

		cin >> s ;

		cout << s << endl ;

		cout << s << endl ;

	}

}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define SUM(n) ((n)+1)*(n)/2
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7;

using namespace std;
using pii = pair<int,int>;

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

  int n, a[105];
  cin >> n;
  rep(i,n){
    cin >> a[i];
  }
  sort(a,a +n);
  cout << a[n-1] - a[0] << '\n';
  return 0;
}


Measured memory_bytes: 256