akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
/*vector<Type> v;
vector<Type> v();
vector<Type> v(n);
vector<Type> v(n, d);
vector<vector<Type>> vv;
vector<vector<Type>> vv();
vector<vector<Type>> vv(n);
vector<vector<Type>> vv(n, vector<Type>(m));
vector<vector<Type>> vv(n, vector<Type>(m, d));*/

int main() {
  int l, r, d;
  cin >> l>>r>>d;
  int count=0;
  for(int i=l;i<=r;i++){
    if(i%d==0){
      count++;
    }
  }
  cout << count;

  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
    string o,e;
    cin >> o >> e;
    int sz;
    sz = o.size() + e.size();
    int cno,cne;
    cno=0;
    cne=0;
    for(int i=0; i<sz; i++){
        if(i%2==0){
            cout << o[cne];
            cne++;
        }else{
            cout << e[cno];
            cno++;
        }
    }
    cout << endl;
}




Measured memory_bytes: 3600
results :: Int -> Int -> Int -> [Int]
results a b c = [a + 10*b + c, 10*a + b + c]

main = do
  [a,b,c] <- map read.words <$> getLine
  print $ maximum $ concat $ map (\(x,y,z) -> results x y z) [(a,b,c), (a,c,b), (b,a,c), (b,c,a), (c,a,b), (c,b,a)]

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std ;
#define int long long
int32_t main() 
{
    int m, y, s ;
    cin >> m >> y >> s ;
    if (m % y == 0 ) {
        cout << s * (m / y) << endl;
    }
    else {
        cout << s * ( (m /y) + 1 ) << endl ;
    }
    return 0 ;
}

Measured memory_bytes: 3592
import operator

N, D = map(int, input().split())
points = []
for n in range(N):
    points.append(tuple(map(int, input().split())))

o = 0
for n in range(N):
    for j in range(n+1, N):
        dist = sum(map(operator.pow, list(map(operator.sub, points[n], points[j])), [2]*D))**(1/2)
        if dist == int(dist):
            o += 1
print(o)


Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
          int a,x,c;
          scanf("%d",&a);
          while(a!=0)
          {
                    x=a%10;
                    a=a/10;
                    if(x==7)
                              c++;
          }
          if(c>0)
                    printf("Yes\n");
          else
                    printf("No\n");
}


Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n), b(n);
  for (int i = 0; i < n - 1; ++i) scanf("%d", &b[i]);
  for (int i = 0; i < n; ++i) {
    if (i > 0 && i < n - 1) a[i] = min(b[i], b[i - 1]);
    else if (i == 0)  a[i] = b[i];
    else  a[i] = b[i - 1];
  }
  int sum = 0;
  for (int i = 0; i < n; ++i)
    sum += a[i];
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
using namespace std;
typedef long long ll;

int main() {
	pair<ll, ll> a, b;
	cin >> a.first >> a.second >> b.first >> b.second;
	ll res;
	if (a.first >= b.second || b.first >= a.second) {
		res = 0;
	}
	else
		res = min(a.second, b.second) -max(a.first, b.first);
	cout << res << endl;
}

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

using namespace std;
typedef long long ll;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  bool ans = false;
  for(int i=0; i<s.length(); i++){
    if(s[i] == '7') {ans = true; break;}
  }
  if(ans)
    cout << "Yes\n";
  else
    cout << "No\n";

  return 0;
}


Measured memory_bytes: 3040
#include<iostream>
#include<string>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

int main(){
  int i,j=0,flag=0,flag1=0,n,k;
  string str,kstr = "keyence";
  cin >> str;
  if(str == "keyence"){
    cout << "YES";
    return 0;
  }
  n = str.length();
  //cout << n;
  for(i=0;i<n;i++){
   if(str.substr(i,1) == kstr.substr(i,1)){
     j++;
   }else{
     flag++;
   }
   if(flag)break;
  }
  for(k=n-1;k>0;k--){
  //  cout << k;
   if(str.substr(k,1) == kstr.substr(7-(n-k),1)){
     j++;
     
   }else{
     flag1++;
   }
   if(flag1)break;
  }
  //cout << j;
  if(j >= 7){
    cout << "YES";
    return 0;
  //}else if(str.substr(i,1) == str.substr(k,1) || j==8){
  //  cout << "YES";
  //  return 0;
  }else{
    cout << "NO";
    return 0;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n;
    cin>>n;
    int sum=0;
    for(int i=1;i<=n;i++)
        if(i%3!=0&&i%5!=0)
            sum+=i;
    cout<<sum<<endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <stack>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);

    stack<uint> carbarn;
    carbarn.push(0);            // dummy
    uint input;

    while(cin >> input)
    {
        if(input == 0)
        {
            cout << carbarn.top() << endl;
            carbarn.pop();
        }
        else
        {
            carbarn.push(input);
        }
    }
}

