akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc100/tasks/abc100_c

N = read_a_int()
A = read_ints()
# 2で割れる個数をカウントすれば良い
ans = 0
for a in A:
    while a % 2 == 0:
        a //= 2
        ans += 1
print(ans)


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

int main(){
  int n, a, c = 0;
  cin >> n;
  vector<int> v;
  for(int i = 0; i < n; i++){
    c = 0;
    cin >> a;
    while(a % 2 == 0){
      c++;
      a = a / 2;
    }
    v.push_back(c);
  }
  sort(v.begin(), v.end());
  cout << v[0];
}

Measured memory_bytes: 3592
MOD = 10**9 + 7
N = gets.chomp.to_i
ans = 0

ONE = '1'.freeze
bits = Array.new(60, 0)

gets.chomp.split.each do |s|
  index = 0
  xxxx = s.to_i
  while xxxx > 0
    bits[index] += xxxx%2
    xxxx = xxxx >> 1
    index += 1
  end
end

s = N/2
bits.each_with_index do |val, i|
  ans = (ans + (1 << i)%MOD * (N - val) * val)%MOD
end

puts ans

Measured memory_bytes: 38020
def calc(l):
  t=0
  for ai,bi,ci,di in zip(a,b,c,d):
    if l[bi]-l[ai]==ci:
      t+=di
  return t

def dfs(l):
  if len(l)==n:
    return calc(l)
  res=0
  prev_last=0
  if len(l)>0:
    prev_last=l[-1]
  for v in range(prev_last,m):
    l.append(v)
    res=max(res,dfs(l))
    l.pop()
  return res

n,m,q=map(int,input().split())
a,b=[],[]
c,d=[],[]
for i in range(q):
  aa,bb,cc,dd=map(int,input().split())
  a.append(aa-1)
  b.append(bb-1)
  c.append(cc)
  d.append(dd)

print(dfs([]))




Measured memory_bytes: 9240
#include <stdio.h>
#include <stdlib.h>
#define ms_valtype int

//比較関数
int compare_ms(ms_valtype a, ms_valtype b){
	return a - b;
}

//昇順
void sort_sub(ms_valtype *origin, int left, int right, ms_valtype *tmp){
	if(right - left > 1){
		int i, j, k, half = (left + right) / 2;
		sort_sub(origin, left, half, tmp);
		sort_sub(origin, half, right, tmp);
		for(i = left; i < right; i++){
			tmp[i] = origin[i];
		}
		for(i = left, j = left, k = half; i < right; i++){
			if(k == right){
				origin[i] = tmp[j];
				j++;
			}
			else if(compare_ms(tmp[j], tmp[k]) <= 0 && j < half){
				origin[i] = tmp[j];
				j++;
			}
			else{
				origin[i] = tmp[k];
				k++;
			}
		}
	}
}

void sort(ms_valtype *origin, int N){
	ms_valtype *tmp = (ms_valtype *)malloc(sizeof(ms_valtype) * N);
	sort_sub(origin, 0, N, tmp);
	free(tmp);
}

int MOD(int a, int p){
	a %= p;
	return a >= 0 ? a : a + p;
}

