akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<cctype>
#include<cstring>
#include<functional>

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define debug(...) fprintf(stderr,__VA_ARGS__)

using namespace std;


inline char nc(){ static char buf[100000] , *p1,*p2 ; return p1 == p2 && (p2 = (p1 = buf) + fread(buf,1,100000,stdin),p1 == p2) ? EOF : *p1++;}
template<class T>inline void rd(T & x){ x = 0;char ch = nc();for(;!isdigit(ch);ch = nc());for(;isdigit(ch);ch = nc()) x = x * 10 - 48 + ch;}

const int maxn = 1e5 + 10;

typedef pair<int,int> pii;
typedef long long ll;
int a[maxn] ,b[maxn];
bool used[maxn];
pii xa[maxn * 2];
int main(){
	int n;
	ll sum = 0,suma = 0,sumb = 0,res = 0,cnt = 0, halfSum = 0;
	rd(n);
	for(int i = 1;i <= n;i++){
		rd(a[i]);rd(b[i]);
		sum += a[i] + b[i];
		suma += a[i];
		sumb += b[i];
		xa[++cnt] = mp(a[i],i);
		xa[++cnt] = mp(b[i],i);
	}
	res = max(suma,sumb);
	sort(xa + 1,xa + cnt + 1,greater<pii>() );
	bool hasTwo = 0;
	for(int i = 1;i <= n;i++){
		if(used[xa[i].Y]) hasTwo = 1;
		halfSum += xa[i].X;
		used[xa[i].Y] = 1;
	}
	if(hasTwo){
		res = max(res,halfSum);
	} else {
		for(int i = n + 1;i <= n * 2;i++){
			if(xa[n].Y == xa[i].Y){
				res = max(res,halfSum + xa[i].X - xa[n - 1].X);
			} else {
				res = max(res,halfSum + xa[i].X - xa[n].X);
			}
		}
	}
	printf("%lld\n",sum - res);
	return 0;
} 

Measured memory_bytes: 2688
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

struct Ring{
    vector<int> s;
    bool kaku;
    
    void clear(){
        s.clear();
        kaku=false;
    }
}ring[101];

int bfs(int now){
    int re=0;
    
    ring[now].kaku=true;
    for(int i=0;i<ring[now].s.size();i++){
        if(!ring[ring[now].s[i]].kaku){
            re=max(bfs(ring[now].s[i]),re);
        }
    }
    ring[now].kaku=false;
    return re+1;
}

int solve(int n){
    int a,b,ans=0;
    
    for(int i=1;i<=100;i++){
        ring[i].clear();
    }
    
    
    for(int i=0;i<n;i++){
        scanf("%d%d",&a,&b);
        ring[a].s.push_back(b);
        ring[b].s.push_back(a);
    }
    
    for(int i=1;i<=100;i++){
        if(!ring[i].kaku){
            ans=max(bfs(i),ans);
        }
        for(int i=1;i<=100;i++){
            ring[i].kaku=false;
        }
    }
    
    printf("%d\n",ans);
    
    return 0;
}

int main(){
    int n;
    while(1){
        scanf("%d",&n);
        if(n==0) break;
        solve(n);
    }
    return 0;
}

Measured memory_bytes: 1216
def wczytaj_liste():
    ciag = input()
    rozdzielona_lista = ciag.split()
    odp = []
    for wyraz in rozdzielona_lista:
        liczba = int(wyraz)
        odp.append(liczba)
    return odp

def C():
    N, K = wczytaj_liste()
    zycie_monsterow = wczytaj_liste()
    zycie_monsterow.sort()
    ilosc_monsterow = N-K
    if ilosc_monsterow <= 0:
        print(0)
    else:
        print(sum(zycie_monsterow[:ilosc_monsterow]))

C()

Measured memory_bytes: 89036
#include <bits/stdc++.h>
#include <math.h>
#include<map>
#include<algorithm>
using namespace std;
typedef long long int ll;
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 all(a)  (a).begin(),(a).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define vll vector<ll>
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i]>>y[i];
const ll INF =1LL << 62;
int main(){
  int A,B,C,D,E;
  cin >> A >> B >> C >> D >> E;
  int a=0,b=0,c=0,d=0,e=0;
  if(A%10 ==0)a+=10;
  if(B%10 ==0)b+=10;
  if(C%10 ==0)c+=10;
  if(D%10 ==0)d+=10;
  if(E%10 ==0)e+=10;
  int ans =min({A+(B-B%10+10)+(C-C%10+10)+(D-D%10+10)+(E-E%10+10)-b-c-d-e,
                B+(A-A%10+10)+(C-C%10+10)+(D-D%10+10)+(E-E%10+10)-a-c-d-e,
                C+(B-B%10+10)+(A-A%10+10)+(D-D%10+10)+(E-E%10+10)-a-b-d-e,
                D+(B-B%10+10)+(C-C%10+10)+(A-A%10+10)+(E-E%10+10)-a-b-c-e,
                E+(B-B%10+10)+(C-C%10+10)+(D-D%10+10)+(A-A%10+10)-a-b-c-d});
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int H,W;
    int h,w;
    cin>>H>>W>>h>>w;
    cout<<(H-h)*(W-w)<<endl;
    return 0;
}

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

