akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main()
{
  long long int n,k,x,y,rem,coast;
    cin>>n>>k>>x>>y;
    if(n>k)
    {
        rem = n-k;
        coast = (k*x) + (rem*y);
    }
    else if(n==k)
        coast = k * x;
    else
        coast = n * x;
    cout<<coast<<endl;
    return 0;
}

Measured memory_bytes: 3548
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		ArrayList<Integer[][]> list = new ArrayList<Integer[][]>();
		for(int i = 0; i < n; i++){
		    int a = sc.nextInt();
		    Integer[][] xy = new Integer[a][2];
		    for(int j = 0; j < a; j++){
		        int x = sc.nextInt();
		        int y = sc.nextInt();
		        xy[j][0] = x;
		        xy[j][1] = y;
		    }
		    list.add(xy);
		}
		
		// 計算
		int result = 0;
		for(int i = 0; i < (1<<n); i++){
		    String s = Integer.toString(i, 2);
		    boolean bool = true;
		    for(int j = 0; j < n; j++){
		        if(((i>>j) & 1) == 1){
		            Integer[][] a = list.get(j);
		            for(int k = 0; k < a.length; k++){
		                int index = a[k][0]-1;
		                int tf = a[k][1];
		                if(s.length()-1-index >= 0 && (s.charAt(s.length()-1-index)-'0') != tf){
		                    bool = false;
		                    break;
		                }else if(s.length()-1-index < 0 && tf == 1){
		                    bool = false;
		                    break;
		                }
		            }
		        } 
		        if(!bool) break;
		    }
		    if(bool) result = max(result, Integer.bitCount(i));
		}
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 28628
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int main() {
    int n, m; cin >> n >> m;
    vector<int> A(n);
    
    int sum=0,cnt=0;

    REP(i, n){
        cin >> A[i];
        sum += A[i];
    }

    sort(A.begin(),A.end(),greater<int>());

    REP(i, m){
        if(4*m*A[i] >= sum) cnt++;
    }

    if(cnt == m) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
cons=[[0,0,0,0] for i in range(50)]
for i in range(50):
    a,b,c = list(map(int,input().split()))
    if (a+1)*(a+1) + (b+1)*(b+1) + (c+1)*(c+1) == 0:
        break
    asse = 'N'
    if (a == -1) + (b == -1):
        asse = 'F'
    elif a+b < 30:
        asse = 'F'
    elif (a+b <50)*(c < 50):
        asse = 'D'
    elif (a+b<65):
        asse='C'
    elif a+b < 80:
        asse='B'
    elif a+b >= 80:
        asse='A'
    cons[i] = [a,b,c,asse]
for j in range(i):
    print(cons[j][3])


Measured memory_bytes: 5604
n = int(input())
l = list()

for i in range(n):
    l.append(input())

if len(l) != len(set(l)):
    print("No")
    exit()

for i in range(n-1):
    if l[i][len(l[i])-1] != l[i+1][0]:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N;
        cin >> N;
        Int ans = N - 1;
        for (Int i = 1; i * i <= N; ++i) {
            if (N % i == 0) {
                Int j = N / i;
                Int tmp = i - 1 + j - 1;
                chmin(ans, tmp);
            }
        }
        cout << ans << endl;
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=500+19;

char s[N][N];
int n,m;

void gao1(){
	For(i,1,n+1){
		For(j,1,m+1){
			if (j!=m&&(j==1||i%2==1||s[i][j]=='#')) putchar('#');else putchar('.');
		}
		puts("");
	}
}
void gao2(){
	For(i,1,n+1){
		For(j,1,m+1){
			if (j!=1&&(j==m||i%2==0||s[i][j]=='#')) putchar('#');else putchar('.');
		}
		puts("");
	}
}

int main(){
	n=IN(),m=IN();
	For(i,1,n+1){
		scanf("%s",s[i]+1);
	}
	gao1();
	puts("");
	gao2();
}

Measured memory_bytes: 1024
H,W,N = map(int,input().split())
Nli=[]
for k in range(N):
    a,b=map(int,input().split())
    for n in range(-1,2):
        for m in range(-1,2):
            if 0<=a-2-m<H-2 and 0<=b-2-n<W-2:
                Nli.append((b-n)*(H)+(a-m))
import collections
s = collections.Counter(Nli)
v = list(s.values())
print((H-2)*(W-2)-len(set(Nli)))
for k in range(1,10):
    print(v.count(k))

Measured memory_bytes: 166912
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdint>
#include <utility>
#include <tuple>
#include <map>    
#include <queue> 
#include <set>  
#include <stack> 
#include <deque>  
#include <unordered_map> 
#include <unordered_set> 
#include <bitset>

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;

	int count = 0;
	for (int i = 0; i < 3; i++) {
		if (s.at(i) == t.at(i)) {
			count++;
		}
	}
	cout << count << endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = 0;
	}
	for (int i = n - 1; i >= 0; i--) {
		if (2 * i >= n - 1) {
			b[i] = a[i];
		}
		else {
			int j = 2 * (i + 1);
			int count = a[i];
			while (j <= n) {
				count += b[j - 1];
				j += i + 1;
			}
			b[i] = count % 2;
		}
	}

	int ansnum = 0;
	for (auto e : b) ansnum += e;
	cout << ansnum << endl;
	bool first = true;
	for (int i = 0; i < n; i++) {
		if (b[i]) {
			if (first) first = false;
			else cout << " ";
			cout << i + 1;
		}
	}
	if (ansnum > 0) cout << endl;
	return 0;
}

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

