akhauriyash/Code-Regression huggingface dataset:
/*
 * FILE: ABC 123C.cpp
 *
 * @author: Piyush Kanti Das <piyush123kantidas[at]gmail[dot]com>
 *
 * LINK:
 *
 * DATE CREATED: 31.07.2019 03:27:35 +06
 *
 * DESCRIPTION:
 *
 * DEVELOPMENT HISTORY:
 * Date         Version     Description
 * --------------------------------------------------------------
 * 31-07-2019	1.0         File Created
 *
 */


/*
// _______________________________________________________________/\\\_________
//  ______________________________________________________________\/\\\_________
//   ___/\\\\\\\\\___/\\\____/\\\__/\\\____________________________\/\\\_________
//    __/\\\/////\\\_\///____\//\\\/\\\___/\\\____/\\\__/\\\\\\\\\\_\/\\\_________
//     _\/\\\\\\\\\\___/\\\____\//\\\\\___\/\\\___\/\\\_\/\\\//////__\/\\\\\\\\\\__
//      _\/\\\//////___\/\\\_____\//\\\____\/\\\___\/\\\_\/\\\\\\\\\\_\/\\\/////\\\_
//       _\/\\\_________\/\\\__/\\_/\\\_____\/\\\___\/\\\_\////////\\\_\/\\\___\/\\\_
//        _\/\\\_________\/\\\_\//\\\\/______\//\\\\\\\\\___/\\\\\\\\\\_\/\\\___\/\\\_
//         _\///__________\///___\////_________\/////////___\//////////__\///____\///__
//
*/

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

typedef long long           ll;
typedef double              lf;
typedef unsigned long long  ull;
typedef pair<int, int>      pii;
typedef vector<pii>         vpii;
typedef vector<int>         vi;
typedef vector<long long>   vll;

#define __FastIO        ios_base::sync_with_stdio(false); cin.tie(0)

#define forr(i, a, b)   for (__typeof (a) i=a; i<=b; i++)
#define rof(i, b, a)    for (__typeof (a) i=b; i>=a; i--)
#define rep(i, n)       for (__typeof (n) i=0; i<n; i++)
#define forit(i, s)     for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define all(ar)         ar.begin(), ar.end()

#define fill(ar)   		memset(ar, -1, sizeof(ar))
#define clr(a)          memset(a, 0, sizeof(a))

#define nl              cout << '\n';
#define sp              cout << ' ';
#define ckk             cout << "##########\n"

#define pb              push_back
#define MP 				make_pair

#define debug1(x)       cerr << #x << ": " << x << endl
#define debug2(x, y)    cerr << #x << ": " << x << '\t' << #y << ": " << y << endl
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z << endl

#define gama 0.57721566490
#define PI              acos(-1.0)
#define INF             0x7fffffff
#define MOD             1000000007
#define EPS             1e-7
#define MAX             100005

int Set(int N,int pos){return N=N | (1<<pos);}
int Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}


ll BM( ll a , ll b , ll m )
{
    if ( b == 0 ) return 1 ;
    ll x = BM(a,b/2,m);
    x = (( x % m) * (x % m))%m;
    
    if( b % 2 ) x = (( x % m) * (a %m)) % m ;
    return x ;
}

//Auto-format --> ctrl+shift+a
/********************* Code starts here ************************/



