akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;
using pi = pair<int, int>;
using vp = vector<pi>;

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

#define P (1'000'000'007)

signed main() {
    int n, m;
    cin >> n >> m;

    map<int, int> mp;

    int sum = 0;

    rep(i, n) {
        capi(a);
        sum += a;
        sum %= m;
        if (auto it = mp.find(sum); it != mp.end()) {
            ++mp[sum];
        } else {
            mp.emplace(sum, 1);
        }

    }

    int ans = 0;
    for (auto x: mp) {
        if (x.first == 0) ans += x.second * (x.second + 1) / 2;
        else ans += x.second * (x.second - 1) / 2;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 6944
n = int(input())
S = [int(i) for i in input().split()]
q = int(input())
T = [int(j) for j in input().split()]

ans = 0

def binarySearch(key,array):
    left = 0
    right = len(array)

    while left < right:
        mid = (right+left)//2

        if array[mid] == key:
            return True
        else:
            if key < array[mid]:
                right = mid
            else:
                left = mid+1

    return False


for i in range(q):
    key = T[i]

    if binarySearch(key,S):
        ans += 1

print(ans)


Measured memory_bytes: 16892
N=int(input())
L=list(map(int,input().split()))
counter=0
L.sort()
for i in range(N-2):
    k=i+2
    for j in range(i+1,N-1):    
        while k < N and L[k] < L[i] + L[j]:
            k += 1
        counter += k - j -1
print(counter)





Measured memory_bytes: 3188
def DFS(word,n):
  if len(word)==N:
    return print(word)
  else:
    for i in range(n+1):
      if i==0 :
        DFS(word+chr(97+i),n+1)
      elif chr(97+i-1) in word:
        DFS(word+chr(97+i),n+1)

N=int(input())
DFS('',0)

Measured memory_bytes: 4340
n=gets.to_i
v=gets.split.map &:to_i
c=gets.split.map &:to_i
max=0
[0,1].repeated_permutation(n).each do |i|
  sum=0
  for j in 0..n-1
    if i[j]==1
      sum+=(v[j]-c[j])
    end
  end
  max=[max,sum].max
end
puts max


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

using namespace std;

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  vector<int> divs;
  for (int i = 100; i > 0; i--) {
    if (a % i == 0 && b % i == 0) {
      divs.push_back(i);
    }
  }
  cout << divs[k - 1] << '\n';
  return 0;
}

Measured memory_bytes: 256
fn get_line() -> Vec<String> {
    let stdin = std::io::stdin();
    let mut s = String::new();
    stdin.read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|s| s.into()).collect();
}

fn main() {
    let v : i32 = get_line()[0].parse().unwrap();
    if v < 1200 {
        // println!("{}", );
        println!("ABC");
    } else {
        println!("ARC");
    }
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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


void insertionSort(int A[], int N) {
    for(int i = 1; i < N; ++i) {
        int v = A[i];
        int j = i - 1;
        while(j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            --j;
        }
        A[j + 1] = v;

        rep(i, N) {
            if(i) cout << " ";
            cout << A[i];
        }
        cout << endl;
    }
}

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

    int A[100];
    int n; cin >> n;
    rep(i, n) cin >> A[i];
    rep(i, n) {
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    insertionSort(A, n);
}


Measured memory_bytes: 3164
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, m;
        cin >> n >> m;
        if(n == 0)
            return 0;

        vector<string> winNum(n);
        vector<int> winMoney(n);
        for(int i=0; i<n; ++i)
            cin >> winNum[i] >> winMoney[i];

        int ret = 0;
        while(--m >= 0){
            string s;
            cin >> s;
            for(int i=0; i<n; ++i){
                bool ok = true;
                for(int j=0; j<8; ++j){
                    if(winNum[i][j] != '*' && winNum[i][j] != s[j])
                        ok = false;
                }
                if(ok)
                    ret += winMoney[i];
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
from collections import Counter


def main():
    N = int(input())
    A = [input() for _ in range(N)]

    C = Counter(A)
    most_c = C.most_common()
    max_num = most_c[0][1]
    ANS = []
    for c in most_c:
        if c[1] < max_num:
            break
        ANS.append(c[0])
    for ans in sorted(ANS):
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 49204
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a<0&&b<0){
    if(a<=b){
      cout<<b-a;
    }else{
      cout<<a-b+2;
    }
  }else if(a>0&&b<0){
    if(a<=abs(b)){
      cout<<abs(b)-a+1;
    }else{
      cout<<a-abs(b)+1;
    }
  }else if(a<0&&b>0){
    if(abs(a)>=b){
      cout<<abs(a)-b+1;
    }else{
      cout<<b-abs(a)+1;
    }
  }else if(a>0&&b>0){
    if(a<=b){
      cout<<b-a;
    }else{
      cout<<a-b+2;
    }
  }else{
    if(b>0){
      cout<<b-a;
    }else if(b<0){
      cout<<a-b+1;
    }else if(a>0){
      cout<<a-b+1;
    }else if(a<0){
      cout<<b-a;
    }else{
      cout<<0;
    }
  }
}


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

int main()
{
	int n;
	cin>>n;
	int a[n+2],b[n+2],c[n+2];
	int i,j,k;
	for(i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	
	int dp[4][n+2];
	
	dp[1][1]=a[1];
	dp[2][1]=b[1];
	dp[3][1]=c[1];
	
	for(i=2;i<=n;i++)
	{
		dp[1][i]=max(dp[2][i-1]+a[i],dp[3][i-1]+a[i]);
		dp[2][i]=max(dp[1][i-1]+b[i],dp[3][i-1]+b[i]);
		dp[3][i]=max(dp[2][i-1]+c[i],dp[1][i-1]+c[i]);
	}
	
	cout<<max(dp[1][n],max(dp[2][n],dp[3][n]));
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void){
    int a, b, c, k,ans , answer;
    cin >>a >> b >>c >> k;
    ans = max({a,b,c});
    answer =a + b + c + (ans*pow(2,k))-ans;
    
    cout << answer;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

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

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int a;
  string s;
  cin >> a >> s;
  if(3200<=a) cout<< s <<endl;
  else cout<< "red" <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)2e5+5;
const int M = (int)1e3+5;
const int Q = 102;
const int logN = 19;

const double pie = acos(-1);

int calc(int n) {
    int lo=1, hi = 20, mi;
    while(lo<hi) {
        mi = 1 + (lo+hi)/2;
        if((mi*(mi+1))/2<=n) lo = mi;
        else hi = mi-1;
    }
    return lo;
}
void solve() {
    ll n;
    cin>>n;
    unordered_map<ll,int> mp;
    for(int i=2;(ll)i*i<=n;i++) {
        while(n%i==0) {
            mp[i]++;
            n/=i;
        }
    }
    if(n>1) mp[n]++;
    int ans = 0;
    for(auto it:mp) {
        ans += calc(it.second);
    }
    cout<<ans;
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


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

using namespace std;

int a[50], b[50], c[50];

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n - 1; i++) {
		cin >> c[i];
	}
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		cnt += b[a[i] - 1];
		if (i > 0) {
			if (a[i] == a[i - 1] + 1)
				cnt += c[a[i - 1] - 1];
		}
	}
	cout << cnt << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;
constexpr i64 MOD = 1e9 + 7;

i64 modpow(i64 a, i64 n, i64 mod) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        i64 t = modpow(a, n / 2, mod);
        return t * t % mod;
    }
    return a * modpow(a, n - 1, mod) % mod;
}