Measured memory_bytes: 1192
#include <cstdio>
#include <cstring>
using namespace std;

#define QUE_SIZE 1000000
typedef struct {
    char name[10];
    int time;
} QUE;
QUE que[QUE_SIZE];

int main() {
    int i,n,q,time=0,head=0,tail;
    char name[10];
    scanf("%d %d", &n, &q);
    tail=n;
    for(i=0;i<n;i++) scanf("%s %d", que[i].name, &que[i].time);
    time=0;
    while(head!=tail){
        if(que[head].time <= q || (QUE_SIZE+tail-head)%QUE_SIZE == 1) {
            time += que[head].time;
            printf("%s %d\n", que[head].name, time);
            head = (head+1)==QUE_SIZE?0:(head+1);
        } else {
            time += q;
            que[head].time -= q;
            que[tail] = que[head];
            head = (head+1)==QUE_SIZE?0:(head+1);
            tail = (tail+1)==QUE_SIZE?0:(tail+1);
        }
    }
    return 0;
}


Measured memory_bytes: 5188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for(int i = a; i <= b; i++) {
        if(i / 10000 == i % 10 && i / 1000 % 10 == i / 10 % 10) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using Complex = complex<double>;


string N;
int mem[20][2][2][2][2][2];


int solve(int k = 0, bool l = true, bool s = false, bool f = false, bool t = false, bool z = true){
    if(k == SIZE(N)) return s&&f&&t;
    int r = (l ? N[k]-'0' : 7);
    int& ret = mem[k][l][s][f][t][z];
    if(ret != -1) return ret;
    ret = 0;
    repe(i, 0, r){
        if(z && i == 0) ret += solve(k+1, false, false, false, false, true);
        if(i == 3) ret += solve(k+1, l && i == r, s, f, true, false);
        if(i == 5) ret += solve(k+1, l && i == r, s, true, t, false);
        if(i == 7) ret += solve(k+1, l && i == r, true, f, t, false);
    }
    return ret;
}


signed main(){
    cin >> N;

    rep(i, 0, SIZE(N))
    rep(j, 0, 2)
    rep(k, 0, 2)
    rep(l, 0, 2)
    rep(m, 0, 2)
    rep(n, 0, 2) mem[i][j][k][l][m][n] = -1;

    cout << solve() << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.math.BigInteger;

public class Main {
	
    public static void main(String[] args) {
    	FastScanner sc = new FastScanner();
        
    	BigInteger a = BigInteger.valueOf(sc.nextInt());
    	BigInteger b = BigInteger.valueOf(sc.nextInt());
    	BigInteger c = BigInteger.valueOf(sc.nextInt());
    	BigInteger d = BigInteger.valueOf(2);
    	BigInteger e = BigInteger.valueOf(1);

    	BigInteger result;
    	
    	if(a.add(b).compareTo(c) == -1){
    		result = a.add(b.multiply(d)).add(e);
    	}
    	else{
    		result = b.add(c);
    	}
    	
    	System.out.println(result);
    }
    
}

class FastScanner {
    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: 21332
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
const int MAXN = 100005;
const int mod = 998244353;

int n, m, x;
vector<int> v[MAXN];

int solve(vector<int> x, vector<int> y){
	if(x.size() > y.size()) swap(x, y);
	int ret = 0, reu = 0;
	for(int i=0; i+1<x.size(); i++){
		if(x[i] == x[i+1]){
			ret++;
			i++;
		}
	}
	for(int i=0; i+1<y.size(); i++){
		if(y[i] == y[i+1]){
			reu++;
			i++;
		}
	}
	int dap = x.size() * 2;
	dap += 2 * min(reu, (int)(y.size() - x.size()) / 2);
	return dap;
}

int main(){
	scanf("%d %d",&n,&m);
	for(int i=1; i<=n; i++){
		int x; scanf("%d",&x);
		v[x % m].push_back(x);
	}
	for(int i=0; i<m; i++){
		sort(v[i].begin(), v[i].end());
	}
	int ret = 0;
	for(int i=0; i<=m-i; i++){
		if(2 * i == m || i == 0){
			ret += v[i].size() - v[i].size() % 2;
		}
		else{
			ret += solve(v[i], v[m-i]);
		}
	}
	cout << ret / 2 << endl;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define Mp make_pair
#define pb push_back

using ll = long long;
using db = double;
using pii = pair<int, int>;
using vi = vector<int>;
mt19937 mrand(time(0));
ll get(ll r) { return ((ll)mrand() * mrand() % r + r) % r; }
ll get(ll l, ll r) { return get(r - l + 1) + l; }

signed main() {
	string n; ll sum = 0; cin >> n;
	for(char ch : n) sum += ch - '0';
	cout << (sum % 9 == 0 ? "Yes" : "No") << endl;
	fprintf(stderr, "time=%.4f\n", (db)clock()/CLOCKS_PER_SEC);
	return 0;
	/* 取模直接除，爆零两行泪
	 * 不开ll见祖宗
	 */
}

Measured memory_bytes: 3896
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, c, k;
	cin >> n >> c >> k;
	vector<int> t(n);
	rep(i, n) cin >> t[i];
	sort(all(t));
	priority_queue<int, vector<int>, greater<int>> pq;
	int ans = 0;
	rep(i, n) {
		if (pq.empty()) pq.push(t[i] + k);
		else {
			if (t[i] > pq.top()) {
				ans++;
				while (pq.size()) pq.pop();
			}
			pq.push(t[i] + k);

		}
		if (pq.size() == c) {
			ans++;
			while (pq.size()) pq.pop();
		}
	}
	if (pq.size()) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//??????????????°
		int nissuu;
		int shakkinn = 100000;
		double risoku;
		int newShakkinn;

		Scanner sc = new Scanner(System.in);		//?????????????????§??\???
		nissuu = sc.nextInt();		//?????±????????\?????????

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

			risoku = shakkinn * 0.05;
			newShakkinn = shakkinn + (int)risoku;		//1??\????????????

			BigDecimal bd = new BigDecimal(newShakkinn);		//??°???????????????bd?????\??????
			bd = bd.setScale(-3 , BigDecimal.ROUND_UP);		//1000??\????????????????????????
			shakkinn = (int)bd.doubleValue();

		}

		System.out.println(shakkinn);

	}
}

Measured memory_bytes: 26232
#include <stdio.h>

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

    char c;
    for(int i = 0; i < N; i++){
       scanf("%c", &c);
       if(c == 'Y'){
           printf("Four\n");
           return 0;
       }
    }
    printf("Three\n");
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;

const int mx=1e5+5;

vector<pil>g[mx];

ll dis[mx];
int color[mx];

void dfs(int u)
{
	if(color[u]) return;
	color[u]=1;
	for(auto it: g[u])
	{
		if(!color[it.first]) dis[it.first]=dis[u]+it.second;
		dfs(it.first);
	}
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int n;
	cin>>n;
	for(int i=1;i<n;i++)
	{
		int u,v;
		ll w;
		cin>>u>>v>>w;
		g[u].push_back({v,w});
		g[v].push_back({u,w});
	}
	
	dfs(1);
	
	for(int i=1;i<=n;i++) cout<<dis[i]%2<<"\n";
						                                				
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	
	return 0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define f first
#define s second
#define mset(m,v) memset(m,v,sizeof(m))
#define mod 1000000007
const int N = 2e5 + 5;
#define PI acos(-1.0)
long double EPS = 1e-9;
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
#define pqll_max priority_queue<ll> // max heap. push(),pop(),top(),size(),empty()
#define pqll_min priority_queue<ll,vector<ll>,greater<ll> >
#define lb(v,val)   lower_bound(v.begin(),v.end(),val) //first equal to or lower than [------------
#define ub(v,val)   upper_bound(v.begin(),v.end(),val) //first greater than ------------)
#define bs(v,x) binary_search(v.begin(),v.end(),x)
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(int x, int y) { x -= y; if (x < 0) x += mod; return x; }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
void solve() {
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
}
signed main()
{
	fastio;
	//cout<<fixed<<setprecision(15);
	//clock_t begin = clock();
	int tc;
	tc = 1;
//	cin >> tc;
	while (tc--) {
		solve();
	}
	//clock_t end = clock();double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;cerr << elapsed_secs;
}


//Error?
// clear lists for every test case
// print new line for each tc
// check for int or ll
// check if problem can be solved without any heavy DS like priority_queue or map



Measured memory_bytes: 3648
#include<stdio.h>

#define N 100
#define W 0
#define G 1
#define B 2

int n,M[N][N],c[N],U[N],V[N],t;

void dfs_visit(int a){
  int b;
  c[a] = G;
  U[a] = ++t;

  for(b = 0;b < n;b++){
    if(M[a][b] == 0) continue;
    if(c[b] == W){
      dfs_visit(b);
    }
  }
    c[a] = B;
    V[a] = ++t;
}

void dfs(){
  int u;

  for(u = 0;u < n;u++){
    c[u] = W;
  }

  t = 0;

  for(u = 0;u < n;u++){
    if(c[u] == W)dfs_visit(u);
  }
  for(u = 0;u < n;u++){
    printf("%d %d %d\n",u+1,U[u],V[u]);
  }
}

int main(){
  int a,b,i,j,k;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      M[i][j] = 0;
    }
  }

  for(i = 0;i < n;i++){
    scanf("%d%d",&a,&b);
    a--;
    for(j = 0;j < b;j++){
      scanf("%d",&k);
      k--;
      M[a][k] = 1;
    }
  }

  dfs();
  
  return 0;
  
}