int main() {
    __FastIO;   //Be aware to use it!
	
	ll n, ara[6], mn = 10000000000000000;
	
	cin >> n;
	
	rep(i, 5){
		cin >> ara[i];
		mn = min(mn, ara[i]);
	}
	
	

	
	cout << (n + mn - 1)/mn + 4 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define per(i,a,n) for(int i=(n)-1;i>=(a);i--)
#define MP make_pair

typedef double db;

const db EPS = 1e-8;

inline int sign(db a) {
	return a < -EPS ? -1 : a > EPS;
}

inline int cmp(db a, db b){
	return sign(a-b);
}

struct P {
	db x, y;
	P() {
	}
	P(db _x, db _y) :
			x(_x), y(_y) {
	}
	P operator+(P p) {
		return P(x + p.x, y + p.y);
	}
	P operator-(P p)  {
		return P(x - p.x, y - p.y);
	}
	P operator*(db d) {
		return P(x * d, y * d);
	}
	P operator/(db d) {
		return P(x / d, y / d);
	}
	bool operator<(P p) const {
		int c = sign(x - p.x);
		if (c)
			return c == -1;
		return sign(y - p.y) == -1;
	}
	db dot(P p) {
		return x * p.x + y * p.y;
	}
	db det(P p) {
		return x * p.y - y * p.x;
	}
	db distTo(P p) { return (*this-p).abs(); }

	db alpha() {
		return atan2(y, x);
	}
	void read() {
		cin>>x>>y;
	}
	db abs() {
		return sqrt(abs2());
	}
	db abs2() {
		return x * x + y * y;
	}
	P rot90(){
		return P(-y,x);
	}
};

#define cross(p1,p2,p3) ((p2.x-p1.x)*(p3.y-p1.y)-(p3.x-p1.x)*(p2.y-p1.y))
#define crossOp(p1,p2,p3) sign(cross(p1,p2,p3))

P isLL(P p1, P p2, P q1, P q2) {
	db a1 = cross(q1, q2, p1), a2 = -cross(q1, q2, p2);
	return (p1 * a2 + p2 * a1) / (a1 + a2);
}

bool intersect(db l1,db r1,db l2,db r2){
	if(l1>r1) swap(l1,r1); if(l2>r2) swap(l2,r2); 
	return !( cmp(r1,l2) == -1 || cmp(r2,l1) == -1 );
}

bool isSS(P p1, P p2, P q1, P q2){
    return intersect(p1.x,p2.x,q1.x,q2.x) && intersect(p1.y,p2.y,q1.y,q2.y) && 
    crossOp(p1,p2,q1) * crossOp(p1,p2,q2) <= 0 && crossOp(q1,q2,p1)
            * crossOp(q1,q2,p2) <= 0;
}

bool isMiddle(db a, db m, db b) {
    return sign(a - m) == 0 || sign(b - m) == 0 || (a < m != b < m);
}
 
bool isMiddle(P a, P m, P b) {
    return isMiddle(a.x, m.x, b.x) && isMiddle(a.y, m.y, b.y);
}

bool onSegment(P p1, P p2, P q){
	return crossOp(p1,p2,q) == 0 && isMiddle(p1, q, p2);
}

P proj(P p1, P p2, P q) {
    P dir = p2 - p1;
    return p1 + dir * (dir.dot(q - p1) / dir.abs2());
}

P reflect(P p1, P p2, P q){
	return proj(p1,p2,q) * 2 - q;
}

db nearest(P p1,P p2,P q){
	P h = proj(p1,p2,q);
	if(isMiddle(p1,h,p2))
		return q.distTo(h);
	return min(p1.distTo(q),p2.distTo(q));
}

db disSS(P p1, P p2, P q1, P q2){
	if(isSS(p1,p2,q1,q2)) return 0;
	return min(min(nearest(p1,p2,q1),nearest(p1,p2,q2)), min(nearest(q1,q2,p1),nearest(q1,q2,p2)) );
}

db getrad(P p1,P p2){
	return atan2l(p1.det(p2),p1.dot(p2));
}

db incircle(P p1, P p2, P p3){
	db A = p1.distTo(p2);
	db B = p2.distTo(p3);
	db C = p3.distTo(p1);
	return sqrtl(A*B*C/(A+B+C));
}

int main(){
	int n;cin>>n;
	rep(i,0,n){
		P p1,p2,q1,q2;
		p1.read(),p2.read(),q1.read(),q2.read();
		printf("%0.10f\n", disSS(p1,p2,q1,q2));
	}

	return 0;
}

Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
#define fst first
#define snd second
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> inline int Log2(T& x) {int k; for(k=0; (T(1)<<k)<=x; ++k); return k;} // number of binary digits


int main() {
  ll N, M; cin >> N >> M;

  VV to(N);
  for (int i = 0; i < M; ++i) {
    int u, v; cin >> u >> v;
    u--; v--;
    to[u].push_back(v);
  }

  Vld E(N);
  drep(u, N-1) {
    ld x = 0;
    for (auto v : to[u]) x += E[v];
    E[u] = x / to[u].size() + 1;
  }

  Vld p(N);
  p[0] = 1;
  rep(u, N-1) for (auto v : to[u]) p[v] += p[u] / to[u].size();

  ld cmax = 0;
  rep(u, N-1) {
    int d = to[u].size();
    if (d <= 1) continue;
    for (auto v : to[u]) chmax(cmax, p[u] / (d - 1) * (E[v] - E[u] + 1));
  }

  ld ans = E[0] - cmax;
  cout << setprecision(12);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
N = int(input())
SUM = [0]*(N+1)
for i in range(1,N+1):
    if i%3 == 0 and i%5 == 0:
        SUM[i] = 0
    elif i%3 == 0:
        SUM[i] = 0
    elif i%5 == 0:
        SUM[i] = 0
    else:
        SUM[i] = i
print(sum(SUM))

Measured memory_bytes: 33688
from itertools import product
N, M = map(int, input().split())
K = []
S = []
for i in range(M):
    tmp1 = list(map(int, input().split()))
    K.append(tmp1[0])
    tmp2 = []
    for j in tmp1[1:]:
        tmp2.append(j-1)
    S.append(tmp2)

P = list(map(int, input().split()))

ans = 0
for v in product([0, 1], repeat=N):
    flag = False
    cnt_M = 0
    for j in range(M):
        cnt_light = 0
        for i in range(N):
            for k in range(K[j]):
                if v[i] == 1 and i == S[j][k]:
                    cnt_light += 1
        if cnt_light % 2 == P[j]:
            cnt_M += 1
        else:
            break
        if cnt_M == M:
            ans += 1
print(ans)






Measured memory_bytes: 43248
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
A = np.array(read().split(),np.int64)

Acum = A.cumsum()

L = Acum[:-1]
R = Acum[-1] - L

answer = np.abs(L-R).min()
print(answer)

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

using namespace std;

const int MX = 100000;

void ans(int* p, int n) {
	for (int i = 0; i < n; i++) printf("%d ", p[i]);
	printf("\n");
	
	exit(0);
}

int n;

void mult(int* p, int* q, int* r) {
	for (int i = 0; i < n; i++) {
		r[i] = p[q[i] - 1];
	}
}

int p[55][MX];

void binpow(int* a, int k) {
	iota(p[44], p[44] + n, 1);
	while (k > 0) {
		if (k % 2 == 1) {
			mult(p[44], a, p[45]);
			memmove(p[44], p[45], 4 * n);
		}
		
		mult(a, a, p[45]);
		memmove(a, p[45], 4 * n);
		
		k /= 2;
	}
	
	memmove(a, p[44], 4 * n);
}

void getInv(int* p, int* r) {
	for (int i = 0; i < n; i++) r[p[i] - 1] = i + 1;
}

int main() {
	int k;
	ignore = scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) ignore = scanf("%d", p[0] + i);
	for (int i = 0; i < n; i++) ignore = scanf("%d", p[1] + i);
	
	for (int i = 2; i < 10; i++) {
		for (int j = 0; j < n; j++) {
			p[i][p[i - 2][j] - 1] = p[i - 1][j];
		}
	}
	
	if (k < 10) ans(p[k - 1], n);
	
	getInv(p[0], p[11]);
	getInv(p[1], p[12]);
	
	mult(p[1], p[11], p[13]);
	mult(p[13], p[12], p[14]);
	mult(p[14], p[0], p[15]);
	
	binpow(p[15], (k - 1) / 6);
	
	mult(p[11], p[1], p[21]);
	mult(p[21], p[0], p[22]);
	mult(p[22], p[12], p[23]);
	
	binpow(p[23], (k - 1) / 6);
	
	mult(p[15], p[(k - 1) % 6], p[33]);
	mult(p[33], p[23], p[34]);
	
	ans(p[34], n);
	
	return 0;
}


Measured memory_bytes: 15104
#include<cstdio>
#include<cmath>
int s[100005],a[100005];
int main()
{
	a[1]=1;int n=100000;
	for(int i=2;i<=sqrt(n);i++)
	{
		if(a[i]) continue;
		for(int j=i*i;j<=n;j+=i) a[j]=1;
	}
	for(int i=1;i<=n;i+=2)
	if(!a[i]&&!a[(i+1)/2]) s[i]=1;
	for(int i=1;i<=n;i++) s[i]+=s[i-1];
	scanf("%d",&n);
	for(;n--;)
	{
		int x,y;scanf("%d%d",&x,&y);
		printf("%d\n",s[y]-s[x-1]);
	}
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  ll n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, k) {
    int d;
    cin >> d;
    rep(j, d) {
      int t;
      cin >> t;
      a[t - 1]++;
    }
  }

  int ans = 0;
  rep(i, n) {
    if(a[i] == 0) {
      ans++;
    }
  }
  cout << ans;
}