i64 modinv(i64 a, i64 mod) {
    // mod is prime
    return modpow(a, mod - 2, mod);
}

struct Combination {
    const int MAX_N = 1 << 21;
    vi fact = vi(MAX_N);
    vi factinv = vi(MAX_N);

    Combination() {
        fact[0] = 1;
        for (int i = 1; i < MAX_N; i++) {
            fact[i] = fact[i - 1] * i % MOD;
        }
        factinv[MAX_N - 1] = modinv(fact[MAX_N - 1], MOD);
        for (int i = MAX_N - 2; i >= 0; i--) {
            factinv[i] = factinv[i + 1] * (i + 1) % MOD;
        }
    }

    i64 ncr(i64 n, i64 r) {
        if (r < 0 || r > n) return 0;
        return fact[n] * factinv[r] % MOD * factinv[n - r] % MOD;
    }

    i64 npr(i64 n, i64 r) {
        if (r < 0 || r > n) return 0;
        return fact[n] * factinv[n - r] % MOD;
    }

    i64 nhr(i64 n, i64 r) {
        if (n == 0 && r == 0) return 1;
        return ncr(n + r - 1, r);
    }
};

int main() {
    int n, k;
    cin >> n >> k;
    if (n > k) {
        cout << 0 << endl;
        return 0;
    }
    Combination comb;
    cout << comb.npr(k, n) << endl;
}


Measured memory_bytes: 35572
n, d = map(int, input().split())
ls_x = [[int(i) for i in input().split()] for i in range(n)]

cub_of_ds = 0
cnt = 0

for i in range(n):
    for j in range(i+1, n):
        for k in range(d):
            cub_of_ds += (ls_x[i][k] - ls_x[j][k])**2
        if ((cub_of_ds)**(1/2)).is_integer() == True:
            cnt += 1
        cub_of_ds = 0
        
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

int main(void){
  int n,i;
  vector<string> s,t;
  string cur;
  cin>>n;

  s.resize(n);
  t.clear();

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

  sort(s.begin(),s.end());
  s.push_back("0");

  int max=0,cnt=1;
  cur=s[0];  
  for(i=1;i<=n;i++){
    if(cur==s[i]){
      cnt++;
    }
    else{
      if(max<cnt){
        max=cnt;
        t.clear();
        t.push_back(cur);
        cur=s[i];
        cnt=1;
      }
      else if(max==cnt){
        t.push_back(cur);
        cur=s[i];
        cnt=1;
      }
      else{
        cur=s[i];
        cnt=1;
      }
    }
  }

  for(i=0;i<t.size();i++){
    cout<<t[i]<<endl;
  }

  return 0;
}


Measured memory_bytes: 19300
import java.util.Scanner;

public class Main {

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