Measured memory_bytes: 2104
#include<iostream>
#include<ctype.h>
#include<stdio.h>
using namespace std;
int main(){
	int i = 0;
	char key;
	char a[1200];
	while (scanf("%c", &key) != EOF){
		if (islower(key)){
			key = toupper(key);
		}
		else if (isupper(key)){
			key = tolower(key);
		}
		a[i] = key;
		i++;
	}
	for (int i2 = 0; i2 < i - 1; i2++){
		cout << a[i2];
	}
	cout << endl;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <cstdlib> 
#include <string.h>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <ctime>
#include <algorithm>
#include <cmath>
#define PI 3.1415926535897932384626433832795l
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define deci(n) cout<<fixed<<setprecision(n);
#define F first
#define S second
#define mk make_pair
#define pb push_back
#define ALPHA 27
#define ll long long int
#define ld long double
#define mmset(arr, n) memset(arr, n, sizeof arr)
#define debug(x) cerr << '#' << ' ' << x << '\n'
#define len(s) s.length()
#define ForA(i,a,b) for(int i = a; i < b; i++)
#define ForA1(i,a,b) for(int i = b - 1; i >= a; i--)
#define ForB1(i,a,b) for(int i = b; i > a; i--)
#define ForB(i,a,b) for(int i = a; i <= b; i++)
#define INT_SIZE 18 
#define maxn 200010
#define Maxn 100010

using namespace std;

const ll INF = (ll)(8e18);
const ll MOD = 1000000007;

ll c[maxn], dp[maxn];
vector <ll> G[maxn];

int main()
{
    IOS;       
    int n; cin >> n;
    ForB(i,1,n) cin >> c[i];
    dp[0] = 1;
    ForB(i,1,n){
        if((ll)G[c[i]].size() > 0 && G[c[i]].back() + 1 != i){
                 dp[i] += dp[G[c[i]].back()];
                 dp[i] %= MOD;
        }
        else if((ll)G[c[i]].size() == 0) G[c[i]].pb(i);
        G[c[i]].pb(i);
        dp[i] += dp[i - 1];
        dp[i] %= MOD;
    }
    cout << dp[n] << '\n';
    #ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0 ;
}


Measured memory_bytes: 14336
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    if(N < 2) {
    	System.out.println("Yes");
    }
    else {
    	int a, b, count;
    	String output = "Yes";
    	a = sc.nextInt();
    	//b = sc.nextInt();
    	count = 0;
    	for(int i = 1; i < N; i++) {
    		b = sc.nextInt();
    		if(b - a <= -2) {
    			output = "No";
    			break;
    		}
    		if(b - a == -1) {
    			count++;
    			if(count == 2) {
        			output = "No";
        			break;
        		}
    		}else if(b - a > 0) {
    			count = 0;
    		}
    		a = b;
    	}
    	System.out.println(output);
    	sc.close();
    }
  }
}

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