Measured memory_bytes: 3596
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
using namespace std;

#define A_MAX 500000

typedef struct _tree {
    int parent;
    int left;
    int right;
    int key;
} Tree;

void preorder(Tree *nodes, int n, int i) 
{
    printf(" %d", nodes[i].key);
    if (nodes[i].left != -1) {
        preorder(nodes, n, nodes[i].left);
    }
    if (nodes[i].right != -1) {
        preorder(nodes, n, nodes[i].right);
    }
    
    return;
}

void inorder(Tree *nodes, int n, int i) 
{
    if (nodes[i].left == -1) {
        printf(" %d", nodes[i].key);
    }
    else {
        inorder(nodes, n, nodes[i].left);
        printf(" %d", nodes[i].key);
    }
    if (nodes[i].right != -1) {
        inorder(nodes, n, nodes[i].right);
    }
    
    return;
}

void postorder(Tree *nodes, int n, int i) 
{
    if (nodes[i].left != -1) {
        postorder(nodes, n, nodes[i].left);
    }

    if (nodes[i].right != -1) {
        postorder(nodes, n, nodes[i].right);
    }
    
    printf(" %d", nodes[i].key);

    return;
}


int insert(Tree *nodes, int n, int root) {
    int y = -1;
    int x = root;
    while (x != -1) {
        y = x;
        if (nodes[n].key < nodes[x].key) {
            x = nodes[x].left;
        }
        else {
            x = nodes[x].right;
        }
    }
    nodes[n].parent = y;
    if (y == -1) {
        root = n;
    }
    else if (nodes[n].key < nodes[y].key) {
        nodes[y].left = n;
    }
    else {
        nodes[y].right = n;
    }
    return root;
}


int main() {
    int m;
    int n = 0;
    int key;
    char order[10];
    Tree nodes[A_MAX];
    int root = -1;

    cin >> m;

    for (int i = 0; i < m; i++) {
        scanf("%s", order);
        if (strcmp(order, "insert") == 0) {
            cin >> key;
            nodes[n].parent = -1;
            nodes[n].left = -1;
            nodes[n].right = -1;
            nodes[n].key = key;
            root = insert(nodes, n, root);
//            printf("root = %d\n", root);
            n++;
        }
        else if (strcmp(order, "print") == 0) {
            inorder(nodes, n, root);
            cout << endl;
            preorder(nodes, n, root);
            cout << endl;
        }
    }

    return 0;
}



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