    while (true) {
      int H = scan.nextInt();
      int W = scan.nextInt();

      if ((H == 0) && (W == 0)) {
        break;
      }

      for (int j = 0; j < W; j++) {
        System.out.print("#");
      }
      System.out.println();

      for (int i = 1; i < H - 1; i++) {
        System.out.print("#");
        for (int j = 1; j < W - 1; j++) {
          System.out.print(".");
        }
        System.out.println("#");
      }

      for (int j = 0; j < W; j++) {
        System.out.print("#");
      }
      System.out.println();

      System.out.println();
    }

  }
}


Measured memory_bytes: 36868
/**
*    author:  souzai32
*    created: 02.08.2020 18:06:18
**/

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

int main() {

    string s;
    cin >> s;
    int n=s.size();
    int ans=n,num,count=0;

    rep(i,26){
        num=0;
        count=0;
        rep(j,n){
            if(s.at(j)=='a'+i){
                num=max(count,num);
                count=0;
            }
            else count++;
            if(j==n-1) num=max(count,num);
        }
        //cout << num << endl;
        ans=min(ans,num);
    }

    cout << ans << endl;

    return 0;
}

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

int sum[1000];
int gods,gode;
int list[1000]; //0 is logout 

int main(void){
	int n;
	while(cin >> n,n){
		for(int i=0;i<1000;i++)
			sum[i]=0;
		int cm=0,cd=0;

		for(int i=0;i<n;i++){
			string s;
			int m,d;
			cin >> s;
			m=(s[0]-'0')*10+(s[1]-'0');
			d=(s[3]-'0')*10+(s[4]-'0');
			if(m!=cm||d!=cd)
				for(int i=0;i<1000;i++)
					list[i]=0;
			cm=m,cd=d;
			cin >> s;
			int min=((s[0]-'0')*10+(s[1]-'0'))*60+((s[3]-'0')*10+(s[4]-'0'));
			char state;int num;
			cin >> state >> num;
			
			if(state=='I')
				list[num]=min;
			else{
				if(num){
					if(list[0]){
						int start=max(list[0],list[num]);
						sum[num]+=min-start;
					}
				}else{
					for(int j=1;j<1000;j++){
						if(list[j]){
							int start=max(list[0],list[j]);
							sum[j]+=min-start;
						}
					}
				}
				list[num]=0;
			}
		}

		int ans=0;
		for(int i=1;i<1000;i++)
			ans=max(ans,sum[i]);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
import math
a,b,c=map(float,input().split())
if c == 90:
    S=(a*b/2)
    L=(math.sqrt(a**2+b**2)+a+b)
    h=(2*S/a)
else:
    S=(math.sin(math.radians(c))*a*b/2)
    L=(a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(c))))
    h=(2*S/a)
print(S)
print(L)
print(h)


Measured memory_bytes: 5672
#include <stdio.h>

