akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std; 
int main() { 
  int K,A,B;
  cin>>K>>A>>B;

  for(int i=A;i<=B;i++){

    if(i%K==0){

      cout<<"OK"<<endl;

      break;

      }

    if(i==B){

      cout<<"NG"<<endl;

      }

    }

  return 0;

  }



Measured memory_bytes: 3584
(let ((a (read))
    (b (read))
    (c (read))
    (tmp 0)
    (ans "No"))

    (if (< b a)
        (progn
            (setq tmp b)
            (setq b a)
            (setq a tmp)
        )
    )
    (loop for i from a to b do
        (if (= i c)
            (progn
                (setq ans "Yes")
                (return)
            )
        )
    )
    (princ ans)
)

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

char string[11];
char x;
int i,j;
short flag;

int main(void){
for(i = 0;i < 1000;i++){
scanf("%s",string);
j = 0;
x = string[0];
flag = 1;
while(flag && string[++j]){
switch(string[j]){
case 'A':
if(x != 'B' && x != 'D')flag = 0;
break;
case 'B':
if(x != 'A' && x != 'C' && x != 'E')flag = 0;
break;
case 'C':
if(x != 'B' && x != 'F')flag = 0;
break;
case 'D':
if(x != 'A' && x != 'E' && x != 'G')flag = 0;
break;
case 'E':
if(x != 'B' && x != 'D' && x != 'F' && x != 'H')flag = 0;
break;
case 'F':
if(x != 'C' && x != 'E' && x != 'I')flag = 0;
break;
case 'G':
if(x != 'D' && x != 'H')flag = 0;
break;
case 'H':
if(x != 'G' && x != 'E' && x != 'I')flag = 0;
break;
case 'I':
if(x != 'H' && x != 'F')flag = 0;
break;
}
x = string[j];
}
if(flag)puts(string);
}
return 0;
}

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

#define scl(x) scanf("%lld",&x)
#define sc(x)  scanf("%d",&x)
#define ll long long
#define lop(i,n) for(int i=0;i<n;++i)
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

const int N=2e5+100;

int n,arr[N];
ll out=0;

int main(){
#ifndef ONLINE_JUDGE
	//freopen("i.txt","r",stdin);
#endif
	sc(n);
	lop(i,n){
		sc(arr[i]);
		if(arr[i]>i)return puts("-1"),0;
	}
	for(int i=n-1;i>=1;i--){
		int cur=max(0,arr[i+1]-1);
		if(i==n-1)cur=0;
		if(cur>arr[i])return puts("-1"),0;
		if(cur<arr[i]){
			out+=arr[i];
		}
	}
	cout<<out<<endl;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/24  Problem: 006_agc_b / Link: https://agc006.contest.atcoder.jp/tasks/agc006_b?lang=en  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N, X;

LL ans = 0LL;

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

	cin >> N >> X;

	if (X == 1 || X == 2 * N - 1) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
		VI a(2 * N - 1);
		FOR(i, 0, SZ(a))a[i] = i + 1;
		swap(a[N - 1], a[X - 1]);
		swap(a[0], a[N - 2]);
		swap(a[2 * N-2], a[N]);

		FOR(i, 0, SZ(a)) {
			cout << a[i] << endl;
		}

	}
	return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define ll long
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n;
	cin >> n;
	ll x = 1000;
	while (x < n) {
		x += 1000;
	}
	cout << x - n << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
long long n,k,ans,j,l;
long long sum1=1,sum2=1;
int main()
{
    cin>>n>>k;
    j=k-1;
    sum1*=k;
    n--;
    while(n>0)
    {
        n--;
        sum1=sum1*j;
    }
    sum1%=2147483647;
    cout<<sum1<<endl;
    return 0;
}

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

int if_coinside(char Sd[64], char T[64], int lengthT, int st){
	int i;
	for(i = 0; i < lengthT; i += 1) {
		if(Sd[i + st] != T[i] && Sd[i + st] != '?') {
			return 0;
		}
	}
	return 1;
}

int compare_renew_candidate(char old[64], char new[64], int lengthS) {
	int i;
	int if_swap;
	if_swap = 0;
	for(i = 0; i < lengthS; i += 1) {
		if((int)old[i] < (int)new[i]) {
			if_swap = 0;
			break;
		} else if((int)old[i] > (int)new[i]) {
			if_swap = 1;
			break;
		}
	}
	if(if_swap == 1) {
		sprintf(old, "%s", new);
	}
	return 0;
}

int gen_candidate(char Sd[64], char T[64], char candidate[64], int lengthS, int lengthT, int st){
	int i;
	for(i = 0; i < st; i += 1) {
		if(Sd[i] == '?') {
			candidate[i] = 'a';
		} else {
			candidate[i] = Sd[i];
		}
	}
	for(i = st; i < st + lengthT; i += 1) {
		candidate[i] = T[i - st];
	}
	for(i = st + lengthT; i < lengthS; i += 1) {
		if(Sd[i] == '?') {
			candidate[i] = 'a';
		} else {
			candidate[i] = Sd[i];
		}
	}
	return 0;
}

