akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.lang.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
            int P = sc.nextInt();
            int Q = sc.nextInt();
            int R = sc.nextInt();
            sc.close();

            System.out.println(Math.min(Math.min(P+Q,Q+R),R+P));
    }
}



Measured memory_bytes: 20692
N = int(input())
temp = [int(i) for i in input().split()]

num = temp[0]
A = [num]
for i in range(1, N):
    if temp[i] != num:
        A.append(temp[i])
        num = temp[i]
A += [0]

ls = []
bottom = A[0]
for i in range(1, len(A)-1):
    if A[i-1] < A[i] and A[i] > A[i+1]:
        ls += [bottom, A[i]]
    if A[i-1] > A[i] and A[i] < A[i+1]:
        bottom = A[i]

stucks = 0
money = 1000
for i in range(len(ls)):
    if i % 2 == 0:
        stucks = money // ls[i]
        money -= stucks * ls[i]
    else:
        money += stucks * ls[i]
        stucks = 0

print(money)

Measured memory_bytes: 9280
#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 ordered_set tree<pair<int,int>, null_type,less<pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update>
#define standardVar ll n,m,i,j,k,num,num1,num2,flag=0
#define nn <<"\n"
#define __ <<" "<<
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define ittr(x,v) for(auto x=v.begin();x!=v.end();x++)
#define itr(x,n) for(x=0;x<n;x++)
#define itrab(x,a,b) for(x=a;x<b;x++)
#define itpr(v) ittr(x,v)cout<<*x<<" "; cout nn
#define itppr(v) ittr(x,v)cout<<(*x).ff<<" "<<(*x).ss<<"  "; cout nn
#define size(x) (ll)x.size()
#define pi 3.14159265359
#define dTor(x) ((x)*pi)/180.0
#define INF 1000000100;
#define INFF 1000000000000000100;

typedef long long int ll;       //TYPEDEFS
typedef long double ld;
typedef vector<ll> vl;
typedef map<ll,ll> ml;
typedef set<ll> sl;
typedef string str;
typedef pair<ll, ll> pl;
typedef vector< pl > vpl;
typedef map<pl,ll> mpl;
typedef set< pl > spl;
typedef vector<str> vst;
typedef vector<vl> vvl;

const ll M=1000000007;          //COMMON MODULO PRIMES
const ll N=998244353;

ll power(ll x, ll y, ll p){     //MODULAR EXPONENTIATION
    ll res=1;
    x=x%p;
    if(x==0)
        return 0;
    while(y>0){
        if(y&1)
            res=(res*x)%p;
        y=y>>1;
        x=(x*x)%p;
    }
    return res;
}
ll inv(ll x, ll m){             //FERMAT INVERSE
    return power(x,m-2,m);
}
struct comp{                    //COMPARISON ON PAIRS
    template<typename T>        
    bool operator()(const T &a, const T &b){
        if (a.ff==b.ff)
            return (a.ss<b.ss);
        else
            return (a.ff<b.ff);
    }
};
bool mod(const pair<ll,ll> &a, const pair<ll,ll> &b){   //COMPARATOR FOR PAIRS (SORTING)
    if(a.ff!=b.ff)
        return (a.ff>b.ff);
    else
        return (a.ss>b.ss);
}
vector<bool> pr(1000000+1,1);
void sieve(ll mn, ll mx){       //SIEVE OF ERATOSTHENES
    for(ll i=mn;i*i<=mx;i++)
        if(pr[i-mn]==1)
            for(ll j=i*i;j<=mx;j+=i)
                pr[j-mn]=0;
}
bool isValid(ll i, ll j, ll n, ll m){   //CHECKS FOR OVERFLOW
    if(i>=0&&i<n&&j>=0&&j<m){
        return true;
    }
    return false;
}

//MAIN FUNCTION STARTS HERE

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    standardVar;
    cin>>n;
    vl v;
    itr(i,n){
        cin>>num;
        v.pb(num);
    }
    ll c=0;
    itr(i,n){
        itrab(j,i+1,n){
            if(i!=j){
                itrab(k,j+1,n){
                    if(j!=k){
                        if(v[i]!=v[j]&&v[j]!=v[k]&&v[i]!=v[k]){
                            if(v[i]+v[j]>v[k]&&v[j]+v[k]>v[i]&&v[k]+v[i]>v[j])
                                c++;
                        }
                    }
                }
            }
        }
    }
    cout<<c nn;
    return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    string A, B, C;
    cin >> A >> B >> C;
    
    string next;
    next.push_back( A[ 0 ] );
    
    int a{}, b{}, c{};
    while( true )
    {
        if( next == "a" )
        {
            if( A.empty() )
            {
                cout << "A" << endl;
                break;
            }
            next = *A.begin();
            A.erase( A.begin() );
            a++;
        }
        if( next == "b" )
        {
            if( B.empty() )
            {
                cout << "B" << endl;
                break;
            }
            next = *B.begin();
            B.erase( B.begin() );
            b++;
        }
        if( next == "c" )
        {
            if( C.empty() )
            {
                cout << "C" << endl;
                break;
            }
            next = *C.begin();
            C.erase( C.begin() );
            c++;
        }
    }
    return 0;
}