int main()
{
    string s,t;
    ll n;

    cin >> s ;
    cin >> t;

    n = s.size();

    ll cnt = 0,i;

    for(i = 0 ; i< n ;i ++)
    {
        if(s[i] != t[i])cnt++;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 3916
fun main(args: Array<String>) = println(run {
    val (n,k) = readLine()!!.split(" ").map { it.toInt() }
    val ks = (1..k).map { readLine(); readLine()!!.split(" ").map { it.toInt() } }

    val ok = BooleanArray(n)
    ks.forEach {
        it.forEach {
            ok[it-1] = true
        }
    }
    ok.count{!it}
})

Measured memory_bytes: 39072
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{ return firstElof.second < secondElof.second; }
//**Snippetリスト**//
//rep, vin, all//
//gcdlcm, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; 
ll MOD = 1000000007; ll INF = 9999999999999; ll ans = 1;
vl flag, color; vll path; vl D;
//***********//
int main() {
	string S;
	cin >> S;
	ll N = S.length();
	for (i = 0; i < N/2; i++) {
		if (S[i] != S[N - i - 1])ans = 0;
	}
	string T = S.substr(0, N / 2);
	ll M = T.length();
	//cout << T;
	for (i = 0; i < M / 2; i++) {
		if (T[i] != T[M - i - 1])ans = 0;
	}
	T = S.substr(N/2+1, N / 2);
	M = T.length();
	//cout << T;
	for (i = 0; i < M / 2; i++) {
		if (T[i] != T[M - i - 1])ans = 0;
	}
	if (ans) cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, k;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> k;
    int ans = n % k == 0 ? 0 : 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int n;
	cin >> n;
	char s[n];
	REP(i,n) cin >> s[i];
	bool bb=0;
	int cnt=0;
	for(char c='G';c<='Y';c++){
		REP(i,n){
			if(c==s[i]) bb=1;
		}
		if(bb) cnt++;
		bb=0;
	}
	cout << (cnt==3 ? "Three" : "Four") << endl;
/////////////////////////////////////////////
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
int d,n;
scanf("%d %d",&d,&n);

/* d := 100でちょうどd回割り切れる数 */
/* N := そのうちn番目に小さい数 */
int sum = 1;
while(d){
	sum *= 100;
	d--;
}

if(n != 100)
	sum *= n;
else
	sum *= (n+1);

printf("%d\n",sum);


return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String input = null;
		try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
			input = reader.readLine();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
		int num = Integer.parseInt(input);
		int ans = calcCubic(num);
		System.out.println(ans);
	}

	/**
	 * @param num
	 * @return
	 */
	private static int calcCubic(int num) {
		return (int) Math.pow(num, 3);
	}

}

Measured memory_bytes: 24260
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll K, A, B;
	cin >> K >> A >> B;
	ll ans = 1;
	if (B - A > 2) {
		K -= A - 1;
		ans += A - 1;
		ans += (B - A) * (K / 2);
		K %= 2;
	}
	ans += K;
	cout << ans << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 504
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int n,i;
	cin >> n >> i;
	cout << n-i +1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  ll a, b;
  cin >> a >> b;
  if (a < 10 && b < 10)
    cout << a * b << endl;
  else
    cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 888
N = int(input())

tmp = []
for i in range(1,int(N **(0.5)) + 2):
    if N % i == 0:
        tmp.append(i -1)
        tmp.append(N // i - 1)

res = 0

for t in tmp:
    if t > 0 and N // t == N % t:
        res += t

print(res)


Measured memory_bytes: 40172
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		 String a = sc.next();

		 if(a.equals("A")){
			 System.out.println("T");
		 }
		 else if(a.equals("T")){
			 System.out.println("A");
		 }
		 else if(a.equals("G")){
			 System.out.println("C");
		 }
		 else if(a.equals("C")){
			 System.out.println("G");
		 }
	}
}

Measured memory_bytes: 22740
#include <iostream>

using namespace std;

int main() {
  int K;
  cin >> K;
  int even_count = 0;
  int odd_count = 0;
  for (int i = 1; i <= K; i++) {
    if (i % 2 == 0) {
      even_count++;
    } else {
      odd_count++;
    }
  }
  int res = even_count * odd_count;
  cout << res << endl;
}


Measured memory_bytes: 256
unit :: Char -> String
unit n
    | n `elem` ['2', '4', '5', '7', '9'] = "hon"
    | n `elem` ['0', '1', '6', '8'] = "pon"
    | n `elem` ['3'] = "bon"

main :: IO()
main = do
    n <- getLine
    putStrLn $ unit ( last n )

Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int N,U,V;
  cin>>N>>U>>V;
  VI A(N-1),B(N-1);
  rep(i,N-1) cin>>A[i]>>B[i];
  VVI X(N,VI(0));
  rep(i,N-1){
    X[A[i]-1].pb(B[i]-1);
    X[B[i]-1].pb(A[i]-1);
  }
  VI ud(N,-1),vd(N,-1);
  ud[U-1]=0;
  vd[V-1]=0;
  queue<int> Q;
  Q.push(U-1);
  while(!Q.empty()){
    int tmp=Q.front();
    Q.pop();
    rep(i,X[tmp].size()){
      if(ud[X[tmp][i]]==-1){
        ud[X[tmp][i]]=ud[tmp]+1;
        Q.push(X[tmp][i]);
      }
    }
  }
  Q.push(V-1);
  while(!Q.empty()){
    int tmp=Q.front();
    Q.pop();
    rep(i,X[tmp].size()){
      if(vd[X[tmp][i]]==-1){
        vd[X[tmp][i]]=vd[tmp]+1;
        Q.push(X[tmp][i]);
      }
    }
  }
  int ans=0;
  rep(i,N) if(X[i].size()==1 and ud[i]<vd[i]) ans=max(ans,vd[i]-1);
  cout<<ans<<endl;
}