int main (void)
{
    int D;

    scanf("%d", &D);

    printf("Christmas");

    switch (D) {
    case 22:
        printf(" Eve");
    case 23:
        printf(" Eve");
    case 24:
        printf(" Eve");
    }

    puts("");

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
    #include <string>
    #include <vector>
    #include <algorithm>
    #include <map>
    using namespace std;
    typedef long long ll;
    #define rep(i,n) for (int i=0;i < (int)(n);i++)

int kind[9];
    int main(){
      int n;
      map<int,int> m;
      cin >> n;
      vector<int> v(n);
      rep(i,n) {
        cin >> v[i];
        if (v[i] < 400) kind[0]++;
        else if(v[i] >= 400 && v[i] < 800) kind[1]++;
        else if (v[i] >= 800 && v[i] < 1200) kind[2]++;
        else if (v[i] >= 1200 && v[i] < 1600) kind[3]++;
        else if (v[i] >= 1600 && v[i] < 2000) kind[4]++;
        else if (v[i] >= 2000 && v[i] < 2400) kind[5]++;
        else if (v[i] >= 2400 && v[i] < 2800) kind[6]++;
        else if (v[i] >= 2800 && v[i] < 3200) kind[7]++;
        else kind[8]++;
      }
      int k=0;
      for (int i=0;i < 8;i++){
        if (kind[i] != 0) k++;
      }
      if (k == 0){
        cout << 1 << " " << kind[8] << endl;
        return 0;
      }
      cout << k << " " << k+kind[8] << endl;
      
      return 0;
    }
      
      

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

using namespace std;

int main()
{
    int num;
    bool isEvenNum = true;
    int divideCount = 0;

    cin >> num;

    vector<int> a;

    for(int i = 0; i < num ; i++)
    {
        int tmp;
        cin >> tmp;

        a.push_back(tmp);
    }

    while (isEvenNum)
    {
        for (int i = 0; i < num; i++)
        {
            if (a[i] % 2 == 1)
            {
                isEvenNum = false;
                break;
            }

            a[i] = a[i] / 2;
        }

        if (isEvenNum)
        {
            divideCount++;
        }
    }

    cout << divideCount << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int n,num;
  int x,y;

  while(1){
    cin>>n;
    if(n==0)break;
    int squre[15][15]={};
    x=n/2+1;
    y=n/2;
    for(num=1;num<=n*n;num++){
      squre[x][y]=num;
      x=(x+1)%n;
      y=(y+1)%n;
      if(squre[x][y]){
	x=(x+1)%n;
	y=(y+n-1)%n;
      }
    }
    int i,j;
    rep(i,n){
      rep(j,n)
	printf("%4d",squre[i][j]);
      puts("");
    }
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll R, G, B, N,an=0;
	cin >> R >> G >> B >> N;
	rep(r, 3001) {
		rep(g, 3001) {
			if ((N - r* R - g * G) % B == 0&& (N - r* R - g * G)>=0) {
				an++;
			}
		}
	}
	cout << an << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[]l = new int[N];
		for(int i = 0; i < N; i++) {
			l[i] = sc.nextInt();
		}
		sc.close();
		Arrays.sort(l);
		int sum = 0;
		for(int i = N - 1; i >= N - K; i--) {
			sum += l[i];
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
bool c=0,f=0;
string a;
int main()
{
	cin>>a;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='C')
			c=1;
		if(a[i]=='F'&&c)
			f=1;
		if(c&&f)
			break;
	}
	cout<<(c&&f?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
#define MN 200005
int n,last[MN],cir[MN],mem,now,sg[MN],sg2[MN],f[MN],vis[MN];
bool found,inq[MN],cime[MN],Vis[MN];
struct edge{int to,nex;}e[MN];int cnt,hr[MN];
inline void ins(int f,int t){
	e[++cnt]=(edge){t,hr[f]};hr[f]=cnt;
}
void findcircle(int x){
	if(found) return;inq[x]=Vis[x]=true;
	for(int i=hr[x];i;i=e[i].nex){
		if(inq[e[i].to]){for(int j=x;j!=e[i].to;j=last[j]) cir[++mem]=j;cir[++mem]=e[i].to;found=true;}
		else if(!Vis[e[i].to]) last[e[i].to]=x,findcircle(e[i].to);
	}
	inq[x]=false;
}
void dp(int x){
	register int i;
	for(i=hr[x];i;i=e[i].nex) if(!cime[e[i].to]) dp(e[i].to);
	++now;for(i=hr[x];i;i=e[i].nex) if(!cime[e[i].to]) vis[sg[e[i].to]]=now;
	for(;vis[sg[x]]==now;sg[x]++);
	for(sg2[x]=sg[x]+1;vis[sg2[x]]==now;sg2[x]++);
}
bool check(){
	f[1]=sg[cir[1]];register int i;
    for(i=2;i<=mem;i++) f[i]=f[i-1]==sg[cir[i]]?sg2[cir[i]]:sg[cir[i]];
    if(f[mem]!=sg[cir[1]]) return true;
    f[1]=sg2[cir[1]];
    for(i=2;i<=mem;i++) f[i]=f[i-1]==sg[cir[i]]?sg2[cir[i]]:sg[cir[i]];
    if(f[mem]==sg[cir[1]]) return true;
    return false;
}
int main(){
	n=read();register int i;
	for(i=1;i<=n;i++) ins(read(),i);
	for(i=1;i<=n;i++) findcircle(i);
	for(i=1;i<=mem;i++) cime[cir[i]]=true;
	for(i=1;i<=mem;i++) dp(cir[i]);
	printf(check()?"POSSIBLE\n":"IMPOSSIBLE\n");
    return 0;
}

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

int main(){
  int N;
  int x;
  cin>>N;
  x = N%10;
  if(x ==3) cout<<"bon"<<endl;
  else if(x == 0||x== 1||x==6||x==8) cout<<"pon"<<endl;
  else cout<<"hon"<< endl;
}
  

Measured memory_bytes: 3548
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;
// a < b
int gcd(int a, int b) {
    if(a > b) {
        int t = a;
        a = b;
        b = t;
    }
    return a == 0 ? b : gcd(b % a, a);
}

void leftgcd(vector<int>& v, vector<int>& a) {
    int n = v.size();
    a[0] = v[0];
    for(size_t i = 0; i < n-1; i++)
    {
        a[i+1] = gcd(a[i], v[i+1]);
    }
}

void rightgcd(vector<int>&v, vector<int>& a) {
    int n = v.size();
    a[n-1] = v[n-1];
    for(size_t i = n-1; i > 0; i--)
    {
        a[i-1] = gcd(a[i], v[i-1]);
    }
}

int main() {
    int n, mg = 0;
    cin >> n;
    vector<int> a(n), l(n, 0), r(n, 0);
    for (size_t i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    leftgcd(a, l);
    rightgcd(a, r);

    for (size_t i = 0; i < n; i++)
    {
        int g;
        if(i == 0) {
            g = r[i+1];
        } else if(i == n-1) {
            g = l[i-1];
        } else {
            g = gcd(l[i-1], r[i+1]);
        }
        mg = max(mg, g);
    }
    cout << mg << endl;
}


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

int main(){
  
  char s[3];
  
  for(int i =0;i < 3;i++){
    
    cin>>s[i];
    
  }
    
  for(int i =0;i < 3;i++){
    
    if(s[i]=='7'){
    cout<<"Yes";
      return 0;
  }

  }
  
  cout<<"No";
    

  return 0;
}

Measured memory_bytes: 3580
L = input()
N = len(L)
mod = 10**9 + 7

dpT = [0]*N
dpF = [0]*N

dpT[0] = 1
dpF[0] = 2

for i in range(1, N):
  if L[i] == "1":
    dpT[i] = dpT[i-1] * 3 + dpF[i-1] * 1
    dpF[i] = dpF[i-1] * 2
    dpT[i] %= mod
    dpF[i] %= mod
  else:
    dpT[i] = dpT[i-1] * 3
    dpF[i] = dpF[i-1] * 1
    dpT[i] %= mod
    dpF[i] %= mod

print((dpT[-1]+dpF[-1])%mod)
#print(dpT, dpF)

Measured memory_bytes: 16800
#include <stdio.h>
#include <stdlib.h>

int main(){
	int i;
	char S[6];
	scanf("%s", S);
	for(i = 0; S[i] != '\0'; i++){
		if(S[i] == 'A' && S[i + 1] == 'C'){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}
vector<int> raj;
void dfs(int vis[],vector<int> v[],int curr,int a[],int n)
{
	vis[curr]=1;
	int i=curr;
	//cout << curr << " ";
	raj.push_back(curr);
	
	for(int j=0;j<v[i].size();j++)
	{
		int x=v[i][j];
		if(vis[x]==0)
		{
			
			dfs(vis,v,x,a,n);
		}
	}
}
int32_t main()
{
	int n,m;
	cin >> n >> m;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
	}	
	vector<int> v[n+1];
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		int temp=0;
		for(int j=0;j<v[i].size();j++)
		{
			int x=v[i][j];
			temp=max(temp,a[x]);
			
		}
		if(a[i]>temp)
		cnt++;
	}	
	cout << cnt;
}


Measured memory_bytes: 10188
def gcd(x, y):
  if(y==0):
    return x
  return gcd(y, x % y)

def gcds(a, b, c):
  tmp = gcd(a, b)
  return gcd(tmp, c)

def comb(i, j, k):
  l = [i, j, k]
  s = set(l)
  if len(s)==1:
    return 1
  elif len(s)==2:
    return 3
  else:
    return 6

K = int(input())

ans = 0
for i in range(1, K+1):
  for j in range(i, K+1):
    for k in range(j, K+1):
      ans += comb(i, j, k) * gcds(i, j, k)
      
print(ans)

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

int main() {
  int n , k;
  cin >> n >> k;
  int num = 1;

  for(int i = 0; i < n; i++){
    if (num < k)
      num *= 2;
    else
      num += k;
  }
  cout << num << endl;
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
def f(x):
    if x%10==0:
        return x
    else:
        return x+(10-x%10)
A=f(a)
B=f(b)
C=f(c)
D=f(d)
E=f(e)
if a%10==0 and b%10==0 and c%10==0 and d%10==0 and e%10==0:
    s=0
else:
    list_a=[]
    if not a%10==0:
        list_a.append(a%10)
    if not b%10==0:
        list_a.append(b%10)
    if not c%10==0:
        list_a.append(c%10)
    if not d%10==0:
        list_a.append(d%10)
    if not e%10==0:
        list_a.append(e%10)
    s=10-min(list_a)
print(A+B+C+D+E-s)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
  long long x,y,z;cin>>x>>y>>z;
  if((long long)x*y*z % 2 == 0){
	cout << 0 << endl;
    return 0;
  }
  if(x > y && x > z){
    cout << y*z << endl;
  }else if(y > z && y > x){
    cout << x*z << endl;
  }else{
    cout << x*y << endl;
  }
}

Measured memory_bytes: 256
def dot(c1, c2):
    return c1.real * c2.real + c1.imag * c2.imag

def cross(c1, c2):
    return c1.real * c2.imag - c1.imag * c2.real

def string_to_complex(s):
    x, y = map(int, s.split())
    return x + y * 1j

def contains(polygon, point):
    flag = False
    for v1, v2 in zip(polygon[0:], polygon[1:]):
        a = v1 - point
        b = v2 - point
        if a.imag > b.imag:
            a, b = b, a
        cross_ab = cross(a, b)
        if a.imag <= 0 and b.imag > 0 and cross_ab > 0:
            flag = not flag
        if cross_ab == 0 and dot(a, b) <= 0:
            return 1
    if flag:
        return 2
    else:
        return 0

import sys

file_input = sys.stdin

n = int(file_input.readline())

polygon = [string_to_complex(file_input.readline()) for i in range(n)]
polygon.append(polygon[0])

q = int(file_input.readline())

for line in file_input:
    t = string_to_complex(line)
    print(contains(polygon, t))

Measured memory_bytes: 7844
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
int main(void) {
	char a[3];
	scanf("%s",a);
	for (int i = 0; i < 3; i++) {
		printf("%c", (a[i] == '1') ? '9' : '1');
	}
	printf("\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  int h[105];
  int count=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  count+=h[0];
  for(int i=1;i<n;i++){
    if(h[i]>h[i-1]){
      count+=h[i]-h[i-1];
    }
  }
  cout<<count<<endl;
  return 0;
}


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

int main(void){
    int n,d,a,x=0;
    cin>>n>>d>>x;
    rep(i,n){
        cin>>a;
        x += (d-1)/a + 1;
    }
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    char x,y;
    cin >> x >> y;
    cout << (x > y? '>':x == y? '=' : '<') << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

void Compute(ll n)
{
    KAKA
    vector<pll> vec(n);
    pragi(0,n)
    {
        cin>>vec[i].F>>vec[i].S;
    }
    bool ok = false;
    pragi(0,n - 2)
    {
        if((vec[i].F == vec[i].S) and (vec[i + 1].F == vec[i + 1].S) and (vec[i + 2].F == vec[i + 2].S))
        {
            ok = true;
            break;
        }
    }
    if(ok) cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
}
int main()
{
    KAKA
    ll n;
    cin>>n;
    Compute(n);
}

Measured memory_bytes: 3656
input = gets
r = input.split(" ")[0].to_i
D = input.split(" ")[1].to_i
x2000 = input.split(" ")[2].to_i

if r > 5 || r < 2
  exit
end

if D > 100 || r < 1
  exit
end

if x2000 > 2000 || x2000 <= D
  exit
end

x = x2000
i = 0
while i<10 do
  x = r * x - D
  print "#{x}\n"
  i = i + 1
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define int long long

int G[10][10];

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

  int n,m; cin >> n >> m;
  //vector<int> G[n];
  for(int i = 0; i < m; i++){
    int a,b; cin >> a >> b;
    a--,b--;
    G[a][b] = G[b][a] = 1;
  }

  vector< vector<int> > dp(1 << n,vector<int> (n,0));
  for(int i = 0; i < n; i++){
    dp[(1 << n) - 1][i] = 1;
  }
  function< int(int,int) > rec =
  [&](int S,int u){
    if(dp[S][u] != 0) return dp[S][u];

    int res = 0;
    for(int i = 0; i < n; i++){
      if(!(S >> i & 1) && G[u][i]){
        res += rec(S | 1 << i,i);
      }
    }
    return dp[S][u] = res;
  };
  cout << rec(1,0) << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&A[i])
	}
	const p = 1000_000_000 + 7

	sum := 0
	tmp := 0

	for i := N - 2; i >= 0; i-- {

		tmp += A[i+1]
		tmp %= p
		sum += A[i] * tmp
		sum %= p
	}
	//fmt.Println(sum)

	fmt.Println(sum)

}


Measured memory_bytes: 6488
#include<bits/stdc++.h>
using namespace std;
int kk;
long long ans=0;
int main()
{
	scanf("%d",&kk);
	int i=1,j=1,k=1;
	while(i<=kk)
	{
		j=1;
		while(j<=kk)
		{
			k=1;
			while(k<=kk)
			{
				ans+=1ll*__gcd(__gcd(i,j),k);
				++k;
			}
			++j;
		}
		++i;
	}
	printf("%lld\n",ans);
	return 0;
}
/*
#include<bits/stdc++.h>
using namespace std;
long long n,ans=0;
int main()
{
	scanf("%lld",&n);
	ans=(1+n)*n/2;
	long long tmp=n/3ll;
	if(n>=3) ans-=(tmp*3ll+3ll)*tmp/2ll;
	tmp=n/5ll;
	if(n>=5) ans-=(tmp*5ll+5ll)*tmp/2ll;
	tmp=n/15ll;
	if(n>=15) ans+=(tmp*15ll+15ll)*tmp/2ll;
	printf("%lld\n",ans);
	return 0;
}
*/
/*
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
	scanf("%d",&n);
	int i=1,p=1;
	while(i<=5)
	{
		int tmp=n%(p*10);
		tmp/=p;
		if(tmp==7)
		{
			printf("Yes\n");
			return 0;
		}
		++i;
	}
	printf("No\n");
	return 0;
}
*/

Measured memory_bytes: 3820
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n = s.size();

    int b = 1;

    if (s[0] != 'A') b = 0;

    int c = 0;
    for (int i = 2; i < n - 1; i++) {
        c += (s[i] == 'C');
    }
    if (c != 1) b = 0;

    int d = 0;
    for (int i = 0; i < n; i++) {
        if ('A' <= s[i] && s[i] <= 'Z') d++;
    }
    if (d != 2) b = 0;

    cout << (b ? "AC" : "WA") << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma comment (linker, "/STACK:256000000")
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long a = 0;a < b;++a)
#define ALL(x) (x).begin(),(x).end()
void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}
void solve() {
    int n;
    cin >> n;
    int back;
    cin >> back;
    int ans = 0;
    REP(i, n - 1) {
        int t;
        cin >> t;
        if (back < t) {
            ans++;
        }
        back = t;
    }
    cout << ans << endl;
}
int main() {
    init();
    solve();
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
void add_self(int &a,int b)
{
    a+=b;
    if(a>=mod)
    {
        a-=mod;
    }
}
int main() {
	// your code goes her
	int n;
	cin>>n;
	int a[n][n];
	    vector<int> dp(1<<n);
	    dp[0]=1;
	    for(int i=0;i<n;i++)
	    {
	        for(int j=0;j<n;j++)
	        {
	            cin>>a[i][j];
	        }
	    }
	    for(int i=0;i<(1<<n)-1;i++)
	    {
	        int row=__builtin_popcount (i);
	        for(int b=0;b<n;b++)
	        {
	            if(a[row][b]&&!(i&(1<<b)))
	            {
	                int m2=i^(1<<b);
	                add_self(dp[m2],dp[i]);
	            }
	        }
	    }
	   cout<<dp[(1<<n)-1]<<endl; 
	return 0;
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
int main(){
int R, G, B, N;
cin >> R >> G >> B >> N;
int ans = 0;
for(int i=0;i<=N/R;i++){
for(int j=0;j<=(N-i*R)/G;j++){
if((N-i*R-j*G)%B ==0) ans++;
}
}
cout << ans << endl;
}


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

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


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int N, i, x, y, z, a, b;
  scanf ("%d", &N);
  for(i = 0; i < N; i++) {
    scanf("%d %d %d", &x, &y, &z);
    if(x >= y && x >= z) {
      a = x * x;
      b = y * y + z * z;
    } else if(y >= x && y >= z) {
      a = y * y;
      b = x * x + z * z;
    } else {
      a = z * z;
      b = x * x + y * y;
    }

    if(a == b) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  rep(i,n) cin >> A.at(i);
  vector<int> ans(n);
  if(n%2 == 0){
    int i = 0;
    int j = n-1;
    rep(k,n){
      if(k%2 == 0){
        ans.at(j) = A.at(n-k-1);
        j --;
      }else{
        ans.at(i) = A.at(n-k-1);
        i ++;
      }
    }
    reverse(ans.begin(),ans.end());
  }else{
    int i = 0;
    int j = n-1;
    rep(k,n){
      if(k%2 == 0){
        ans.at(i) = A.at(n-k-1);
        i ++;
      }else{
        ans.at(j) = A.at(n-k-1);
        j --;
      }
    }
  }
  rep(i,n) cout << ans.at(i) << " " ;
  cout << endl;
}

Measured memory_bytes: 3712
import sys

X, Y = map(int,input().split())
p = 10**9 + 7

if (X + Y)% 3 != 0:
    print(0)
    sys.exit()

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p    

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

n,r = 5000,5

n = (X + Y)//3
r = min(X, Y) - n
print(cmb(n, r, p))

Measured memory_bytes: 122056
from bisect import *

N, V = map(int, input().split())

boxs = []
for i in range(4):
    boxs.append(list(map(int, input().split())))

pre = [a+b for a in boxs[0] for b in boxs[1]]
af = [c+d for c in boxs[2] for d in boxs[3]]
    
pre.sort()
af.sort()

ans = 0
for ab in pre:
    target = V - ab
    ans += bisect_right(af,target) - bisect_left(af,target)
print(ans)    


Measured memory_bytes: 101184
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>

int main(){
    ll N;
    cin >> N;
  	ll ans=0;
  	if(N<=1000)ans=1000-N;
  	else if(N<=2000)ans=2000-N;  	
  	else if(N<=3000)ans=3000-N;
  	else if(N<=4000)ans=4000-N;
  	else if(N<=5000)ans=5000-N;
  	else if(N<=6000)ans=6000-N;
  	else if(N<=7000)ans=7000-N;
  	else if(N<=8000)ans=8000-N;
    else if(N<=9000)ans=9000-N;
  	else if(N<=10000)ans=10000-N;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    ll N; cin >> N;
    ll ans = 0;
    for(ll i=1; i*i<=N; i++){
        if(i*i == N) continue;
        if(N%i==0 && N/i - 1 > i) ans += (N/i - 1);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
/*
   ,##.                   ,==.
 ,#    #.                 \ o ',
#        #     _     _     \    \
#        #    (_)   (_)    /    ; 
 `#    #'                 /   .'  
   `##'                   "=="
*/

#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <complex>
#include <cassert>
#define ll long long
#define null NULL
#define all(a) a.begin(), a.end()
#define debug(a) cerr << #a << " = " << a << endl
#define forn(i, n) for (int i = 0; i < n; ++i)
#define int long long

using namespace std;

const ll MOD = 1e9 + 7;

const int mx = 3e5;
const int INF = 1e9;
int n, a[mx];
map<int, int> mp;

signed main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		a[i] = i - a[i];
	}
	for (int i = 0; i < n; ++i) {
		if (a[i] < 0 || a[i] >= n) {
			cout << -1 << endl;
			return 0;
		}
	}
	int suf = n, clr = -1;
	ll ans = 0;
	for (int i = n - 1; i >= 0; --i) {
		if (a[i] >= suf && a[i] != clr) {
			cout << -1 << endl;
			return 0;
		}
		if (i >= suf && a[i] == clr) {
			continue;
		}
		ans += (i - a[i]);
		suf = a[i];
		clr = a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define riterator reverse_iterator
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int N = 2000;
struct Edge
{
	int v,nxt;
} e[(N<<1)+3];
int fe[N+3];
int fa[N+3];
int dep[N+3];
int sum[N+3];
int sz[N+3];
int dp[N+3];
char a[N+3];
int n,ans,en;

void addedge(int u,int v)
{
	en++; e[en].v = v;
	e[en].nxt = fe[u]; fe[u] = en;
}

void dfs(int u)
{
	sz[u] = a[u]=='1'?1:0; sum[u] = 0;
	for(int i=fe[u]; i; i=e[i].nxt)
	{
		int v = e[i].v; if(v==fa[u]) continue;
		fa[v] = u; dep[v] = dep[u]+1;
		dfs(v);
		sz[u] += sz[v]; sum[u] += sum[v]+sz[v];
	}
	dp[u] = 0;
	for(int i=fe[u]; i; i=e[i].nxt)
	{
		int v = e[i].v; if(v==fa[u]) continue;
		dp[u] = max(dp[u],max(sum[u]&1,(dp[v]+sz[v])-(sum[u]-(sum[v]+sz[v]))));
	}
}

int main()
{
	scanf("%d",&n);
	scanf("%s",a+1);
	for(int i=1; i<n; i++) {int u,v; scanf("%d%d",&u,&v); addedge(u,v); addedge(v,u);}
	int ans = N*N;
	for(int i=1; i<=n; i++)
	{
		memset(sum,0,sizeof(int)*(n+2)); memset(fa,0,sizeof(int)*(n+2)); memset(dep,0,sizeof(int)*(n+2)); memset(dp,0,sizeof(int)*(n+2));
		dfs(i);
//		printf("i=%d\n",i);
//		printf("sum: "); for(int u=1; u<=n; u++) printf("%d ",sum[u]); puts("");
//		printf("dp: "); for(int u=1; u<=n; u++) printf("%d ",dp[u]); puts("");
		if(sum[i]&1) continue;
		if(dp[i]>0) continue;
		ans = min(ans,sum[i]>>1);
	}
	printf("%d\n",ans==N*N?-1:ans);
	return 0;
}

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

#define forall(i,a,b) for(int i=a;i<b;i++)
#define foreach(v, c) for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a) a.begin(), a.end()
#define fill(a,v)  memset(a, v, sizeof a)
#define maX(a,b)  ( (a) > (b) ? (a) : (b))
#define miN(a,b)  ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)  ( (n >> b) & 1)
#define ll long long
#define endln '\n'
#define nperm next_permutation
#define forel(i, str) forall(i, 0, str.size())
#define contains(needle,haystack) (haystack.find(needle) != haystack.end())
#define strlower(data) transform(data.begin(), data.end(), data.begin(), ::tolower)
#define strupper(data) transform(data.begin(), data.end(), data.begin(), ::toupper)
#define umap unordered_map
#define pb(i) push_back(i)
#define pf(i) push_front(i)
#define is_pow2(a) ((a & (a - 1)) == 0)
#define between(a, b, c) (a >= b && a <= c)
#define pq priority_queue
#define v(type) vector<type>

using namespace std;

int n, k, x, y;

int main() {
	std::ios::sync_with_stdio(false);
	// freopen("_in","r",stdin);
    // freopen("_out","w",stdout);

	cin >> n >> k >> x >> y;

    int total = 0;
    if (n > k) {
    	total = k * x + (n - k) * y;
    } else {
    	total = n * x;
    }

    cout << total << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(void)
{
    ll a,b;
    cin >> a >> b;
    vector<ll> nums;
    nums.push_back(a + b);
    nums.push_back(a - b);
    nums.push_back(a * b);
    sort(all(nums));

    cout << *max_element(all(nums)) << endl;

    return 0;
}

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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

ll d[101];

int main() {
    ll n,k;
    cin >> n;
    REP(i,n)cin >> d[i];

    ll ans = 0;
    REP(i,n){
        for(int  j = i+1;j < n;j++){
            ans += d[i] * d[j];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
const int N=1e5+5;
int d[N],n,num[N];
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",d+i);
    std::sort(d+2,d+1+n);
    if(d[1]!=0||d[2]==0&&n>1) return !printf("0");
    long long ans=1,mod=998244353;
    num[0]++;
    for(int i=2;i<=n;i++) {
        int t=d[i]-1;
        ans=ans*num[t]%mod;
        num[d[i]]++;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(){
int a[3];
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  int five=0,sevne=0;
  int i;
    for(i=0;i<3;i++){
    if(a[i]==5){
    five++;
    }else if(a[i]==7){
    sevne++;}
    }
  if(five==2 && sevne==1){
  
  printf("YES\n");
  }else{
  printf("NO\n");
  }
  return(0);
}


Measured memory_bytes: 128
N=int(input())
A = list(map(int, input().split()))
gray=any([1<=i<=399 for i in A])
brown=any([400<=i<=799 for i in A])
green=any([800<=i<=1199 for i in A])
sky=any([1200<=i<=1599 for i in A])
blue=any([1600<=i<=1999 for i in A])
yellow=any([2000<=i<=2399 for i in A])
orange=any([2400<=i<=2799 for i in A])
red=any([2800<=i<=3199 for i in A])
color_list=[gray,brown,green,sky,blue,yellow,orange,red]
count= color_list.count(True)
change=len([i for i in A if 3200<=i])
if count==0:
    print(1,change)
else:
    print(count,count+change)

Measured memory_bytes: 38256
N, M = map(int, input().split())
A = list(map(int, input().split()))

dp = [-1] * (N+1)
need = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp[0] = 0

for i in range(N+1):
    for j in A:
        if i + need[j] > N:
            continue
        dp[i+need[j]] = max(dp[i+need[j]], dp[i]*10+j)
print(dp[N])

Measured memory_bytes: 14692