Measured memory_bytes: 3640
MOD = 2019
L, R = map(int, input().split())
ans = 2020
for i in range(L, R):
    for j in range(i+1, R+1):
        ans = min(ans, (i*j) % MOD)
        if ans == 0:
            break
    else:
        continue
    break
print(ans)

Measured memory_bytes: 38896
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

def main():
  n  = int(input())
  Hs = list(map(int, input().strip().split()))
  dp = numpy.zeros(n, dtype=numpy.int)
  dp[1] = abs(Hs[1] - Hs[0])
  for i in range(2, n):
    dp[i] = numpy.min([dp[i-1]+abs(Hs[i] - Hs[i-1]), dp[i-2]+abs(Hs[i] - Hs[i-2])])
  print(dp[-1])

if __name__=='__main__':
  main()

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

int main()
{
	int n,m,x,i,j,ans=2147483647,s1=0,s2=0;
	cin>>n>>m>>x;
	int a[n+1];
	memset(a,0,sizeof(a));
	for(i=1;i<=m;i++) 
	{
		cin>>j;
		a[j]=1;
	}
	for(i=1;i<x;i++) s1+=a[i];
	for(i=x+1;i<n;i++) s2+=a[i];
	cout<<min(s1,s2);
	return 0;
}

Measured memory_bytes: 256
using System;

namespace kekW
{
    internal static class Program
    {
        private static void Main()
        {
            var nbrs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var x = nbrs[0];
            var y = nbrs[1];
            int res = 0;

            while(x != y)
            {
                if(x < y)
                {
                    if (-x - y > x - y && -x <= y)
                    {
                        x = -x;
                        res++;
                    }
                    else if(x < 0 && y > 0)
                    {
                        int temp = y - x - y * 2;
                        x += temp;
                        res += temp;
                    }
                    else
                    {
                        int temp = y - x;
                        x += temp;
                        res += temp;
                    }
                }
                else
                {
                    if (-x >= y && x < 0 || -x == y)
                    {
                        x = -x;
                        res++;
                    }
                    else if(Math.Abs(y) -x > 0)
                    {
                        int temp = Math.Abs(y) - x;
                        x += temp;
                        res += temp;
                    }
                    else
                    {
                        x = -x;
                        res++;
                    }
                }
            }

            Console.WriteLine(res);
        }
    }
}



Measured memory_bytes: 17868
#include<bits/stdc++.h>
using namespace std;
int main (){
string S;
cin >> S;
int x = S.size();
int count = 0;
if(x%2 ==0){
  for(int i = 0; i <x/2; i++){
    if(S[i] != S[x-i-1])count++;
  }
}
else{
  for(int i = 0; i < x/2 ; i++){
    if(S[i] != S[x-i-1]) count++;
  }
}
cout << count << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 2147483647;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1); //3.1415...
const ll SIZE = 2000005;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[SIZE], finv[SIZE], inv[SIZE];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge>> G;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
auto mod_pow(T a, T b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

ll n, ans;
map<ll, ll>m;
int main() {
	cin >> n;
	vector<ll>v(n);
	for (int i = 0; i < n; ++i) { cin >> v[i]; }

	for (int i = n - 1; i >= 0; --i) {
		ans += m[i + v[i]];
		++m[i - v[i]];
	}

	cout << ans << endl;
}

Measured memory_bytes: 27368
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define Cout(s) cout<<s<<endl
typedef long long ll;
using namespace std;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

ll  a = 0, b = 0, c, d, n, k = 0;
string s, t;



int main()
{
   ll n; 
	cin >> n >> a >> b;
	if (b <a || (n == 1 && a != b))
	{
		cout << 0 << endl; return 0;
	}
    ll ans = b * (n - 1) + a - (a * (n - 1) + b)+1;
	if (n==1)
		cout << 1<< endl;
	else
		cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n)cin >> a[i];
    sort(all(a));
    cout << a[n/2]-a[n/2-1] << endl;
}


Measured memory_bytes: 1024
import sys

for num in sys.stdin:
    num = int(num)
    counter = 0
    for i in range(0,10):
        for j in range(0,10):
            for k in range(0,10):
                for l in range(0,10):
                    if (i+j+k+l) == num:
                        counter += 1
    print(counter)

Measured memory_bytes: 7624
#include<iostream>
#include<list>
#include<vector>
#include<string>
#include<cmath>

using namespace std;