int main(void) {
	int i, j;
	int lengthS, lengthT;
	int exist_candidate, match;
	char Sd[64], T[64];
	char new_candidate[64] = {'\0'};
	char old_candidate[64] = {'\0'};
	char buf[128], *ch;

	fgets(Sd, sizeof(buf), stdin);
	fgets(T, sizeof(buf), stdin);

	lengthS = strlen(Sd) - 1;
	lengthT = strlen(T) - 1;
	//delete '\n'
	if(Sd[lengthS] == '\n') {
		Sd[lengthS] = '\0';
		T[lengthT] = '\0';
	}

	if(lengthS < lengthT) {
		printf("UNRESTORABLE\n");
		return 0;
	}
	exist_candidate = 0;
	for(i = 0; i < lengthS - lengthT + 1; i += 1) {
		match = if_coinside(Sd, T, lengthT, i);
		if(match == 1) {
			if(exist_candidate == 0) {
				gen_candidate(Sd, T, old_candidate, lengthS, lengthT, i);
				exist_candidate = 1;
			} else {
				gen_candidate(Sd, T, new_candidate, lengthS, lengthT, i);
				compare_renew_candidate(old_candidate, new_candidate, lengthS);
			}
		}
	}

	if(exist_candidate == 0) {
		printf("UNRESTORABLE\n");
	} else {
		printf("%s\n", old_candidate);
	}
	return 0;
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 210000;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n + 1);
    vector<ll> v;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    v.push_back(1);
    int num = 1;
    vector<ll> cnt(maxn);
    cnt[num] = 1;
    int cur;
    while (true)
    {
        num = a[num];
        if (cnt[num])
        {
            cur = num;
            break;
        }
        cnt[num] = 1;
        v.push_back(num);
        //DBG(num);
    }
    int len = v.size();
    int pos;
    for (int i = 0; i < len; i++)
    {
        if (v[i] == cur)
        {
            pos = i;
            break;
        }
    }
    if (k <= pos)
    {
        cout << v[k] << "\n";
    }
    else
    {
        ll cnt = k - pos;
        vector<int> b;
        for (int i = pos; i < v.size(); i++)
        {
            b.push_back(v[i]);
        }
        int cur1 = b.size();
        int cur2 = cnt % cur1;
        cout << b[cur2] << "\n";
    }
    return 0;
}

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

const int N = 2e5 + 5;
typedef long long ll;
const ll INF = 8e18 + 7;

// lower -even-> start -odd-> end -even-> upper
int n;
ll a[N], sum[N];
int sumOfEven[N], sumOfOdd[N];
ll minCarry[4];
ll f[N][4];

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
        sumOfEven[i] = sumOfEven[i - 1] + (a[i] % 2 == 0);
        sumOfOdd[i] = sumOfOdd[i - 1] + (a[i] % 2 != 0) + 2 * (a[i] == 0);
    }
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j < 4; j++) {
            f[i][j] = INF;
        }
    }
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j < 4; j++) {
            if (j == 0) {
                f[i][j] = sum[i] - sum[0];
                minCarry[j] = min(minCarry[j], f[i][j] - sumOfOdd[i]);
            } else if (j == 1 || j == 3) {
                f[i][j] = sumOfOdd[i] + minCarry[j - 1];
                minCarry[j] = min(minCarry[j], f[i][j] - sumOfEven[i]);
            } else {
                f[i][j] = sumOfEven[i] + minCarry[j - 1];
                minCarry[j] = min(minCarry[j], f[i][j] - sumOfOdd[i]);
            }
        }
    }
    ll res = INF;
    for (int i = 1; i <= n; i++) {
        //printf("%lld %lld %lld %lld\n", f[i][0], f[i][1], f[i][2], f[i][3]);
        res = min(res, f[i][3] + sum[n] - sum[i]);
    }
    cout << res << endl;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  string a,b,c;
  cin>>a>>b>>c;
  int la=a.size();
  int lb=b.size();
  int lc=c.size();
  set<int> dab, dbc, dac;
  for(int i = -lb+1; i < la; ++i) {
    bool ok = true;
    for(auto&& j:irange(0,la)) {
      if (j-i < 0 || j-i >= lb) continue;
      if (a[j] == '?') continue;
      if (b[j-i] == '?') continue;
      if (a[j] != b[j-i]) ok = false;
    }
    if (ok) dab.insert(i);
  }
  for(int i = -lc+1; i < la; ++i) {
    bool ok = true;
    for(auto&& j:irange(0,la)) {
      if (j-i < 0 || j-i >= lc) continue;
      if (a[j] == '?') continue;
      if (c[j-i] == '?') continue;
      if (a[j] != c[j-i]) ok = false;
    }
    if (ok) dac.insert(i);
  }
  for(int i = -lc+1; i < lb; ++i) {
    bool ok = true;
    for(auto&& j:irange(0,lb)) {
      if (j-i < 0 || j-i >= lc) continue;
      if (b[j] == '?') continue;
      if (c[j-i] == '?') continue;
      if (b[j] != c[j-i]) ok = false;
    }
    if (ok) dbc.insert(i);
  }
  int mn = la+lb+lc;
  dab.insert(la);
  dab.insert(-lb);
  dac.insert(la);
  dac.insert(-lc);
  dbc.insert(lb);
  dbc.insert(-lc);
  for (auto&& ab:dab) {
    for(auto&& ac:dac) {
      int bc = ac - ab;
      if (bc > -lc && bc < lb) {
        if (!dbc.count(bc)) continue;
      }
      int s = min({0,ab,ac});
      int t = max({la,ab+lb,ac+lc});
      mn = min(mn, t-s);
    }
  }
  for(auto&& ac:dac) {
    int ca = -ac;
    for(auto&& bc:dbc) {
      int cb = -bc;
      int ab = cb - ca;
      if (ab > -lb && ab < la) {
        if (!dab.count(ab)) continue;
      }
      int s = min({0,ca,cb});
      int t = max({lc,ca+la,cb+lb});
      mn = min(mn, t-s);
    }
  }
  for(auto&& ab:dab) {
    int ba = -ab;
    for(auto&& bc:dbc) {
      int ac = bc - ba;
      if (ac > -lc && ac < la) {
        if (!dac.count(ac)) continue;
      }
      int s = min({0,ba,bc});
      int t = max({lb,ba+la,bc+lc});
      mn = min(mn, t-s);
    }
  }
  cout<<mn<<endl;
  return 0;
}