Measured memory_bytes: 7424
N = int(input())
boxes = [0] * (N + 1)
ans = tuple(n for n, digit in reversed(tuple(enumerate(map(int, input().split()), 1))) if (sum(d for d in boxes[n::n]) & 1 != digit and (boxes.__setitem__(n, 1) or 1)))

print(len(ans))
if ans:
    print(*ans)


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

class Unionfind {
  public: 
    vector<int> par;
    vector<int> rank;
    vector<int> size;
    Unionfind(int N) : par(N), rank(N, 0), size(N, 1) {
      for (int i = 0; i < N; i++) {
        par[i] = i;
      }
    }
    int root(int x) {
      return par[x] == x ? x : par[x] = root(par[x]);
    }
    bool same(int x, int y) {
      return root(x) == root(y);
    }
    void unite(int x, int y) {
      x = root(x);
      y = root(y);
      if (x == y) {
        return;
      }
      if (rank[x] < rank[y]) {
        par[x] = y;
        size[y] += size[x];
      } else {
        par[y] = x;
        size[x] += size[y];
        if (rank[x] == rank[y]) {
          rank[x] += 1;
        }
      }
    }
};

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> data(M, vector<int>(2));
  for (int i = 0; i < M; i++) {
    cin >> data[i][0];
    cin >> data[i][1];
    data[i][0] -= 1;
    data[i][1] -= 1;
  }

  reverse(data.begin(), data.end());

  Unionfind uf(N);
  
  vector<long long> union_array(M);

  for (int i = 0; i < M; i++) {
    int x = uf.root(data[i][0]);
    int y = uf.root(data[i][1]);
    if (!uf.same(x, y)) {
      long long ans = uf.size[x] * uf.size[y];
      uf.unite(x, y);
      union_array[i] = ans;
    } else {
      union_array[i] = 0;
    }
  }

  reverse(union_array.begin(), union_array.end());

  long long op = 0;

  for (int i = 0; i < M; i++) {
    op += union_array[i];
    cout << op << endl;
  }
};
 

Measured memory_bytes: 8704
#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;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multi_set;

#define mod         1000000007
#define pi          3.1415926535898
#define eps         1e-9


#define fast       ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define vt vector
#define ar array
#define fs          first
#define sc          second
#define pb         push_back
#define sp          printf(" ")
#define nl          '\n'
#define all(a) a.begin(),a.end()
#define unique(c) (c).resize(unique(all(c)) - (c).begin())
#define sz(x) (int)(x).size()
#define revsort(x) sort(all(x));reverse(all(x))

#define set0(a)     memset(a,0,sizeof(a))
#define setneg(a)   memset(a,-1,sizeof(a))
#define setinf(a)   memset(a,126,sizeof(a))

#define REP(i,start,end) for (int i = start; i <=end; i++)
#define RREP(i,end,start) for (int i=end; i>=start ;i--)
#define EACH(x, a) for (auto& x: a)

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef vector<double> vd;
typedef vector<vector<LL> > matrix;
typedef vector<vector<int> > graph;


 
template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {
    cin >> x;
}
void read(double& d) {
    string t;
    read(t);
    d=stod(t);
}
void read(long double& d) {
    string t;
    read(t);
    d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
    read(t...);
}
template<class A> void read(vt<A>& x) {
    EACH(a, x)
        read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
    EACH(a, x)
        read(a);
}

LL powm(LL x, LL y,LL m) {
    if (y==0) return 1;
    if (y==1) return x%m;
    if (y&1) return (x*(powm((x*x)%m,y/2,m)))%m;
    return powm((x*x)%m,y/2,m)%m;
}

LL inv(LL x, LL m) {
    return powm(x,m-2,m);
}

int add(int var1, int var2) {
    return (((((LL)(var1)) % mod + (LL)(var2)) % mod) + mod) % mod;
}


int mul(int var1, int var2) {
    return (((LL)(var1)) % mod * (LL)(var2)) % mod;
}

LL INF=1e9;

void solve() {
    int n;
    read(n);
    vll a(n);
    read(a);
    sort(all(a));
    int ans = 0;

    REP(i, 0, n-1) REP(j, i+1, n-1) REP(k, j+1, n-1) {
        if (a[i] == a[j] or a[j] == a[k] or a[i] == a[k]) continue;
        if (a[i]+a[j] > a[k]) ans++;
    }

    cout << ans << nl;
}

int main() {
    fast;
        solve();
}


Measured memory_bytes: 3636
fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(' ').map(String::toInt)
    var ret = true
    val canvas = (1..h).map { readLine()!! }
    outside@ for ((i, ss) in canvas.withIndex()){
        inside@ for ((j, s) in ss.withIndex()) {
            if (s == '#') {
                if (i - 1 >= 0 && canvas[i - 1][j] == '#') {
                    continue@inside
                }
                if (i + 1 < h && canvas[i + 1][j] == '#') {
                    continue@inside
                }
                if (j - 1 >= 0 && canvas[i][j - 1] == '#') {
                    continue@inside
                }
                if (j + 1 < w && canvas[i][j + 1] == '#') {
                    continue@inside
                }
                ret = false
                break@outside
            }
        }
    }
    print(if (ret) "Yes" else "No")
}

Measured memory_bytes: 38500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