int main(){
    string S;
    cin >> S;
    int size = S.size();
    int tail = size - 5;
    bool flag = true;
  	while (tail >= 0) {
      string substr = S.substr(tail, 5);
      if (substr == "dream" || substr == "erase") {
        // cout << substr << endl;
        tail -= 5;
      }
      else {
        tail -= 1;
        string substr = S.substr(tail, 6);
        if (substr == "eraser") {
          	// cout << substr << endl;
        	tail -= 5;
      	}
        else {
          tail -= 1;
          string substr = S.substr(tail, 7);
          if (substr == "dreamer") {
            // cout << substr << endl;
            tail -= 5;
          }
          else {
            flag = false;
            break;
          }
        }
      }
      // cout << tail << endl;
    }
  
  	string ans;
  	if (flag) {
      ans = "YES";
    }
  	else {
      ans = "NO";
    }
  
  	cout << ans;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

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

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 DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	vector<string> s(3);
	rep(i,3) cin >> s[i];
	cout << s[0][0] << s[1][0] << s[2][0] << endl;
	return 0;
}

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

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	if ( (a < c && b > c) || (a > c && b < c) ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;
#define pai 3.141592653589793238462643383279





int main(){
  ll a, w, b, v, t; cin >> a >> w >> b >> v >> t;
  if((w-v)*t>=abs(a-b)) cout << "YES" << endl;
  else cout << "NO" << endl;
}
    

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

int main() {
    int N, K;
    cin >> N >> K;
    bool flag = true;
    int i = 0;
    while(flag){
        if(N < pow(K, i)){
            flag = false;
        } else {
            i++;
        }
    }
    cout << i << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double x = Math.PI;
        double cir = 2 * r * x;
        double area = r * r * x;
        String a = String.format("%.5f", area);
        String b = String.format("%.5f", cir);
        System.out.println(a + " " + b);                
    }    
}