using namespace std;

#define uint unsigned int

#define REP(i, lim) for(int i=0; i<lim; i++)

#define MOD (1000000007)

int main(){
    string S;
    cin >> S;
    uint l = S.length();
    uint dp[100000][4] = {};

    REP(i, l)
        dp[i][0] = 1;
    for(int i = 0; i < l; i++){
        switch(S[i]){
            case 'A':
                dp[i+1][0] = dp[i][0]; 
                dp[i+1][1] = (dp[i][0] + dp[i][1]) % MOD; 
                dp[i+1][2] = dp[i][2]; 
                dp[i+1][3] = dp[i][3]; 
                break;
            case 'B':
                dp[i+1][0] = dp[i][0]; 
                dp[i+1][1] = dp[i][1]; 
                dp[i+1][2] = (dp[i][1] + dp[i][2] ) %MOD; 
                dp[i+1][3] = dp[i][3]; 
                break;
            case 'C':
                dp[i+1][0] = dp[i][0]; 
                dp[i+1][1] = dp[i][1]; 
                dp[i+1][2] = dp[i][2]; 
                dp[i+1][3] = (dp[i][2] + dp[i][3]) % MOD; 
                break;
            case '?':
                dp[i+1][0] = (3*dp[i][0]) % MOD; 
                dp[i+1][1] = (dp[i][0] + 3*dp[i][1]) % MOD; 
                dp[i+1][2] = (dp[i][1] + 3*dp[i][2]) % MOD; 
                dp[i+1][3] = (3*dp[i][3] + dp[i][2]) % MOD; 
                break;
            default:
                cout << "error : " << S[i] <<endl;
        }
    }
    //REP(i,l+1){
    //    printf("%04d %04d %04d %04d\n", dp[i][0], dp[i][1], dp[i][2], dp[i][3]);
    //}

    cout << dp[l][3] << endl;
    return 0;
}


Measured memory_bytes: 2048
//ABC112 A-PROGRAMMINNG EDUCATION
#include<bits/stdc++.h>
using namespace std;
 int main(){
     int N;cin >> N;
     if(N ==  1){
         cout << "Hello World" << endl;
     }
     else if(N == 2){
         int A,B; cin >> A >> B;
         cout << A + B << endl;
     }
     return 0;
 }

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define PI 3.141592653589
 
int main()
{
    double r,S,l ;
 
    cin >>  r ;
 
    S = (r * r) * PI;
    l = (2.0 * r) * PI ;
     
    cout << fixed  << S << ' ' << fixed << l << endl; 
 
    return 0;
}

Measured memory_bytes: 3236
N,K= map(int,input().split())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
n = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

# a = cmb(n,r,mod)

for i in range(K):
    if i== 0:
        a = 1
    else:
        a = cmb(K-1,i,mod)
    
    b = cmb(2+i+N-K-i-1,N-K-i,mod)
    

    ans = a*b%mod
    print(ans)



Measured memory_bytes: 4716
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int a = Integer.parseInt(scan.next());
		int b = Integer.parseInt(scan.next());
		int c = Integer.parseInt(scan.next());
		
		int maxNum;
		int minNum;
		if(a > b){
			maxNum = a;
			minNum = b;
		} else {
			maxNum = b;
			minNum = a;
		}
		
		int result;
		if(maxNum > c){
			result = maxNum * 10 + minNum + c;
		} else {
			result = c * 10 + maxNum + minNum;
		}
		scan.close();
		
		System.out.print(result);
	}
}

Measured memory_bytes: 21716
#include<stdio.h>
#define ARRAY_MAX 50
#define COUNT_RESET 0
#define RETURN 0
#define ARRAY_END -1
#define TEST_ABSENT -1
#define BORDER_A 80
#define BORDER_B 65
#define BORDER_C 50
#define BORDER_D 30

struct test_result{
    signed short ssW_D_mid;
    signed short ssW_D_fin;
    signed short ssW_D_re;
    unsigned char ubW_D_eval;
};

unsigned char s_EVALUATE(struct test_result test);