//long longのシフト演算には気をつけよう

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

    if(n%2 == 1){
        for(int i=n; i>=1; i-=2){
            if(i != n) cout << " ";
            cout << a[i];
        }
        for(int i=2; i<n; i+=2){
            cout << " " << a[i];
        }
    }
    else{
        for(int i=n; i>1; i-=2){
            if(i != n) cout << " ";
            cout << a[i];
        }
        for(int i=1; i<n; i+=2){
            cout << " " << a[i];
        }
    }
    cout << endl;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#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 FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    string a, b, c;
    cin >> n >> a >> b >>c;
    ll ans = 0;
    REP(i,n) {
        set<char> st;
        st.insert(a[i]);
        st.insert(b[i]);
        st.insert(c[i]);
        int cnt = st.size();
        cnt--;
        ans += cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
private fun readIntArray(): List<Int> {
    return readLine()!!.split(" ").map{ it.toInt() }
}

private fun readInt(): Int {
    return readLine()!!.toInt()
}

private fun readTextArray(): List<String> {
    return readLine()!!.split(" ")
}

fun main(args: Array<String>) {
    val N = readInt()
    val (D, X) = readIntArray()

    var consumption = 0
    for (i in 0 until N) {
        val count = 1 + (D - 1) / readInt()
        consumption += count
    }

    print(consumption + X)

}

Measured memory_bytes: 37848
import java.util.*;
public class Main {
	
	public static void main (String[]args) {
		Scanner sc = new Scanner(System.in);
		
		int N =  sc.nextInt();
		
		int A = sc.nextInt();
		
		int B = sc.nextInt();
		
		int total = 0; 
		
		for (int i = 1; i <= N ; i++ ) {
			
			String judge = String.valueOf(i);
			
			String[] nums = judge.split("");
			
			
			int judgeNum = 0; 
			
			for (String numString :nums) {
			
				int num = Integer.parseInt(numString);
			
				judgeNum  += num;
			}
			
			if (A <= judgeNum && B >= judgeNum ) 
				total += i; 
			
		}
		
		System.out.println(total);
					
	}	


}

Measured memory_bytes: 33492
n = int(input())
a = list(map(int, input().split()))

m = 10**9+7
r, b, g = 0, 0, 0
ans = 1

for aa in a:
    if aa == r == b == g:
        ans *= 3
    elif aa == r == b or aa == b == g or aa == g == r:
        ans *= 2
    elif aa != r and aa != b and aa != g:
        print(0)
        exit()
    ans %= m

    aa += 1
    if aa > r:
        r = aa
    elif aa > b:
        b = aa
    elif aa > g:
        g = aa

print(ans%m)

Measured memory_bytes: 83612
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int N = sc.nextInt();
		long[] a = new long[N];
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextLong();
		}
		long count = 0;
		long max = 0;
		for (int i = 0; i < a.length - 1; i++) {
			if (a[i] >= a[i + 1]) {
				count++;
			} else {
				count = 0;
			}
			max = Math.max(count, max);
		}
		System.out.println(max);
	}

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

Measured memory_bytes: 22996
package main

import "fmt"

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)

	ansT, ansA := a, b

	if a >= k {
		ansT -= k
	} else if b >=k-a {
		ansT = 0
		ansA -= k-a
	} else {
		ansT = 0
		ansA = 0
	}
	fmt.Println(ansT,ansA)
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;

constexpr ll mod = 1000000007;
constexpr ll v[] = { 0, 765144583, 346175634, 347662323, 5655049, 184117322, 927321758, 444014759, 542573865, 237315285, 417297686, 471090892, 183023413, 660103155, 727008098, 539588932, 729548371, 700407153, 404391958, 962779130, 184117322, 927321758, 444014759, 542573865, 237315285, 417297686, 471090892, 183023413, 660103155, 727008098 };

int main() {
	int N, T; scanf("%d", &T);
	for (int _t = 0; _t < T; _t++) {
		scanf("%d", &N);
		ll ans = 869418286;
		if (N & 1) {// odd
			for (int i = 14, j = 29; i >= 0; i--, j--) {
				ans = (ans * N + v[j]) % mod;
			}
		}
		else {// even
			for (int i = 14; i >= 0; i--) {
				ans = (ans * N + v[i]) % mod;
			}
		}
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 3216
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();
		int ans=0;
		if(k<=a) {
			ans=k;
		}else if(k<=b) {
			ans=a;
		}else {
			ans = a-(k-(a+b));
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 35760
<?php
$n = intval(fgets(STDIN));
for($i = 0; $i < $n; $i++){
  list($a, $b) = array_map("intval", explode(" ", trim(fgets(STDIN))));
  $C[] = $a + $b;
  $A[] = $a;
  $B[] = $b;
}
array_multisort($C, SORT_DESC, $A, $B);
$score = 0;
for($i = 0; $i < $n; $i++){
  if($i%2==0){
    $score+=$A[$i];
  }else{
    $score-=$B[$i];
  }
}
printf("%d", $score);


Measured memory_bytes: 28272
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#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,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

unsigned int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w; return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}


int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	vector<pair<int, int>> sum;
	rep(i, n) {
		cin >> a[i] >> b[i];
		sum.push_back(make_pair(a[i] + b[i], i));
	}
	sort(sum);
	reverse(sum);

	ll ans=0;
	rep(i, n) {
		if (i % 2 == 0) {
			ans += a[sum[i].second];
		}
		else {
			ans -= b[sum[i].second];
		}
	}
	cout << ans << endl;
	return 0;
}





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

int main(void) {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i=0; i<n; i++) cin >> p[i];

    int match = 0;
    for (int i=0; i<n; i++) {
        if (i+1 == p[i]) match++;
    }

    int sub = 0;
    for (int i=0; i<n-1; i++) {
        if (i+1 == p[i] and i+2 == p[i+1]) {
            sub++;
            i++;
        }
    }

    cout << match - sub << endl;

    return 0;
}