int main(){
	int N, L, T, i;
	scanf("%d%d%d", &N, &L, &T);
	int *X = (int *)malloc(sizeof(int) * N);
	int *W = (int *)malloc(sizeof(int) * N);
	int fW1 = -1, W2num = 0;
	for(i = 0; i < N; i++){
		scanf("%d%d", &X[i], &W[i]);
		if(fW1 == -1 && W[i] == 1){
			fW1 = i;
		}
		if(W[i] == 2){
			W2num++;
		}
	}
	if(fW1 == -1){
		for(i = 0; i < N; i++){
			printf("%d\n", MOD(X[i] - T, L));
		}
		return 0;
	}
	int gap = X[fW1];
	int *X2 = (int *)malloc(sizeof(int) * N);
	int *W2 = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		X2[i] = MOD(X[MOD(i + fW1, N)] - gap, L);
		W2[i] = W[MOD(i + fW1, N)];
	}
	int *X3 = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		X3[i] = MOD(X2[i] + (W2[i] == 1 ? T : -T), L);
	}
	sort(X3, N);
	int encountcount = ((2 * T) / L) * W2num;
	for(i = 0; i < N; i++){
		if(W2[i] == 2 && X2[i] < MOD(2 * T, L)){
			encountcount++;
		}
	}
	int fW1will;
	for(i = 0; i < N; i++){
		if(X3[i] == MOD(T, L)){
			fW1will = i;
			break;
		}
	}
	int *ans = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		ans[MOD(i + fW1, N)] = MOD(X3[MOD(fW1will + i - encountcount, N)] + gap, L);
	}
	for(i = 0; i < N; i++){
		printf("%d\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 3448
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N, K;
  cin >> N >> K;
  vector<int> x(N);
  for(int i = 0; i < N; i++) {
    cin >> x.at(i);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (x.at(i) < K - x.at(i)) {
      ans += 2 * x.at(i);
    }
    else ans += 2 * (K-x.at(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main () {
    int N;
    cin >> N;
    vector<int> A(N), B;
    for (int &a : A) cin >> a;
    B = A;
    sort(B.rbegin(), B.rend());
    int mx = *max_element(B.begin(), B.end());
    for (int a : A) cout << ((a != mx) ? mx : B.at(1)) << "\n";
}

Measured memory_bytes: 3200
a,b=map(int,input().split())
s=list(input())

abc='0123456789'
ans='Yes'
for i in range(a):
    if s[i] not in abc:
        ans='No'
        break
if s[a]!='-':
    ans='No'

for i in range(a+1,a+b+1):
    if s[i] not in abc:
        ans='No'
        break
print(ans)
        
    

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;
typedef struct pair<int,int> P;
int p[1001]={};
int x[1001]={};
int y[1001]={};

int dp[9][(1<<8)]={};
vector<int> v;
int n,m,s;
int d[201][201];
int r[201]={};


//int calc(int s1,int d1){
//	if(dp[s1][d1]>0)return dp[s1][d1];
//	if(d1==(1<<s1))return 0;
//	int d2=d1-(1<<s1);
//	dp[s1][d1]=200000001;
//	for(int i=0;i<s;++i){
//		int k=(1<<i);
//		if((d2&k)==k)dp[s1][d1]=min(dp[s1][d1],d[r[s1]][r[i]]+calc(i,d2));
//	}
//	return dp[s1][d1];
//}
int main() {
	int x,a,b;
	cin>>x>>a>>b;
	if(abs(a-x)>abs(x-b)){
		cout<<"B"<<endl;
	}else{
		cout<<"A"<<endl;
	}
//	cout<<min(abs(a-x),abs(x-b))<<endl;
//	int a[100002]={};
//	int n;
//	cin>>n;
//	int a1;
//	for(int i=0;i<n;i++){
//		cin>>a1;
//		a[a1]++;
//		if(a1>0)a[a1-1]++;
//		a[a1+1]++;
//	}
//	int t=0;
//	int k=0;
//	for(int i=0;i<100002;i++){
//		if(t<a[i]){
//			t=a[i];
//			k=i;
//		}
//	}
//	cout<<t<<endl;
//
//	for(int i=0;i<201;++i){
//		for(int j=0;j<201;++j){
//			d[i][j]=200000001;
//		}
//	}
//	cin>>n>>m>>s;
//	bool flg=true;
//	int a,b,c;
//	int ct=0;;
//	for(int i=0;i<s;++i){
//		cin>>r[i];
//		ct+=(1<<i);
//	}
//	for(int i=0;i<m;++i){
//		cin>>a>>b>>c;
//		d[a][b]=c;
//		d[b][a]=c;
//	}
//	while(flg){
//		flg=false;
//		for(int i=1;i<n+1;++i){
//			for(int j=1;j<n+1;++j){
//				for(int k=1;k<n+1;++k){
//					if(d[i][j]>(d[i][k]+d[k][j])){
//						flg=true;
//						d[i][j]=d[i][k]+d[k][j];
//					}
//				}
//			}
//		}
//	}
//
//	int t=200000001;
//
//	for(int i=0;i<s;++i){
//		t=min(t,calc(i,ct));
//	}

//	cout<<max(x-t,0)<<endl;

	return 0;
}


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

#define int long long
#define double long double

using namespace std;

#define REP(i, a, b) for (int(i) = (a); i < (b); (i)++)
#define rep(i, n) REP(i, 0, n)
#define PER(i, a, b) for (int(i) = (a - 1); i >= (b); (i)--)
#define per(i, n) PER(i, n, 0)
#define each(i, n) for (auto &i : n)
#define clr(a) memset((a), 0, sizeof(a))
#define mclr(a) memset((a), -1, sizeof(a))
#define all(a) (a).begin(), (a).end()
#define dum(val) cerr << #val " = " << val;
#define dump(val) cerr << #val " = " << val << endl;
#define FILL(a, v) fill(a, a + sizeof(a) / sizeof(*a), v)

typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const int dx[8] = {+1, +0, -1, +0, +1, +1, -1, -1};
const int dy[8] = {+0, -1, +0, +1, -1, +1, -1, +1};
const int mod = 1e9 + 7;
const int INF = 1e9;

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

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

	deque<int> q;

	rep(i, n) {
		if (i % 2 == 0) {
			q.push_back(a[i]);
		} else {
			q.push_front(a[i]);
		}
	}

	rep(i, n) {
		if (n % 2 == 0) {
			cout << q[i] << " ";
		} else {
			cout << q[n - i - 1] << " ";
		}
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n,m,q;
  string a[100],b[100];
  cin>>n>>m;
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<m;i++) cin>>b[i];
  for(int i=0;i<=n-m;i++){
    for(int j=0;j<=n-m;j++){
      q=1;
      for(int k=0;k<m;k++){
        for(int l=0;l<m;l++){
          if(a[i+k][j+l]!=b[k][l]) q=0;
        }
      }
      if(q){
        cout<<"Yes\n";
        return 0;
      }
    }
  }
  cout<<"No\n";
}

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

int main()
{
    int n;
    cin>>n;
    int h[n], dp[n];
    for(int i=0;i<n;++i)
        cin>>h[i];
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=2;i<n;++i)
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 4328
//https://blog.csdn.net/hesorchen
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define mod 1000000007
int t[200005];
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> t[i];
    sort(t, t + n);
    for (int i = 1; i < n; i++)
        if (t[i] == t[i - 1])
            return !printf("NO\n");
    return !printf("YES\n");

    return 0;
}

Measured memory_bytes: 1024
import math
n = int(input())
A = [int(s) for s in input().split()]
i = 0
flag = 0
count = 0
sum = 0


def bynum(x):
  count = 0
  while True:
    if x % 2 == 0:
      x = x / 2
      count += 1
    else:
      return count

for a in A:
  sum += bynum(a)

print(sum)


    



"""
while i < len(A):
  if A[i] %2 == 0:
    flag = 0
    A[i] = A[i] /2
    count += 1
    i = 0
    
    continue
  else:
    flag += 1
    if flag == len(A):
      print(count)
      exit()
    i += 1
  """

  
  
  
    


Measured memory_bytes: 4148
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;

int main() {
    ll N;
    cin >> N;
    
    vector<ll> A(N + 1);
    // rep(i, N + 1) cin >> A[i];
    for (ll i = 0; i < N + 1; i++) {
        cin >> A[i];
    }

    if (N == 0) {
        if (A[0] == 1) cout << "1" << endl;
        else cout << "-1" << endl;
        return 0;
    }

    if (A[0] != 0) {
        cout << -1 << endl;
        return 0;
    }

    vector<ll> up(N + 1);
    ll inf = 10000000000000;

    up[0] = 1;
    for (ll i = 1; i <= N; i++) {
        up[i] = up[i - 1] * 2 - A[i];
        up[i] = min(up[i], inf);

        if (up[i] < 0 || (i < N && up[i] <= 0)) {
            cout << "-1" << endl;
            return 0;
        }
    }

    ll nw = 0;
    ll ans = 0;
    for (ll i = N; i >= 0; i--) {
        nw = min(nw, up[i]);
        nw += A[i];
        ans += nw;
    }

    cout << ans << endl;
}


Measured memory_bytes: 4780
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n >> k;
  string s;cin>>s;


  cout<<n*k<<endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	vector<int> l(n);
	for( auto &k : l ) cin >> k;
	sort( l.begin(), l.end() );
	ll ans = 0;
	for( int i = 0; i < n; ++i ){
		for( int j = i+1; j < n; ++j ){
			for( int k = j+1; k < n; ++k ){
				if( l[k] < l[i]+l[j] ) ++ans;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
static const int INF = 1145141919;
 
int main()
{
	int n;
	cin >> n;
	int h[100001];
	for (int i = 0; i < n; ++i)
	{
		cin >> h[i];
	}
	int dp[100001];
	for (int i = 0; i < n; ++i)
	{
		dp[i] = INF;
	}
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	for (int i = 2; i < n; ++i)
	{
		dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        if((a*b)%2==0){
            System.out.println("Even");
        }else{
            System.out.println("Odd");
        }
    }
}

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

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

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

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



signed main() {
	int q, h, s, d,n;
	cin >> q >> h >> s >> d >> n;
	h = min(h, q * 2);
	s = min(s, h * 2);
	d = min(d, s * 2);
	cout << n / 2 * d + n % 2 * s << endl;
}



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

int main()
{
    long long t=1,n,i,h,k,j,b1,b2,b3,u,v;
    //cin>>t;
    while(t--)
    {
        cin>>n;
        cout<<!n<<'\n';
    }
    return 0;
}


Measured memory_bytes: 3596
n = int(input())
p = list(map(int,input().split()))
cnt = 0
for i in range(1,n):
    minp = min(p[i-1:i+2])
    maxp = max(p[i-1:i+2])
    if p[i] != minp and p[i] != maxp:
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i< (int) n; i++)
 
 
int main () {
    int A,B;

    cin >> A >> B;

    int ans = 0;
    for(int i = A; i< B+1; i++){
        int s = i%10, t  = i/ 10000 % 10;
        int u = i /10 %10, v = i/1000 %10;
        if (s == t && u ==v) ans ++;
            
        }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;

// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

const int S = 0;
const int W = 1;
char i2c[2] = {'S', 'W'};

int animal[100010];

int next_animal(string &s, int i) {
  int m = s.size();
  char a = s[i+1];
  if (a == 'o' && animal[i+1] == S) return animal[(i+m)%m];
  if (a == 'x' && animal[i+1] == W) return animal[(i+m)%m];
  // a == 'o' && animal[i+1] == W
  // a == 'x' && animal[i+1] == S
  return 1-animal[(i+m)%m];
}

bool exists(string &s, int first, int second) {
  animal[0] = first;
  animal[1] = second;
  for (int i = 0; i < s.size()-2; ++i) { 
    animal[i+2] = next_animal(s, i);
  }
  if (next_animal(s, s.size()-2) != animal[0]) return false;
  if (next_animal(s, -1) != animal[1]) return false;
  return true;
}

void write(int n) {
  for (int i = 0; i < n; ++i) {
    cout << i2c[animal[i]];
  }
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  if (exists(s, S, S)) { write(n); return 0; }
  if (exists(s, S, W)) { write(n); return 0; }
  if (exists(s, W, W)) { write(n); return 0; }
  if (exists(s, W, S)) { write(n); return 0; }
  cout << "-1" << endl;
}



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

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

    int k;
    cin >> k;

    cout << k/2 * (k/2 + k%2) << endl;
}

Measured memory_bytes: 256
function filter_evens(numbers){
  return numbers.filter(x => x%2==0)
}

function main(input){
  const lines = input.split('\n');
  const N = parseInt(lines[0]);
  var As = lines[1].split(' ').map(x => parseInt(x));

  // Aの配列から偶数を取り出して、その個数を数える
  // 残った配列を2で割って、偶数をを数える、あとはこの繰り返し
  As = filter_evens(As);
  var result = As.length;
  while(As.length > 0){
    As = As.map(x => x/2).filter(x => !(x-Math.floor(x)>0));
    As = filter_evens(As);
    result += As.length;
  }

  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 14448
//#define _GLIBCXX_DEBUG
#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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int INF=1<<30;

const int MAX=200001; //nCrのnのMAX+1
ll fac[MAX],finv[MAX],inv[MAX];

void cominit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll com(int n,int k){
  if (n<k) return 0;
  if (n<0||k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
//Add cominit(); in main function.

struct mint{
  ll x;
  mint(ll 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{
    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*=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{
    mint res(*this);
    return res/=a;
  }
};

int main(){
  cominit();
  mint sum1=0;
  mint sum2=0;
  int N,K; cin >> N >> K;
  vector<ll> a(N);
  rep(i,N) cin >> a[i];
  sort(all(a));
  rep(i,N){
    sum1+=a[i]*com(i,K-1);
    sum2+=a[i]*com(N-1-i,K-1);
  }
  mint ans=sum1-sum2;
  cout << ans.x << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;
const double PI = acos(-1.0);

int N;
int a[100010];

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

    mem(a, 0);
    cin >> N;
    REP(i, N){
        int x;
        cin >> x;
        a[x]++;
        a[x+1]++;
        a[x-1]++;
    }
    int ans = -1;
    REP(i,100010){
        ans = ans < a[i] ? a[i] : ans;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    ll n;
    cin >> n;
    vector<ll> f1(n), f2(n);
    for(ll i = 0; i < n; i++){
        ll x, y;
        cin >> x >> y;
        f1[i] = (x - y);
        f2[i] = (x + y);
    }
    // cout << abs(f1mx-f1mi) << endl;
    // cout << abs(f2mx-f2mi) << endl;
    sort(f1.begin(), f1.end());
    sort(f2.begin(), f2.end());
    ll ans = max(abs(f1[0]-f1[n-1]), abs(f2[0]-f2[n-1]));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6424
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  map<int,bool> m;
  for(int i=0;i<n;i++){
    cin>>a[i];
    //奇数番目treu,偶数番目false
    if(i%2==0) m[a[i]]=true;
    else m[a[i]]=false;
  }
  sort(a.begin(),a.end());
  int t=0,f=0;
  for(int i=0;i<n;i++){
    if(i%2==0){
      if(!m[a[i]]) t++;
    }else{
      if(m[a[i]]) f++;
    }
  }
  cout<<max(t,f);
}

Measured memory_bytes: 5376
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 100000;
ll const MOD = 1000000007;

int main() {
    ll H, W;
    cin >> H >> W;
    vector<vector<char>> a(H, vector<char>(W, 0));
    rep(i, H) {
        rep(j, W) { cin >> a[i][j]; }
    }

    map<char, ll> cnt;

    rep(i, H) {
        rep(j, W) { cnt[a[i][j]]++; }
    }

    ll h_four = floor(H / 2) * floor(W / 2);
    rep(i, h_four) {
        repv(cnt) {
            char c = (*it).first;
            if ((*it).second >= 4) {
                (*it).second -= 4;
                break;
            }
        }
        // cout << "cnt: " << endl;
        // repv(cnt) cout << (*it).first << "," << (*it).second << endl;
    }

    if (H % 2 == 1) {
        ll h_two = floor(W / 2);
        rep(i, h_two) {
            repv(cnt) {
                char c = (*it).first;
                if ((*it).second >= 2) {
                    (*it).second -= 2;
                    break;
                }
            }
        }
        // cout << "cnt: " << endl;
        // repv(cnt) cout << (*it).first << "," << (*it).second << endl;
    }

    if (W % 2 == 1) {
        ll h_two = floor(H / 2);
        rep(i, h_two) {
            repv(cnt) {
                char c = (*it).first;
                if ((*it).second >= 2) {
                    (*it).second -= 2;
                    break;
                }
            }
        }
        // cout << "cnt: " << endl;
        // repv(cnt) cout << (*it).first << "," << (*it).second << endl;
    }

    if (H % 2 == 1 && W % 2 == 1) {
        repv(cnt) {
            char c = (*it).first;
            if ((*it).second >= 1) {
                (*it).second -= 1;
                break;
            }
        }
        // cout << "cnt: " << endl;
        // repv(cnt) cout << (*it).first << "," << (*it).second << endl;
    }

    bool flg = true;
    repv(cnt) {
        if ((*it).second != 0) {
            flg = false;
            break;
        }
    }

    if (flg) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    // cout << "cnt: " << endl;
    // repv(cnt) cout << (*it).first << "," << (*it).second << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define cmod 1000000007;
int main(){
    string S;
    cin>>S;
    vector<vector<long long>> dp(S.length()+1,vector<long long>(13,0));
    dp[0][0]=1;
    for(int i=0;i<S.length();i++){
        if(S[i]=='?'){
            for(int j=0;j<10;j++){
                for(int k=0;k<13;k++){
                    int temp=(k*10+j)%13;
                    dp[i+1][temp]+=dp[i][k];
                    dp[i+1][temp]=dp[i+1][temp]%cmod;
                }
            }
        }else{
            int temp2=S[i]-'0';
            for(int k=0;k<13;k++){
                    int temp=(k*10+temp2)%13;
                    dp[i+1][temp]+=dp[i][k];
                    dp[i+1][temp]=dp[i+1][temp]%cmod;
            }
        }
    }
    
    cout<<dp[S.length()][5]<<endl;
    return 0;
}

Measured memory_bytes: 13696
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli, lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v) {
    for (lli i=0;i<v.size();i++)
        cout<<v.at(i)<<endl;
}
int main() {
    cout << std::fixed << std::setprecision(10);
    string rec="";
    string s;
    string tmp="";
    cin>>s;
    lli ans=0;
    rep(i, s.size()) {
        tmp=tmp+s[i];
        if (tmp!=rec) {
            ans++;
            rec=tmp;
            tmp="";
        }
    }
    out(ans);
}

Measured memory_bytes: 3712
require 'set'

n, k = gets.strip.split.map(&:to_i)
td = readlines.map {|line| line.strip.split.map(&:to_i) }.sort_by(&:last).reverse

already_max = Set.new
td = td.map do |t, d|
  unless already_max.include?(t)
    already_max.add(t)
    [1, d]
  else
    [0, d]
  end
end

all = td.sort.sort_by(&:last).reverse
#p all

selected = all.take(k)
unselected = all[k...n]

mobile = []
in_result = 0
selected.each do |t, d|
  if !t.zero?
    in_result+=1
  else
    mobile.push([t, d])
  end
end

current_score = selected.map(&:last).inject(:+)

result = current_score + in_result**2

if n==k
  p result
  exit
end

#p selected
unselected.each do |t, d|
  next if t.zero?

  swap_target = mobile.pop
  break if swap_target.nil?
  current_score -= swap_target.last
  current_score += d
  in_result+=1
  current_result = current_score + in_result**2

  if current_result > result
#    p [result, current_result, [current_score, in_result**2], t,d, swap_target]
    result = current_result 
  end
end

p result



Measured memory_bytes: 30812
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout <<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";

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

template< class Abel > class BIT {
public:
  BIT() : N(0) {}
  // 以下[1, N]なので+1する必要がある(1-indexed)
  BIT(int n) : N(n), bit(N + 1, 0) {}
  BIT(int n, Abel init) : N(n), bit(N + 1, init) {}

  void add(int i, Abel x) {
    i++;
    // for (int t = ++i; t < N; t += t & -t) bit[t] += x;
    while (i <= N) { bit[i] += x; i += i & -i; }
  }

  Abel sum(int i) {
    Abel res = 0; int t = i;
    while (t > 0) {
      res += bit[t];
      t -= t & -t;
    }
    return res;
  }

  // [i, j)の半開区間
  Abel sum(int i, int j) {
    return sum(j) - sum(i);
  }

private:
  int N;
  vector< Abel > bit;
};

signed main() {
  INIT;

  VAR(int, n);
  VEC(int, a, n);

  if (n == 1) {
    OUT(a[0])BR;
    return 0;
  }
  
  auto check = [&](int x) {
    vector< int > b(n);
    REP(i, n) b[i] = (a[i] >= x) ? 1 : -1;

    vector< int > c(n + 1, n);
    REP(i, n) c[i + 1] = c[i] + b[i];

    BIT<int> bit(2 * n);

    int cnt = 0;
    RREP(i, n + 1) {
      cnt += bit.sum(c[i], 2 * n);
      bit.add(c[i], 1);
    }

    return cnt >= n * (n + 1) / 4;
  };
  
  int ok = 0, ng = 1e9 + 1;
  while (ng - ok > 1) {
    int mid = (ok + ng) / 2;
    if (check(mid)) ok = mid;
    else ng = mid;
  }
  OUT(ok)BR;
  return 0;
}


Measured memory_bytes: 4236
#include <stdio.h>

int main(void){

    int n;
    long long int sum = 0;
    long long int Num = 1000000007;
    scanf("%d", &n);

    long long int a[n];
    long long int s[n];

    for(int i = 0; i < n; i++){
        scanf("%lld", &a[i]);
        a[i] %= Num;
    }
    s[n-1] = a[n-1];

    for(int i = n-2; i >= 0; i--){
        s[i] = s[i+1] + a[i];
        s[i] %= Num;
    }


    for(int i = 0; i < n-1; i++){
        sum += (a[i] * s[i+1]);
        sum %= Num;
    }

    printf("%lld", sum);

}



Measured memory_bytes: 5264
#include <stdio.h>

void call(int n){
	int i = 1;
	do{
		int x = i;
		if ( x % 3 == 0 ){
			printf(" %d", i);
			continue;
		}
		while(1){
			if ( x % 10 == 3 ){
				printf(" %d", i);
				break;
			}
			x /= 10;
			if (!x) break;
		}
	}while( ++i <= n );
	puts("");
}
int main(){
	int n;
	scanf("%d", &n);
	call(n);
	return 0;
}

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

#define MOD 1000000007

vector<string> node;
vector<int> edge[1005];

// now:現在見てるノードの番地
long long dfs(int now){
  long long rec = 0;
  if(edge[now].size() == 0){
    if(node[now] == "E?"){
      return 2;
    }else{
      return 1;
    }
  }else if(node[now] == "E"){
    // 必ず選ぶ
    rec = 1;
    for(int i = 0;i < edge[now].size();++i){
      rec = (rec * dfs(edge[now][i])) % MOD;
    }
  }else if(node[now] == "E?"){
    // 選ぶかどうかは任意
    rec = 1;
    for(int i = 0;i < edge[now].size();++i){
      rec = (rec * dfs(edge[now][i])) % MOD;
    }
    rec++;
  }else if(node[now][0] == 'R'){
    int temp;
    rec = 1;
    for(int i = 0;i < edge[now].size();++i){
      temp = dfs(edge[now][i]);
      rec = (rec * (temp + 1)) % MOD;
    }
    if(node[now] != "R?") --rec;
    if(rec < 0) rec = MOD - 1;
  }else if(node[now][0] == 'A'){
    for(int i = 0;i < edge[now].size();++i){
      rec = (rec + dfs(edge[now][i])) % MOD;
    }
    if(node[now] == "A?") ++rec;
  }

  //cout << rec % MOD << endl;
  return rec % MOD;
}

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

  int n;
  cin >> n;

  string temp;
  for(int i = 0;i < n;++i){
    cin >> temp;
    node.push_back(temp);
  }

  int s, t;
  for(int i = 0;i < n - 1;++i){
    cin >> s >> t;
    --s; --t;
    edge[s].push_back(t);
  }

  cout << dfs(0) << endl;

  return 0;
}



Measured memory_bytes: 3284
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int n,m,k;
    cin>>n>>m>>k;
    vector<int> a(n);
    vector<int> p1,p2;
    int sum = 0;
    p1.pb(0);
    rep(i,0,a.size()){
        cin>>a[i];
        sum += a[i];
        p1.pb(sum);
    }
    sum = 0;
    vector<int> b(m);
    rep(i,0,b.size()){
        cin>>b[i];
        sum += b[i];
        p2.pb(sum);
    }
    int ans = 0;
    rep(i,0,p1.size()){
        int c = i;
        int x = k - p1[i];
        if ( x < 0 ){
            break;
        }
        else{
            auto v = upper_bound(all(p2),x);
            c += (v - p2.begin());
        }

        ans = max(ans,c);
    }

    cout<<ans<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 11072
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
const int MAX = 100005;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
    a[i]--;
  }
  vector<int> id(n);
  rep(i,n) id[a[i]] = i;
  set<int> s;
  ll ans = 0;
  for(int x = n-1;x >= 0;--x){
    int i = id[x];
    ll c = 0;
    s.insert(i);
    vector<int> l(2,-1);
    vector<int> r(2,n);
    auto it = s.find(i);
    auto itr = s.find(i);
    rep(j,2){
      if(it == s.begin()) break;
      --it;
      l[j] = *it;
    }
    rep(j,2){
      ++itr;
      if(itr == s.end()) break;
      r[j] = *itr;
    }
    int ld_0 = i-l[0]; 
    int ld_1 = l[0]-l[1];
    int rd_0 = r[0]-i;
    int rd_1 = r[1]-r[0];
    c = (ll)rd_1*ld_0 + (ll)ld_1*rd_0;
    ans += c*(x+1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int TEN(int n) {return (n==0)?1:10*TEN(n-1);}

template<class T>
T pow(T x, ll n) {
    T r = 1;
    while (n) {
        if (n & 1) r *= x;
        x *= x;
        n >>= 1;
    }
    return r;
}

template<uint MD>
struct ModInt {
    uint v;
    ModInt() : v{0} {}
    ModInt(ll v) : v{normS(v%MD+MD)} {}
    static uint normS(const uint &x) {return (x<MD)?x:x-MD;};
    static ModInt make(const uint &x) {ModInt m; m.v = x; return m;}
    const ModInt operator+(const ModInt &r) const {return make(normS(v+r.v));}
    const ModInt operator-(const ModInt &r) const {return make(normS(v+normS(MD-r.v)));}
    const ModInt operator*(const ModInt &r) const {return make((ull)v*r.v%MD);}
    ModInt& operator+=(const ModInt &r) {return *this=*this+r;}
    ModInt& operator-=(const ModInt &r) {return *this=*this-r;}
    ModInt& operator*=(const ModInt &r) {return *this=*this*r;}
    static ModInt inv(const ModInt &x) {
        return pow(ModInt(x), MD-2);
    }
};

using Mint = ModInt<TEN(9)+7>;
const int MN = 440;
int N, C;
int a[MN], b[MN];
Mint psm[MN][MN];

void first() {
    for (int i = 0; i < MN; i++) {
        psm[i][0] = 0;
        for (int j = 0; j < MN-1; j++) {
            psm[i][j+1] = psm[i][j] + pow(Mint(j), i);
        }
    }    
}

Mint dp[MN][MN];
bool used[MN][MN] = {};
Mint calc(int n, int c) {
    if (n == N) {
        if (c == 0) return 1;
        return 0;
    }
    if (used[n][c]) return dp[n][c];
    used[n][c] = true;
    Mint ans = 0;
    for (int i = 0; i <= c; i++) {
        ans += calc(n+1, c-i)*(psm[i][b[n]]-psm[i][a[n]]);
    }
    return dp[n][c] = ans;
}

int main() {
    first();
    cin >> N >> C;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> b[i]; b[i]++;
    }
    cout << calc(0, C).v << endl;
    return 0;
}

Measured memory_bytes: 1920
import java.util.*;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		long money = 100000;
		
		for(int i=1; i<=n; i++){
			money = (long) (money*1.05);
			if(money % 1000 != 0)
				money = money - money%1000 +1000 ; 
				
		}
		
		System.out.println(money);

	}

}

Measured memory_bytes: 11000
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
	static final long MOD = 1000000007L;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		
		int N = sc.ni();
		int[] nums = new int[N];
		for (int i = 0; i < N; i++)
			nums[i] = sc.ni();
		Arrays.sort(nums);
		int ans = 0;
		for (int i = 0; i < N; i++) {
			for (int j = i+1; j < N; j++) {
				for (int k = j+1; k < N; k++) {
					if (nums[i] != nums[j] && nums[j] != nums[k] && nums[k] < nums[i]+nums[j])
						ans++;
				}
			}
		}
		pw.println(ans);
		pw.close();
	}
	
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            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(); 
        }
        
        int ni() { 
            return Integer.parseInt(next()); 
        }
  
        long nl() { 
            return Long.parseLong(next()); 
        } 
  
        double nd() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() {
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str;
        }
    }
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

ll powMod(ll a, ll b) {
    ll ans = 1;
    while (b > 0) {
        if (b & 1) ans = ans * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return ans;
}
ll modinv(ll a) {
    return powMod(a, MOD - 2);
}
ll nCkMod(int n, int r) {
    ll N = 1;
    ll K = 1;
    for (ll i = n; i > (n - r); i--) {
        N *= i;
        N %= MOD;
    }
    for (ll i = 1; i <= r; i++) {
        K *= i;
        K %= MOD;
    }
    return (N * modinv(K)) % MOD;
}
int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n, a, b;
    cin >> n;
    cin >> a >> b;
    ll res = powMod(2, n) - 1;
    res += MOD;
    res -= nCkMod(n, a);
    res -= nCkMod(n, b);
    while (res < 0) res += MOD;
    cout << res % MOD << endl;

    return 0;
}


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

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

int res[ma];
bool isp[ma];
int main(void){
	int i, j, n, m;
	rep(i, ma){
		res[i] = 1;
		isp[i] = true;
	}
	isp[0] = false; isp[1] = false; res[0] = 0;
	for(int i = 2;i < ma;++i){
		if(!isp[i])continue;
		for(j = i + i;j < ma;j+=i)isp[j] = false;
		if(i > 5){
			for(j = i;j < ma;j+=i)res[j] = 0;
		}
	}
	rep(i, ma - 1)res[i + 1] += res[i];

	for(;;){
		scanf("%d%d", &m, &n);
		if(m == 0)break;
		printf("%d\n", res[n] - res[m - 1]);
	}
}

Measured memory_bytes: 8016
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			String input[] = br.readLine().split("\\s+");

			BigInteger A = new BigInteger(input[0]);
			BigInteger B = new BigInteger(input[1]);

			BigInteger ans[] = A.divideAndRemainder(B);

			System.out.println(ans[1]);

		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}
}




Measured memory_bytes: 25140
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
vector<pi>ret;
int main(){
	bool pos = false;
	bool neg = false;
	int n;
	cin>>n;
	long long arr[n];
	for(int i=0; i<n; i++){
		cin>>arr[i];
		if(arr[i]>0) pos = true;
		else if(arr[i]<0) neg = true;
	}	
	if(pos && neg){
		long long mn = *min_element(arr,arr+n);
		long long mx = *max_element(arr,arr+n);
		if(abs(mx)>=abs(mn)){ //양수가 더 힘이 세다면 
			int index;
			for(int i=0; i<n; i++){
				if(arr[i]==mx){
					index = i;
					break;
				}
			}
			cout<<2*n-1<<'\n';
			for(int i=1; i<=n; i++) cout<<index+1<<" "<<i<<'\n';
			for(int i=1; i<n; i++) cout<<i<<" "<<i+1<<'\n';
		}
		else{
			int index;
			for(int i=0; i<n; i++){
				if(arr[i]==mn){
					index = i;
					break;
				}
			}
			cout<<2*n-1<<'\n';
			for(int i=1; i<=n; i++) cout<<index+1<<" "<<i<<'\n';
			for(int i=n; i>1; i--) cout<<i<<" "<<i-1<<'\n';
		}
	}
	if(pos && !neg){
		cout<<n-1<<'\n';
		for(int i=0; i<n-1; i++) cout<<i+1<<" "<<i+2<<'\n';
	}
	if(!pos && neg){
		cout<<n-1<<'\n';
		for(int i=n-1; i>0; i--) cout<<i+1<<" "<<i<<'\n';
	}
	if(!pos && !neg){
		cout<<0;
	}
}

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

vector<ll> G[200009];
ll c[200009];

void dfs(ll u, ll p) {
	c[u] += c[p];
	for(auto v : G[u])
		if(v != p)
			dfs(v, u);
}

int main() {
	ll n, q, u, v;
	cin >> n >> q;

	for(int i = 1; i < n; ++i) {
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}

	while(q--) {
		cin >> u >> v;
		c[u] += v;
	}

	dfs(1, 0);

	cout << c[1];
	for(int i = 2; i <= n; ++i)
		cout << " " << c[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 24320
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/28 16:29:01 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

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

// TOP
void	Main()
{
	int	k, s;
	cin >> k >> s;

	int cnt;
	cnt = 0;
	for (int i = max(s - 2 * k, 0); i <= s && i < k + 1; i++)
	{
		for (int j = max(s - 2 * k, 0); i + j <= s && j < k + 1; j++)
		{
			int	x;
			x = s - (i + j);
			if (x >= 0 && x < k + 1)
				cnt++;
		}
	}
	cout << cnt << endl;
}
// END

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


Measured memory_bytes: 256
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){e.exports=function(e){for(var r=e.split("\n"),t=Number(r[0]),n=0,o=0,u=0,i=0;i<t;i++){var f=Number(r[i+1]);f>o&&(o=f),f>n&&(o=n,n=f,u=i)}for(var l=0;l<t;l++)l==u?console.log(o):console.log(n)}},function(e,r){e.exports=require("fs")}]);

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

int main() {
  int n;
 cin >> n;
  vector<int> vec(n+1);

for(int i=1;i<n+1;i++) cin>>vec.at(i);
int j=1;
vector<int> s(n+1);
for(int i=1;i<n+1;i++){
  if(vec.at(j)==2){
      cout<<i<<endl; break;
    }
    else{
      if(s.at(vec.at(j))==1){
        cout<<"-1"<<endl; break;
      }
      else{
          s.at(vec.at(j))=1;
      }
    }
  j=vec.at(j);
}
}

Measured memory_bytes: 1024