Measured memory_bytes: 28092
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  string s;
  cin >> n >> s;
  ll ans=0;
  ll c[26];
  mem(c);
  rep(i,n) c[s[i]-'a']++;
  ll sum=1;
  rep(i,26) {
    ans+=c[i]*sum;
    ans%=MAX;
    sum*=c[i]+1;
    sum%=MAX;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,n,k,y,s,a,b,c;
    while(cin>>n>>k>>x>>y)
    {
        if(n>k)
        {
            a=n-k;
            s=k*x+a*y;
        }
        else s=n*x;
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t A, B, C, D;
  cin >> A >> B >> C >> D;
  int64_t ans;
  ans = max(A*C, max(A*D, max(B*C, B*D)));
  cout << ans << endl;
}


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


int dx[]={0,0,-1,1},dy[]={1,-1,0,0};
char S[1000][1000];

int main(){
	int h,w;
	cin >> h >> w;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin >> S[i][j];
		}
	}
	
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(S[i][j]=='#'){
				int cnt=0;
				for(int k=0;k<4;k++){
					if(S[i+dx[k]][j+dy[k]]=='#') cnt++;
				}
				if(cnt==0){
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

char mns(char c) {
	if (c == '0') return '2';
	if (c == '1') return '1';
	return '0';
}

char multi(char c1, char c2) {
	if (c1 == '0' || c2 == '0') return '0';
	if (c1 == '2' && c2 == '2') return '2';
	return '1';
}

char pls(char c1, char c2) {
	if (c1 == '2' || c2 == '2') return '2';
	if (c1 == '0' && c2 == '0') return '0';
	return '1';
}

char eval(string s) {
	if (s.size() == 1) return s[0];

	if (s[0] != '(') {
		int i = 0;
		while (s[i] == '-') i++;
		string t = s.substr(i);
		if (i % 2) return mns(eval(t));
		return eval(t);
	}


	s = s.substr(1, (int)s.size() - 2);
	
	int cnt = 0;
	int pt = 0;
	while (!(cnt == 0 && (s[pt] == '+' || s[pt] == '*'))) {
		if (s[pt] == '(') cnt++;
		else if (s[pt] == ')') cnt--;
		pt++;
	}

	string a = s.substr(0, pt);
	string b = s.substr(pt + 1);

	if (s[pt] == '+') return pls(eval(a), eval(b));
	return multi(eval(a), eval(b));
}

signed main() {
	while (true) {
		string t;
		cin >> t;

		if (t == ".") break;

		int ret = 0;
		for (char p = '0'; p <= '2'; p++) {
			for (char q = '0'; q <= '2'; q++) {
				for (char r = '0'; r <= '2'; r++) {
					string s = t;
					rep(i, s.size()) {
						if (s[i] == 'P') s[i] = p;
						else if (s[i] == 'Q') s[i] = q;
						else if (s[i] == 'R') s[i] = r;
					}
					ret += (eval(s) == '2');
				}
			}
		}

		cout << ret << endl;
	}

    return 0;
}

Measured memory_bytes: 3164
#include<cstdio>
using namespace std;
const int MAX_N = 100;
int N;
int A[MAX_N];
int D;
int X;
int main(){
scanf("%d", &N);
scanf("%d%d", &D, &X);
for(int i = 0; i < N; ++i){
scanf("%d", A + i);
}
int ans = X;
for(int i = 0; i < N; ++i){
int tmp = (D - 1) / A[i] + 1;
ans += tmp;
}
printf("%d\n", ans);
return 0;
}

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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

int c[505];
int s[505];
int f[505];
unsigned long answer[505] ={0};

int main(void){
    int n;
    int i, j;
    scanf("%d", &n);
    for (i = 0; i < n-1; i++){
        scanf("%d %d %d", &c[i], &s[i], &f[i]);
    }

    for (i = 0; i < n-1; i++){
        answer[i] += s[i];
        answer[i] += c[i];
        for (j = i+1; j < n-1 ; j++){
            if (answer[i] < s[j]){
                answer[i] += s[j] - answer[i];
            }else
            if ((answer[i]-s[j]) % f[j] != 0){
                answer[i] += f[j] - (answer[i]-s[j])%f[j];
            }
            answer[i] += c[j];
        }
    }

    answer[n-1] = 0;

    for (i = 0; i < n; i++){
        printf("%lu\n", answer[i]);
    }
    
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

template <ll mod>
struct ModCombination{
    ll N;
    vector<ll> fact,inv,finv;

    ModCombination(ll n):N(n){
        fact.assign(n+1, 1);
        inv.assign(n+1, 1);
        finv.assign(n+1,1);
        for(int i=1;i<n;i++){
            fact[i+1] = fact[i]*(i+1)%mod;
            inv[i+1] = inv[mod%(i+1)]*(mod-mod/(i+1))%mod;
            finv[i+1] = finv[i]*inv[i+1]%mod;
        }
    }

    ll Comb(ll n,ll k){
        return (fact[n]*finv[k]%mod)*finv[n-k]%mod;
    }
};


int main(){
  ll N,M;cin>>N>>M;
  ll ans=1;
  ModCombination<MOD> C(112345);
  for(int i=2;i*i<=M;i++){
    int cnt=0;
    for(;M%i==0;M/=i,cnt++);
    ans = ans*C.Comb(N+cnt-1,cnt)%MOD;
  }
  if(M>1){
    ans = ans*N%MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2944
#define TEST_SNO	1
#define TEST_ENO	3

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

FILE *in, *ans;
int t;
int v[5];

int
out(const char *s)
{
#ifdef TEST
	char buf[8192];
	fgets(buf, sizeof(buf), ans);
	if (strcmp(buf, s)) {
		printf("err\n");
	}
#else
	printf(s);
#endif
	return 0;
}

int
outi(int i)
{
	char s[128];
	sprintf(s, "%d\n", i);
	out(s);
	return 0;
}

int
getint()
{
	int i;
	fscanf(in, "%d", &i);
	return i;
}

int
getstr(char *s)
{
	fscanf(in, "%s", s);
	return 0;
}

int
sortfnc(const void *v1, const void *v2)
{
	int *i1 = (int *)v1;
	int *i2 = (int *)v2;

	if (*i1 > *i2) {
		return 1;
	}
	else if (*i1 < *i2) {
		return -1;
	}

	return 0;
}

int
chk()
{
	int i, j, k, l, m;
	int max = 1000;
	for (i = 0; i < 5; i++) {
		for (j = 0; j < 5; j++) {
			if (i == j) {
				continue;
			}
			for (k = 0; k < 5; k++) {
				if (i == k) {
					continue;
				}
				if (j == k) {
					continue;
				}
				for (l = 0; l < 5; l++) {
					if (i == l) {
						continue;
					}
					if (j == l) {
						continue;
					}
					if (k == l) {
						continue;
					}
					for (m = 0; m < 5; m++) {
						if (i == m) {
							continue;
						}
						if (j == m) {
							continue;
						}
						if (k == m) {
							continue;
						}
						if (l == m) {
							continue;
						}
						int time = (v[i] + 9) / 10 * 10;
						time += (v[j] + 9) / 10 * 10;
						time += (v[k] + 9) / 10 * 10;
						time += (v[l] + 9) / 10 * 10;
						time += v[m];
						if (max > time) {
							max = time;
						}
					}
				}
			}
		}
	}
	return max;
}

int
fnc()
{
	for (int i = 0; i < 5; i++) {
		v[i] = getint();
	}

	int r = chk();
	outi(r);

	return 0;
}

int
main()
{
#ifdef TEST
	for (t = TEST_SNO; t <= TEST_ENO; t++) {
		char str[128];
		sprintf(str, "test%d.txt", t);
		in = fopen(str, "r");
		sprintf(str, "ans%d.txt", t);
		ans = fopen(str, "r");
		fnc();
		fclose(in);
		fclose(ans);
	}
	printf("end\n");
#else
	in = stdin;
	fnc();
#endif

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(void){
	string s;
	int i;
	getline(cin,s);
	for(i=0;i<s.size();i++){
		if('a'<=s[i]&&s[i]<='z')	s[i]-='a'-'A';
	}
	cout<<s<<endl;
	return 0;
}


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

using namespace std;

int main()
{
    int ile=1;
    int n; cin>>n;
    int * a=new int[n];
    for(int i=0;i<n;i++) cin>>a[i];
    int maxx=a[0];
    for(int i=1;i<n;i++)
    {
        if(a[i]>=maxx) ile++;
        maxx=max(maxx,a[i]);
    }
    cout<<ile;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector<int>x(n);
	int mn_tot=1e9+777;
	for(int i=0;i<n;i++) cin>>x[i];
	for(int p=1;p<=100;p++){
		int cur_tot=0;
		for(int i=0;i<n;i++){
			int stm=x[i]-p;
			stm = stm*stm;
			cur_tot+=stm;
		}
		mn_tot= min(cur_tot,mn_tot);
	}
	cout<<mn_tot<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 long long int a[105][105];
 long long int b[105][105];
 long long int result[105][105]={{0}};

 int main()
 {
   int n,m,l;
   cin>>n>>m>>l;
   for(int i=0;i<n;i++)
   {
     for(int j=0;j<m;j++)
     {
       cin>>a[i][j];        
     }        
   }
   for(int i=0;i<m;i++)
   {
     for(int j=0;j<l;j++)
     {
       cin>>b[i][j];        
     }        
   }
   for(int i=0;i<n;i++)
   {
     for(int j=0;j<l;j++) 
     {
       for(int k=0;k<m;k++)
       {
         result[i][j]+=(a[i][k]*b[k][j]);        
       }        
     }       
   }
   for(int i=0;i<n;i++)
   {
     for(int j=0;j<l-1;j++)
     {
       cout<<result[i][j]<<" ";        
     }
     cout<<result[i][l-1];
     cout<<endl;        
   }
   //while(1);
   return 0;
 }
 
 

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

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTS(s) printf("%s\n",(s))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

typedef long long ll;

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
ll Max(int a, int b) {
	return (a) > (b) ? (a) : (b);
}

int main() {
	int c[3][3];
	REP(i, 3) {
		REP(j, 3) {
			scanf("%d", &c[i][j]);
		}
	}
	int x[2], y[2];
	x[0] = c[0][0] - c[0][1];
	x[1] = c[0][0] - c[0][2];
	y[0] = c[0][0] - c[1][0];
	y[1] = c[0][0] - c[2][0];
	REP(i, 2) {
		REP(j, 2) {
			if (c[i+1][0] - c[i+1][j+1] != x[j]) {
				puts("No");
				return 0;
			}
		}
	}
	REP(i, 2) {
		REP(j, 2) {
			if (c[0][i+1] - c[j+1][i+1] != y[j]) {
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	int N;
	cin >> N;

	ll kotae = 0;
	map<ll, int> MP;
	MP[0]++;
	ll ruiseki = 0;
	rep(i, N) {
		ll A;
		cin >> A;
		ruiseki += A;
		kotae += MP[ruiseki];
		MP[ruiseki]++;
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 12800
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;



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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <random>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;

int main()
{
	string S;
	string T;
	cin >> S >> T;
	int n = S.size();
	int m = T.size();
	int k = n - m;
	int ans = m;
	for (int i = 0; i <= k; ++i)
	{
		int ct = 0;
		for (int j = 0; j < m; ++j)
		{
			if (T[j] != S[j + i])
				++ct;
		}
		ans = min(ct, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3620
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var (
	N, K int
)

func readVariables() {
	N, K = nextInt(), nextInt()
}

func main() {
	readVariables()
	answer := 0.
	for x := 1; x <= N; x++ {
		answer += f(x)
	}
	fmt.Println(answer)
}
func f(x int) float64 {
	M := 0
	for x < K {
		x *= 2
		M++
	}
	result := math.Pow(2., -float64(M))
	// fmt.Println(x, float64(K)/float64(x), M, result)
	return result / float64(N)
}

/* Template */

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt returns minimum argument
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt returns maximum argument
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt returns |x| for x
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow calculates integer power with modulo operation
//if modulo <= 1, it powers w/o module operation
//if base < 0, return value might be negative too.
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 640
import java.util.*;
public class Main
{
public static void main(String[] args)
{
 
Scanner sc=new Scanner(System.in);
String s=sc.next();
int a=0;
int b=1;
 if(s.charAt(a)==s.charAt(b))
{
    System.out.println(1+" "+2);
}
else if(s.length()==2)
{
    System.out.println(-1+" "+-1);
}
else{
for(int i=2;i<s.length();i++)
{
    if(s.charAt(a)==s.charAt(i))
    {
        System.out.println((a+1)+" "+(i+1));
        break;
    }
    if(s.charAt(b)==s.charAt(i))
    {
       System.out.println((b+1)+" "+(i+1));
        break; 
    }
    if(i==s.length()-1)
    {
        System.out.println(-1+" "+-1);
    }
    a=b;
    b=i;
}}}}

Measured memory_bytes: 24020
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
int N;
const int MAX_N=5e5;
string S;
int dp[MAX_N+1],nxt0[MAX_N+1];
int main(){
	cin>>N>>S;
	dp[0]=0;
	nxt0[0]=0;
	REP(i,N){
		if(S[i]=='0'){
			nxt0[i+1]=i+1;
		}else{
			nxt0[i+1]=nxt0[i];
		}
	}
	REP(i,N){
		dp[i+1]=dp[i];
		if(S[i]=='1' && i>0){
			if(i>1 && S[i-1]=='0' && S[i-2]=='1'){
				for(int j=i-2;j>=0 && S[j]=='1';j--){
					dp[i+1]=max(dp[i+1],(i-1-j)+dp[j]);
				}
			}
			if(nxt0[i+1]>1 && S[nxt0[i+1]-2]=='1'){
				dp[i+1]=max(dp[i+1],(i+1)-nxt0[i+1]+dp[nxt0[i+1]-2]);
			}
		}
	}
	cout<<dp[N]<<endl;		
		
}

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

struct Rational {
    long long num;
    long long den;
    bool operator==(const Rational& r) const {
        return num == r.num && den == r.den;
    }
    bool operator!=(const Rational& r) const { return !(*this==r); }
    bool operator<(const Rational& r) const { return compare(r) < 0; }
    bool operator>(const Rational& r) const { return compare(r) > 0; }
    bool operator<=(const Rational& r) const { return compare(r) <= 0; }
    bool operator>=(const Rational& r) const { return compare(r) >= 0; }
    inline long long compare(const Rational& r) const {
        long long ln = num, ld = den, rn = r.num, rd = r.den;
        if ( ld < 0 ) ln = -ln, ld = -ld;
        if ( rd < 0 ) rn = -rn, rd = -rd;
        return ln * rd - ld * rn;
    }
};


ll donguri(ll n, vector<ll> a, vector<ll> b) {
    Rational r0{b[0],a[0]}, r1{b[1],a[1]}, r2{b[2],a[2]}, t, e{1,1};
    if ( r0 < r1 ) t = r0, r0 = r1, r1 = t;
    if ( r0 < r2 ) t = r0, r0 = r2, r2 = t;
    if ( r1 < r2 ) t = r1, r1 = r2, r2 = t;
    int c=0;
    if ( r0 > e ) c++;
    if ( r1 > e ) c++;
    if ( r2 > e ) c++;

    if ( c == 0 ) {
        return n;
    } else if ( c == 1 ) {
        ll d = n/r0.den * r0.num + n%r0.den;
        return d;
    } else if ( c == 2 ) {
        ll d_max = 0;
        for ( int i = 0; i * r0.den <= n ; i++ ) {
            ll n2 = n - i * r0.den;
            ll d = i * r0.num + n2/r1.den * r1.num + n2%r1.den;
            if ( d_max < d ) d_max = d;
        }
        return d_max;
    } else if ( c == 3 ) {
        ll d_max = 0;
        for ( int i = 0; i * r0.den <= n ; i++ ) {
            ll n2 = n - i * r0.den;
            for ( int j = 0; j * r1.den <= n2 ; j++ ) {
                ll n3 = n2 - j * r1.den;
                ll d = i * r0.num + j * r1.num + n3/r2.den * r2.num + n3%r2.den;
                if ( d_max < d ) d_max = d;
            }
        }
        return d_max;
    }
}

int main() {
    ll N, GA, SA, BA, GB, SB, BB;
    vector<ll> A(3), B(3);
    cin >> N;
    cin >> A[0] >> A[1] >> A[2];
    cin >> B[0] >> B[1] >> B[2];

    ll tmp = donguri(N, A, B);
    ll ans = donguri(tmp, B, A);
    cout << ans << '\n';
    return 0;
}

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

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    ll n;
    cin >> n;
    ll res = 0, cnt = 1;
    while( n > 0 ) {
        n /= 2;
        res += (cnt);
        cnt *= 2;
    }
    cout << res << "\n";
}


Measured memory_bytes: 256
n = int(input())

num = 0
for i in range (1, n+1, 2):
  #print(n+1)
  ans = 0
  for j in range (1, i+1):
    if i%j == 0:
      ans += 1
      #print(i, j)
  if ans == 8: #more than 8? less than 8?
    num += 1
    ans = 0
print(num)

Measured memory_bytes: 3060
S = input()

odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']

for i in range(len(S)):
    if (i+1) % 2 == 0:
        if not S[i] in even:
            print('No')
            exit()
    else:
        if not S[i] in odd:
            print('No')
            exit()

print('Yes')

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

using namespace std;

int main() {
    if (fopen("A.inp", "r"))
    freopen("A.inp", "r", stdin),
    freopen("A.out", "w", stdout);
    double x; cin >> x;
    double tmp = 100;
    for (int i = 1; i <= 100000; i++) {
        tmp += (long long)(tmp * 0.01);
        if (tmp >= x) {
            cout << i;
            break;
        }
    }
}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


ll hpow(ll x,ll y){
    ll ans=1;
    ll i=x;
    if(y==0)return 1;
    while(y>0){
        if(y%2==1){
            ans=(ans*i)%i_7;
        }
        i=(i*i)%i_7;
        y=y/2;
        
    }
    return ans;
}

int main(){fastio
    ll n;cin>>n;
    ll ans=0;
    ans=mod(ans+hpow(10,n));
    ans=mod(ans-2*hpow(9,n));
    ans=mod(ans+hpow(8,n));
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 3628
<?php
list($h, $w) = explode(" ", trim(fgets(STDIN)));
$n = trim(fgets(STDIN));
$array = explode(" ", trim(fgets(STDIN)));
$c = 0;
foreach($array as $i => $count){
    for($j = 0; $j < $count; $j++){
        $map[floor($c/$w)][$c%$w] = $i+1;
        $c++;
    }
}
foreach($map as $i => $ar){
    if($i % 2 == 1){
        $map[$i] = array_reverse($map[$i]);
    }
    echo implode(" ", $map[$i])."\n";
}


Measured memory_bytes: 6776
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

// O(√n) time
bool is_prime(int n) {
    if (n < 2) return false;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return true;
}

int dfs(int idx, vector<int> &v, vector<int> w) {
    if (idx == w.size()) return 1;
    int res = 0;
    for (int i = 0; i < v.size(); ++i) {
        int tmp = v[i];
        if (v[i] >= w[idx]) {
            v[i] = -1;
            res += dfs(idx + 1, v, w);
            v[i] = tmp;
        }
    }
    return res;
}

void _main() {
    int N;
    cin >> N;
    vector<int> v;
    FOR (i, 2, N + 1) if (is_prime(i)) {
        int cnt = 0, p = i;
        while (N / p > 0) {
            cnt += N / p;
            p *= i;
        }
        if (cnt > 1) v.push_back(cnt);
    }
    int ans = 0;
    ans += dfs(0, v, {2, 4, 4}) / 2;
    ans += dfs(0, v, {4, 14});
    ans += dfs(0, v, {2, 24});
    ans += dfs(0, v, {74});
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <vector>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int c, n = 0;
	bool minus = false;
	if ((c = gcu()) == '-') minus = true;
	else ungetc(c, stdin);
	while ((c = gcu()) >= '0' && c <= '9') n = 10 * n + (c - '0');
	return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
svo(int n) {
	static char buf[20];
	char *p = buf;
	if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
svo(const char *s){while(*s)pcu(*s++);}
//svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
template <typename T>
svo(vector<T> v){for(T &x:v)out(' '),out(x);out('\n');}
//svo(vector<T> &v){for(int &x:v)out(&x == &v[0]?"":" ",x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}

typedef vector<int> v;

template <typename T>
struct treap {
	struct node {
		T v;
		int p;
		node *n[2];

		node(T x, T p) {
			v = x;
			this->p = p;
			n[0] = n[1] = nullptr;
		}
	};

	typedef node N;
	N *root = nullptr;

	N* rotate(N* t, int b) {
		N *s = t->n[1 - b];
		t->n[1 - b] = s->n[b];
		s->n[b] = t;
		return s;
	}
	N* insert(T k, int p, N *t) {
		if (!t)
			return new N(k, p);
		int b = !(k < t->v);
		t->n[b] = insert(k, p, t->n[b]);
		return (t->p < t->n[b]->p) ? rotate(t, 1 - b) : t;
	}
	void insert(T k, int p) {
		root = insert(k, p, root);
	}
	N* erace(N *t, T x) {
		if (!t)
			;
		else if (t->v > x)
			t->n[0] = erace(t->n[0], x);
		else if (t->v < x)
			t->n[1] = erace(t->n[1], x);
		else {
			t = erace(!t->n[0] && !t->n[1] ? nullptr :
					  !t->n[0] ? rotate(t, 0) :
					  !t->n[1] ? rotate(t, 1) :
					  rotate(t, t->n[0]->p > t->n[1]->p), x);
		}
		return t;
	}
	void erace(T x) {
		root = erace(root, x);
	}
	bool find(N *t, T x) {
		return !t ? false : t->v > x ? find(t->n[0], x) : t->v < x ? find(t->n[1], x) : true;
	}
	bool find(T x) {
		return find(root, x);
	}
	void print(N *r, v &buf) {
		if (r == nullptr)
			return;
		buf.push_back(r->v);
		print(r->n[0], buf);
		out(' ', r->v);
		print(r->n[1], buf);
	}
	void print() {
		v buf;
		print(root, buf);
		out('\n', buf);
	}
};

int main() {
	int n = in(), x;
	char s[20];
	treap<int> t;

	while (n--) {
		scan(s);
		switch(*s) {
		case 'i':
			x = in();
			t.insert(x, in()); break;
		case 'f':
			out(t.find(in()) ? "yes\n": "no\n"); break;
		case 'd':
			t.erace(in()); break;
		default:
			t.print();
		}
	}
}


Measured memory_bytes: 9572
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <math.h>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const long long MOD_NUM = 1000000007LL;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}


static void C_task();

#if 1
int main()
{
	C_task();
	fflush(stdout);
	return 0;
}
#endif


static void C_task()
{
	LLONG N;
	get1int(N);
	
	LLONG max = (LLONG)sqrtl((long double)N);
	LLONG ans = N - 1;
	for (LLONG i = 1; i <= max; i++) {
		if ((N % i) == 0) {
			ans = tp_min<LLONG>(ans, (N / i) + i - 2);
		}
	}
	printf("%lld\n", ans);
}


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

int main() {
  int N , K;
  cin >> N >> K;
  if (N <= K) {
    cout << 0 <<endl;
  }
  else {
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
      cin >> h.at(i);
    }
    sort(h.begin(), h.end());
    int p = N - K;
    long long int s = 0;
    for (int i = 0; i < p; i++) {
      s += h.at(i);
    }
    cout << s <<endl;
  }
}

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

int main(){
  ll N, A,B;
  cin >> N >> A >> B;
  ll ans = 0;
  ll x = N % (A+B);
  ans = N/(A+B) * A;
  ans += min(A,x);
  cout << ans << endl;
}

Measured memory_bytes: 3608
// I'm a f*cking looser
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fasino ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
#define asc(A) sort(A.begin(),A.end())
#define dsc(A) sort(A.begin(),A.end(),greater<ll>())
#define input(A,N) for(ll i=0;i<N;i++) cin>>A[i];
int main()
{
    fasino
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    //#endif
    ll n;
    cin>>n;
    vector<ll> A(n);
    //set<ll> st;
    input(A,n);
    asc(A);
    //for(auto i:A) st.insert(i);
    ll maxi[A[n-1]+1]={0};
    for(int i=0;i<n;i++){
        for(int j=A[i];j<=A[n-1];j+=A[i]){
            maxi[j]++;
        }
    }
    ll ans =0;
    for(int i=0;i<n;i++){
        // cout<<maxi[A[i]]<<" ";
        if(maxi[A[i]]==1){// and st.find(i)!=st.end()){
            ans++;
            // cout<<i<<" ";
        }
    }
    // if(ans==n){
    //     cout<<0;
    // }
    // else
        cout<<ans;
    return 0;
}

Measured memory_bytes: 12700
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}

class ModCom {
    public:
        ModCom(int _n, long long _mod){
            assert(_n>=2);
            n = _n+1;
            mod = _mod;
            fac.assign(n,0);
            finv.assign(n,0);
            inv.assign(n,0);
            init();
        }

        long long com(int _n, int k){
            if(_n < k){return 0;}
            if(_n < 0 || k < 0){return 0;}
            return fac.at(_n) * (finv.at(k) * finv.at(_n - k) % mod) % mod;
        }

    private:
        int n;
        long long mod;
        vector<long long> fac;
        vector<long long> finv;
        vector<long long> inv;

        void init(void){
            fac.at(0) = fac.at(1) = 1;
            finv.at(0) = finv.at(1) = 1;
            inv.at(1) = 1;
            for(int i = 2;i < n; i++){
                fac.at(i) = fac.at(i - 1) * i % mod;
                inv.at(i) = mod - inv.at(mod % i) * (mod / i) % mod;
                finv.at(i) = finv.at(i - 1) * inv.at(i) % mod;
            }
            return;
        }
};

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ModCom com(100005,MOD);
    ll n;cin>>n;
    vector<ll> check(n+1,-1);
    vector<ll> a(n+1);
    ll range;
    rep(i,n+1){
        ll tmp;cin>>tmp;
        if(check[tmp]==-1){
            check[tmp]=i;
        }else{
            range = check[tmp]+n-i;
        }
    }
    DEBUG{
        printf("range: %lld\n",range);
    }
    repr(i,1,n+2){
        ll res = com.com(n+1,i);
        res %= MOD;
        if(i-1<=range){
            res += MOD-com.com(range,i-1);
            res %= MOD;
        }
        cout << res << endl;
    }

    return 0;
}


Measured memory_bytes: 5120