int main() {
  int x;
  cin >> x;
  for (;; ++x) {
    bool fail = false;
    for (int i = 2; i * i <= x; ++i) {
      if (x % i == 0) {
        fail = true;
        break;
      }
    }
    if (!fail)
      break;
  }

  cout << x;
  return 0;
}


Measured memory_bytes: 256
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n,m = lr()
f = make_divisors(m)
f.reverse()
for num in f:
    if num * n <= m:
        print(num)
        sys.exit()

Measured memory_bytes: 77836
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int ma = 0, now = 0;
    bool yes;
    for (auto ch : s)
    {
        yes = false;
        for (auto x : {'A', 'G', 'T', 'C'})
        {
            if (ch == x) {
                yes = true;
                break;
            }
        }
        if (yes == true){
            now++;
        } else {
            ma = max(now, ma);
            now = 0;
        }
    }
    cout << max(now, ma) << endl;
}

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

int N,a[205],ans;

int main()
{
    ios::sync_with_stdio(0);
    cin>>N;
    for(int i=1;i<=N*2;i++)cin>>a[i];
    sort(a+1,a+N*2+1);
    for(int i=1;i<=2*N;i+=2)ans+=a[i];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] tmp = Console.ReadLine().Split(' ');
            long n = long.Parse(tmp[0]);
            long m = long.Parse(tmp[1]);
            if (n>=m/2)
            {
                Console.WriteLine(m/2);
            }
            else
            {
                Console.WriteLine(n + (m - 2 * n) / 4);
            }
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
bool cmp(int lhs,int rhs) {
	return abs(lhs)<abs(rhs);
}
int abs(int x) {
	if(x<0)return -x;
	return x;
}
int main(){
  int N,L;
  scanf("%d %d",&N,&L);
  int a[200+5];
  for(int i =1;i<=N;i++){
    a[i] = L+i-1;
  }
  sort(a+1,a+N+1,cmp);
  int sum=0;
  for(int i=2;i<=N;i++)
	sum+=a[i];
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 3804
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

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

using namespace std;
typedef long long int ll;
const ll INF = 1000000000000000000;
const double PI = 3.1415926535897932;
const ll MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<int> v(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
        v[i] = i;
    }

    vector<double> dist;
    do {
        double d = 0.0;
        rep(i, n-1) {
             double x_sq = (double)(x[v[i+1]] - x[v[i]]) * (double)(x[v[i + 1]] - x[v[i]]);
             double y_sq = (double)(y[v[i+1]] - y[v[i]]) * (double)(y[v[i + 1]] - y[v[i]]);
             d += sqrt(x_sq + y_sq);
        }
        dist.push_back(d);
    } while (next_permutation(v.begin(), v.end()));
    double sum = 0.0;
    rep(i, dist.size()) {
        sum += dist[i];
    }
    double ans = sum / (double)(dist.size());
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 892
import java.util.*;
import java.lang.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();

		List<Integer> listX = new ArrayList<>();
		List<Integer> listY = new ArrayList<>();
		for(int i=0;i<n;i++){
			listX.add(sc.nextInt());
		}
		for(int i=0;i<m;i++){
			listY.add(sc.nextInt());
		}

		Collections.sort(listX);

		Collections.sort(listY);
		// System.out.println(listX.get(n-1));
		// System.out.println(listY.get(0));

		if(listX.get(n-1)<listY.get(0)){
			if(listY.get(0)>x&&listX.get(n-1)<y){
		System.out.println("No War");

			}else{
				
		System.out.println("War");
			}


		}else{
		System.out.println("War");
		}



	}
}