int main(){
    int N, A, B; cin >> N;
    int Min = 100000;
    for (int i = 1; i < N; i++){
        A = i;
        B = N - i;
        int sumA = 0, sumB = 0;
        while(A > 0){
            sumA += A % 10;
            A /= 10;
        }
        while(B > 0){
            sumB += B % 10;
            B /= 10;
        }
        Min = min(sumA + sumB, Min);
    }

    cout << Min << endl;
}

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

int main(){
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    map<int, int> mp;
    int64_t ans = 0;
    int sum = 0, base = 1;
    mp[0] = 1;
    for(char c : S){
        sum += base*(c-'0');
        sum %= 2019;
        base *= 10;
        base %= 2019;
        if(mp.count(sum)) ans += mp[sum];
        mp[sum]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3724
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;
#define LL long long
#define mp make_pair
#define fr first
#define sc second
#define pb push_back
#define lc (x<<1)
#define rc ((x<<1)|1)
const int N=5005;
int f[N][N],g[N][N],a[N];
int main(){
  //  freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
    int i,j,k,n,K,ans=0;
    cin>>n>>K;
    for (i=1;i<=n;i++) scanf("%d",&a[i]);
    f[0][0]=g[n+1][0]=1;
    for (i=1;i<=n;i++){
        for (j=0;j<K;j++) f[i][j]=f[i-1][j];
        if (a[i]>=K) continue;       
        for (j=a[i];j<K;j++) f[i][j]|=f[i-1][j-a[i]];
    }
    for (i=n;i>=1;i--){
        for (j=0;j<K;j++) g[i][j]=g[i+1][j];
        if (a[i]>=K) continue;       
        for (j=a[i];j<K;j++) g[i][j]|=g[i+1][j-a[i]];
    }
    for (i=1;i<=n;i++){
        if (a[i]>=K) continue;
        for (j=0,k=K-1;;j++){
            while (j<K&&!f[i-1][j]) j++;
            while (k>=0&&(j+k>=K||!g[i+1][k])) k--;
            if (j>=K||k<0) break;
            if (j+k+a[i]>=K) {ans--;break;}
        }
        ans++;
    }
    cout<<ans<<endl;
  //  system("pause");
    return 0;
}


Measured memory_bytes: 195840
n = int(input())
for i in range(n, 2 * n):
    cnt = 0
    for j in range(2, int(i ** 0.5) + 1):
        if i % j != 0:
            cnt += 1
    
    if cnt == int(i ** 0.5) - 1:
        print(i)
        break
            

Measured memory_bytes: 3060
N = int(input())
L = list(map(int, input().split()))


def calcu(N,L):

    if N <= 2:
        return 0

    res = 0
    for i in range(N-2):
        for j in range(i+1,N-1):
            for k in range(j+1,N):
                a = L[i]
                b = L[j]
                c = L[k]
                if a == b or b == c or c == a:
                    pass
                elif a+b>c and b+c>a and c+a>b:
                    res += 1
    return res

print(calcu(N,L))

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

int main() 
{
	set<int>s;  int x,y;
	cin>>x>>y; s.insert(x); s.insert(y);
	for(int i=1;i<=3;i++)
	{
		if(!s.count(i))
		{
			cout<<i; return 0;
		}
	}
	
}

Measured memory_bytes: 256
import           Data.List
import           Control.Monad.State

sort' :: Ord a => [a] -> State Int [a]
sort' [] = return []
sort' xs = do
  res <- bubleAll xs
  case res of
    (y : ys) -> do
      l <- sort' ys
      return $ y : l
    [] -> return []

bubleAll :: Ord a => [a] -> State Int [a]
bubleAll [] = return []
bubleAll xs =
  foldr (\o acc -> acc >>= buble o) (return xs) [1 .. (length xs - 1)]

buble :: Ord a => Int -> [a] -> State Int [a]
buble n xs
  | x1 <= x2 = return xs
  | otherwise = do
    modify (+ 1)
    return $ h ++ [x2] ++ [x1] ++ t
 where
  x1 = last $ take n xs
  x2 = head $ drop n xs
  h  = take (n - 1) xs
  t  = drop (n + 1) xs

main = do
  n <- readLn
  l <- getLine
  let (rs, cnt) =
        runState (sort' $ take n $ map (read :: String -> Int) (words l)) 0
  putStrLn $ unwords (map show rs)
  print cnt




Measured memory_bytes: 5328
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define debug(...) \
    { cerr << "# " << __VA_ARGS__ << "\n"; }
#else
#define debug(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 1e9 + 7;
class {
   public:
    i64 pw2[maxn];
    void solve() {
        int n;
        cin >> n;
        vector<i64> a(n);
        for (int i = 0; i < n; ++i) cin >> a[i];
        if (n == 1) {
            cout << a[0] * 2 % MOD << '\n';
            return;
        }
        pw2[0] = 1;
        for (int i = 1; i < maxn; ++i) pw2[i] = pw2[i - 1] * 2 % MOD;
        sort(a.begin(), a.end());
        i64 ans = 0;
        for (int i = 0; i < n; ++i) {
            ans = (ans + a[i] * (pw2[n - 1] + ((n - 1 - i) * pw2[n - 2]) % MOD) % MOD) % MOD;
        }
        ans = ans * pw2[n] % MOD;
        cout << ans << '\n';
    }
} NSPACE;
int main() {
    FPEN;
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    NSPACE.solve();
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M, K;
int E[710][710];
int dp[710][710];
int color[710];
pi P[710];
bool used[710];

pi loop(int v, int c) {
	color[v] = c;
	used[v] = true;
	// debug(v, c);
	pi res(0, 0);
	if(c == 0) res.fst++;
	else res.sec++;
	rep(i, 0, N) {
		if(E[v][i]) {
			if(!used[i]) {
				pi p = loop(i, c ^ 1);
				if(p.fst >= inf) return pi(inf, inf);
				res.fst += p.fst;
				res.sec += p.sec;
			}
			else {
				if(color[i] == c) {
					return pi(inf, inf);
				}
			}
		}
	}
	return res;
}

void solve() {
	cin >> N >> M;
	rep(i, 0, N) {
		rep(j, 0, N) {
			if(i == j) continue;
			E[i][j] = 1;
		}
	}
	rep(i, 0, M) {
		int a, b; cin >> a >> b; a--; b--;
		E[a][b] = 0;
		E[b][a] = 0;
	}
	// rep(i, 0, N) {
	// 	rep(j, i + 1, N) {
	// 		// debug(i, j, E[i][j]);
	// 	}
	// }
	int K = 0;
	rep(i, 0, N) {
		if(!used[i]) {
			P[K++] = loop(i, 0);
			if(P[K - 1].fst >= inf) {
				cout << "-1\n";
				return;
			}
		}
	}
	dp[0][0] = 1;
	rep(i, 0, K) {
		rep(j, 0, N + 1) {
			if(!dp[i][j]) continue;
			dp[i + 1][j + P[i].fst] = 1;
			dp[i + 1][j + P[i].sec] = 1;
		}
	}
	int res = inf;
	rep(i, 0, N + 1) {
		if(dp[K][i]) {
			MIN(res, i * (i - 1) / 2 + (N - i) * (N - i - 1) / 2);
		}
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

int main(){
  int A, B;
  string S;
  cin >> A >> B >> S;
  int L=S.size();
  int Ans=1;
  if(L!=A+B+1){
    Ans=0;
  }
  else{
    for(int i=0; i<A; i++){
      if('0'<=S.at(i) && S.at(i)<='9'){
      }
      else{
        Ans=0;
      }
    }
    if(S.at(A)!='-'){
      Ans=0;
    }
    for(int i=A+1; i<A+B+1; i++){
      if('0'<=S.at(i) && S.at(i)<='9'){
      }
      else{
        Ans=0;
      }
    }
  }
  if(Ans==1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int i, sum;
  char x[1001];

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

  return 0;
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
 
P project(P a,P b,P c){
  b-=a,c-=a;
  return a+b*real(c/b);
}
 
int main(){
  int n;
  double ax,ay,bx,by,cx,cy;
  scanf("%lf %lf %lf %lf %d",&ax,&ay,&bx,&by,&n);
  while(n--){
    scanf("%lf %lf",&cx,&cy);
    P p=project(P(ax,ay),P(bx,by),P(cx,cy));
    printf("%.8f %.8f\n",p.real(),p.imag());
  }
  return 0;
}

Measured memory_bytes: 1252
from collections import defaultdict
import sys
import math
from datetime import datetime

def sol(n, k, S):
    return S[:k-1]+S[k-1].lower()+S[k:]


do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    n = int(parsed_lines[0][0])
    k = int(parsed_lines[0][1])
    S = parsed_lines[1][0]
    return n, k, S


if not do_submit:
    a, b, c = input_parse("""
    3 1
    ABC
    """)
    print(sol(a, b, c))

    a, b, c = input_parse("""
    4 3
    CABA
    """)
    print(sol(a, b, c))

else:
    n, k = list(map(int, input().split()))
    S = input().split()
    print(sol(n, k, S[0]))

    # S = input().strip()
    # print(sol(S))

Measured memory_bytes: 3820
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

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

using namespace std;

int main(){
    int K, X;
    int min, max;
    cin >> K >> X;
    
    min = X - K + 1;
    max = X + K - 1;

    for (int i=min; i<=max; i++){
        printf("%d%c",i,(i==max) ? '\n' : ' ');
    }

    return 0;
}



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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<bool> vb;
using Graph= vector<vector<ll>>;



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


void dfs(const Graph &g, ll v,vb &flag,vll &d){
 flag[v]=true;
 for(auto next_v:g[v]){
  if(flag[next_v]) continue;
   d[next_v]=d[v]+1;
  dfs(g,next_v,flag,d);
}
}

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
 Graph G(n);
  
  rep(i,0,n-1){
   ll a,b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  
  } 
 vb flag_f(n,false),flag_s(n,false);
 vll df(n,0),ds(n,0);
  
  dfs(G,0,flag_f,df);
  dfs(G,n-1,flag_s,ds);
  
  ll f=0,s=0;
  rep(i,0,n) if(df[i]<=ds[i]) f++;
  
  if(f>n-f) cout <<"Fennec" << endl;
  else cout << "Snuke" << endl;
  
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

/* modとる */
inline ll modu(ll a){
    return(a % mod + mod) % mod;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    ll answer = 0;
    vector<ll> A(N);
    REP(i,N)A[i] = in<ll>();
    REP(i,62){
        ll counter = 0;
        REP(l,N){
            if(A[l] & 1LL << i)counter++;
        }
        answer += modu(counter * (N - counter)) * modu(1LL << i);
        answer = modu(answer);
    }
    cout << answer << "\n";
}

Measured memory_bytes: 2560
n=gets.to_i
xs=gets.split.map(&:to_i)
ys=gets.split.map(&:to_i)

invalid = false

last = -1
for i in 0..(n-1)
    if last < xs[i]
        last = xs[i]
        if last > ys[i]
            STDERR.puts "-> @#{i}"
            invalid = true
        end
    end
end

last = -1
for i in (n-1).downto(0)
    if last < ys[i]
        last = ys[i]
        if last > xs[i]
            STDERR.puts "<- @#{i}"
            invalid = true
        end
    end
end

if invalid
    p 0
    exit 0
end

memo = [false] * n
memo[0] = true
memo[n-1] = true


ans = 1
for i in 1..(n-2)
    if xs[i-1] < xs[i]
        ans *= 1
    elsif ys[i] > ys[i+1]
        ans *= 1
    else
        ans *= [xs[i], ys[i]].min
        ans %= 1000000007
    end
end
p ans


Measured memory_bytes: 20252
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int) n; i++)
#define repb(i, n) for (int i = (int) n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int) m; i < (int) n; i++)
#define repsb(i, m, n) for (int i = (int) m; i >= (int) n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define pb(a) push_back(a)
#define ll long long int
const ll LLINF = 1e18 + 10;
int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return 1; } return 0; }
template < class T > bool chmin(T & a,const T & b) { if (b < a) { a = b; return 1; } return 0; }
//vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));
using namespace std;
int main(int argc, char const * argv[]){
    string s;
    vector<bool> v(4,false);
    cin >> s;
    rep(i,s.size()){
        if(s[i]=='W')
            v[0] = true;
        else if (s[i] == 'S')
            v[1] = true;
        else if (s[i] == 'E')
            v[2] = true;
        else
            v[3] = true;
    }
    if(v[0]==v[2]&&v[1]==v[3]){
        cout<<"Yes"<<endl;
        return 0;
    }
    
    cout<<"No"<<endl;

    return 0;
}

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

int main(){
	string O, E;
	cin >> O >> E;
	rep(i,E.size()){
		cout << O[i] << E[i];
	}
	if (O.size()-E.size() == 1) cout << O.back() << endl;
	else cout << endl;
	return 0;
}


Measured memory_bytes: 3576
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		java.util.Scanner s = new java.util.Scanner(System.in);
		System.out.println(IntStream.rangeClosed(s.nextInt(), s.nextInt()).mapToObj(val -> String.valueOf(val))
				.filter(str -> new StringBuilder(str).reverse().toString().equals(str)).count());
	}
}

Measured memory_bytes: 39376
from collections import Counter

def submit():
    n = int(input())
    a = list(map(int, input().split()))
    count = Counter(a)
    s = sum(a)

    # クエリ処理
    q = int(input())
    ans_q = []
    for _ in range(q):
        b, c = map(int, input().split())
        diff = c - b
        s += diff * count[b]
        ans_q.append(s)
        count[c] += count[b]
        count[b] = 0

    for ans in ans_q:
        print(ans)


submit()
        

Measured memory_bytes: 26920
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>

int N;
int X[2050],Y[2050],C[2050];

struct edge{int to,nxt,flow;long long cost;}E[50050];
int H[4050],tot=1;
void add_edge(int a,int b,int f,long long c){
	E[++tot]=(edge){b,H[a],f,c},H[a]=tot;
	E[++tot]=(edge){a,H[b],0,-c},H[b]=tot;
}

int S,T,M0,M1,M2,M3;
const int inf=0x3f3f3f3f;
const long long dinf=0xcfcfcfcfcfcfcfcf;

long long dis[4050];
int lst[4050],fl[4050];
bool inQ[4050];

bool SPFA(){
	memset(dis,0xcf,sizeof(long long)*(M3+1));
	memset(inQ,0,sizeof(bool)*(M3+1));
	memset(lst,0,sizeof(int)*(M3+1));
	dis[S]=0,fl[S]=inf;
	std::queue<int> Q;
	Q.push(S);
	while (!Q.empty()){
		int now=Q.front();
		Q.pop();
		for (int i=H[now];i;i=E[i].nxt){
			if (E[i].flow&&dis[now]+E[i].cost>dis[E[i].to]){
				dis[E[i].to]=dis[now]+E[i].cost;
				if (!inQ[E[i].to]) inQ[E[i].to]=true,Q.push(E[i].to);
				lst[E[i].to]=i,fl[E[i].to]=std::min(fl[now],E[i].flow);
			}
		}
		inQ[now]=false;
	}
	return dis[T]!=dinf;
};

long long EK(){
	long long ret=0;
	while (SPFA()){
		ret+=fl[T]*dis[T];
		for (int i=lst[T];i;i=lst[E[i^1].to]) E[i].flow-=fl[T],E[i^1].flow+=fl[T];
	}
	return ret;
}

int main(){
	scanf("%d",&N);
	for (int i=1;i<=N+N;i++) scanf("%d%d%d",&X[i],&Y[i],&C[i]);
	S=N+N+1,T=S+1,M0=T+1,M1=M0+1,M2=M1+1,M3=M2+1;

	for (int i=1;i<=N;i++) add_edge(S,i,C[i],0);
	for (int i=N+1;i<=N+N;i++) add_edge(i,T,C[i],0);

	for (int i=1;i<=N;i++) add_edge(i,M0,inf,X[i]+Y[i]),add_edge(M0,i+N,inf,-X[i+N]-Y[i+N]);
	for (int i=1;i<=N;i++) add_edge(i,M1,inf,X[i]-Y[i]),add_edge(M1,i+N,inf,-X[i+N]+Y[i+N]);
	for (int i=1;i<=N;i++) add_edge(i,M2,inf,-X[i]+Y[i]),add_edge(M2,i+N,inf,X[i+N]-Y[i+N]);
	for (int i=1;i<=N;i++) add_edge(i,M3,inf,-X[i]-Y[i]),add_edge(M3,i+N,inf,X[i+N]+Y[i+N]);

	printf("%lld\n",EK());
}


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

const int INF = 1001001001;
int K[25][25];

template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;} //aをより小さい値にする関数

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; i++){ //ワーシャルフロイド用に初期化
        for(int j = 0; j < n; j++){
            if(i == j) K[i][j] = 0;
            else K[i][j] = INF;
        }
    }
    for(int i = 0; i < m; i++){
        int a, b, c, d;
        scanf("%d,%d,%d,%d", &a, &b, &c, &d);
        a--; b--; // 0-indexed
        K[a][b] = c; //aからbはコストc
        K[b][a] = d; //bからaはコストd
    }
    int s, g, V, P;
    scanf("%d,%d,%d,%d", &s, &g, &V, &P);
    s--; g--;
    for(int k = 0; k < n; k++){ //kは経由地点
        for(int i = 0; i < n; i++){ //iは始点
            for(int j = 0; j < n; j++){ //jは終点
                chmin(K[i][j], K[i][k] + K[k][j]);
            }
        }
    }
    int cost = K[s][g] + K[g][s] + P; //かかったお金は移動費と木材費
    cout << V - cost << endl;
}


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