int main(){
    struct test_result test[ARRAY_MAX];
    unsigned short usW_C_i;
    unsigned short usW_C_count = COUNT_RESET;

    for(usW_C_i = COUNT_RESET;usW_C_i < ARRAY_MAX;usW_C_i++){
        scanf("%d %d %d", &test[usW_C_i].ssW_D_mid, &test[usW_C_i].ssW_D_fin, &test[usW_C_i].ssW_D_re);
        if(test[usW_C_i].ssW_D_mid == ARRAY_END && test[usW_C_i].ssW_D_fin == ARRAY_END && test[usW_C_i].ssW_D_re == ARRAY_END){
            break;
        }
        test[usW_C_i].ubW_D_eval = s_EVALUATE(test[usW_C_i]);
        usW_C_count++;
    }

    for(usW_C_i = COUNT_RESET;usW_C_i < usW_C_count;usW_C_i++){
        printf("%c\n", test[usW_C_i].ubW_D_eval);
    }

    return RETURN;
}

unsigned char s_EVALUATE(struct test_result test){
    signed short ssW_D_sum;
    unsigned char ubW_D_result;

    ssW_D_sum = test.ssW_D_mid + test.ssW_D_fin;

    if(test.ssW_D_mid == TEST_ABSENT || test.ssW_D_fin == TEST_ABSENT){
        ubW_D_result = 'F';
    }
    else if(ssW_D_sum >= BORDER_A){
        ubW_D_result = 'A';
    }
    else if(ssW_D_sum >= BORDER_B){
        ubW_D_result = 'B';
    }
    else if(ssW_D_sum >= BORDER_C){
        ubW_D_result = 'C';
    }
    else if(ssW_D_sum >= BORDER_D){
        if(test.ssW_D_re >= BORDER_C){
            ubW_D_result = 'C';
        }
        else{
            ubW_D_result = 'D';
        }
    }
    else{
        ubW_D_result = 'F';
    }

    return ubW_D_result;
}


Measured memory_bytes: 2040
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		final int NUMBER = 753;
		int ans = Integer.MAX_VALUE;
		for(int i = 0; i <s.length()-2;i++) {
			int temp = Integer.parseInt(s.substring(i,i+3));
			if(Math.abs(NUMBER-temp)<ans) {
				ans = Math.abs(NUMBER-temp);
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23636
def main():
    h, w, *a = map(int, open(0).read().split())

    cnt = 0
    ans = ''
    for k in range(h * w):
        i, j = divmod(k, w)

        if a[k] % 2 == 0:
            continue
        if j != w - 1:
            cnt += 1
            a[k + 1] += 1
            ans += '{0} {1} {2} {3}\n'.format(i + 1, j + 1, i + 1, j + 2)
        elif i != h - 1:
            cnt += 1
            a[k + w] += 1
            ans += '{0} {1} {2} {3}\n'.format(i + +2, j + 1, i + 1, j + 1)
        else:
            pass
    print(cnt)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 12408
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF  2000000000
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
#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;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d); BR;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
#define SUM(a, n) accumulate(a, a+n, 0)
#define VSUM(v) accumulate(ALL(v), 0);
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

string sum(string a, string b){
    reverse(ALL(a));
    reverse(ALL(b));

    string ans = "";
    if(a.size() > 80 || b.size() > 80) return "overflow";
    int t = 0;
    REP(k, max(a.size(), b.size())){
        int i = k < a.size() ? a[k] - '0' : 0;
        int j = k < b.size() ? b[k] - '0' : 0;
        int sum = i + j + t;
        ans += (char)(sum%10 + '0');
        t = sum / 10;
    }
    if(t) ans += (char)(t + '0');
    if(ans.size() > 80) return "overflow";
    reverse(ALL(ans));
    return ans;
}

signed main(){ INIT;
    VAR(int, n);
    REP(i, n){
        VAR(string, a, b);
        OUTL(sum(a, b));
    }
RET;}

Measured memory_bytes: 3028
n = int(input())
raw = []
for _ in range(n):
  now = input()
  add = []
  for j in range(len(now)):
    add.append(now[j])
  raw.append(add)
abc = 'qwertyuiopasdfghjklzxcvbnm'
ABC = []
for j in range(26):
  ABC.append(abc[j])
ABC.sort()
ans = ''
for j in range(26):
  use = ABC[j]
  here = []
  for i in range(n):
    here.append(raw[i].count(use))
  ans += use * min(here)
print(ans)

Measured memory_bytes: 3064
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int main() {
	int n;
	cin >> n;
	LL ans = 0;
	vector<int>a(n);
	for (int i = 0; i < n; i++)  cin >> a[i];
	sort(ALL(a));
	vector<int>b(n);
	for (int i = 0; i < n; i++)  cin >> b[i];
	sort(ALL(b));
	for (int v = 28; v >= 0; v--) {
		LL cnt = 0;
		for (int i = 0; i < n; i++) b[i] %= (1 << (v + 1));
		sort(ALL(b));
		for (int i = 0; i < n; i++) {
			if (a[i] & (1 << v)) {
				LL it = a[i] % (1 << (v + 1));
				cnt += n;
				cnt -= lower_bound(ALL(b), (1 << (v + 1)) + (1 << v) - it) - b.begin();
				cnt += lower_bound(ALL(b), (1 << (v + 1)) - it) - b.begin();
			}
			else {
				LL it = a[i] % (1 << (v + 1));
				cnt += lower_bound(ALL(b), (1 << (v + 1)) - it) - b.begin();
				cnt -= lower_bound(ALL(b), (1 << v) - it) - b.begin();
			}
		}
		if (cnt & 1)  ans += (1 << v);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
struct node{
	int x, y;
};
node a[100005];
int main()
{
	int n, m;
	cin >> n >> m;
	for (int i=1;i<=m;i++)
		cin >> a[i].x >> a[i].y;
	int least=0, most=100000;
	for (int i=1;i<=m;i++){
		least=max(a[i].x,least);
		most=min(a[i].y,most);
	}
	if (most-least+1<0) cout << "0";
	else cout << most-least+1;
	return 0;
} 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n, k; cin >> n >> k;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  ll ans = 0;
  for(int i = 0; i < n; i++){
    ans += min(v[i]*2, abs(v[i]-k)*2);
  }
  cout << ans << endl;
  system("pause");
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    if((a+b)%2 == 0) cout << (a+b)/2 << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)
	
func main() {
	var n int
	fmt.Scan(&n)
	li := make([]float64, n)
	total := 1.0
	for i:=0; i<n;i++{
		fmt.Scan(&li[i])
		total *= li[i]
	}
	bo := 0.0
	for i:=0; i<n; i++ {
		bo += (total/li[i])/total
	}
	fmt.Println(1.0/bo)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define lll __int128
#define ull unsigned long long
#define fi first
#define se second
#define db double
#define ld long double
#define lld __float128

/// order_of_key, find_by_order

template<class T, class COMP>
using custom_set = tree<T, null_type, COMP, rb_tree_tag, tree_order_statistics_node_update>;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<class T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<class T, class U>
using ordered_map = tree<T, U, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd_64(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
    ll a, b, n; cin >>  a >> b >> n;
    ll mx = max(a, b);
    cout <<(n+mx-1) / mx << endl;
}






































/// shche ne vmerla Ykraina


Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <chrono>
#include <valarray>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = std::vector<int>;
using Vlli = std::vector<lli>;
using Wint = std::vector<Vint>;
using Wlli = std::vector<Vlli>;
using Vbool = std::vector<bool>;
using Wbool = std::vector<Vbool>;
using pii = std::pair<int, int>;
using pll = std::pair<lli, lli>;
template <class T>
using Vec = std::vector<T>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {std::make_pair(1, 0), std::make_pair(-1, 0), std::make_pair(0, 1), std::make_pair(0, -1)};
constexpr char BR = '\n';

#define DEBUG(x) std::cerr << #x << " = " << x << '\n';
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); ++(i))
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); --(i))
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())
#define rSORT(A) std::sort((A).rbegin(), (A).rend())
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())