Measured memory_bytes: 512
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def ii(): return stdin.readline()
num = ii()
def do():
    for i in range(1,4):
        if num[i] == num[i - 1]:
            return "Bad"
    else:
        return "Good"
print(do())


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 nn, aa = 0, bb = 0;
	cin >> nn;
	vector<int64> memo(nn);
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> memo[ii];
	}
	sort(memo.begin(), memo.end());
	reverse(memo.begin(), memo.end());
	for(int64 ii = 0;ii < nn;ii++)
	{
		if(ii % 2 == 0)
		{
			aa += memo[ii];
		}
		else
		{
			bb += memo[ii];
		}
	}
	cout << (aa - bb) << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
typedef long long ll;
const int N=100010;
int n,k,x;
string s;
vector<int>g[N];
int dp[N];
int dfs(int u){
	if(dp[u]!=-1)return dp[u];
	if(!g[u].size())
		return 0;
	for(int i =0;i<g[u].size();i++){
		dp[u]=max(dp[u],dfs(g[u][i])+1);
	}
	return dp[u];
}
int main(){

	scanf("%d%d",&n,&k);
	for(int i =0,a,b;i<k;i++){
		scanf("%d%d",&a,&b);
		g[a].push_back(b);
	}
	memset(dp,-1,sizeof dp);
	int mx=0;
	for(int i =1;i<=n;i++){
			mx=max(mx,dfs(i));
	}
	printf("%d\n",mx );
	return 0;
}

Measured memory_bytes: 8192
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <numeric>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>