Measured memory_bytes: 23764
#include <stdio.h>
int main(void){
    // Here your code !
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b){
        printf("%d\n",c);
    }
    else if(a==c){
        printf("%d\n",b);
    }
    else printf("%d\n",a);
    return 0;
    
}


Measured memory_bytes: 128
#include<cstdio>
using namespace std;
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a+b==c+d) printf("Balanced\n");
	else if(a+b>c+d) printf("Left\n");
	else if(a+b<c+d) printf("Right\n");
	return 0;
}

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

using namespace std;

int main(){
    int count=0;
    string S,T;
    cin>>S>>T;
    for(int i=0;i<3;i++){
        if(S[i]==T[i]){
            count++;
        }
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define msg(x) debug() << x
#define int long long
const int xx = 2e9;

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

  int n;
  string s;
  cin >> n;
  cin >> s;

  for(int i=0;i<s.size();i++){
    int x = s[i];
    dg1(x);
    int tmp = x + n;
    if(tmp > 90){
      tmp = tmp - 90;
      tmp = tmp % 27;
      dg1(tmp);
      tmp = tmp + 65 - 1;
      dg1(tmp);
    }
    s[i] = (char)tmp;
  }
  cout << s << '\n';

}

Measured memory_bytes: 256
///=======================///
/// coder: Andy - Tohrumi ///
///=======================///

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(__typeof(b) i = a; i < b; i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; i--)

using namespace std;

typedef pair<ll, ll> pll;	typedef pair<int, int> ii;
typedef vector<pll> vll;	typedef vector<string> vs;		typedef vector<ii> vii;
typedef vector<int> vi; 	typedef vector<ll> vl;

///======code start here======///

int dp[3005][3005];

signed main() {
	fastio;
	string s, t; cin >> s >> t;
	int n = s.length(), m = t.length();
	rep(i, 1, n + 1) {
		rep(j, 1, m + 1) {
			if(s[i - 1] == t[j - 1]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else {
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}
	string ans;
	int x = n, y = m;
	while(x > 0 && y > 0) {
		if(s[x - 1] == t[y - 1]) {
			ans.pb(s[x - 1]);
			x--; y--;
		}
		else {
			if(dp[x - 1][y] > dp[x][y - 1]) x--;
			else y--;
		}
	}
	reverse(all(ans));
	cout << ans << endl;
	return 0;
}



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

int main(){
	int N;
	cin >> N;
	int A[N-1], B[N];
	for(int i=0;i<N;i++){
		B[i] = 0;
	}
	for(int i=0;i<N-1;i++){
		cin >> A[i];
		B[A[i] - 1]++;
	}
	for(int i=0;i<N;i++){
		cout << B[i] << endl;
	}
}


Measured memory_bytes: 5192
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int[] list = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    
    int n = sc.nextInt();
    System.out.printf("%d", list[n-1]);
  }
}

Measured memory_bytes: 21716
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define black_tree tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define pair_black_tree tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update>
#define gp __gnu_pbds
#define INF 1000000000
#define MOD 123456789
#define MAX 1000000
#define endl '\n'
#define ll long long
#define ld long double
#define lli long long int
#define ull unsigned long long
#define ulli unsigned long long int
#define pb push_back
#define pf push_front
#define ook order_of_key
#define fbo find_by_order
#define np next_permutation
#define mp make_pair
#define eb emplace_back
#define mae max_element
#define mie min_element
#define lb lower_bound 
#define ub upper_bound
#define bs binary_search
#define ff first
#define ss second
using namespace std;
using namespace gp;
ll n;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	while(n--){
		cout<<"ACL";
	}
}

Measured memory_bytes: 3652
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

mod = 1000000007

"""
# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

if __name__ == "__main__":
    N, K = map(int, sys.stdin.readline().split())
    if N % K == 0:
        print(0)
    else:
        print(1)

Measured memory_bytes: 5100
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>

using namespace std;
//数字が何桁か数える関数
int main()
{
	string fig1, fig2;
	int a;
	bool flag = 0;
	cin >> fig1>> fig2;
	a=(stoi(fig1)*pow(10, fig2.size())) + stoi(fig2);
	for (int i = 1; i <= 1000; i++) {
		if (a == pow(i, 2)) {
			flag = 1;
			break;
		}
	}
	if(flag==1) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class FordFulkerson
{
    class Edge {
	public int to, cap, rev;
	public Edge(int _to, int _cap, int _rev)
	{
	    to = _to; cap = _cap; rev = _rev;
	}
    }

    List<Edge>[] G;
    bool[] used;
    int MAX_V;

    public void AddEdge(int from, int to, int cap)
    {
	G[from].Add(new Edge(to, cap, G[to].Count));
	G[to].Add(new Edge(from, 0, G[from].Count - 1));
    }
    
    int dfs (int v, int t, int f)
    {
	if (v == t) return f;
	used[v] = true;
	for (int i = 0; i < G[v].Count; i++)
	{
	    Edge e = G[v][i];
	    if (!used[e.to] && e.cap > 0)
	    {
		int d = dfs(e.to, t, Math.Min(f, e.cap));
		if (d > 0)
		{
		    e.cap -= d;
		    G[e.to][e.rev].cap += d;
		    return d;
		}
	    }
	}
	return 0;
    }

    public int MaxFlow(int s, int t)
    {
	int flow = 0;
	while (true)
	{
	    used = new bool[MAX_V];
	    int f = dfs(s, t, 1000000000);
	    if (f == 0) return flow;
	    flow += f;
	}
    }

    public FordFulkerson(int maxv)
    {
	MAX_V = maxv;
	G = new List<Edge>[MAX_V];
	for (int i = 0; i < MAX_V; i++)
	    G[i] = new List<Edge>();
    }
}



class Program
{
    public static void Main()
    {

	int n = int.Parse(ReadLine());
	int[] a = new int[n];
	int[] b = new int[n];
	int[] c = new int[n];
	int[] d = new int[n];

	for (int i = 0; i < n; i++)
	{
	    var tmp = ReadIntArray();
	    a[i] = tmp[0]; b[i] = tmp[1];
	}
	for (int i = 0; i < n; i++)
	{
	    var tmp = ReadIntArray();
	    c[i] = tmp[0]; d[i] = tmp[1];
	}

	var mf = new FordFulkerson(10000);
	
	// node#
	//  red : 1 .. n
	//  blue: n+1 .. 2n
	//  s:0, t: 2n+1
	for (int i = 0; i < n; i++)
	{
	    for (int j = 0; j < n; j++)
	    {
		if (a[i] < c[j] && b[i] < d[j])
		{
		    mf.AddEdge(i+1, n+j+1, 1);
		}
	    }
	}

	for (int i = 1; i <= n; i++)
	{
	    mf.AddEdge(0, i, 1);
	    mf.AddEdge(n+i, 2*n+1, 1);
	}

	WriteLine(mf.MaxFlow(0, 2*n+1));
    }
}


Measured memory_bytes: 14304
from itertools import product
S = input()
i,L = 0,len(S)
ops = list(product(" +", repeat=L-1))

T = 0
for op in ops:
    W = ""
    for i in range(L-1):
        W += S[i]+op[i]
    W += S[L-1]
    T += eval(W.replace(" ",""))
print(T)

Measured memory_bytes: 3060
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 998244353;
int h[100010];
int dp[100010];
int N;

int main(void){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }
    
    dp[0] = INF;
    dp[1] = 0;
    for(int i = 2; i <= N; i++){
        if(i > 2){
            dp[i] = min(dp[i-1] + abs(h[i-1]-h[i-2]), dp[i-2] + abs(h[i-1]-h[i-3]) );
        }
        else{
            dp[i] = dp[i-1] + abs(h[i-1]-h[i-2]);
        }
    }
    cout << dp[N] << endl;
    
}



Measured memory_bytes: 1024
import sys
from functools import lru_cache
sys.setrecursionlimit(1000000)

t = int(input())
l = [list(map(int, input().split())) for i in range(t)]

 
for i in range(t):
    N = l[i][0]
    A = l[i][1]
    B = l[i][2]
    C = l[i][3]
    D = l[i][4]
    @lru_cache(maxsize=10**18)
    def min_coin(n):
        if(n == 0):
            return 0
        elif(n == 1):
            return D
        else:
            if(n%2 == 0):
                a = min_coin(n//2)
            else:
                a = min(min_coin(n//2)+D,min_coin(n//2+1)+D)
            if(n%3 == 0):
                b = min_coin(n//3)
            elif(n%3 == 1):
                b = min(min_coin(n//3)+D,min_coin(n//3+1)+D*2)
            else:
                b = min(min_coin(n//3)+D*2,min_coin(n//3+1)+D)
            if(n%5 == 0):
                c = min_coin(n//5)
            else:
                re = n%5
                c = min(min_coin(n//5)+D*re,min_coin(n//5+1)+D*(5-re))
            return min(a+A,b+B,c+C,D*n)   
    print(int(min_coin(N)))


Measured memory_bytes: 12204
# coding = SJIS
n = int(input())
valu = list(map(int, input().split()))
cost = list(map(int, input().split()))
ans = 0
for i in range(n):
    if cost[i] < valu[i]:
        ans += valu[i] - cost[i]
    else:
        ans += 0
print(ans)

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

class MODCombination {
   private:
    ll max, mod, *fac, *finv, *inv;

   public:
    MODCombination(ll max, ll mod) {
        this->max = max;
        this->mod = mod;
        fac = new ll[max];
        finv = new ll[max];
        inv = new ll[max];
        inv[0] = 0;
        fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
        for (int i = 2; i < max; i++) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    ~MODCombination() {
        delete[] fac;
        delete[] finv;
        delete[] inv;
    }
    ll calc(ll n, ll k) {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }
};

int main() {
    ll mod = 1e9 + 7;
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    sort(A.begin(), A.end());
    MODCombination com(N + 1, mod);
    ll ans = 0;
    rep(i, N) {
        ans = (ans + ((A[i] * com.calc(i, K - 1)) % mod)) % mod;
        ans = (ans - ((A[i] * com.calc(N - 1 - i, K - 1)) % mod)) % mod;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
let input = require('fs').readFileSync('/dev/stdin', 'UTF-8');
let array = input.split('\n'); // 3人分の試験データ配列
let result = '';

// 学生分ループ
for (let i=0; i<array.length; i++) {
  let data = array[i].split(' ').map(Number);
  let fScore = data[0];
  let lScore = data[1];
  let retest = data[2];

  // データが全て-1の時終了する
  if (fScore === -1 && lScore === -1 && retest === -1) break;

  if (i !== 0) result += '\n';

  // 中間試験、期末試験のいずれかを欠席した場合成績はF
  if (fScore === -1 || lScore === -1) {
    result += 'F';
  } else {
    let sum = fScore + lScore;
    switch (true) {
      case sum >= 80:
        result += 'A';
        break;
      case 65 <= sum && sum < 80:
        result += 'B';
        break;
      case 50 <= sum && sum < 65:
        result += 'C';
        break;
      case 30 <= sum && sum < 50:
        result += retest >= 50 ? 'C' : 'D';
        break;
      default:
        result += 'F';
    };
  }
}
console.log(result);


Measured memory_bytes: 15136
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int main()
{
    string s;
    cin>>s;
    int len = s.size();
    int flag = 1;
    for(int i = 0; i < len;){
        if(flag == 0)break;
        int flagd1 = 0, flagd2 = 0;
        int flage1 = 0, flage2 = 0;
        if(s[i] == 'd'){
            if(i+5 <= len){
                if(s.substr(i, 7)=="dreamer"){
                    flagd2 = 1, i+=7;
                    if(s.substr(i-2, 5)=="erase"){
                        flagd1 = 1, i-=2;
                        continue;
                    }
                }
                else {
                    if(s.substr(i, 5)=="dream")flagd1 = 1, i+=5;
                }
            }
            if(flagd1 || flagd2)continue;
            else {
                flag = 0;
                break;
            }
        }
        else if(s[i] == 'e'){
            if(i+5 <= len){
                if(s.substr(i, 6)=="eraser")flage2 = 1, i+=6;
                else {
                    if(s.substr(i, 5)=="erase")flage1 = 1, i+=5;
                }
            }
            if(flage1 || flage2)continue;
            else {
                flag = 0;
                break;
            }
        }
        else {
            flag = 0;
            break;
        }
    }
    if(flag){
        cout<<"YES";
    }
    else cout<<"NO";
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
V<ll>fac,rfac;void setFac(int n, int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
ll w, h, x, y;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> w >> h >> x >> y;
  printf("%.12f %d\n",double(w)*h/2, x*2==w && y*2==h);
}

Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

ll A[100000];
ll B[100000];
int id[100000];
vector<vector<ll>> a;
vector<vector<ll>> b;

int main(){
  int N;
  cin >> N;
  rep(i, N){
    cin >> A[i];
    cin >> B[i];
  }
  rep(i, N){ vector<ll> v = {B[i] + A[i], A[i], A[i] - B[i], i, A[i], A[i], B[i]}; a.emplace_back(v); }
  rep(i, N){ vector<ll> v = {A[i] + B[i], B[i], B[i] - A[i], i, B[i], A[i], B[i]}; b.emplace_back(v); }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
#if 0
  rep(i, N) printf("a[%lld %lld]\n", a[i][5], a[i][6]);
  rep(i, N) printf("b[%lld %lld]\n", b[i][5], b[i][6]);
#endif
  ll ans = 0;
  int ai = 0;
  int bi = 0;
  rep(i, N){
    if(i % 2 == 0){
      while(1){
        if(id[a[ai][3]]){
          ai++;
          continue;
        }
        id[a[ai][3]] = 1;
        ans += a[ai][4];
        break;
      }
    }else{
      while(1){
        if(id[b[bi][3]]){
          bi++;
          continue;
        }
        id[b[bi][3]] = 1;
        ans -= b[bi][4];
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> D(N);
  for (int i = 0; i < N; i++) cin >> D[i];
  sort(D.begin(), D.end());

  cout << D[N / 2] - D[N / 2 - 1];
  return 0;
}


Measured memory_bytes: 768
n = input()
if n[0] >= n[1] and (n[0] >= n[2] or n[1] >= n[2]):
    print(n[0]+n[0]+n[0])
else:
    print(str(int(n[0])+1) + str(int(n[0])+1) + str(int(n[0])+1))

Measured memory_bytes: 61824