template <class T> inline int argmin(std::vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(std::vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){if(a < b) a = b;}
template <class T> inline void chmin(T &a, T b){if(a > b) a = b;}
inline int BitI(int k){return 1 << k;}
inline lli BitL(int k){return 1LL << k;}
inline void putsDouble(double d){printf("%.16lf\n", d);}
inline int toInt(const string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res;
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;}
  std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




int main(void){
  int n, m; scanf("%d%d", &n, &m);
  Vint A(n); REP(i, n) scanf("%d", &A[i]);
  Vint S(n); S[0] = A[0] % m;
  FOR(i, 1, n) S[i] = (A[i] + S[i-1]) % m;
  std::map<int, int> KingCrimson; KingCrimson[0]++;
  REP(i, n) KingCrimson[S[i]]++;
  lli res = 0, add;
  vREP(ele, KingCrimson){
    add = ele.second; add *= ele.second - 1; add >>= 1;
    res += add;
  }
  printf("%lld\n", res);
  return 0;
}

Measured memory_bytes: 3968
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  int X;

  sc.scan(X);

  if (X == 7 || X == 5 || X == 3)
    writeln("YES");
  else
    writeln("NO");
}


Measured memory_bytes: 256
import numpy as np

def get_rotation_matrix(rad):
    rot = np.array([[np.cos(rad), -np.sin(rad)],
                  [np.sin(rad), np.cos(rad)]])
    return rot

x1,y1,x2,y2= map(int,input().split())

vec1=np.array([x1,y1])
vec2=np.array([x2,y2])

vec2to1=vec1-vec2
vec2to3=np.dot(get_rotation_matrix(np.pi*3/2),vec2to1)