Measured memory_bytes: 3684
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;
    cin >> s;
    
    string tmp = "keyence";
    for(int i = 0; i < s.size() - 7; i++) {
        if(tmp == s.substr(i, 7)) {
            cout << "YES" << endl;
            return 0;
        }
    }
    
    int i = 0;
    while(s[i] == tmp[i]) {
        i++;
    }
    
    int j = 0;
    while(s[s.size() - 1 - j] == tmp[tmp.size() - 1 - j]) {
        j++;
    }
    
    if(i + j >= 7) {
        cout << "YES" << endl;
    }
    else {
        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 namespace std;
typedef long long ll;
 
int main(void){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i, n){
        cin>>v[i];
    }
    int ans = 0;
    rep(i, n){
        if((i+1)%2==1 && v[i]%2 == 1) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;
typedef long long LL;

#define re register

const int N = 1000005;
const LL mod = 998244353;

int n, m;
LL fac[N], ifac[N];

LL Pow(LL x, int y)
{
	LL res = 1; x %= mod;
	while (y)
	{
		if (y & 1)
			res *= x, res %= mod;
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}

void Prepare()
{
	fac[0] = 1;
	for (re int i = 1; i <= N; i++)
		fac[i] = fac[i - 1] * i % mod;
	
	ifac[N] = Pow(fac[N], mod - 2);
	for (re int i = N - 1; i >= 0; i--)
		ifac[i] = ifac[i + 1] * (i + 1) % mod;
}
inline LL C(int x, int y)
{return fac[x] * ifac[y] % mod * ifac[x - y] % mod;}
inline LL Cinv(int x, int y)
{return ifac[x] * fac[y] % mod * fac[x - y] % mod;}

int main()
{
	Prepare();
	
	scanf("%d %d", &n, &m);
	
	if (n < m) swap(n, m);
	LL ans = 0;
	for (re int i = 1; i <= m; i++)
		ans = (ans + C(m + n - i * 2, n - i) * C(2 * i, i) % mod * Cinv(m + n, n) % mod) % mod;
	
	ans = ans * ifac[2] % mod;
	printf("%lld\n", (ans + n) % mod);
	return 0;
} 

Measured memory_bytes: 17360
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <set>
#include <cmath>
using namespace std;
const int maxn=2e5+5;
int n;
int a[maxn];
bool chk(int x){
	int cur=1;
	int cnt=0;
	for (int i=1;i<=n;i++){
		if (a[i]==cur){
			cur++;
			cnt++;
		}
	}
	return cnt>=x;
}
int main(){
	cin>>n;
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	int l=1,r=n,ans=-1;
	while(l<=r){
		int mid=(l+r)/2;
		if (chk(mid)){
			ans=mid;
			l=mid+1;
		}
		else{
			r=mid-1;
		}
	}
	if (ans==-1)  cout<<"-1"<<endl;
	else cout<<n-ans<<endl;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	static int[] fib;
	static int N=1001,V,d;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		fib=new int[1001];
		fib[0]=2;
		fib[1]=3;
		for(int i=0;i<fib.length;i++){
			fib(i);
		}		
		for(;cin.hasNext();){
			N=cin.nextInt();
			d=cin.nextInt();
			UnionFind u=new UnionFind(N);
			for(int i=0;i<N;i++){
				for(int j=i+1;j<N;j++){
					if(Math.abs(fib[i]-fib[j]) < d ){
						u.union(i,j);
					}
				}
			}
			System.out.println(u.num);
		}
		
		
	}
	static int fib(int i){
		if(fib[i]!=0)return fib[i];
		fib[i]=(fib[i-1]+fib[i-2])%N;
		
		return fib[i];
	}
	static class UnionFind {
		final int[] tree;
		int num;
		public UnionFind(int n) {
			this.tree = new int[n];
			Arrays.fill(tree, -1);
			num=n;
		}

		// merge the set contains x and the set contains y
		void union(int x, int y) {
			x = root(x);
			y = root(y);
			if(x != y) {
				if(tree[x] < tree[y]) {
					x ^= y; y ^= x; x^= y;
				}
				tree[x] += tree[y];
				tree[y] = x;
				num--;
			}
		}
		// decide if x and y belong to the same set
		boolean find(int x, int y) {
			return root(x) == root(y);
		}
		int root(int x) {
			return tree[x] < 0 ? x : (tree[x] = root(tree[x]));
		}
		// return size of the set contains x
		int size(int x) {
			return -tree[root(x)];
		}
		// return the number of sets
		int getNum() {
			return num;
		}
	}
}

Measured memory_bytes: 20276
//#pragma GCC optimize("O3")
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#define int long long
#define x first
#define y second
#define pb push_back

#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}

vector<string> inp;
map<pair<int,int>,int> dist;
map<pair<int,int>,bool> vis;
int h,w;
bool val(pair<int,int> p)
{
	return ((p.x>=0)&(p.y>=0)&(p.x<h)&&(p.y<w));
}
vector<pair<int,int> > nexs(pair<int,int> pres)
{
	vector<pair<int,int> > ret;
	for(int i=-1;i<2;++i)
	{
		for(int j=-1;j<2;++j)
		{
			if((abs(i)+abs(j)==2)||(abs(i)+abs(j)==0)){continue;}
			if(val({pres.x+i,pres.y+j})){ret.push_back({pres.x+i,pres.y+j});}
		}
	}
	return ret;
}
void solve(pair<int,int> node)
{
	queue<pair<int,int>> q;
	vis[node]=1;
	dist[node]=0;
	q.push(node);
	while(!q.empty())
	{
		pair<int,int> pres=q.front();
		q.pop();
		for(auto next:nexs(pres))
		{
			if(!vis[next]&&inp[next.x][next.y]!='#')
			{
				vis[next]=1;
				dist[next]=dist[pres]+1;
				q.push(next);
			}
		}
	}
}
signed main()
{
	speed
	cin>>h>>w;
	inp.resize(h);
	for (int i = 0; i < h; ++i)
	{
		cin>>inp[i];
	}
	int maxi=0;
	for(int i=0;i<h;++i)
	{
		for(int j=0;j<w;++j)
		{			
			if(inp[i][j]=='#'){continue;}
			dist.clear();
			vis.clear();
			solve({i,j});
			for(int i=0;i<h;++i)
			{
				for(int j=0;j<w;++j)
				{
					maxi=max(maxi,dist[{i,j}]);
				}
			}
		}
	}
	cout<<maxi<<"\n";
}

Measured memory_bytes: 256
//merge sort
#include <iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right){
	int n1 = mid-left;
	int n2 = right-mid;
	//分成左右两个数组 
	for(int i=0; i<n1; i++)
		L[i] = A[left+i];
	for(int i=0; i<n2; i++)
		R[i] = A[mid+i];
	L[n1]=R[n2]=SENTINEL;//将左右两个数组的边界设为无穷大
	int i=0,j=0;
	//保证数组的左边部分小于右边部分 
	for(int k=left;k<right;k++){
		cnt++;
		if(L[i]<R[j])
			A[k]=L[i++];
		else
			A[k]=R[j++];
	} 
}

void mergeSort(int A[], int n, int left, int right){
	int mid=(left+right)/2;
	if(left+1<right){
		//无限二分割直至每个数组剩下一个或者两个数？ 
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		//自底而上进行归并 
		merge(A, n, left, mid, right);
	}
}

int main(){
	
	int n;
	cin>>n;
	int A[MAX];
	for(int i=0; i<n;i++)
		cin>>A[i];
	
	cnt = 0;
	mergeSort(A, n, 0, n);
	
	//这种输出方法似乎比我的牛逼？？ 
	for(int i=0;i<n;i++){
		if(i)
			cout<<" ";
		cout<<A[i];
	} 
	cout<<endl<<cnt<<endl; 
	
	return 0;
}


Measured memory_bytes: 6912
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;

bool check(vector<pair<int,int>>e,vector<int>p){
    if(p[0]!=1)return false;
    for(int i = 0; i < p.size()-1; i++)
    {
        pair<int,int>edge1=make_pair(p[i],p[i+1]);
        pair<int,int>edge2=make_pair(p[i+1],p[i]);
        for(int j = 0; j < e.size(); j++)
        {
            if(edge1==e[j]||edge2==e[j])break;
            if(j==e.size()-1)return false;
        }
    }
    return true;
}

int main(){
    int n,m,a,b,ans=0;  cin>>n>>m;
    vector<pair<int,int>>e;

    for(int i = 0; i < m; i++)
    {
        cin>>a>>b;
        e.push_back(make_pair(a,b));
    }

    vector<int>p(n);
    iota(p.begin(),p.end(),1);

    do{if(check(e,p))ans++;}while(next_permutation(p.begin(),p.end()));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define va first
#define vb second
#define lb lower_bound
#define pb push_back
#define all(v) v.begin(),v.end()
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
using ll = long long;
using lf = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

const int o = 262144;
struct Idxtree{
   ll O[o+o];
   void update(int i, ll v){
       i += o;
       O[i] = v;
       while(i>1){
           O[i >> 1] = max(O[i], O[i^1]);
           i >>= 1;
       }
   }
   ll gmax(int s, int e){
       s += o; e += o;
       ll m = max(O[s],O[e]);
       while( s <= e){
            m = max({m, O[s], O[e]});
            ++s >>= 1;
            --e >>= 1;
       }
       return m;
   }
} I;

int h[o], a[o];
int n;

int main(){
    fio;
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> h[i];
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++){
        ll d = I.gmax(1,h[i]) + a[i];
        I.update(h[i], d);
    }
    cout << I.gmax(1,n) << '\n';
}

Measured memory_bytes: 5888
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int a[100000];
pair<int, int> p[1000000];
int main() {
  int n, m;
  long long res = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    res += a[i];
  }
  sort(a, a+n);

  for (int i = 0; i < m; i++) {
    cin >> p[i].second >> p[i].first;
  }
  sort(p, p+m);
  
  int id = m-1;
  for (int i = 0; i < n && id >= 0; i++) {
    if (a[i] < p[id].first) {
      res += p[id].first - a[i];
      p[id].second--;
      if (p[id].second == 0) {
        id--;
      }
    }
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 3072