akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


using namespace std;
using namespace __gnu_pbds;

typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<pair<int,int>, null_type,less<pair<int, int> >,rb_tree_tag,tree_order_statistics_node_update > pbds;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)

#define pb push_back
#define ft first
#define sd second
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll power(ll a, ll b) {
    ll res = 1;
    while(b) {
        if(b % 2) {
            res *= a;
        }
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll power(ll a, ll b, ll mod) {
    ll res = 1;
    a %= mod;
    while(b) {
        if(b % 2) {
            res *= a;
            res %= mod;
        }
        a = a * a % mod;
        b >>= 1;
    }
    return res % mod;
}
const int N = 5e6 + 5;
int n, k, p;


signed main() {
    int t;
    // cin >> t;
    for(int _=1; _<=t; _++) {
        t = 1;
        int n, m;
        cin >> n >> m;
        cout << n * (n -1)/2 + m*(m-1)/2 << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int n;
    cin >> n;

    vector<int> a(n), b(n);
    int64_t s = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s -= a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        s += b[i];
    }

    if (s < 0) {
        cout << "No" << endl;
        quick_exit(0);
    }

    int64_t sa = s, sb = s;
    while (sa >= 0 && sb >= 0) {
        int d = 0;
        for (int i = 0; i < n; i++) {
            if (!(sa >= 0 && sb >= 0)) break;
            int t = b[i] - a[i];
            if (t > 0) {
                d = 1;
                t = (t + 1) / 2;
                sa -= t;
                a[i] += t * 2;
            } else if (t < 0) {
                d = 1;
                t *= -1;
                sb -= t;
                b[i] += t;
            }
        }
        if (d == 0) break;
    }

    int c = 1;
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) c = 0;
    }

    cout << (c && sa >= 0 && sb >= 0 && sa * 2 == sb ? "Yes" : "No") << endl;

    return 0;
}

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