int main() {
  intmax_t W, H, x, y;
  scanf("%jd %jd %jd %jd", &W, &H, &x, &y);

  double S = W*H/2.0;
  bool f = ((x*2 == W) && (y*2 == H));
  printf("%.12f  %d\n", S, f);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define per(i,n) for (int i = n - 1; i >= 0; --i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const long long MOD = 1e9+7;
#define precout() cout << std::fixed << std::setprecision(20);
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
static const double pi = 3.141592653589793;

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

  string s; cin >> s;
  ll n = s.size();
  vector<ll> cnt(26, 0);
  for(auto&c:s) {
    ++cnt[c-'a'];
  }
  ll ans = (n * (n - 1)) / 2 + 1;

  rep(i, 26) {
    ans -= (cnt[i] * (cnt[i] - 1)) / 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 720
#include<stdio.h>
int main(void){
	int i,n;
	int number;
	long long int sum=0;
	int min=0;
	int max=0;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	{
		scanf("%d",&number);
		
		if(i==0)
		{
			min = number;
			max = number;
		}
		if(number<min) min = number;
		if(number>max) max = number;
		
		sum += number;
	}
	
	printf("%d %d %lld\n",min,max,sum);
	
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

int main(void)
{
	int number, n, i, student[100];
	double kg, m;
	
	n = 0;
	while (scanf("%d,%lf,%lf", &number, &kg, &m) != EOF){
		if (kg / m / m >= 25.0){
			student[n] = number;
			n++;
		}
	}
	
	for (i = 0; i < n; i++){
		printf("%d\n", student[i]);
	}
	
	return (0);
}

Measured memory_bytes: 628
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        l: [usize; n],
    }
    let mut res = 0;
    for i in 0 .. n {
        for j in i .. n {
            for k in j .. n {
                let a = l[i];
                let b = l[j];
                let c = l[k];
                if a == b || b == c || c == a {
                    continue;
                } else if a + b > c && b + c > a && c + a > b {
                    res += 1;
                }
            }
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 2176
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <queue>
#pragma warning( disable:4996 )
using namespace std;

#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))


int main(void) {
	int r;
	scanf("%d", &r);
	printf("%d\n", 3 * r*r);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        Boolean isCoffee = false;

        if(S.charAt(2) == S.charAt(3)){
            if(S.charAt(4) == S.charAt(5)){
                isCoffee = true;
            }
        }

        if(isCoffee){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}









Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,e,sum=1;
	cin>>a>>b;
	d=b;
	for(;;){
		d=d/10;
		if(d>0){
			sum=sum+1;
		}
		else {
			break;
		}
	}
	for(int i=1;i<=sum;i++){
		a=a*10;
	}
	c=a+b;
	for(int i=1;i<=c;i++){
		if(i*i==c){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

char n[105][205];
int dp[105][205]; 

void nor(int len);

int main(void)
{
	int i, j;
	int len;
	
	i = 0;
	while (fgets(n[i], sizeof(n[i]), stdin) != NULL){
		i++;
	}
	
	len = i;
	nor(len);
	
	for (i = 0; i < len; i++){
		j = 0;
		while (dp[i][j] != -1){
			
			if (i < len / 2){
				if (j == 0){
					dp[i + 1][j] += dp[i][j];
				}
				if (dp[i][j] < dp[i][j + 1] && dp[i + 1][j + 1] != -1){
					dp[i + 1][j + 1] += dp[i][j + 1];
				}
				else if (dp[i + 1][j + 1] != -1){
					dp[i + 1][j + 1] += dp[i][j];
				}
			}
			else{
				if (dp[i][j] < dp[i][j + 1] && dp[i + 1][j] != -1){
					dp[i + 1][j] += dp[i][j + 1];
				}
				else if (dp[i + 1][j] != -1){
					dp[i + 1][j] += dp[i][j];
				}
			}
			j++;
		}
	}
	
	
	
	printf("%d\n", dp[len - 1][0]);
	
	return (0);
}




void nor(int len)
{
		int i, j, k;
		
		for (i = 0; i < len; i++){
			j = k = 0;
			while (n[i][j] != '\n'){
				
				if ('0' <= n[i][j] && n[i][j] <= '9'){
					
					dp[i][k] = n[i][j] - '0';
					if ('0' <= n[i][j + 1] && n[i][j + 1] <= '9'){
						dp[i][k] = dp[i][k] * 10 + n[i][j + 1] - '0';
						j++;
					}
					k++;
				}
				j++;
			}
			dp[i][k] = -1;
		}
		
}

Measured memory_bytes: 616
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int A, B;
int ans;

int main() {
	cin >> A >> B;
	
	ans = A - 2 * B;

	if (ans < 0) ans = 0;
	
	cout << ans << endl;

	return 0;
}

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

#define FOR(i, a, b) for (int i = a; (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using namespace std;

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

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

using ll = long long;
using ld = long double;

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<int>;
using vvi = vc<vi>;

template<class T>
using va = valarray<T>;
using vad = va<ld>;

vi Read(ll n) {
    auto      v = vi(n);
    for (auto i = std::size_t(0); i < n; ++i) {
        cin >> v[i];
    }
    return v;
}

template<class T>
void Dump(const T& A) {
    REP(i, A.size() - 1) cout << A[i] << " ";
    cout << A[A.size() - 1] << "\n";
}

int gcd(int x, int y){
    if (x < y) swap(x, y);

    while (y > 0){
        const auto r = x % y;
        x = y;
        y = r;
    }
    return x;
}

bool isPrime(int x){
    if (x == 2) return true;
    if (x < 2 || x % 2 == 0)  return false;

    auto i = 3;
    while (i <= sqrt(x)){
        if (x % i == 0) return false;
        i += 2;
    }
    return true;
}


int main() {
    int n;
    cin >> n;
    const auto num = Read(n);

    auto count = 0;
    REP(i, n) if(isPrime(num[i])) ++count;
    cout << count << endl;
    return 0;
}



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

#define _GLIBCXX_DEBAC
typedef long long ll;
using namespace std;


int main() {
	int n;
	string s, t;
	cin >> n >> s >> t;
	for (int i = 0; i < n; i++) {
		cout << s[i] << t[i];
	}
		return 0;
}









Measured memory_bytes: 256
n,k = map(int,input().split())
h_ls = list(map(int, input().split()))
mincost_ls = [float('inf')] * n
mincost_ls[0] = 0
for i in range(n):
    for j in range(i+1,i+k+1):
        if j < n:
            mincost_ls[j] = min(mincost_ls[j], mincost_ls[i] + abs(h_ls[j]-h_ls[i]))
print(mincost_ls[-1])



Measured memory_bytes: 85804
def InputData():
    
    sequence_len = int(input())
    sequence = list(map(int, input().split()))

    description_len = int(input())
    description = list(map(int, input().split()))

    return sequence_len, sequence, description_len, description

def Solve(sequence_num, description_value, sequence, sequence_len):
    if description_value == 0: return True
    elif sequence_num >= sequence_len or description_value > sum(sequence): return False
    res = Solve(sequence_num + 1, description_value, sequence, sequence_len) or \
    Solve(sequence_num + 1, description_value - sequence[sequence_num], sequence, sequence_len)
    
    return res

def main():
    [sequence_len, sequence, description_len, description] = InputData()
    for i in description:
        if Solve(0, i, sequence, sequence_len):
            print("yes")
        else:
            print("no")
        

if __name__ == "__main__":
    main()

    


Measured memory_bytes: 5624
a = [input() for i in range(2)]
 
N = int(a[0])
data = a[1].split(' ')
 
data = [int(i) for i in data]
 
result = []
a = 0
for i in range(N):
    a = a ^ data[i]
    
if a == 0:
    print('Yes')
    exit()
    
print('No')


Measured memory_bytes: 14980
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  int L = a + b;
  int R = c + d;
  if (L > R){
    cout << "Left" << endl;
  } else if (L == R){
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}

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

int w,d;
int h[2][11];
bool used[13];
int main(void){
	while(1){
		scanf("%d %d",&w,&d);
		if(w+d==0)break;
		for(int i=0;i<w;i++){
			scanf("%d",&h[0][i]);
		}
		for(int i=0;i<d;i++){
			scanf("%d",&h[1][i]);
		}
		memset(used,false,sizeof(used));
		if(w>=d){
			int res=0;
			for(int i=0;i<w;i++){
				res+=h[0][i];
				for(int j=0;j<d;j++){
					if(!used[j] && h[1][j]==h[0][i]){
						used[j]=true;
						break;
					}
				}
			}
			for(int i=0;i<d;i++){
				if(!used[i])res+=h[1][i];
			}
			printf("%d\n",res);
		}else{
			int res=0;
			for(int i=0;i<d;i++){
				res+=h[1][i];
				for(int j=0;j<w;j++){
					if(!used[j] && h[0][j]==h[1][i]){
						used[j]=true;
						break;
					}
				}
			}
			for(int i=0;i<w;i++){
				if(!used[i])res+=h[0][i];
			}
			printf("%d\n",res);
		}
	}
	return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/


int N, H, A[101010], B[101010];
//---------------------------------------------------------------------------------------------------
int solve() {
    int ma = 0;
    rep(i, 0, N) ma = max(ma, A[i]);
    vector<int> v;
    rep(i, 0, N) if (ma < B[i]) v.push_back(B[i]);
    sort(v.begin(), v.end(), greater<int>());

    int ans = 0;
    fore(x, v) {
        ans++;
        H -= x;
        if (H <= 0) return ans;
    }

    ans += (H + ma - 1) / ma;
    return ans;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> H;
    rep(i, 0, N) cin >> A[i] >> B[i];
    cout << solve() << endl;
}

Measured memory_bytes: 1660
#include<stdio.h>

int main(void)
{
	int i, j, temp;
	int num[5];
	
	scanf("%d %d %d %d %d",&num[0],&num[1],&num[2],&num[3],&num[4]);
	
	//printf("%d\n",num[4]);
	for(i=0;i<5;i++)
	{
		for(j=i+1;j<5;j++)
		{
			if(num[i]<num[j])
			{
				temp = num[i];
				num[i] = num[j];
				num[j] = temp;
			}
		}
	}
	for(i=0;i<4;i++)
	{
		printf("%d ",num[i]);
	}
	printf("%d\n",num[4]);
	return 0;	
}

Measured memory_bytes: 596
# ABC117C - Streamline
def main():
    n, m = list(map(int, input().rstrip().split()))
    lst = sorted(list(map(int, input().rstrip().split())))
    dis = []
    cur = lst[0]
    for i in lst:
        dis += [i - cur]
        cur = i
    print(sum(sorted(dis, reverse=True)[n - 1 :]))


if __name__ == "__main__":
    main()

Measured memory_bytes: 13968
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    struct Node
    {
        public int Parent { set; get; }
        public int Left { set; get; }
        public int Right { set; get; }
    }

    static void Preorder(Node[] data, int root)
    {
        if (root == -1)
        {
            return;
        }
        Console.Write(" " + root);
        Preorder(data, data[root].Left);
        Preorder(data, data[root].Right);

    }

    static void Inorder(Node[] data, int root)
    {
        if (root == -1)
        {
            return;
        }
        Inorder(data, data[root].Left);
        Console.Write(" " + root);
        Inorder(data, data[root].Right);
    }

    static void Postorder(Node[] data, int root)
    {
        if (root == -1)
        {
            return;
        }
        Postorder(data, data[root].Left);
        Postorder(data, data[root].Right);
        Console.Write(" " + root);
    }

    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        Node[] data = new Node[n];
        bool[] parentexi = new bool[n];
        string[] input;
        bool[] isChild = new bool[n];
        int p = 0;
        int r = 0;
        int l = 0;
        int root = 0;

        for (int i = 0; i < n; i++)
        {
            input = Console.ReadLine().Split(' ');
            p = int.Parse(input[0]);    //親
            l = int.Parse(input[1]);    //右の子
            r = int.Parse(input[2]);    //左の子           

            data[p].Left = l;
            data[p].Right = r;

            //親はだれか
            /*
            if (l != -1)
            {
                data[l].Parent = p;
            }
            if (r != -1)
            {
                data[r].Parent = p;
            }
            */

            if (l != -1) isChild[l] = true;
            if (r != -1) isChild[r] = true;
        }

        root = Array.IndexOf(isChild, false);
     
        Console.WriteLine("Preorder");
        Preorder(data, root);
        Console.WriteLine();

        Console.WriteLine("Inorder");
        Inorder(data, root);
        Console.WriteLine();

        Console.WriteLine("Postorder");
        Postorder(data, root);
        Console.WriteLine();

    }
}


Measured memory_bytes: 17888
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	string W[101];
	scan(N);
	rep(i,N){
		scan(W[i]);
	}
	int flag=1;
	rep1(i,N-1){
		if(W[i][0]!=W[i-1].back()){
			flag=0;
			break;
		}
		rep(j,i){
			if(W[j]==W[i]){
				flag=0;
				break;
			}
		}
	}
	if(flag) prin("Yes");
	else prin("No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    fp((n % 500) <= m);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a,b;
	cin>>a>>b;
	if(a.size()>b.size())cout<<"GREATER"<<endl;
	if(a.size()<b.size())cout<<"LESS"<<endl;
	if(a.size()==b.size())cout<<(a==b?"EQUAL":(a>b?"GREATER":"LESS"))<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

string lcs(string s, string t) {
    vvi dp(s.size() + 1, vi(t.size() + 1));
    
    for(int i = 0; i < s.size(); i++) {//LCS
        for(int j = 0; j < t.size(); j++) {
            if(s[i] == t[j]) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            }
            else{
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
            }
        }
    }
    // 復元
    string ans = "";
    int i = (int)s.size(), j = (int)t.size();
    while (i > 0 && j > 0){
        // (i-1, j) -> (i, j) と更新されていた場合
        if (dp[i][j] == dp[i-1][j]) {
            --i; // DP の遷移を遡る
        }
        // (i, j-1) -> (i, j) と更新されていた場合
        else if (dp[i][j] == dp[i][j-1]) {
            --j; // DP の遷移を遡る
        }
        // (i-1, j-1) -> (i, j) と更新されていた場合
        else {
            ans = s[i-1] + ans;
            --i, --j; // DP の遷移を遡る
        }
    }
    return ans;
}

int main() {
    
    string s,t;
    cin>>s>>t;
    cout<<lcs(s,t)<<endl;
}
/*
ll n,W;
    cin>>n>>W;
    vll w(n+1),v(n+1);
    rep(i,n)cin>>w[i+1]>>v[i+1];
    fin(knapsack(n,W,w,v));
*/

Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;

int n,m,u,v;
vector<int>G[maxn];
int dp[maxn];
inline int dfs(int u,int fa)
{
	int cnt=0;
	for(int i=0;i<G[u].size();++i)
	{
		int v=G[u][i];
		if(v==fa)continue;
		dfs(v,u);
		dp[u]+=dp[v];
		if(!dp[v])cnt++;
	}
	--cnt;
	if(cnt>=0)dp[u]+=cnt;
	return dp[u];
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;++i)
	{
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	int t=-1;
	for(int i=0;i<n&&t==-1;++i)
		if(G[i].size()>=3)t=i;

	printf("%d\n",t!=-1?dfs(t,-1):1);
	//int t=dfs(0,-1);
	//printf("%d\n",t?t:1);
	return 0;
}
 

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

ll x[] = {1, 1, 2, 3, 5, 8, 13, 21};

int main()
{
  int h, w, k;
  cin >> h >> w >> k;
  
  vector<ll> c(w+2, 0);
  ++c[1];
  
  for (int i = 0; i < h; ++i) {
    vector<ll> buf = c;
    for (int j = 1; j <= w; ++j) {
      ll s, t, u;
      s = buf[j-1] ; t = buf[j]; u = buf[j+1];
      
      if (j >= 3) u *= x[j-1];
      if (j >= 4) s *= x[j-2];
      if (j <= w-2) s *= x[w-j];
      if (j <= w-3) u *= x[w-j-1];
      t *= x[j-1] * x[w-j];
      
      c[j] = s + t + u;
      c[j] %= L;
    }
  }
  cout << c[k] << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
D = [0]*(n+1)

def check_div_n(div_list, n):
  return len([d for d in div_list if d>=n and d!=0])

for i in range(2, n+1):
  check_n = i
  for j in range(2, n+1):
    while check_n%j==0:
      D[j] += 1
      check_n = check_n//j
      
ans = check_div_n(D, 74) + \
      (check_div_n(D, 4)-1)*check_div_n(D, 14) + \
      (check_div_n(D, 2)-1)*check_div_n(D, 24) + \
      check_div_n(D, 4)*(check_div_n(D, 4)-1)//2 * \
      (check_div_n(D, 2)-2)
  
print(ans)

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	var day int
	fmt.Scanf("%d", &day)
	if day <= 25 && day > 0 {
		fmt.Printf("Christmas")
		for i := 0; 25-day > i; i++ {
			fmt.Printf(" Eve")
		}
	}
	fmt.Printf("\n")
}


Measured memory_bytes: 512
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize
    }
    let l = sieve(n);
    let ans = (1..=n).map(|x| x * l[x]).sum::<usize>();
    println!("{}", ans);
}

fn sieve(n: usize) -> Vec<usize> {
    let mut l = vec![0; n + 1];
    l[1] = 1;
    for i in 1.. {
        if i * i > n { break; }
        for j in (2..=n/i).rev() {
            if i > j { break; }
            l[i * j] += if i == j { 1 } else { 2 };
        }
    }
    l
}


Measured memory_bytes: 80264
N = int(input()[-1])
hons = [2, 4, 5, 7, 9]
pons = [0, 1, 6, 8]
bons = [3]

for i in hons:
    if i == N:
        print('hon')
for i in pons:
    if i == N:
        print('pon')
for i in bons:
    if i == N:
        print('bon')


Measured memory_bytes: 9172
<?php
declare(strict_types=1);

//red blue
//3 4
//red

$h = STDIN;

//list($a,$b) = explode(' ', trim(fgets($h)));

$str = trim(fgets($h));
for ($i = 0, $iMax = strlen($str); $i < $iMax; $i++){
    echo 'x';
}


Measured memory_bytes: 4604
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int main(){
    int N;
    cin >> N;
    vector<vector<int>> G(N);
    vector<pair<int,int>> edge(N-1);
    vector<int> cnt(N,0);
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
        cnt[a]++;
        cnt[b]++;
        edge[i] = {a,b};
    }
    int K=0;
    rep(i,N){
        K = max(K,cnt[i]);
    }
    queue<pair<int,int>> q;
    map<pair<int,int>,int> m;
    vector<int> seen(N,-1);
    q.push({0,-1});
    while(!q.empty()){
        int v = q.front().first;
        seen[v] = 0;
        int NGcolor = q.front().second;
        q.pop();
        int color = 1;
        for(auto u:G[v]){
            if(seen[u] == 0) continue;
            if(color == NGcolor) color++;
            q.push({u,color});
            m[{v,u}] = color;
            m[{u,v}] = color;
            color++;
        }
    }
    cout << K << endl;
    rep(i,N-1){
        auto e = edge[i];
        cout << m[e] << endl;
    }
}


Measured memory_bytes: 22732
#include <iostream>
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
#define fastio std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pii pair<int, int>
#define mpi make_pair
#define F first
#define S second
#define pb push_back
#define INF 1e15

int main()
{   
    fastio

    int n;
    cin>>n;
    ll siz = (1<<n);
    ll mod = 1e9+7;
    vector<vector<int>> mat(n , vector<int>(n , 0));
    vector<ll> curr(siz ,0);
    
    for(int i=0;i<n;i++)
        for(int j = 0 ; j<n;j++)
            cin>>mat[i][j];

    vector< vector< int >> num(22);
    for(int i = 0 ; i<siz;i++)
    {   
        int t = 0;
        for(int j = 0;j<=20;j++)if((i&(1<<j)) != 0)t++;
        num[t].push_back(i);
    }

    // for(int i= 0;i<=n;i++)
    // {
    //     for(int j = 0 ; j<num[i].size();j++)
    //         cout<<num[i][j]<<" ";
    //     cout<<endl;
    // }

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

    for(int i =1;i<n;i++)
    {   
        
        vector<int> girls;
        for(int k=0;k<n;k++)
        if(mat[i][k] == 1)girls.pb(k);
        
        
        for(int j = 0;j<num[i].size();j++)
        {   
            int dg = num[i][j];
            for(int k:girls)
            {
                if((dg&(1<<k)) == 0)
                {   
                    int ind = dg|(1<<k);
                    curr[ind] = (curr[ind]+curr[dg])%mod;
                }
            }
        }
        // for(int i=0;i<siz;i++)cout<<curr[i]<<" ";
        //     cout<<endl;
    }

    ll ans = 0;

    // cout<<cnt_start<<" "<<cnt_end<<endl;
    for(int i:num[n])
        ans = (ans + curr[i])%mod;

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


Measured memory_bytes: 26560
/*
	Name:
	Author: xiaruize
	Date:
*/
 
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
 
inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	n++;
	for(ll i=k;i<=n;i++)
	{
		ans=(ans+(n-i)*i+1)%MOD;
	}
	cout<<ans%MOD<<endl;
	return 0;
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadLong();

            ulong sum = 0;
            var sqrt = Math.Sqrt(N);
            for (long i = 1; i <= sqrt; i++)
            {
                if (N % i != 0) continue;
                long k1 = i, k2 = N / i;
                long m1 = k1 - 1, m2 = k2 - 1;
                if (m1 != 0 && N / m1 == N % m1) sum += (ulong) m1;
//                Console.WriteLine(m1);
                if (k1     == k2) continue;
                if (N / m2 == N % m2) sum += (ulong) m2;
//                Console.WriteLine(m2);
            }

            Out(sum);
        }

        //最小公倍数
        static int LCM(int num1, int num2)
        {
            var gcd = GCD(num1, num2);
            return num1 * (num2 / gcd);
        }

        static long LCM(long num1, long num2)
        {
            var gcd = GCD(num1, num2);
            return num1 * (num2 / gcd);
        }

        //最大公約数
        static int GCD(int num1, int num2)
        {
            int a = Math.Max(num1, num2);
            int b = Math.Min(num1, num2);
            int mod;
            while ((mod = a % b) != 0)
            {
                a = b;
                b = mod;
            }

            return b;
        }

        static long GCD(long num1, long num2)
        {
            long a = Math.Max(num1, num2);
            long b = Math.Min(num1, num2);
            long mod;
            while ((mod = a % b) != 0)
            {
                a = b;
                b = mod;
            }

            return b;
        }

        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static string ReadString()
        {
            return Console.ReadLine();
        }

        static void Out(object o)
        {
            Console.WriteLine(o);
        }
    }

    static class EnumerableExtension
    {
        public delegate void Function<in T>(T val);

        public static void ForEach<T>(this IEnumerable<T> enumerable, Function<T> function)
        {
            foreach (var x in enumerable)
            {
                function(x);
            }
        }
    }

    class PriorityQueue<T>
    {
    }
}

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

typedef long long ll;
const int N = 1e6;
const ll MOD = 1e9+7;

inline ll dmod(ll x){
	return x%MOD;
}

ll fe(ll x, ll p){
	if(p == 0) return 1ll;
	if(p == 1) return x;
	ll ret = fe(x,p/2);
	ret = dmod(ret*ret);
	if(p&1) ret = dmod(ret*x);
	return ret;
}

ll fakto[N+5];

void pre(){
	fakto[0] = 1ll;
	for(int i=1;i<=N;i++){
		fakto[i] = dmod(fakto[i-1] * (ll) i);
	}
	return;
}

ll nCr(ll x, ll y){
	ll ret = dmod(fakto[y]*fakto[x-y]);
	ret = fe(ret,MOD-2);
	ret = dmod(ret*fakto[x]);
	return ret;
}

int x,y;

int main(){
	pre();
	scanf("%d%d",&x,&y);
	ll ans = 0ll;
	for(int i=0;i<=x;i++){
		int nx = x-(i*3);
		int ny = y-(i*3);
		if(nx < ny) swap(nx,ny);
		if(2*ny == nx){
			ans = dmod(ans + nCr(2*i+ny,i));
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
bool FIND(string S, char T) { return(S.find(T) != string::npos); }
string LAST = "zyxwvutsrqponmlkjihgfedcba";


int main() {
    string S;
    cin >> S;
    if (S == LAST) { cout << -1 << endl; return 0; }
    
    int N = S.length();
    if (N < 26) {
        for (char c = 'a'; c <= 'z'; c++) {
            if (!FIND(S, c)) { S += c; break; }
        }
        cout << S << endl;
        return 0;
    }
    
    int pl = N-1;
    for (int i = N-1; i > 0; i--) {
        if (S[i-1] > S[i]) continue;
        pl = i-1;
        break;
    }
    char add = S[pl] + 1;
    S = S.substr(0, pl);
    while (add <= 'z') {
        if (FIND(S, add)) add++;
        else break;
    }
    S += add;
    
    cout << S << endl;
    return 0;
}

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

int main() {
    long long n;
    cin >> n;
    vector< long long>a(n);
    vector<long long>s(n+1,0);
    for( long long i=0; i<n; ++i){
        cin >> a[i];
        s[i+1]=s[i]+a[i];
    }
    long long ans=1e18;
    for( int i=1; i<n; ++i){
        long long l=s[i];
        long long r=s[n]-s[i];
        long long d=abs(l-r);
        ans=min(ans,d); 
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();

    let mut ans: usize = 1;
    const MOD: usize = 1_000_000_007;
    let mut counts = vec![0_usize; n];
    for i in 0..n {
        if a[i] == 0 {
            ans *= 3 - counts[a[i]];
        } else {
            ans *= counts[a[i] - 1] - counts[a[i]];
        }
        counts[a[i]] += 1;
        ans %= MOD;
    }
    ans.to_string()
}


Measured memory_bytes: 4236