vec1to2=vec2-vec1
vec1to4=np.dot(get_rotation_matrix(np.pi/2),vec1to2)

vec3=vec2+vec2to3
vec4=vec1+vec1to4

print(
  int(round(vec3[0],0)),
  int(round(vec3[1],0)),
  int(round(vec4[0],0)),
  int(round(vec4[1],0)))


Measured memory_bytes: 21764
/*
[ ( ^ _ ^ ) ]
*/

import java.io.*;
import java.util.*;


public class Main {
    int INF = (int)1e9;
    long MOD = 1000000007;

    long abs(long x) {
        return Math.abs(x);
    }

    long max(long ... x) {
        long rs = x[0];
        for(long y: x) rs = Math.max(rs, y);
        return rs;
    }

    void solve(InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = in.nextInt();
            b[i] = in.nextInt();
            c[i] = in.nextInt();
        }
        long[][] dp = new long[n][3];
        dp[0][0] = a[0];
        dp[0][1] = b[0];
        dp[0][2] = c[0];
        for(int i=1; i<n; i++) {
            dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
            dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
            dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
        }
        out.println(max(dp[n-1]));
    }
    

    public static void main(String[] args) throws IOException {
        if(args.length>0 && args[0].equalsIgnoreCase("d")) {
            DEBUG_FLAG = true;
        }
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;//in.nextInt();
        long start = System.nanoTime();
        while(t-- >0) {
            new Main().solve(in, out);
        }
        long end = System.nanoTime();
        debug("\nTime: " + (end-start)/1e6 + " \n\n");
        out.close();
    }
    
    static boolean DEBUG_FLAG = false;
    static void debug(String s) {
        if(DEBUG_FLAG) System.out.print(s);
    }
    
    public static void show(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
    
    static class InputReader {
        static BufferedReader br;
        static StringTokenizer st;
    
        public InputReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 50200
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    if n%2 == 0:
        print(n//2-1)
    else:
        print(n//2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<numeric>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    ll x;
    cin>>x;
    ll k = lcm(360,x) / x;
    cout<<k<<endl;
}

Measured memory_bytes: 3588
/* Simplicity and Goodness */
 
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 1e6+2;


void solve()
{
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);

    vl a(n), b(m);

    for(auto& i : a)
        lscn(i);
    for(auto&i : b)
        lscn(i);

    rep(i, 1, n)
        a[i] += a[i-1];
    rep(j, 1, m)
        b[j] += b[j-1];

    // rep(i, 0, n) {
    //     cout << a[i] << ' ';
    // }puts("");
    // rep(j, 0, m) {
    //     cout << b[j] << ' ';
    // }puts("");

    int best = upper_bound(all(b), k) - b.begin();

    rep(i, 0, n) {
        int aval = k - a[i];

        if(aval < 0)
            break;

        int j = upper_bound(all(b), aval) - b.begin();

        best = max(best, i + 1 + j);
    }

    prin(best);
}

int main()
{
    int t = 1;
    // scanf("%d", &t);

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

Measured memory_bytes: 6424
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<vector<int>> Graph;

int main() {

	int a, b;
	cin >> a >> b;

	int now = 1;
	int ans = 0;
	while (now < b) {
		now += a - 1;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
long long int mod = 1e9+7;
int main(){
	int n;
	cin>>n;
	vector<int> map(26,1);
	char tmp;
	rep(i,n){
		cin>>tmp;
		map[tmp-'a']+=1;
	}
	long long int sum = 1;
	rep(i,26){
		sum = (sum*map[i])%mod;
	}
	cout<<(sum-1)%mod<<endl;
	return 0;
}

Measured memory_bytes: 3572
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

ll p[100010], q[100010], pp[100010];
signed main(void)
{
	int w, h;
	cin >> w >> h;
	REP(i, w) cin >> q[i];
	REP(i, h) cin >> p[i];
	p[h] = 0;
	sort(p, p+h+1);
	REP(i, h+1) pp[i] = p[i];
	//pの累積和
	FOR(i, 1, h+1) pp[i] += pp[i-1];
	//REP(i, h+1) cout << p[i] << " "; cout << endl;
	//REP(i, h+1) cout << pp[i] << " "; cout << endl;

	ll ans = pp[h];
	REP(i, w) {
		int itr = upper_bound(p, p+h+1, q[i]) - p - 1;
		ans += pp[itr] + (h+1-itr)*q[i];
		//cout << itr << " " << ans << endl;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
using namespace std;

int main(){
    int n;
    cin >> n;
    int d[n];
    REP(i,n) cin >> d[i];
    
    sort(d, d+n);
    int half = n/2 - 1;
    if(d[half]==d[half+1]){
        cout << 0 << endl;
    }
    else{
        int ans=0;
        for(int i=d[half]+1; i<=d[half+1]; i++){
            ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<vector<int>>board(2,vector<int>(n));
    for(int i=0; i<2; i++){
        for(int j=0; j<n; j++){
            cin>>board.at(i).at(j);
        }
    }

    int answer=0;
    for(int i=0; i<n; i++){
        int total=0;
        for(int j=0; j<=i; j++){
            total+=board.at(0).at(j);
        }
        for(int j=i; j<n; j++){
            total+=board.at(1).at(j);
        }
        answer=max(answer,total);
    }
    cout<<answer<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    double xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2;
    while (cin>>xa1>>ya1>>xa2>>ya2>>xb1>>yb1>>xb2>>yb2) {
        if (xb2<xa1||xa2<xb1||yb1>ya2||ya1>yb2) { 
            cout<<"NO"<<endl;
        } else {
            cout<<"YES"<<endl;
        }
    }
}


Measured memory_bytes: 3196
import numpy as np

n, m, x = map(int, input().split())
ca = np.array([list(map(int, input().split())) for _ in range(n)])

pattern = []
for i in range(2 ** n):
    temp = [0] * n
    for j in range(n):
        if (i >> j) & 1:
            temp[j] = 1
    pattern.append(temp)

ans = 10 ** 10
for p in pattern:
    check = [0] * (m + 1)
    for i in range(n):
        if p[i] == 1:
            check += ca[i]
    flag = True
    for a in check[1:]:
        if a < x:
            flag = False
            break
    if flag:
        ans = min(ans, check[0])

print(ans) if ans != 10 ** 10 else print(-1)


Measured memory_bytes: 27624
#include <stdio.h>

int main(void)
{
	int x1,x2;
	scanf("%d %d",&x1,&x2);
	if(x1>x2){
		printf("%d\n",x1-x2);
	}
	else{
		printf("%d\n",x2-x1);
	}
	return 0;
}


Measured memory_bytes: 2120
# 繰り返し二乗法(MODを取る)
def modpow(base, exp, mod = 10 ** 9 + 7)
  if exp == 0
    1
  elsif exp.even?
    modpow(base, exp / 2, mod) ** 2 % mod
  else
    modpow(base, exp / 2, mod) ** 2 * base % mod
  end
end

MOD = 10 ** 9 + 7
n, k = gets.split.map(&:to_i)
count_memo = Array.new(n + 1, 0)
ans = 0
k.downto(1) do |num|
  # num の倍数の数
  multiple = k / num
  # gcd が num の倍数である個数
  count = modpow(multiple, n)
  # num の 2 倍、3 倍…………の gcd の count を全て引く
  2.upto(multiple) { |i| count -= count_memo[num * i] }
  count_memo[num] = count
  ans += num * count
  ans %= MOD
end
puts ans % MOD


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

using namespace std;
#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;


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

    // ifstream in("in.txt");
    // cin.rdbuf(in.rdbuf());

    ll a, b, c, k; cin >> a >> b >> c >> k;

    ll ans = 0;
    if (a < k) {
        k -= a;
        ans += a;
    } else {
        ans += k;
        k = 0;
    }

    if (b < k) {
        k -= b;
    } else {
        k = 0;
    }

    if (c < k) {
        k -= c;
        ans -= c;
    } else {
        ans -= k;
        k = 0;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
import math
import itertools


# 与えられた数値の桁数と桁値の総和を計算する.
def calc_digit_sum(num):
    digits = sums = 0
    while num > 0:
        digits += 1
        sums += num % 10
        num //= 10
    return digits, sums


s = input()
t = input()

answer = len(t)
for index in range(len(s) - (len(t) - 1)):
    d = s[index:index+len(t)]
    match = 0
    for idx in range(len(t)):
        if t[idx] == d[idx]:
            match += 1

    answer = min(answer, len(t) - match)

print(answer)

Measured memory_bytes: 73408
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<cstdlib>
#include<stack>
#include<queue>
#define ll long long
using namespace std;
const int maxn=5e5+7;
const int mod=1e9+7;
ll fac[maxn],inv_fac[maxn];
ll quick(ll a,ll n){
    ll res=1,t=a;
    while(n){
        if(n&1) res=(res*t)%mod;
        t=(t*t)%mod;
        n/=2;
    }
    return res;
}
void init(){
    fac[0]=1;
    for(int i=1;i<=maxn;i++) fac[i]=(fac[i-1]*i)%mod;
    inv_fac[maxn]=quick(fac[maxn],mod-2);
    for(int i=maxn-1;i>=0;i--) inv_fac[i]=(inv_fac[i+1]*(i+1))%mod;
    /*for(int i=0;i<=maxn;i++){
        inv_fac[i]=quick(fac[i],mod-2);
    }*/
}
ll C(int n,int m){
    if(n<0||m<0||m>n) return 0;
    if(m==0||m==n) return 1;
    return fac[n]*inv_fac[n-m]%mod*inv_fac[m]%mod;
}
int main(){
    init();
    //cout<<C(5,2)<<endl;
    int n,m,a,b;
    cin>>n>>m>>a>>b;
    ll ans=0;
    for(int i=b+1;i<=m;i++) ans=(ans+(C(n-a-1+i-1,i-1)*C(a-1+m-i,m-i))%mod)%mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 8696
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		A = A==1?14:A;
		B = B==1?14:B;
		System.out.println(A==B?"Draw":A>B?"Alice":"Bob");
		scanner.close();
	}

}


Measured memory_bytes: 21972
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0 {
    class Program {
        static void Main(string[] args) {
            var H = int.Parse(Console.ReadLine());
            var W = int.Parse(Console.ReadLine());
            var N = int.Parse(Console.ReadLine());

            //int a = (int)Math.Ceiling(144.0 / 12.0);


            if (H > W) {
                Console.WriteLine(Math.Ceiling(N / (double)H).ToString("0"));
            } else {
                Console.WriteLine(Math.Ceiling(N / (double)W).ToString("0"));

            }
            //Console.ReadLine();

        }
    }
}

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


int main(void)
{
	int K = 0, X = 0;
	cin >> K >> X;

	int start = max(-1000000, X - K + 1);
	int end = min(1000000, X + K - 1);

	for (int i = start; i <= end; i++)
	{
		cout << i;
		if (i < end) cout << " ";
	}

	cout << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#define INF 999999999

using namespace std;

int main()
{
    int h, w, z, dis[10], cnt[10]={0}, ans=0; dis[1]=0;
    vector<pair<int, int>> c[10];
    cin>>h>>w;
    for (int i=0; i<10; i++)
    {
        for (int j=0; j<10; j++)
        {
            cin>>z;
            if (i!=j) c[i].push_back({j, z});
        }
    }
    for (int i=0; i<10; i++)
    {
        if (i==1) continue;
        priority_queue<pair<int, int>> q;
        bool vis[10]={0};
        int d[10]; for (int j=0; j<10; j++) d[j]=INF;
        q.push({0, i});
        d[i]=0;
        while (!q.empty() && !vis[1])
        {
            int a=-q.top().first, b=q.top().second;
            q.pop();
            if (vis[b]) continue;
            vis[b]=true; //d[b]=a;
            for (auto u : c[b])
            {
                if (d[u.first]>d[b]+u.second)
                {
                    d[u.first]=d[b]+u.second;
                    q.push({-d[u.first], u.first});
                }
            }
        }
        dis[i]=d[1];
    }
    for (int i=0; i<h; i++) for (int j=0; j<w; j++) { cin>>z; if (z!=-1) cnt[z]++; }
    for (int i=0; i<10; i++) ans+=cnt[i]*dis[i];
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256
import sys
r=sys.stdin.readline
X,Y=map(int,r().split())
#a=X-2b, b=Y-2a
if 2*X-Y<0 or (2*X-Y)%3!=0 or 2*Y-X<0 or (2*Y-X)%3!=0:
    print(0)
    exit(0)   
a=(2*Y-X)//3
b=(2*X-Y)//3
MOD=10**9+7
#ex) ab, ba --> a+bCa
def pow(a,b):
    ans=1
    while b:
        if b&1:
            ans=(ans*a)%MOD
        a=(a**2)%MOD
        b=b//2
    return ans 
N=a+b
K=a
fac=[1 for _ in range(N+1)]
for i in range(2,N+1):
    fac[i]=(fac[i-1]*i)%MOD
A=fac[N]
B=(fac[N-K]*fac[K])%MOD
print((A%MOD)*pow(B,MOD-2)%MOD)



Measured memory_bytes: 35396
import java.util.Scanner;

class Main{
	public static void main(String[] args){
     	Scanner sc = new Scanner(System.in);
      	String s = sc.nextLine();
      	String[] spl = s.split(" ");
      	int N = Integer.parseInt(spl[0]);
      	int D = Integer.parseInt(spl[1]);
      	int ans = N / (D * 2 + 1);
      	int mod = N % (D * 2 + 1);
      	if(mod == 0){
      		System.out.println(ans);
        }else{
          	System.out.println(ans + 1);
        }
    }
}

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

int main() {
    long long int h,w;
    cin>>h>>w;
    if(h==1 || w==1){
        cout<<1<<endl;
        return 0;
    }
    cout<<((h+1)/2)*((w+1)/2)+(h/2)*(w/2)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	ll h, n;
	ll s = 0;
	cin >> h >> n;
	for (int i = 0; i < n; i++) {
		ll t;
		cin >> t;
		s += t;
	}
	if (h - s <= 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3076
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(int i = a;i < b; i++)

int main() {

	string s, t;

	cin >> s >> t;

	int count = 0;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == t[i]) count++;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
t,*a=open(0)
h,w=map(int,t.split())
a=[list(map(int,x.split())) for x in a]
ret=[]
for i in range(h):
	for j in range(w-1):
		if a[i][j]%2:
			a[i][j+1]+=1
			ret+=[(i+1,j+1,i+1,j+2)]
for i in range(h-1):
	if a[i][-1]%2:
		a[i+1][-1]+=1
		ret+=[(i+1,w,i+2,w)]
print(len(ret))
for a,b,c,d in ret:
	print(a,b,c,d)

Measured memory_bytes: 24696
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb(x) push_back(x)

typedef pair<ll,ll> pp;
int lcm(int a, int b)
{
    int lar = max(a, b);
    int small = min(a, b);
    for (int i = lar; ; i += lar) {
        if (i % small == 0)
            return i;
    }
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b) {
    return (a.second < b.second);
}

ll power(ll x, unsigned ll y, ll p)
{
    ll res = 1;     // Initialize result
  
    x = x % p; // Update x if it is more than or
                // equal to p
   
    if (x == 0) return 0; // In case x is divisible by p;
  
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;
  
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

struct ArrayWrapper
{
    int a[101][101];
};

bool isPowerOfTwo (ll x)
{
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));
}


void solve(){
    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC\n";
    else cout << "ABC\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //ll t; cin >> t; while(t--)
        solve();
}


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

#define NIL (1<<21)
#define WHITE 0
#define BLACK 1

struct Node{

    int weight;

    int key;

    struct Node *next;

};
  

int n;
int *d;
struct Node *node;

void Input(int);

void MakeNode(int, int, int);

void SSSP(void);

int Heap(int *);

int Set(int *);


int main(){

  int i, num;

  scanf("%d", &n);

  d = (int*)malloc(sizeof(int)*n);

  node = (struct Node*)malloc(sizeof(struct Node)*n);

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

    node[i].weight = -1;

    node[i].key = -1;

    node[i].next = NULL;

  }

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

    scanf("%d", &num);

    Input(num);

  }

  SSSP();

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

    printf("%d %d\n", i, d[i]);

  }

  free(d);

  return 0;

}


void Input(int num){

  int i, k, u, c;

  scanf("%d", &k);

  for(i = 0; i < k; i++){

    scanf("%d %d", &u, &c);

    MakeNode(num, u, c);

  }


}

void MakeNode(int num, int u, int c){

  struct Node *new, *work;

  new = (struct Node*)malloc(sizeof(struct Node));

  new->next = NULL;

  new->weight = c;

  new->key = u;

  work =&node[num];

  while(work->next != NULL){

    work = work->next;

  }

  work->next = new;

}

void SSSP(){

  int i, s, u;

  int S[n];

  struct Node *work;

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

    S[i] = WHITE;

    d[i] = NIL;

  }

  s = WHITE;

d[s] = WHITE;

  while(Set(S) == WHITE){

    u = Heap(S);

    S[u] = BLACK;

    work = node[u].next;

    while(work != NULL){

      if(S[work->key] == BLACK){
      }

      else if(d[u]+work->weight < d[work->key]){

	d[work->key] = d[u]+work->weight;

      }

      work = work->next;

    }
    
  }

}

int Heap(int *S){

  int i, u, min;

  min = NIL;

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

    if(S[i] == BLACK)
      continue;

    if(d[i] < min){

      min = d[i];

      u = i;

    }

  }

  return u;

}

int Set(int *S){

  int i;

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

    if(S[i] == WHITE)
      return 0;

  }

  return 1;

}

Measured memory_bytes: 16220
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
  
int main()
{
    int a[101][101], b[101][101];
    long long c[101][101], s;
    int i, j, k;
    int n, m, l;
  
    scanf("%d%d%d", &n, &m, &l);
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
    }
    for (i = 0; i < m; i++) {
        for (j = 0; j < l; j++) scanf("%d", &b[i][j]);
    }
  
    for (i = 0; i < n; i++) {
        for (j = 0; j < l; j++) {
            s = 0;
            for (k = 0; k < m; k++) {
                s += a[i][k] * b[k][j];
            }
            c[i][j] = s;
        }
    }
  
    for (i = 0; i < n; i++) {
        printf("%lld", c[i][0]);
        for (j = 1; j < l; j++) printf(" %lld", c[i][j]);
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2056
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string t = Console.ReadLine();
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(t);
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(s[i]);
            }
            for (int i = n; i > 0; i--)
            {
                Console.Write(a[i-1]);
                if (i == 1)
                {
                    break;
                }
                Console.Write(" ");
            }
            Console.WriteLine("");
        }
    }
}

Measured memory_bytes: 9176