int main(){
    int a[100010]={0};
    ll k;
    string s;
    cin>>s;
    cin>>k;
    for(int i=0;i<s.size()&&k;i++){
        int m=(26+'a'-s[i])%26;
        if(m<=k){ 
            s[i]='a';
            k-=m;
        }
        if(i==s.size()-1) {
            s[i]='a'+(s[i]-'a'+k)%26;
        }
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main (void)

{

int a,b;

scanf("%d %d",&a,&b);

if(a<b){

printf("a < b\n");

}

else{

if(a>b){

printf("a > b\n");

}

else{

printf("a == b\n");

}

}

return 0;

}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll INF=1e9;
const int Bmax=2e5;
const int Nd=61;


int main(){
  int a,b,c,k; cin>>a>>b>>c>>k;
  int x=0,y=0;
  bool ok=false;

  rep(i,k+2){
    if(b>a){
      rep(j,k+2){
        if(c>b && x+y<=k){
          ok=true;
          cout<<"Yes"<<endl;
          return 0;
          break;
        }
        y++;
        c*=2;
      }
    }
    x++;
    b*=2;

    if(ok)  break;


  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 3624
// Problem : A - Lucky 7
// Contest : AtCoder Beginner Contest 162
// URL : https://atcoder.jp/contests/abc162/tasks/abc162_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

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

#define ff first
#define fs second
#define lb lower_bound
#define ub upper_bound

#define int long long
#define vi vector<int>
#define vvi vector< vector <int> >
#define vpii vector< pair<int, int> >
#define vb vector<bool>
#define si set<int>
#define mii map<int, int>
#define mci map<char, int>
#define md 1000000007
#define pb push_back
#define eb emplace_back

#define qw1(x) cerr<<#x<<": "<<x<<" "<<endl
#define qw2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define qw3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define qw4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl


#define f(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define rl(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define all(x) x.begin(),x.end()
#define endl '\n'

void printv(vector<int>  v){
	for(int i=0;i<v.size();i++) cout<<v[i]<<' '; 
	cout<<endl;
	}

int be(int m , int n, int mod) {
	int res=1;
	while(n){
	     if(n%2!=0) { res*=m; res%=mod; }
	     m*=m;   m%=mod;   n/=2;
	}
	return res;
     }

void sieve(int n, vb &prime){
    prime[0]=false;     prime[1]=false;
    for(int i=2;i*i<=n;i++){
         if(prime[i]==true){
              for(int j=i*i;j<=n;j+=i)    prime[j]=false;
             	  }
    	 }
	}


int32_t main ()
{
  //ios_base::sync_with_stdio (false); cin.tie (NULL);  cout.tie (NULL);
int t=1; 
//cin>>t; 
  while(t--){
int n; cin>>n;
while(n){
	int z=n%10;
	if(z==7) { cout<<"Yes\n"; return 0;}
	n/=10;
}
cout<<"No\n";
   
  }
 
}








Measured memory_bytes: 3636
x=int(input())
y=x%7
if y==1:
  print("fri")
elif y==2:
  print("sat")
elif y==3:
  print("sun")
elif y==4:
  print("mon")
elif y==5:
  print("tue")
elif y==6:
  print("wed")
elif y==0:
  print("thu")


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, x, n) for(int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
//struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();

int main() {
  map<string, int> dict;
  int max = 0;

  int n;
  cin >> n;
  string str;
  REP (i, n) {
    cin >> str;
    if (dict.count(str) == 0) {
      dict[str] = 1;
    } else {
      dict[str]++;
    }
    if (max < dict[str]) {
      max = dict[str];
    }
  }

  string* arr = new string[n];

  int count = 0;
  for (pair<string, int> p: dict) {
    if (p.second == max) {
      arr[count] = p.first;
      count++;
    }
  }

  REP (i, count) {
    cout << arr[i] << "\n";
  }

  return 0;
}


Measured memory_bytes: 26880
#include<iostream>
#include<algorithm>
using namespace std;

int main() {
	int n;
	cin >> n;
	int A;
	pair<int,int> a[100010];
	for (int i = 0; i < n; i++) {
		cin >> A;
		if (n == 1) {
			if (A != 0) {
				cout << 0 << endl;
			}
			else {
				cout << 1 << endl;
			}
			return 0;
		}
		a[A].first++;
		a[A].second = A;
	}
	sort(a, a + 100010, greater<pair<int, int>>());
	int end;
	for (int i = 0; i < n; i++) {
		if (a[i].first == 0) {
			end = i;
			break;
		}
	}
	sort(a, a + end);
	if (n % 2 == 1) {
		if (a[0].first != 1||a[0].second>0) {
			cout << 0 << endl;
			return 0;
		}
		for (int i = 1; i < end; i++) {
			if (a[i].second - a[i - 1].second == 2 && a[i].first == 2) {
				
			}
			else {
				cout << 0 << endl;
				return 0;
			}
		}
		int ans = 1;
		for (int i = 0; i < end-1; i++) {
			ans *= 2;
			if (ans >= 1e9 + 7) {
				ans %= 1000000000 + 7;
			}
		}
		cout << ans << endl;
	}
	else {
		if (a[0].first != 2||a[0].second>1) {
			cout << 0 << endl;
			return 0;
		}
		for (int i = 1; i < end; i++) {
			if (a[i].second - a[i - 1].second == 2 && a[i].first == 2) {
				
			}
			else {
				cout << 0 << endl;
				return 0;
			}
		}
		int ans = 1;
		for (int i = 0; i < end; i++) {
			ans *= 2;
			if (ans >= 1e9 + 7) {
				ans %= 1000000000 + 7;
			}
		}
		cout << ans << endl;
	}
}

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

int main(){
    int H,W;
    while(1){
        cin >> H >> W;
        if (H==0 && W == 0)break;
    
    for(int i=0; i<H ;i++){
        for(int j=0; j<W; j++){
            cout << "#";
        }
        cout << endl;
    }
    cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3032
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef long double ld;
const int maxn=505;
int H,W,h,w,a[maxn][maxn];
void work1() {
	rep(i,1,H)
		rep(j,1,W)
			if((i-1)%h==0) a[i][j]=1000*(h-1)-1;
			else a[i][j]=-1000;
}
void work2() {
	rep(i,1,H)
		rep(j,1,W)
			if((j-1)%w==0) a[i][j]=1000*(w-1)-1;
			else a[i][j]=-1000;
}
int main() {
	scanf("%d%d%d%d",&H,&W,&h,&w);
	if(H%h==0&&W%w==0) return puts("No"),0;
	puts("Yes");
	if(H%h) work1();
	else work2();
	rep(i,1,H) {
		rep(j,1,W-1) printf("%d ",a[i][j]);
		printf("%d\n",a[i][W]);
	}
	return 0;
}

Measured memory_bytes: 2688
def cmpStr(S1, S2):
    for i in range(len(S2)):
        if S1[i] == S2[i] or S1[i] == '?':
            yield S2[i]
        else:
            break

Sp = input()
T = input()
res = []
for i in range(len(Sp)-len(T), -1, -1):
    if Sp[i] == '?' or Sp[i] == T[0]:
        substr = ''.join(list(cmpStr(Sp[i:i+len(T)], T)))

        if len(substr) == len(T):
            res.append(Sp[:i]+T+Sp[i+len(T):])
            res[-1] = res[-1].replace('?', 'a')
            break
if res:
    res.sort()
    print(res[0])
else:
    print("UNRESTORABLE")

Measured memory_bytes: 61856
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[][] dp = new int[n][3];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 3; j++) {
				dp[i][j] = in.nextInt();
			}
		}
		for (int i = 1; i < n; i++) {
			for (int j = 0; j < 3; j++) {
				if(j == 0) dp[i][j] += Math.max(dp[i-1][j+1], dp[i-1][j+2]);
				else if(j == 2) dp[i][j] += Math.max(dp[i-1][j-1], dp[i-1][j-2]);
				else dp[i][j] += Math.max(dp[i-1][j-1], dp[i-1][j+1]);
			}
		}
		System.out.println(Math.max(dp[n - 1][0], Math.max(dp[n - 1][1], dp[n - 1][2])));
	}
}

Measured memory_bytes: 95708
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <iomanip>
#include <set>
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define SORT(s) sort((s).begin(),(s).end())

int main(){
    ll R; cin >> R;
    if(R<1200) cout << "ABC" << endl;
    else if(1200<=R && R < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin >> a;
  vector<int> b(a);
  for (int i = 0; i < a; i++) {
    cin >> b[i];
  }
  sort(b.begin(), b.end());
  cout << b[a / 2] - b[a / 2 - 1];
}

Measured memory_bytes: 640
def main():
    n, *a = map(int, open(0).read().split())
    b = list(map(lambda x: x % 4, a))
    f, g = b.count(0), b.count(2)
    h = g % 2
    print('Yes' if (n - f - g + h) - 1 <= f else 'No')


if __name__ == '__main__':
    main()


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

int n;
char s[111];

int main() {
	scanf("%d%s", &n, s);
	int ans = 0;
	for(int i=2;i<n;i++)
		if(s[i-2]=='A'&&s[i-1]=='B'&&s[i]=='C') ans++;
	printf("%d\n", ans);
	
	return 0;
}

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

int main()
{
        ll N, K; cin >> N >> K;
        map<ll, ll> m;
        rep(i, N) {
                ll tmp; cin >> tmp;
                m[tmp]++;
        }
        ll cnt = K - m.size();
        ll ans = 0;
        vector<ll> V;
        for (auto i : m) {
                V.push_back(i.second);
        }
        sort(V.begin(), V.end());
        rep (i, V.size()) {
                if (cnt >= 0) {
                        break;
                }
                ans += V[i];
                cnt++;
        }
        cout << ans << endl;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N;
	cin >> N;
	
	LL h = -1, n = -1, w = -1;
	int found = 0;
	for(h=1; h<=3500; h++){
		for(w=1; w<=3500; w++){
			LL A = N*h*w;
			LL B = 4*h*w - N*(h+w);
			if(B > 0 && A >= B && (A % B) == 0){
				n = A / B;
				found = 1;
				break;
			}
		}
		if(found == 1){
			break;
		}
	}
	printf("%lld %lld %lld\n", h, n, w);
	return 0;
}

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

int main() {
  int N; cin >> N;
  string S; cin >> S;
  int ans = 0;
  for (int i = 0; i < 1000; i++) {
    string s = "";
    if (i < 10) s += "00" + to_string(i);
    else if (i < 100) s += "0" + to_string(i);
    else s += to_string(i);
    int idx = 0;
    for (int i = 0; i < N; i++) {
      if (S.at(i) == s.at(idx)) idx++;
      if (idx == 3) { ans++; break; }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
  int R[MAX], n;

  cin >> n;
  for(int i=0; i<n; i++) cin >> R[i];

  int maxv = -2000000000;
  int minv = R[0];

  for(int i=1; i<n; i++){
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;

  return 0;
}


Measured memory_bytes: 3884
import heapq

INF = 2**60
# input
N, M, S = list(map(int, input().split()))

E = []
for i in range(N):
    E.append([])

for i in range(M):
    u, v, a, b = list(map(int, input().split()))
    E[u-1].append((v-1, a, b))
    E[v-1].append((u-1, a, b))

C, D = [], []
for i in range(N):
    c, d = list(map(int, input().split()))
    C.append(c)
    D.append(d)
# input

#dist[N][N]
dist = []
for i in range(51):
    dist.append([])
    for j in range(2501):
        dist[i].append(INF)

dist[0][min(S, 2500)] = 0


a = []
heapq.heappush(a, (INF, INF, INF))
heapq.heappush(a, (0, 0, min(S, 2500)))

while True:
    t = heapq.heappop(a)
    at = t[1]
    if t[0] == INF:
        break
    if dist[at][t[2]] < t[0]:
        continue
    if t[2] != 2500:
        if dist[t[1]][min(t[2] + C[at], 2500)] > t[0] + D[at]:
            dist[t[1]][min(t[2] + C[at], 2500)] = t[0] + D[at]
            heapq.heappush(a, (t[0] + D[at], t[1], min(t[2] + C[at], 2500)))

    for v in E[at]:
        nat = v[0]
        nd = t[0] + v[2]
        nrest = t[2] - v[1]
        if t[2] == 2500:
            nrest = 2500
        if nrest < 0:
            continue
        if dist[nat][nrest] > nd:
            dist[nat][nrest] = nd
            heapq.heappush(a, (nd, nat, nrest))


ans = [INF] * N
for i in range(N):
    for j in range(2501):
        ans[i] = min(ans[i], dist[i][j])


for i in range(1, N):
    print(ans[i])


Measured memory_bytes: 24412
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let x = input::<i64>();
    let y = input::<i64>();

    let ans = x + y / 2;
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {

	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	int c = sc.nextInt();
	int n = 100*a + 10*b + c;
	
		if(n%4 == 0) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  string S;
  cin >> S;
  int ans = 0;
  string t, p = "";
  rep(i, S.size())
  {
    t += S[i];
    if (t == p)
    {
      continue;
    }
    p = t;
    t = "";
    ans++;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

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

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, m; cin >> n >> m;
  if(n == 1 && m == 1) cout << 1;
  else if (n == 1) cout << m-2 << endl;
  else if (m == 1) cout << n-2 << endl;
  else cout << (n-2) * (m-2) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define ff first
#define ss second
#define double long double
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string s;
	cin >> s; int ans = 0;
	for (int i = 0; i < 3; i++)
	{
		if (s[i] == 'R')
			ans = 1;
	}
	for (int i = 0; i < 2; i++)
	{
		if (s[i] == 'R' && s[i + 1] == 'R')
			ans = 2;
	}
	if (s[0] == s[1] && s[1] == s[2] && s[2] == 'R')
		ans = 3;
	cout << ans;
	return 0;
}



Measured memory_bytes: 3576
"use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function main(input) {
  var lines = input.split('\n');

  var _splitNum = splitNum(lines.shift()),
      _splitNum2 = _slicedToArray(_splitNum, 2),
      N = _splitNum2[0],
      K = _splitNum2[1];

  var hs = lines.slice(0, N).map(function (l) {
    return parseInt(l);
  });
  hs.sort(function (a, b) {
    return a - b;
  });
  var gdiff = Infinity;

  for (var i = 0; i <= N - K; i++) {
    var diff = hs[i + K - 1] - hs[i];

    if (gdiff > diff) {
      gdiff = diff;
    }
  }

  console.log(gdiff);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function splitNum(line) {
  return line.split(/\s+/).map(function (n) {
    return parseInt(n);
  });
}


Measured memory_bytes: 28740
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int n;

void dfs(string s,char mx) {
    if(s.length() == n) {
        cout<<s.c_str()<<'\n';
    }
    else {
        for(char c='a';c<=mx;c++) {
            dfs(s+c,((c == mx) ? (char)(mx+1) : mx));
        }
    }
}

 
int main() {

    cin >> n;

    dfs("",'a');

 return 0;
}

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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  long long N, M;
  cin >> N >> M;
  vector<pair<long long, long long>> drink;
  for(int i = 0; i < N; i++){
    int a, b;
    cin >> a >> b;
    drink.emplace_back(a, b);
  }
  sort(drink.begin(), drink.end());
  long long ans = 0;
  for(int i = 0; i < N; i++){
    if(M == 0){
      cout << ans <<endl;
      return 0;
    }
    long long amount = drink[i].second;
    long long price = drink[i].first;
    if(amount <= M){
      ans += price * amount;
      M -= amount;
    } else{
      ans += price * M;
      M = 0;
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 5248
#include<iostream>
#include<string>
using namespace std;
long long rest=1000000007;
int main(){
    int n;cin>>n;
    string s[2];cin>>s[0]>>s[1];
    long long ans=3;
    int st=1;
    if(s[0][0]!=s[1][0]){
        ans=6;
        st=2;
    }
    for(int i=st;i<n;i++){
        if(s[0][i-1]==s[1][i-1]){
            ans*=2;
            if(s[0][i]!=s[1][i])i++;
        }
        else{
            if(s[0][i]==s[1][i]){
                ans*=1;
            }
            else{
                ans*=3;
                i++;
            }
        }
        ans%=rest;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int s;
	cin >> s;
	int a = s/100;
	int b = s%100;
	if(1 <= b && b <= 12){
		if(1 <= a && a <= 12){
			cout << "AMBIGUOUS" << endl;
		}else{
			cout << "YYMM" << endl;
		}
	}else{
		if(1 <= a && a <= 12){
			cout << "MMYY" << endl;
		}else{
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]
M = max(A)

count = [0] * (M + 1)
for i in range(N):
    count[A[i]] += 1

check = [True] * (M + 1)
for a in range(1, M + 1):
    if count[a] > 0 and check[a] == True:
        for k in range(2, M // a + 1):
            check[a * k] = False      

ans = 0
for i in range(N):
    if count[A[i]] == 1 and check[A[i]] == True:
        ans += 1

print(ans)

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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string S;
	map<char, bool> mp;
	bool ans = true;

	mp['N'] = false;
	mp['W'] = false;
	mp['S'] = false;
	mp['E'] = false;

	cin >> S;

	rep(i, (int)S.length()) mp[S[i]] = true;

	if ((mp['N'] && !mp['S']) || (!mp['N'] && mp['S'])) ans = false;
	if ((mp['W'] && !mp['E']) || (!mp['W'] && mp['E'])) ans = false;

	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}


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

const int K = 1005;
int n, k, s[2][K][K], ans;

int sum (int I, int XS, int XE, int YS, int YE) {
	return s[I][XE][YE] - s[I][XE][YS-1] - s[I][XS-1][YE] + s[I][XS-1][YS-1];
}

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) {
		int A, B;
		char C[2];
		scanf("%d%d%s",&A,&B,C);
		C[0] = (C[0] == 'B');
		C[0] ^= (A/k+B/k)%2;
		s[C[0]][A%k+1][B%k+1]++;
	}
	for(int i=1;i<=k;i++) {
		for(int j=1;j<=k;j++) {
			s[0][i][j] += s[0][i-1][j] + s[0][i][j-1] - s[0][i-1][j-1];
			s[1][i][j] += s[1][i-1][j] + s[1][i][j-1] - s[1][i-1][j-1];
		}
	}
	for(int i=1;i<=k;i++) {
		for(int j=1;j<=k;j++) {
			ans = max(ans, sum(0, 1, i, 1, j) + sum(1, i+1, k, 1, j) + sum(1, 1, i, j+1, k) + sum(0, i+1, k, j+1, k));
			ans = max(ans, sum(1, 1, i, 1, j) + sum(0, i+1, k, 1, j) + sum(0, 1, i, j+1, k) + sum(1, i+1, k, j+1, k));
		}
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 8064
def cin; gets.split.map(&:to_i) end

# exit if $0 != __FILE__

# n, *x = cin
# s = gets.chomp

# puts n
MOD = 1000000007
n,m = cin
as = Array.new(n+1, -1)
as[0] = 1
m.times do
  as[gets.to_i] = 0
end

(n+1).times do |x|
  next if as[x] >= 0

  a = x >= 1 ? as[x-1] : 0
  b = x >= 2 ? as[x-2] : 0
  as[x] = (a + b) % MOD
end

p as[n]

Measured memory_bytes: 3836
#include<iostream>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;

	if (a == b) {

		cout <<"Draw" << endl;

	}
	else if (a == 1) {
		cout << "Alice" << endl;
	}
	else if (b == 1) {
		cout << "Bob" << endl;
	}
	else if(a < b){
		cout << "Bob" << endl;
	}
	else{
		cout << "Alice" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ds = readLine()!!.split(" ")
    var sum = ds.map { it.toInt() }.reduce { i1,i2 -> i1 + i2 }
    var ans = 0
    for (i in 0..n-1) {
        sum -= ds[i].toInt()
        ans += ds[i].toInt() * sum
    }
    println(ans)
}

Measured memory_bytes: 37608
#include<bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
bool comp(const pair<string,ll> &a,const pair<string, ll> &b)
{
   return a.second>b.second;
}
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, k;
    cin>>n>>k;
    cout<<floor(log(n)/log(k))+1;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (){
	int num1, num2;
	char in [100];
	
	scanf ("%d %d", &num1, &num2);
	scanf ("%s", in);
	
	in[num2-1]=in[num2-1]+32;
	
	printf ("%s", in);
	return 0;
}

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

const double eps = 1e-10;
bool dcmp(double d, double d2 = 0) { return abs(d - d2) < eps; }

struct vec {
  double x, y;
  vec(double x, double y) : x(x), y(y) {}
  vec() : x(0), y(0) {}
  const bool operator==(const vec &v) const {
    return dcmp(x, v.x) && dcmp(y, v.y);
  }
  const bool operator!=(const vec &v) const { return !(*this == v); }
  const vec operator+(const vec &v) const { return vec(x + v.x, y + v.y); }
  const vec operator-() const { return vec(-x, -y); }
  const vec operator-(const vec &v) const { return *this + (-v); }
  const vec operator*(const double d) const { return vec(x * d, y * d); }
  const vec operator/(const double d) const { return *this * (1 / d); }
  const vec unit() const { return *this / len(); };
  const double len() const { return sqrt(x * x + y * y); }
  const double dot(const vec &v) const { return x * v.x + y * v.y; }
  const double cross(const vec &v) const { return x * v.y - y * v.x; }
  const bool parallel(const vec &v) const { return dcmp(cross(v)); }
  const bool perpendicular(const vec &v) const { return dcmp(dot(v)); }
};

typedef vec point;

template <class T> struct optional {
  bool has;
  T val;
  optional() : has(false) {}
  optional(T t) : has(true), val(t) {}
};

struct line {
  double a, b, c;
  line(point p1, point p2) {
    a = p2.y - p1.y;
    b = p1.x - p2.x;
    c = p1.x * p2.y - p2.x * p1.y;
  }
  optional<point> intersect(line l) {
    if (dcmp(a * l.b, b * l.a))
      return optional<point>();
    return point((c * l.b - b * l.c) / (a * l.b - b * l.a),
                 -(c * l.a - a * l.c) / (a * l.b - b * l.a));
  }
};

struct segment {
  point p1, p2;
  point intersect(segment s) {}
};

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    point p0, p1, p2, p3;
    cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;
    line l0(p0, p1);
    line l1(p2, p3);
    point p = l0.intersect(l1).val;
    printf("%.9lf %.9lf\n", p.x, p.y);
  }
}


Measured memory_bytes: 3288
#!/usr/bin/env python3

import sys

sys.setrecursionlimit(10**7)

# Override `input` function because `stdin.readline()` is 10x faster than built-in `input()`
input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def main():
    n, = read_h()
    A = read_h()
    B = read_h()

    ans = 0
    rem_cap = 0
    for a, b in zip(A, B):
        cap = rem_cap + b
        if a >= cap:
            ans += cap
            rem_cap = 0
        elif rem_cap >= a:
            ans += a
            rem_cap = b
        else:
            ans += a
            rem_cap = cap - a

        #  print('killed:', ans)
        #  print('remaining:', rem_cap)

    if rem_cap >= A[-1]:
        ans += A[-1]
    else:
        ans += rem_cap

    print(ans)


if __name__ == '__main__':
    main()


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

# define pb push_back
# define fr first
# define sc second
# define mk make_pair

using namespace std;

const int inf = 1000000000 + 7;
const int N = 1e5 + 1;

typedef long long ll;

ll n, c, k, a[N], t, cnt = 1, ans = 1;

inline void solve()
{
    cin >> n >> c >> k;

    for(int i = 1; i <= n; i ++)
        cin >> a[i];
    sort(a + 1, a + n + 1);

    t = a[1];

    for(int i = 2; i <= n; i ++)
    {
        cnt ++;
        if(a[i] > t + k || cnt > c)
        {
            t = a[i];
            cnt = 1;
            ans ++;
        }
    }

    cout << ans << endl;
}

int tests = 1;

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

    while(tests --)
        solve();
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define mp(a, b) make_pair(a, b)
#define newline cout << endl;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(),v.end()
using namespace std;

template <typename S, typename T> ostream& operator<<(ostream& out, pair<S, T> const& p)
{
	out << '(' << p.ff << ", " << p.ss << ')';
	return out;
}

template <typename T> ostream& operator<<(ostream& out, vector<T> const& v)
{
	int l = v.size();
	for (int i = 0; i < l - 1; i++)
		out << v[i] << ' ';
	if (l > 0)
		out << v[l - 1];
	return out;
}

template <typename T> void trace(const char* name, T&& arg1) { cout << name << " : " << arg1 << endl; }

template <typename T, typename... Args> void trace(const char* names, T&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | ";
	trace(comma + 1, args...);
}

/*Input*/
const ll size = 500;
ll n;
vector<ll> v(size);
/*Input*/

ll solve(ll mid){
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += (mid - v[i])*(mid - v[i]);
    }
    return ans;
}

int main()
{
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	//cout.tie(0);
	clock_t tStart = clock();
	int test;
	test = 1;
	// cin >> test;
	while (test--) {
        cin >> n;
        ll s = 0;
        for(int i = 0; i < n; i++){
            cin >> v[i];
            s += v[i];
        }
        ll mid = s / n;
        ll ans = solve(mid);
        ans = min(ans, solve(mid+1));
        ans = min(ans, solve(mid-1));
        cout << ans << endl;
	}
#ifdef LOCAL_DEFINE
	printf("Time taken: %.2fs\n", (double)(clock() - tStart) / CLOCKS_PER_SEC);
#endif
	return 0;
}


Measured memory_bytes: 256
program B3
  implicit none

  integer :: n, i , j, cnt, min
  integer,allocatable,dimension(:) :: P

  read(*,*) n
  allocate(P(n))
  read(*,*) (P(j), j=1,n)

  cnt=1
  min=P(1)
  do i=2,n
     if(P(i).gt.min)  goto 300
     ! do j = 1,i-1
     !    if(P(j).lt.P(i))  then
     !       goto 300
     !    endif
     ! enddo
     cnt=cnt+1
     min=P(i)
300  continue     
  enddo

  print *, cnt
  
end program B3

Measured memory_bytes: 1536
import java.awt.Point;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int m = 1; m <= n; m++) {
			sc.nextLine();
			sc.nextLine();
			System.out.println("Data " + m+":");
			int[][] map = new int[14][14];
			for (int i = 0; i < 14; i++) {
				Arrays.fill(map[i], -1);
			}
			for (int i = 3; i <= 10; i++) {
				char tmp[] = sc.nextLine().toCharArray();
				for (int j = 0; j < 8; j++) {
					map[i][j + 3] = tmp[j] - '0';
				}
			}
			int sx = sc.nextInt()+2;
			int sy = sc.nextInt()+2;
			Queue<Point> q = new LinkedList<Point>();
			q.add(new Point(sx, sy));
			map[sy][sx] = 0;
			while (q.peek() != null) {
				Point p = q.poll();
				int x = p.x;
				int y = p.y;
				int dx[] = { 0, 1, 0, -1, 0, 2, 0, -2, 0, 3, 0, -3 };
				int dy[] = { 1, 0, -1, 0, 2, 0, -2, 0, 3, 0, -3, 0 };
				for (int i = 0; i < 12; i++) {
					int nx = x + dx[i];
					int ny = y + dy[i];
					if (map[ny][nx] == -1)
						continue;
					if (map[ny][nx] == 1) {
						map[ny][nx] = 0;
						q.add(new Point(nx, ny));
					}
				}
			}
			for (int i = 3; i <= 10; i++) {
				for (int j = 3; j <= 10; j++) {
					System.out.print(map[i][j]);
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main() {
    string s; cin >> s;
    if (s == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
    return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

ll visited[500][500];
ll p = 1;
bool f = false;
void dfs(ll x, ll y, vector<string>& mp, ll H, ll W) {
    if (0 > x || x >= W || y < 0 || y >= H) {
        return;
    }
    if (visited[y][x]) return;
    if (mp[y][x] == '#' && f) return;
    visited[y][x] = p;
    f = true;
    dfs(x + 1, y, mp, H, W);
    dfs(x - 1, y, mp, H, W);
    return;
}
void dfs2(ll x, ll y, vector<string>& mp, ll H, ll W) {
    if (0 > x || x >= W || y < 0 || y >= H) {
        return;
    }
    if (visited[y][x] && f) return;
    if (visited[y][x] == 0) visited[y][x] = p;
    f = true;
    dfs2(x, y+1, mp, H, W);
    dfs2(x, y-1, mp, H, W);
    return;
}


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

    ll H, W, K;
    cin >> H >> W >> K;
    vector<string> maze(H);
    rep(i, H) cin >> maze[i];

    rep(i, H) {
        rep(j, W) {
            if (maze[i][j] == '#') {
                dfs(j, i, maze, H, W);
                p++;
                f = false;
            }
        }
    }
    rep(i, H) {
        rep(j, W) {
            if (visited[i][j]) {
                p = visited[i][j];
                dfs2(j, i, maze, H, W);
                f = false;
            }
        }
    }

    rep(i, H) {
        rep(j, W) {
            cout << visited[i][j] << ' ';
        }
        cout << endl;
    }
}


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

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

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


# a = comb(n, r)
x,y=map(int,input().split())
a=(-x+2*y)//3
b=(2*x-y)//3
if a+2*b==x and 2*a+b==y:
  c = cmb(a+b,a,mod)
  print(c)
else:
  print(0)


Measured memory_bytes: 128508
#include <stdio.h>
#include <string.h>
#include <ctype.h>
char *lwr(char *s)
{
    char *p;
    for (p=s;*p;p++)*p = tolower(*p);
    return s;
}
int main(void){
    char t[1001]="START",w[11],*tok;
    int s=0;
    scanf("%s",w);
    while(1){
        scanf("%s",t);
        if (!strstr(t,"END_OF_TEXT")){
            tok=strtok(lwr(t)," ");
            while(tok){
                if (!strncmp(tok,w,sizeof(w))) s++;
                tok=strtok(NULL," ");
            }
        }
        else break;
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

ll N, K;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> K;

	ll res = 0;
	if(K % 2 == 0) {
		ll tmp = N / (K / 2) - N / K;
		res += tmp * tmp * tmp;
	}

	ll tmp = N / K;
	res += tmp * tmp * tmp;
	cout << res << endl;

}



Measured memory_bytes: 256
#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/03/12  Problem: 067_arc_c / Link: https://arc067.contest.atcoder.jp/tasks/arc067_c?lang=en  ----- */
/* ------問題------

1 から N までの番号のついた N 人の人がいます。 以下の二つの条件を満たすように、彼らをいくつかのグループに分けたいです。

どのグループも、そのグループに含まれる人数が A 人以上 B 人以下である。

ちょうど i 人の人が含まれるようなグループの数を Fi で表したとき、 すべての i について、Fi=0 または C≦Fi≦D が成り立っている。

このようなグループ分けが何通りあり得るか求めてください。 ただし、ある二つのグループ分けが異なるとは、二人の人の組であって、 片方のグループ分けでは同じグループに含まれ、他方では同じグループに含まれないようなものが存在することを意味します。 なお、答えは非常に大きくなることがあるので、109+7 で割った余りを出力してください。

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



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

const long long mod = 1e9 + 7;

long long modpow(long long a, long long b) {
	if (b == 0) return 1;
	return modpow(a * a % mod, b / 2) * (b & 1 ? a : 1) % mod;
}

long long modinv(long long a) {
	return modpow(a, mod - 2);
}
vector<long long> fact, inv_fact;

void init_fact(int n) {
	fact.resize(n);
	fact[0]= 1;
	for (int i = 1; i < n; i++) {
		fact[i] = i * fact[i - 1] % mod;
	}
	inv_fact.resize(n);
	inv_fact[n - 1] = modinv(fact[n - 1]);
	for (int i = n - 2; i >= 0; i--) {
		inv_fact[i] = (i + 1) * inv_fact[i + 1] % mod;
	}
}

long long nPr(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return fact[n] * inv_fact[n - r] % mod;
}

long long nCr(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return fact[n] * inv_fact[r] % mod * inv_fact[n - r] % mod;
}

long long nHr(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return nCr(n + r - 1, r);
}

LL N, A, B, C, D;

LL ans = 0LL;

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


	init_fact(3003);

	cin >> N >> A >> B >> C >> D;
	VVL dp(B + 2, VL(N + 1, 0));
	FOR(i, 0, B + 2)dp[i][0] = 1;

	// dp[i][j] := i人未満のグループを作ったときに、これまでj人を割り振ったときの組み合わせ数
	// dp[i][j] -> dp[i+1][j]
	// dp[i][j] -> dp[i+1][j + i*k]
	FOR(i, A, B + 1) {
		FOR(j, 0, N + 1) {
			if (!dp[i][j])continue;
			if (j) { //a人は割り振らない
				dp[i + 1][j] += dp[i][j];
				dp[i + 1][j] %= mod;
			}
			LL x = 1;
			FOR(k, 1, D + 1) {
				if (j + k*i > N)break;
				x *= (nCr(N - j - (i)*(k - 1), i) * modinv(k)) % mod;
				x %= mod;
				if (C <= k && k <= D) {
					dp[i + 1][j + k*i] += (dp[i][j] * x) % mod;
					dp[i + 1][j + k*i] %= mod;
				}
			}
		}
	}
	ans = dp[B + 1][N];
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 8192
/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
#define sz(v) (int)v.size()
#define endl '\n'
const int mod = 998244353;
ll mul_inv(ll a,ll b = mod) {ll t1=a,t2=b,t3,v1=1,v2=0,v3;while(t2!=1){ll x=t1/t2;t3=t1-x*t2;v3=v1-x*v2;t1=t2,t2=t3;v1=v2,v2=v3;}return(v2+b)%b;}
const int N = 2e7+5;


int32_t main(){
   
   speed_cubing
   
   int a,b;
   cin>>a>>b;
   cout<<a*b;
 
   return 0;
}

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

namespace ConsoleApp15
{
    class Class395
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();

            long sum = a.Sum();
            var d = new long[N + 1];
            for (int i = 0; i < N; i++)
            {
                d[i + 1] = d[i] + a[i];
            }

            long ans = long.MaxValue;
            for (int i = 1; i < N; i++)
            {
                ans = Math.Min(ans, Math.Abs(d[i] - (sum - d[i])));
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 45268
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] P = new int[N];        
        int ans = 0;

        for(int i=0; i<N; i++){
            P[i] = sc.nextInt();
        }
        int max = P[0];
        int min = P[0];
        for(int i=0; i<N; i++){
            if(max>=P[i] && min>=P[i]){
                ans += 1;
            }
            max = Math.max(max, P[i]);
            min = Math.min(min, P[i]);
        }
        System.out.println(ans);
    }
}

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

#define pb push_back
#define ll long long
int mo =  1e9+7;
// int dp[1000][1000];
using namespace std;


int main(int argc, char const *argv[])
{
	// ios::sync_withss_stdio(false);
	// cin.tie(0);
	// cout.tie(0);

	int n, k;
	scanf("%d%d", &n, &k);
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &a[i]);
	}

	long long dp[n+1][k+1];
	long long sumarr[n+1][k+1];
	memset(dp, 0 , sizeof(dp));

	for (int i = 0; i <= k; ++i)
	{
		dp[0][i] = 0;
	}

	dp[0][0] = 1;

	for (int i = 1; i <= n; ++i)
	{
		for (int j = 0; j <= k; ++j)
		{
			if (j == 0)
			{
				sumarr[i-1][j] = dp[i-1][j]%mo;
			} 
			else{
				sumarr[i-1][j] = ((sumarr[i-1][j-1]) + (dp[i-1][j]))%mo; 
			}
		}
		for (int j = 0; j <= k; ++j)
		{
			// int sum = 0;
			// for (int k = 0; k <= min(j , a[i-1]); ++k)
			// {
			// 	sum += dp[i-1][j-k];
			// }
			int t = min(j, a[i-1]);
			if(t == j){
				dp[i][j] = sumarr[i-1][j];
			}
			else{
				dp[i][j] = (sumarr[i-1][j] - sumarr[i-1][j-t-1]+mo)%mo;

			}
		}
	}

	// for (int i = 0; i <= n; ++i)
	// {
	// 	for (int j = 0; j <= k; ++j)
	// 	{
	// 		printf("%lld ", dp[i][j]);
	// 	}
	// 	printf("\n");
	// }
	printf("%lld\n", dp[n][k]);
	// for (int i = 0; i <= n; ++i)
	// {
	// 	for (int j = 0; j <= k; ++j)
	// 	{
	// 		printf("%lld ", sumarr[i][j]);
	// 	}
	// 	printf("\n");
	// }
}




Measured memory_bytes: 158080
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
int a,b;
cin >> a >>b;
int A[10];
A[0] = a + a-1;
A[1] = a + b;
A[2] = b + b-1;
sort(A, A + 3, greater<int>());

cout << A[0] << endl;
return 0;








}


Measured memory_bytes: 256