int main(){
    int n;
    cin >> n;
    for (int i = 1; i < 10; i++) {
        if (n % i == 0 && n/i < 10) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

namespace HABIT{
    #define f(a,b,c,d) for(register int a=b,c=d;a<=c;a++)
    #define g(a,b,c,d) for(register int a=b,c=d;a>=c;a--)
    #define LOCAL
    typedef int i32;
    typedef unsigned int u32;
    typedef long long int i64;
    typedef unsigned long long int u64;
    typedef pair<i32,i32> pii;
    const i32 MAXN=1024;
    typedef i32 ar[MAXN];
    
    template<typename T> inline T Max(T a) { return a; }
    template<typename T,typename... Args> inline T Max(T a,Args... args){
        T b=Max(args...);
        return (a>b)?a:b;
    }
    template<typename T> inline T Min(T a) { return a; }
    template<typename T,typename... Args> inline T Min(T a,Args... args){
        T b=Min(args...);
        return (a<b)?a:b;
    }

    #ifdef LOCAL
        inline char gc() { return getchar(); }
    #else
        inline char gc() {
            static char s[1<<20|1]={0},*p1=s,*p2=s;
            return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
        }
    #endif
    inline i64 read(){
        register i64 ans=0;register char c=gc();register bool neg=0;
        while(c<48||c>57) neg^=!(c^'-'),c=gc();
        while(c>=48&&c<=57) ans=(ans<<3)+(ans<<1)+(c^48),c=gc();
        return neg?-ans:ans;
    }

    char Output_Ans[1<<20|1],*Output_Cur=Output_Ans;
    inline void output() { Output_Cur-=fwrite(Output_Ans,1,Output_Cur-Output_Ans,stdout); }
    inline void print(char c){
        if(Output_Cur-Output_Ans+1>>20) output();
        *(Output_Cur++)=c;
    }
    inline void print(char *s) { while(*s) print( *(s++) ); }
    inline void print(u64 x){
        if(!x) { print('0'); return ; }
        char buf[30]={0},*p=buf+28;
        while(x) *(p--)=x%10+48,x/=10;
        print(p+1);
    }
    inline void print(u32 x) { print( (u64)x ); }
    inline void print(i64 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
    inline void print(i32 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
}
using namespace HABIT;

inline char *ans(i64 A,i64 V,i64 B,i64 W,i64 T){
    if(A==B)
        return "YES";
    if(A<B){
        if(A+V*T>=B+W*T) return "YES";
        return "NO";
    }
    if(A>B){
        if(A-V*T<=B-W*T) return "YES";
        return "NO";
    }
}

int main(){
    i64 A=read(),V=read(),B=read(),W=read(),T=read();
    print( ans(A,V,B,W,T) );
    output();
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
	int m,n,x,i,s1=0,s2=0,b,s;
	int a[100]={0};
	scanf("%d %d %d",&n,&m,&x);
	for(i=0;i<m;i++){
		scanf("%d",&b);
		a[b-1]=1;
	}
	for(i=x-1;i<=n;i++) s1+=a[i];
	//if(s1>0) s1--;
	for(i=x-1;i>=0;i--) s2+=a[i];
	if(s1<s2) s=s1;
	else s=s2;
	
	printf("%d\n",s);
	return 0;
}

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

using namespace std;

int main(void)
{
    int N, M, X, Y;

    cin >> N >> M >> X >> Y;

    vector<int> vx(N + 1), vy(M + 1);

    vx[0] = X;
    for(int i = 0; i < N; ++i)
    {
        cin >> vx[i + 1];
    }
    vy[0] = Y;
    for(int i = 0; i < M; ++i)
    {
        cin >> vy[i + 1];
    }

    for(int Z = -100; Z <= 100; ++Z)
    {
        bool pass = true;
        for(int i = 0; i < vx.size(); ++i)
        {
            if(vx[i] >= Z)
            {
                pass = false;
            }
        }
        for(int i = 0; i < vy.size(); ++i)
        {
            if(vy[i] < Z)
            {
                pass = false;
            }
        }
        if(pass)
        {
            cout << "No War" << endl;
            return 0;
        }
    }

    cout << "War" << endl;

    return 0;
}


Measured memory_bytes: 256
//Compiler optimization
#pragma GCC optimize("Ofast")

//include
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;

//typedef
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vl> mat;

//macro
#define reverse(a) reverse(a.begin(),a.end())
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define each(x, v) for (auto &x : v)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll pow(ll a,ll n, ll m){
    ll ret=1;
    for(;n>0;n>>=1,a=a*a%m){
        if(n%2==1){
        ret=ret*a%m;
        }
    }
    return ret;
}

//abbreviation
#define pb push_back
#define elif else if
#define mp make_pair
#define endl '\n'

//debug
#define debug(x) cerr << #x << ": " << x << endl
#define v_debug(v) cerr << #v << endl;fr(i,v.size()) cerr << i << ": " << v[i] << endl

//const
const  ll INF = 1e18;
const int MAX_A = 300005;
using S = int;
S op(S x, S y){ return max(x, y);}
S e() {return 0;}

atcoder::segtree<S, op, e> dp(MAX_A);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n,k; cin >> n >> k;
    vi a(n);
    fr(i,n)cin >> a[i];

    fr(i,n){
        int x = a[i];
        int l = max(0, x-k);
        int r =min(x + k + 1, MAX_A);
        int now = dp.prod(l, r) + 1;
        dp.set(x, now);
    }
    int ans = dp.prod(0, MAX_A);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8516
a,b,c=map(int,input().split())

ans=0
while a%2==0 and b%2==0 and c%2==0:
  if a==b==c:
    print(-1)
    exit(0)
  aa=a/2
  bb=b/2
  cc=c/2
  a=bb+cc
  b=aa+cc
  c=bb+aa
  ans+=1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
using namespace std;
int main(){
 int N, pr;
 cin >> N;
 for(int i=11;N>0;i+=10){
  pr=1;
  for(int j=3;j<=sqrt(i);j+=2)
   if(i%j==0){pr=0;break;}
  if(pr){if(i!=11)cout<<' ';cout<<i;N--;}
 }
 return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<utility>
#include<vector>
#include<functional>
#include<stack>
#include<queue>
#include<math.h>
#include<deque>
#define rep(i,rept)	for(ll i = 0; i<(ll)rept;++i)
typedef long long ll;
using namespace std;

//Product and GCD
//2 2 2 3 3 3

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	ll n = 0,p_copy = 0,p = 0,ans = 1;
	map<ll, ll> prime;
	cin >> n >> p;

	if (n == 1) {
		cout << p << endl; 
		return 0;
	}

	if (n == p) {
		cout << 1 << endl;
		return 0;
	}

	p_copy = p;
	for (ll i = 2; i <= sqrt(p_copy); i++) {
		while (p%i == 0) {
			prime[i]++;
			p /= i;
		}
	}


	for (ll i = 2; i <= sqrt(p_copy); i++) {

		while (prime[i] >= n) {
			ans *= i;
			prime[i] -= n;
		}

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

Measured memory_bytes: 61952
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<climits>
using namespace std;

struct process{
	char name[11];
	int time;
};

const long LEN=510029;

class queue {
	process data[LEN];
	int head, tail;
public:
	queue(): head(0), tail(0) {}  

	void enqueue(const process& p){
		data[tail+1]=p;
		tail= (tail+1) % LEN;
	}
	process& dequeue(){
		head= (head+1) % LEN;
		return data[head];
	}

	bool isEmpty(){ return head == tail;  }
	bool isFull(){  return (tail+1) % LEN == head;  }
};


int main()
{
	queue q;


	int n;
	short quan;
	cin>>n>>quan;

	process p;



	int passTime=0;

	for( int i=0; !q.isEmpty() || i<n; i++ ) {

		if( i<n ){
			scanf("%s %d", &p.name, &p.time);
		}
		else
			p=q.dequeue();
			


		if( p.time - quan <=0 ){
			passTime+=p.time;
			printf("%s %d\n", p.name, passTime);

		}else{
			passTime+=quan;
			p.time-=quan;
			q.enqueue(p);
		}


	}

}

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

const uint64_t M = 1'000'000'007;
using matrix = vector<vector<uint64_t>>;

void matprod(const matrix &a, const matrix &b, matrix &ret){
    ret.resize(a.size());
    assert(a[0].size() == b.size());
    for(size_t i=0;i<a.size();i++) ret[i].resize(b[0].size());

    for(size_t i=0;i<a.size();i++){
        for(size_t k=0;k<b[0].size();k++){
            ret[i][k] = 0;
            for(size_t j=0;j<b.size();j++){
                ret[i][k] += a[i][j] * b[j][k] % M;
                ret[i][k] %= M;
            }
        }
    }
}

void mpow(const matrix &a, uint64_t n, matrix &ret){
    if(n == 1){
        ret.resize(a.size());
        for(size_t i=0;i<a.size();i++){
            ret[i].resize(a[0].size());
            for(size_t j=0;j<a[0].size();j++){
                ret[i][j] = a[i][j] % M;
            }
        }
        return;
    }
    matrix aa, tmp;
    matprod(a, a, aa);
    if(n%2 == 0) mpow(aa, n/2, ret);
    else{
        mpow(aa, n/2, tmp);
        matprod(tmp, a, ret);
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int n;
    uint64_t k;
    cin >> n >> k;
    matrix m;
    m.resize(n);
    for(int i=0;i<n;i++) m[i].resize(n);

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

    matrix r;
    mpow(m, k, r);
    
    uint64_t ans = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            ans = (ans+r[i][j]) % M;
        }
    }

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

Measured memory_bytes: 1664
# -*- coding: utf-8 -*-
#
import math
import sys
import itertools
import numpy as np

n =int(input())

a = [int(i) for i in input().split()]

now = 0
answer = 0
for i in range(n):
    if now > a[i]:
        answer += now - a[i] #fumidai
    else:
        now = a[i]

print(answer)




Measured memory_bytes: 50996
#include<stdio.h>
int main(){
  int a,b[200000],i,max,min;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&b[i]);
  }
  min=b[0];
  max=b[1]-b[0];
  for(i=1;i<a;i++){
    if(max<b[i]-min){
      max=b[i]-min;
    }
    if(min>b[i]){
      min=b[i];
    }
  }
  
  printf("%d\n",max);
  return 0;
}


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

int main() {
  ll h;
  cin >> h;
  ll a = 1;
  while (a <= h) {
    a *= 2;
  }
  ll ans = a - 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {

	int K, T, a[105], ans;
	cin >> K >> T;
	for (int i = 0; i < T; i++) cin >> a[i];

	sort(a, a+T);

	int cnt = 0, i = T-1, j = T-2;

	if (j == -1) {
		cout << K-1 << endl;
		return 0;
	}

	while (1) {
		sort(a, a+ T);
		i = T - 1;
		j = T - 2;

		if (a[i] > 0 && a[j] > 0) {
			a[i]--;
			a[j]--;
			cnt += 2;
			
			//cout << "cnt: " << cnt << endl;

		}
		else {
			if (a[i] > 0) ans = K - cnt - 1;
			else ans = K - cnt;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int A, B, C; cin >> A >> B >> C;
    if (A == B and B == C and A == C) cout << "No" << endl;
    else if (A == B or B == C or A == C) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
n = int(input())

res = []
for _ in range(n):
    s, f = map(int, input().split())
    res.append([s, f])

for r in res:
    if r[1] > a and r[0] < b:
        print(1)
        break
else:
    print(0)



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

const int mod=1e9+7,N=2050;
int a,b,c[N][N],ans;

int main(){
	int i,j;
	c[0][0]=1;
	for(i=1;i<N;++i){
		c[i][0]=c[i][i]=1;
		for(j=1;j<i;++j)
		 c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	}
	scanf("%d%d",&a,&b);
	ans=a+1;
    for(i=1;i<b;++i){
    	if(b-i>a) continue;
    	for(j=1;j<=b-i;++j){
    		if((b-i)+(b-i-j)>a) continue;
    		ans=(ans+1ll*c[b-1][i-1]*c[b-i-1][j-1]%mod*c[a-(b-i)-(b-i-j)+2][2]%mod)%mod;
    	}
    }
    printf("%d\n",ans);
}

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

using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    priority_queue<ll> q;
    q.push(-((a*x)+(b*y)));
    ll mul=(x*2)*c;
    if(x<y)
        mul+=(y-x)*b;
    q.push(-mul);
    mul=y*c*2;
    if(y<x)mul+=(x-y)*a;
    q.push(-mul);
    cout<<abs(q.top());
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
void read(int &a){
	a=0;
	char c=getchar();
	while(c<'0'||c>'9'){
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		a=a+(c^48);
		c=getchar();
	}
}
int main(){
	int n;
	read(n);
	if(n%9==0){
		puts("Yes");
	}
	else{
		puts("No");
	}
	return 0;
}


Measured memory_bytes: 3032
#include <iostream>
#include <cmath>
#include <iomanip>
 
int main()
{
  long long s;
  std::cin >> s;
  
  long long ss = std::ceil(std::sqrt(s));
  long long rem = ss* ss - s;
  std::cout <<
    std::setprecision(20) <<
    0 << " " << 0 << " " << ss << " " << (rem==0 ? 0 : 1) << " " << rem << " " << ss;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

void swap(char *a, char *b){
  char t[3];
  strcpy(t, a);
  strcpy(a, b);
  strcpy(b, t);
}

int main(){
  int u, i, j, f, min;
  char in[37][3], bs[37][3];

  scanf("%d", &u);
  for(i = 0; i < u; ++i) scanf("%s", in[i]);

  for(i = 0; i < u; ++i) strcpy(bs[i], in[i]);

  for(i = 0; i < u; ++i)
    for(j = u - 1; j > i; --j)
      if(bs[j][1] < bs[j - 1][1])
	swap(bs[j], bs[j - 1]);

  for(i = 0; i < u; ++i) printf(i != 0 ? " %s" : "%s", bs[i]);
  printf("\nStable\n");

  for(i = 0; i < u; ++i){
    min = i;
    for(j = i + 1; j < u; ++j)
      if(in[j][1] < in[min][1]) 
	min = j;
    if(min != i)
      swap(in[min], in[i]);
  }
  
  f = 0;
  for(i = 0; i < u; ++i){
    printf(i != 0 ? " %s" : "%s", in[i]);
    if(in[i][0] != bs[i][0]) f = 1;
  }
  
  puts("");
  puts(f ? "Not stable" : "Stable");

  
  return 0;
}



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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll H, W;
  scanf("%lld %lld", &H, &W);

  ll num1 = (W % 2 == 1) ? W / 2 + 1 : W / 2;
  ll num2 = W / 2;

  ll count1 = (H % 2 == 1) ? H / 2 + 1 : H / 2;
  ll count2 = H / 2;

  if (H == 1 || W == 1) {
    cout << 1 << endl;
    return 0;
  }

  ll a = num1 * count1 + num2 * count2;
  cout << a << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
ll f[61][2][2][2];
const int M=1000000007;
int main() {
	ll L, R;
	cin >> L >> R;
	/*
  i 从左往右前 i 位 ，
  j  是否>L    1是，   0表示==L 
  k  是否<R    1是，   0表示==R 
  x L的第i位
  y R的第i位
  //l 0 表示 小的数==大的数   1表示 小的数<大的数 
  m 0 表示 第一个1 填了没有。 
  d 表示 小的数填d 
  e 表示 大的数填e */
  	f[60][0][0][0]=1;
	for (int i=59; i>=0; i--) 
	rep(j,2) rep(k,2) rep(m,2) {  
		int x=(L>>i)&1;
		int y=(R>>i)&1;
		int low=j?0:x;
		int high=k?1:y;
		for (int d=low;d<=high; d++)
		for (int e=d;e<=high; e++) {
			if (!m && (d^e)) continue;
			ll& t=f[i][j||d>low][k||e<high][m||d];
			t = (t+f[i+1][j][k][m])%M;
		}
	}
	ll ans=0;
	rep(j,2) rep(k,2) ans=(ans+f[0][j][k][1])%M; 
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
#include<array>
#include<algorithm>
#include<queue>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
#include<bitset>
#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

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

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI N,cnt = 0;
	cin >> N;
	vector<LLI>A(N + 1);
	vector<LLI>B(N);
	for (int i = 0; i < N + 1;i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}

	for (int i = 0; i < N;i++) {
		if (A[i] < B[i]) {
			cnt += A[i];
			B[i] -= A[i];
			A[i] = 0;
		}
		else if (A[i] >= B[i]) {
			cnt += B[i];
			A[i] -= B[i];
			B[i] = 0;
		}
		if (A[i + 1] < B[i]) {
			cnt += A[i + 1];
			B[i] -= A[i + 1];
			A[i + 1] = 0;
		}
		else if (A[i + 1] >= B[i]) {
			cnt += B[i];
			A[i + 1] -= B[i];
			B[i] = 0;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
	string s;
	cin>>s;
	int f=0;
	for(int i=0;i<s.size();i++){
		if(f==1&&s[i]=='F') f++;
		if(!f&&s[i]=='C') f=1;
	}
	if(f==2) cout<<"Yes\n";
	else cout<<"No\n";
}

Measured memory_bytes: 256
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

let main() =
    let h = read int
    let w = read int
    let n = read int
    let nax = max h w
    (n + nax - 1) / nax |> puts
    ()

main()
writer.Close()


Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

const ll INF = 1e15;
//始点sとした最短距離を求める O((V+E)logV)
vector<ll> dijkstra(vector<vector<P>>& g, ll s) {
  ll n = SZ(g);
  vector<ll> d(n, INF);
  priority_queue<P, vector<P>, greater<P>> pq;
  vector<bool> fixed(n, false);
  d[s] = 0;
  pq.push(make_pair(0, s));
  while (!pq.empty()) {
    P f = pq.top();
    pq.pop();
    ll cv = f.second;
    fixed[cv] = true;
    if (d[cv] < f.first) continue;
    FOREACH(p, g[cv]) {
      ll nv = p.first;
      ll wgt = p.second;
      if (fixed[nv]) continue;
      if (d[nv] <= d[cv] + wgt) continue;
      d[nv] = d[cv] + wgt;
      pq.push(make_pair(d[nv], nv));
    }
  }
  return d;
}

int main() {
  ll n, m, s, t;
  cin >> n >> m >> s >> t;
  s--, t--;
  vector<vector<P>> yen(n), snuke(n);
  REP(i, m) {
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    u--, v--;
    yen[u].push_back(make_pair(v, a));
    yen[v].push_back(make_pair(u, a));
    snuke[u].push_back(make_pair(v, b));
    snuke[v].push_back(make_pair(u, b));
  }

  auto dist1 = dijkstra(yen, s);
  auto dist2 = dijkstra(snuke, t);

  // cost[i] = 両替所iを使ったときの(コスト，i)
  vector<P> cost(n);
  REP(i, n) { cost[i] = make_pair(dist1[i] + dist2[i], i); }
  sort(ALL(cost));

  const ll ini = 1e15;
  ll p = 0;
  REP(i, n) {
    while (i >= cost[p].second + 1) {
      p++;
    }
    cout << ini - cost[p].first << endl;
  }
}

Measured memory_bytes: 20244