akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

///////////////////////////////////////////////////////////////////////////////////////

int main() {
	ll a[3], x, y;
	repi(i, 0, 3) rd(a[i]);
	sort(a, a + 3);
	x = a[2] - a[0];
	y = a[2] - a[1];
	if ((x + y) % 2 == 0) wrln((x + y) / 2);
	else wrln((x + y) / 2 + 2);
	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastReader in = new FastReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);
            ARainySeason solver = new ARainySeason();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class ARainySeason {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            char[] c = s.next().toCharArray();
            int mx = 0, cur = 0;
            for (char cc : c) {
                if (cc == 'R') cur++;
                else cur = 0;
                mx = Math.max(mx, cur);
            }
            w.println(mx);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public String next() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            StringBuilder res = new StringBuilder();

            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32528
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
  
int main(){
double x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
cout<<fixed<<setprecision(15)<<sqrt(pow((x2-x1),2)+pow((y2-y1),2))<<endl;
return 0;
}

Measured memory_bytes: 1284
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int A[1100000];
int n,dp[110000][40];
const int M=35;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&A[i]);
	int pre=0;
	memset(dp,0x3f,sizeof dp); dp[0][0]=0;
	for (int i=1;i<=n;i++){
		int num=0,flag=0;
		int x=A[i];
		while (x>1){
			x=(x+1)/2; num++;
		}
		x=A[i];
		while (x>1){
			if (x&1) flag=1; x>>=1;
		}
		if (flag==0){
			for (int j=0;j<=M;j++)
				dp[i][num]=min(dp[i][num],dp[i-1][j]+max(0,num-j));
		} else {
			for (int j=1;j<=M;j++)
				dp[i][num-1]=min(dp[i][num-1],dp[i-1][j]+max(0,num-j));
			for (int j=0;j<=M;j++)
				dp[i][num]=min(dp[i][num],dp[i-1][j]+max(0,num-1-j)+1);
		}
	}
	int ans=1e9;
	for (int i=0;i<=M;i++) ans=min(ans,dp[n][i]);
	cout<<ans<<endl;
}

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

using namespace std;

bool isLittlrOrder(int a, int b, int c);

int main()
{
	string input1, input2, input3, output;
	cin >> input1;
	cin >> input2;
	cin >> input3;

	output = isLittlrOrder(stoi(input1), stoi(input2), stoi(input3)) ? "Yes" : "No";
	cout << output << endl;

	return 0;
}

bool isLittlrOrder(int a, int b, int c)
{
	if (a < b && b < c)
	{
		return true;
	}
	else
	{
		return false;
	}
}


Measured memory_bytes: 3228
def readinput():
    n=int(input())
    x=input()
    return n,x

poptbl=[0]*(2*10**5+1)
def popcount(x):
    global poptbl
    #if poptbl[x]!=0:
    #    return poptbl[x]
    
    poptbl[x]=bin(x).count('1')
    return poptbl[x]

ftbl=[0]*(2*10**5+1)
def f(x):
    global ftbl

    #if ftbl[x]!=0:
    #    return ftbl[x]
    
    #print('f(x), x: {}'.format(x))
    if x==0:
        return 0
    else:
        ans=f(x%popcount(x))+1
        #print(ans)
        ftbl[x]=ans
        return ans    

def main():
    n=int(input())
    x=input()
    m=x.count('1')
    #print('m: {}'.format(m))
    xint=int(x,2)
    #print('xint: {}'.format(xint))
    if m!=1:
        xmodm1=xint%(m-1)
    else:
        xmodm1=1
    xmodp1=xint%(m+1)
    pow2mod1=[0]*n
    pow2mod2=[0]*n
    pow2mod1[0]=1
    pow2mod2[0]=1
    for i in range(1,n):
        if m!=1:
            pow2mod1[i]=pow2mod1[i-1]*2 % (m-1)
        pow2mod2[i]=pow2mod2[i-1]*2 % (m+1)

    ans=[]
    #b=2**(n-1)
    for i in range(n):
        if x[i]=='1':
            if m==1:
                a=0
                ans.append(a)
            else:
                xx=( xmodm1 + (m-1) -pow2mod1[n-i-1] )%(m-1)
                #ans.append(f(xx)+1)
                a=f(xx)+1
                ans.append(a)
        else:
            xx=( xmodp1 + pow2mod2[n-i-1] )%(m+1)
            #ans.append(f(xx)+1)
            a=f(xx)+1
            ans.append(a)
        #b=b//2
        print(a)
    return ans

if __name__=='__main__':
    #n,x=readinput()
    ans=main()
    #for a in ans:
    #    print(a)



Measured memory_bytes: 29952
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=210,Maxx=100010;
const int inf=2147483647;
const int mod=1000000007;
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^48),ch=getchar();
	return x*f;
}
void upd(int&x,int y){x+=y;if(x>=mod)x-=mod;}
int n,a[Maxn],f[Maxn][Maxx];
bool cmp(int x,int y){return x>y;}
int main()
{
	n=read(),a[0]=read();
	for(int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+1+n,cmp);
	f[0][a[0]]=1;
	for(int i=0;i<n;i++)
	for(int j=1;j<=a[0];j++)
	if(f[i][j])upd(f[i+1][j],(LL)f[i][j]*(n-i-1)%mod),upd(f[i+1][j%a[i+1]],f[i][j]);
	int ans=0;
	for(int i=1;i<a[n];i++)upd(ans,(LL)i*f[n][i]%mod);
	printf("%d",ans);
}

Measured memory_bytes: 78208
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;
ll mod9 = 1000000009;

signed main(){
    ll n;
    ll m;
    cin>>n>>m;
    ll s[10];
    ll c[10];
    rep(i,m) cin>>s[i]>>c[i];
    ll a[10];
    rep(i,10) a[i]=-1;
    ll ans = 0;
    rep(i,m){
        if(a[s[i]]==-1) a[s[i]]=c[i];
        else if(a[s[i]]!=c[i]){
            ans = -1;
            break;
        }
    }
    if(a[1]==0 && n!=1) ans = -1;
    if(ans!=-1){
        if(a[1]==-1) a[1]=1;
        ans = 0;
        rep(i,n){
            if(a[i+1]==-1) a[i+1]=0;
            ans += a[i+1];
            if(i != n-1) ans *= 10;
        }
    }
    if(n==1 && m==0) ans=0;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)

n, blue = map(int, input().split())

red = n - blue

waru = 10**9+7

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


for i in range(1, blue+1, 1):
    if red + 1 < i:
        print(0) 
    else:
        ans = cmb(red+1, i) * cmb(blue-1, i-1)
        #print(i)
        print(ans%waru)


Measured memory_bytes: 3444
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    vector<bool> era(114514,true);
    era[0] = era[1] = false;

    for(int i = 2; i < era.size(); i++){
        for(int j = 2 * i; j < era.size(); j += i){
            era[j] = false;
        }
    }
    vector<int> rui(114514,0);
    rep(i,3,114514){
        if(era[i] && era[(i + 1) / 2]){
            rui[i]++;
        }
    }
    rep(i,1,114514){
        rui[i] += rui[i-1];
    }
    int Q;
    cin >> Q;
    rep(i,0,Q){
        int l,r;
        cin >> l >> r;
        cout << rui[r] - rui[l-1] << endl;
    }




    return 0;
}


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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    vector<int> v, c;
    for(int i=0;i<n;++i){
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    for(int i=0;i<n;++i){
        int tmp;
        cin >> tmp;
        c.push_back(tmp);
    }
    for(int i=0;i<n;++i){
        ans += max(0, v[i]-c[i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    for(int i=0;i<3000;i++)
    {
        if(i/10==b&&i*2/25==a)
        {
            printf("%d\n",i);
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
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;}

set<int>ng={'q','w','e','r','t','a','s','d','f','g','z','x','c','v','b'};

signed main()
{
	IOS();
	vector<int>ans;
	while(1){
		int N,M;
		cin >> N >> M;
		if(N == 0 && M == 0)break;
		vector<int>a(N);
		rep(i,0,N)cin>>a[i];
		int ma = -1;
		rep(i,0,N){
			rep(j,i+1,N){
				if(a[i]+a[j]<=M){
					chmax(ma,a[i]+a[j]);
				}
			}
		}
		ans.push_back(ma);
	}
	for(auto e:ans){
		if(e!=-1)cout<<e<<endl;
		else cout<<"NONE"<<endl;
	}
}



Measured memory_bytes: 3132
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=998244353;
constexpr int N=200000;
random_device rd;
mt19937 mt(rd());

int D,c[26],s[200000][26],t[200000],T[200000],v,V,l[26];

int main(){
	scanf("%d",&D);
	for(int i=0;i<26;i++){
		scanf("%d",&c[i]);
	}
	for(int i=0;i<D;i++){
		for(int j=0;j<26;j++){
			scanf("%d",&s[i][j]);
		}
	}
	for(int i=0;i<D;i++){
		pair<int,int>mx={-1,-1};
		for(int j=0;j<26;j++){
			mx=max(mx,{s[i][j],j});
		}
		t[i]=mx.second;
	}
	for(int i=0;i<26;i++){
		l[i]=-1;
	}
	for(int i=0;i<D;i++){
		l[t[i]]=i;
		v+=s[i][t[i]];
		for(int j=0;j<26;j++){
			v-=c[j]*(i-l[j]);
		}
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<D;j++){
			if(uniform_int_distribution<int>(0,N*100)(mt)<=N-i){
				T[j]=uniform_int_distribution<int>(0,25)(mt);
			}
			else{
				T[j]=t[j];
			}
		}
		for(int j=0;j<26;j++){
			l[j]=-1;
		}
		V=0;
		for(int j=0;j<D;j++){
			V-=c[T[j]]*(j-l[T[j]]-1)*(j-l[T[j]])/2;
			l[T[j]]=j;
			V+=s[j][T[j]];
		}
		for(int j=0;j<26;j++){
			V-=c[j]*(D-l[j]-1)*(D-l[j])/2;
		}
		if(V>v){
			v=V;
			for(int j=0;j<D;j++){
				t[j]=T[j];
			}
		}
	}
	for(int i=0;i<D;i++){
		printf("%d\n",t[i]+1);
	}
}


Measured memory_bytes: 3840
// AOJ 2180: Water Tank
// 2017.11.03 bal4u@uu

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

#define EPS 1e-7
#define MIN(a,b) ((a)<=(b)?(a):(b))

int n, l, s[86402], t[86402], u[86402];

char buf[30], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int check(double *v, double a)
{
	int i, x;
	double e;

	for (e = *v, x = 0, i = 0; i < n; i++) {
		e = MIN(l, e + a*(s[i]-x));
		x = s[i];
		e = MIN(l, e + (t[i]-x)*(a-u[i]));
		if (e < 0) { *v = e; return 1; }
		x = t[i];
	}
	*v = MIN(l, e + a*(86400-x));
	return 0;
}

int calc(double a)
{
	int i;
	double v[3];
	for (v[0] = l, i = 0; i < 2; i++) {
		if (check(v+i, a)) return 0;
		v[i+1] = v[i];
	}
	return fabs(v[0]-v[1]) <= EPS;
}

int main()
{
	int i;
	double up, low, mid;

	while (fgets(p=buf, 30, stdin) && *p != '0') {
		n = getint(), p++, l = getint();
		for (i = 0; i < n; i++) {
			fgets(p=buf, 30, stdin);
			s[i] = getint(), p++, t[i] = getint(), p++, u[i] = getint();
		}

		low = 0, up = 1000000;
		while (fabs(low - up) > EPS) {
			mid = (low + up)/2;
			if (calc(mid)) up = mid; else low = mid;
		}
		printf("%.8lf\n", up);
	}
}

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

int main() {
  int n;
  cin >> n;
  set<int> st;
  for (int i = 0; i < n; i++) {
    int d;
    cin >> d;
    st.insert(d);
  }

  cout << st.size() << endl;

  return 0;
}


Measured memory_bytes: 3616
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#include <numeric>
#include <map>
#define rep(i,n) for (int i = 0; i < (n); ++i)
 
using namespace std;
 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
int main () {
	int N, C;
    cin >> N >> C;
	vector<int> S(N), T(N), CN(N);
	vector<int> mx(200002,0), tt(200002,0);
	rep(i,N) {
		cin >> S[i] >> T[i] >> CN[i];
	}
	for (int c = 1; c <= C; ++c) {
		fill(tt.begin(), tt.end(), 0);
		rep(i,N) {
			if (CN[i] == c) {
				tt[2*S[i]-1]++;
				tt[2*T[i]]--;
			}
		}
		for (int i = 1; i < 200002; ++i) {
			tt[i] += tt[i-1];
		}
		for (int i = 0; i < 200002; ++i) {
			if (tt[i] > 0) mx[i]++;
		}
	}
	cout << *max_element(mx.begin(), mx.end()) << endl;
    return 0;
}

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

int l[505];
int main(){
	int n; scanf("%d", &n);
	for (int i = 1; i <= 2 * n; ++i)
		scanf("%d", &l[i]);
	sort(l + 1, l + n * 2 + 1);
	int ans = 0;
	for (int i = 1; i <= n; ++i)
		ans += l[i * 2 - 1];
	printf("%d\n", ans);
	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);
			while(sc.hasNext()){
				float weight = sc.nextFloat();
				String WeightClass = check(weight);
				System.out.println(WeightClass);
			}
		}
		static String check(float a){
			if(a > 91 ){
				return "heavy";
			}else if(a>81){
				return"light heavy";
			}else if(a>75){
				return"middle";
			}else if(a>69){
				return"light middle";
			}else if(a>64){
				return"welter";
			}else if(a>60){
				return"light welter";
			}else if(a>57){
				return"light";
			}else if(a>54){
				return"feather";
			}else if(a>51){
				return"bantam";
			}else if(a>48){
				return"fly";
			}else{
			return "light fly";
		}
	}		
}

Measured memory_bytes: 27628
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>

using namespace std;

int main()
{
	int h,w;
	string str;

	scanf("%d %d", &h,&w);

	for(int i = 0; i < h; i++)
	{
		cin >> str;
		cout <<str << endl;
		cout << str << endl;
	}
	

	return 0;
}
	

Measured memory_bytes: 256
N, A = map(int, input().split())
X = list(map(lambda x: int(x) - A, input().split()))
maxn = max(max(X), A)
 
dp = [[0 for _ in range(2 * N * maxn + 1)] for _ in range(N + 1)]
dp[0][N * maxn] = 1
 
for i in range(N):
    for k in range(2 * N * maxn + 1):
        dp[i + 1][k] = dp[i][k]
        if 0 <= k - X[i] < 2 * N * maxn:
            dp[i + 1][k] += dp[i][k - X[i]]
 
print(dp[N][N * maxn] - 1)

Measured memory_bytes: 5232
def main():

    S = input()
    T = input()
    n = len(S)
    m = len(T)

    cand = []
    for i in range(n-m+1):
        flag = True
        for j in range(i, i+m):
            if S[j] != T[j-i] and S[j] != '?':
                flag = False
                break
        if flag:
            cand.append(S[:i] + T + S[i+m:])

    if not cand: return "UNRESTORABLE"
    ans = ""
    for U in cand:
        V = ""
        for c in U:
            if c == '?': V += "a"
            else: V += c
        if ans == "" or ans > V:
            ans = V
    return V

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3064
from collections import deque
x,y,z,n,m,s,t=map(int,input().split())
g=[[]for _ in range(x+y+z)]
for i in range(n):
  a,b=map(int,input().split())
  g[a-1].append(b+x-1)
  g[b+x-1].append(a-1)
  if i==s-1:
    p,q=a-1,b+x-1
for j in range(m):
  a,b=map(int, input().split())
  g[a+x-1].append(b+x+y-1)
  g[b+x+y-1].append(a+x-1)
  if j==t-1:
    u,v=a+x-1,b+x+y-1
d=[-2]*(x+y+z)
d[p],d[q]=0,0
q=deque([p,q])
while q:
  p = q.popleft()
  for node in g[p]:
    if d[node]==-2:
      q.append(node)
      d[node]=d[p]+1
print(min(d[u],d[v])+1)


Measured memory_bytes: 49484
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int 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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    string S;
    cin >> S;
    int left = (S[0] - '0') * 10 + S[1] - '0';
    int right = (S[2] - '0') * 10 + S[3] - '0';
    if(right > 12) {
        if(left != 0) {
            if(left > 12) {
                cout << "NA" << endl;
            } else {
                cout << "MMYY" << endl;
                return 0;
            }
        } else {
            cout << "NA" << endl;
        }
    } else {
        if(left > 12) {
            if(right != 0) {
                cout << "YYMM" << endl;
            } else {
                cout << "NA" << endl;
            }
        } else if(left == 0) {
            if(right == 0) {
                cout << "NA" << endl;
            } else {
                cout << "YYMM" << endl;
            }
        } else if(right == 0) {
            cout << "MMYY" << endl;
        } else {
            cout << "AMBIGUOUS" << endl;
        }
    }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int n, a, b; cin >> n >> a >> b;
	Cout(min(n*a, b));
}

Measured memory_bytes: 384
#include<iostream>
#include<map>
#define lol(i,n) for(int i=0;i<n;i++)
typedef long long ll;

using namespace std;
#define N 200010
ll n,a[N];
bool $(ll k){
    map<ll,ll> mas;
    mas.clear();
    lol(i,n-1){
	if(a[i]<a[i+1])continue;
	mas[a[i+1]]++;
	for(ll j=a[i+1];j>0;j--){
	    if(mas[j]==k)mas[j]=0,mas[j-1]++;
	    else break;
	}
	if(mas[0]>0)return 0;
	while(mas.size()){
	    auto it=--mas.end();
	    if(not(it->first > a[i+1]))break;
	    mas.erase(it);
	}
    }
    return 1;
}
int main(){
    cin>>n;
    lol(i,n)cin>>a[i];
    bool tancho=1;
    lol(i,n-1)if(not(a[i]<a[i+1]))tancho=0;
    if(tancho)return cout<<1<<endl,0;
    ll l=1,r=N,m;
    for(;l<r-1;){
	m=(l+r)/2;
	if($(m))r=m;
	else l=m;
    }
    cout<<r<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;

    ll l,r;
    cin >> l >> r;
    ll minmum = 1000000;
    if(r-l > 2030) {cout << 0 << endl; return 0;}
    for(ll j=l;j<r;j++){
        for(ll k=l+1;k<=r;k++){
            minmum = min(minmum,(j*k)%2019);
        }
    }

    cout << minmum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;
using mat2d_t = std::vector<std::vector<int64_t>>;


int main(int argc, char **argv) {
    int n, m;

    cin >> n >> m;

    std::vector<int> v(n, -1);
    for (int i=0; i<m; ++i) {
        int s, c;
        cin >> s >> c;
        if (v[s-1] != -1 && v[s-1] != c) {
            cout << -1 << endl;
            return 0;
        }
        v[s-1] = c;
    }

    if (v[0]==0 && v.size() != 1) {
        cout << -1 << endl;
        return 0;
    }

    int ans{0};
    for (int i=0; i < v.size(); ++i) {
        int num;
        if (v[i] == -1) {
            if (i==0 && v.size() != 1) num = 1;
            else num = 0;
        } else {
            num = v[i];
        }
        ans = ans * 10 + num;
    }

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

Measured memory_bytes: 256
from bisect import bisect_left

INF = 10 ** 9

N = int(input())
As = list(map(int, input().split()))

adj = [[] for _ in range(N)]
for _ in range(N-1):
    u, v = map(int, input().split())
    adj[u-1].append(v-1)
    adj[v-1].append(u-1)

ans = [0] * N
LIS = [INF] * (N+1)
rewinder = []

parent = [-1] * N
stack = [0]
while stack:
    node = stack.pop()
    for next_node in adj[node]:
        if ans[next_node] == 0:
            parent[next_node] = node
            stack.append(next_node)

    while rewinder and rewinder[-1][0] != parent[node]:
        _, index, prev_value = rewinder.pop()
        LIS[index] = prev_value
    
    index = bisect_left(LIS, As[node])
    rewinder.append((node, index, LIS[index]))
    LIS[index] = As[node]

    ans[node] = bisect_left(LIS, INF)

print(*ans, sep = '\n')

Measured memory_bytes: 78452
n, k = map(int, input().split())
a = list(map(int, input().split()))
rec = [0]
i = 0
flag = [0 for _ in range(n + 1)]
while True:
    if flag[rec[i]] == 0:
        flag[rec[i]] = 1
        rec.append(a[rec[i]] - 1)
    else:
        start = rec.index(a[rec[i]] - 1)
        loop = rec[start:]
        pre = rec[:start]
        break
    i += 1
count = (k - len(pre)) % len(loop)
if k <= len(pre):
    print(pre[k] + 1)
else:
    print(loop[count] + 1)


Measured memory_bytes: 32400
#include <stdio.h>
#include <string.h>
#define N 1001
#define Q 150
int lcs(char *x,char *y);
int main(){
  int i,n,q[Q];
  char hi[N],hii[N];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",hi);
    scanf("%s",hii);
    q[i] =lcs(hi,hii);
  }
  
  for(i=0;i<n;i++){
    printf("%d\n",q[i]);
  }
 

  return 0;
}

int lcs(char *x,char *y){
  int i,j,m,n,count=0;
  int hiii[N+1][N+1];

  m=strlen(x);
  n=strlen(y);
  
  for(i=0;i<=m;i++)
    hiii[i][0]=0;
  for(j=1;j<=n;j++)
    hiii[0][j]=0;

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(x[i-1]==y[j-1]){
	hiii[i][j]=hiii[i-1][j-1]+1;
      }
      else{
	if(hiii[i-1][j]>hiii[i][j-1]){
	  hiii[i][j]=hiii[i-1][j];
	}
	else{
	  hiii[i][j]=hiii[i][j-1];
	}
      }
      if(count>hiii[i][j])
	count=count;
      else
	count=hiii[i][j];
    }
  }
	
  return count;
}



Measured memory_bytes: 5608
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b){
    cout<<c<<endl;
  }else if(b==c){
    cout<<a<<endl;
  }else{
    cout<<b<<endl;
  }
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
char in[310000];
long long dp[310000][4][3];
int main(){
	scanf("%s",in);
	int n=strlen(in);
	dp[0][0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<4;j++)for(int k=0;k<3;k++){
			if(!dp[i][j][k])continue;
			if(in[i]!='1'){
				int tj=j;
				int tk=k;
				tk++;
				if(tk==3)tk=1;
				dp[i+1][tj][tk]=(dp[i+1][tj][tk]+dp[i][j][k])%mod;
			}
			if(in[i]!='0'){
				int tj=j;
				int tk=k;
				if(tk)tk--;
				else{
					tj++;
					tj=min(tj,3);
				}
				dp[i+1][tj][tk]=(dp[i+1][tj][tk]+dp[i][j][k])%mod;
			}
		}
	}
	long long ret=0;
	for(int i=2;i<=3;i++){
		for(int j=0;j<3;j++)ret+=dp[n][i][j];
	}
	ret+=dp[n][1][0];
	ret%=mod;
	printf("%lld\n",ret);
}

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

using namespace std;

int main()
{
    long long m,d, ans = 0;
    cin>>m>>d;
    for(int i = 2; i <= 9; i++){
        for(int j = 2; j <= 9; j++){
            long long z = i*j;
            if(i*10+j <= d && z <= m){
                ans++;
            }
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String str = br.readLine();
        String[] strs = str.split(" ");
        int min = 0;//最小
        int max = 0;//最大
        long sum = 0;//合計
        if(strs.length > 0){
            min = Integer.parseInt(strs[0]);
            max = Integer.parseInt(strs[0]);
        }
        for(int i = 0; i < n; i++){
            if(min > Integer.parseInt(strs[i])){
                min = Integer.parseInt(strs[i]);
            }else if(max < Integer.parseInt(strs[i])){
                max = Integer.parseInt(strs[i]);
            }//if
            sum += Integer.parseInt(strs[i]);
        }//for
        System.out.println(min + " " + max + " " + sum);
	}
}

Measured memory_bytes: 25592
package main

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

var sc = bufio.NewScanner(os.Stdin)

func StrStdin() (stringInput string){
  sc.Scan()
  OneLineString := sc.Text()
  stringInput = strings.TrimSpace(OneLineString)
  return 
}

func IntStdin() (int, error){
  stringInput := StrStdin()
  return strconv.Atoi(stringInput)
}

// ?????????????l??????????Split()
func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
    stringSplited := strings.Split(stringTargeted, delim)

    for _, str := range stringSplited {
        if str != "" {
            stringReturned = append(stringReturned, str)
        }
    }

    return
}

// ?f???~?^??????????????X???C?X???��
func SplitStrStdin(delim string) (stringReturned []string) {
    // ???????1?s?��
    stringInput := StrStdin()
  
    // ???????
    // stringSplited := strings.Split(stringInput, delim)
    stringReturned = SplitWithoutEmpty(stringInput, delim)

    return
}

// ?f???~?^?????????????l?X???C?X???��
func SplitIntStdin(delim string) (intSlices []int, err error) {
    // ??????X???C?X???��
    stringSplited := SplitStrStdin(delim)
	
    // ?????X???C?X????
    for i := range stringSplited {
        var iparam int
        iparam, err = strconv.Atoi(stringSplited[i])
        if err != nil {
            return
        }
        intSlices = append(intSlices, iparam)
    }
    return
}

func main(){
  money, _ := IntStdin()
  one, _ := IntStdin()
  
  amari := money % 500
  
  if amari <= one {
    fmt.Println("Yes")
  }else{
    fmt.Println("No")
  }
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
int main(){
  double x1,x2,y1,y2,ans=0;
  cin>>x1>>y1>>x2>>y2;
  ans = sqrt(pow((x2-x1),2.0)+pow((y2-y1),2.0));
  cout<<fixed<<setprecision(4)<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int a,b,s;
	cin>>s>>a>>b;
	for(int i=1;i<=b;i++)
	{
		if(i*s>=a&&i*s<=b)
		{
			cout<<"OK";
			return 0;
		}
		if(i*s>b)  break;
	}
	cout<<"NG";
    return 0;
}

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

int main(void)
{
    int K, S;
    cin >> K >> S;
    int sum{0};
    for(int X{0}; X<=K; ++X){
        for(int Y{0}; Y<=K; ++Y){
            if(Y>S-X)
                break;
            if(S-X-Y > K)
                continue;
            else
                ++sum;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long n, arr[2][100001], cnt = 0, dp[2][100001], pre;
	bool f = 0;
	cin >> n;
	for(int i=0; i<n; i++) cin >> arr[!f][i];
	sort(arr[!f], arr[!f] + n);
	fill(dp[!f], dp[!f] + n, 1);
	for(int k=0; k<2; k++){
		for(int i=0; i<n; i++) cin >> arr[f][i];
		sort(arr[f], arr[f] + n);
		cnt = pre = 0;
		for(int i=0; i<n; i++){
			while(cnt < n && arr[!f][cnt] < arr[f][i]) pre += dp[!f][cnt++];
			dp[f][i] = pre;
		}
		f = !f;
	}
	pre = 0;
	for(int i=0; i<n; i++) pre += dp[!f][i];
	cout << pre;	
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
long long n,k,a[100000],ans=0;
int cmp(int a,int b)
{
	return a>b;
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=k;i++) ans+=a[i];
	cout<<ans;
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	ll n,m;cin>>n>>m;
	string s,t;cin>>s>>t;
	if(s[0]!=t[0]){
		cout<<-1<<endl;
		return 0;
	}
	ll GCD=gcd(n,m),LCM=lcm(n,m);
	if(GCD==1){
		cout<<n*m<<endl;
	}
	else{
		for(int i=1;i*(LCM/min(n,m))<max(n,m);++i){
			if(s[i*(LCM/m)]!=t[i*(LCM/n)]){
				cout<<-1<<endl;
				return 0;
			}
		}
		cout<<LCM<<endl;
	}
}


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

using namespace std;
typedef long long ll;

int main(void) {
    ll N, tmp;
    int num = 0;
    cin >> N;
    tmp = N + 1;
    vector<int> ans;

    while(tmp) {tmp /= 2; num++;}
    for(int i=0; i<num-1; i++) {
        if(((N+1) >> i) & 1) ans.emplace_back(100-i);
        ans.emplace_back(i+1);
    }

    printf("%d\n", ans.size()+100);
    for(int a : ans) printf("%d ", a);
    for(int i=1; i<=100; i++) printf("%d ", i);
    printf("\n");
    return 0;
}

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

using namespace std;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())

int main(){
    int n,sum=0;
    cin >>n;
    vector<int> x(n);
    REP(i,n){
        cin>>x[i];
        sum+=x[i];
    }
    sum/=n;
    int mini1=0,mini2=0;
    REP(i,n){
        mini1+=pow(x[i]-sum,2);
        mini2+=pow(x[i]-sum-1,2);
    }
    cout<<min(mini1,mini2)<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

struct edge{int to,cost;};
vector<int> G[100005];
 
ll n,m,i,j=1;
long long int a,b;
ll d,ans=0;
long long int x[100005],y[100005];
long long int xx=0;

int main(){
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>x[i+1];
	}
	for(i=1;i<=m;i++){
		cin>>y[i];
	}
	/* for(i=1;i<n;i++){
		for(j=1;j<m;j++){
			a= (((x[i+1]-x[i])%mod)*((y[j+1]-y[j])%mod))%mod;
			b= ((i*(n-i))%mod)*j*(m-j)%mod;
			ans += (a*b)%mod;
			ans = ans %mod;
		}
	} */
	for(i=1;i<n;i++){
		xx += (i*(n-i)%mod)*((x[i+1]-x[i])%mod);
		xx = xx%mod;
	}
	for(j=1;j<m;j++){
		ans += ((j*(m-j))%mod)*(y[j+1]-y[j])%mod;
		ans = ans%mod;
	}
	cout<<xx*ans%mod<<endl;
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL;
  typedef pair<ll,char> PLC;
  typedef pair<char,ll> PCL;

int main(void){
  int v[3],N;cin >> v[0] >> v[1] >> v[2] >> N;
  //dp[i][j]:i番目までの箱を見てNにできる場合の数
  int dp[3+1][N+1];
  int i,j;
  REP(j,N+1)dp[0][j] = 0;
  dp[0][0] = 1;
  REP(i,3){
    REP(j,N+1){
      dp[i+1][j] = dp[i][j];
      if(j-v[i]>=0)dp[i+1][j] += dp[i+1][j-v[i]];
    }
  }
  cout << dp[3][N] << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

K = int(readline())
A, B = map(int, readline().split())

ans = "NG"
for i in range(A, B + 1):
    if i % K == 0:
        ans = "OK"

print(ans)

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

#define ll  long long int
#define PII pair<ll,ll>
#define VI  vector<ll>
#define VB  vector<bool>
#define VC vector<char>
#define VVI vector<vector<ll>>
#define VVC vector<vector<char>>
#define VS  vector<string>
#define VP  vector<PII>
#define lf(i,a,b) for(ll i=a;i<=b;i++)
#define lr(i,a,b) for(ll i=a;i>=b;i--)
#define lfl(i,v) for(ll i=0;i<v.size();i++)
#define lrl(i,v) for(ll i=(ll)(v.size())-1;i>=0;i--)
#define chk2(a,b) cout<<"check :  "<<a<<" "<<b<<endl
#define chk3(a,b,c) cout<<"check :  "<<a<<" "<<b<<" "<<c<<endl
#define chk4(a,b,c,d) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define chk5(a,b,c,d,e) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl
#define l_b(v,k)  lower_bound(v.begin(),v.end(),k)-v.begin()
#define u_b(v,k)  upper_bound(v.begin(),v.end(),k)-v.begin()
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define p_b push_back
#define p_f push_front
#define m_p make_pair
#define fir first
#define sec second
#define sz size()

ll power(ll x,  ll y,  ll m) 
{   if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 

int main()
{   ll n;cin>>n;
    ll t=power(10,n,mod);
    ll n_0= power(9,n,mod);
    ll n_9= power(9,n,mod);
    ll n_9_0= power(8,n,mod);
    ll ans=(t+n_9_0)%mod;
    //cout<<ans<<endl;
    ans=(ans-n_0+mod)%mod;
    //cout<<ans<<endl;
    ans=(ans-n_9+mod)%mod;
    cout<<ans<<endl;   
}   

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;

  int64_t i = 1, c = 0;

  while (i < (n - i) / i) {
    if ((n - i) % i == 0) {
      c += (n - i) / i;
    }
    i++;
  }

  std::cout << c << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    double res=0,t;
    for(int i=1;i<=n;i++){
        cin>>t;
        res+=1.0/t;
    }
    res=1.0/res;
    cout<<res;
    return 0;
}




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

ll dp[2001][2001];
int S[2000];
int T[2000];

/* 10^9+7で割った余りを出力

iまでのS部分列とjまでのT部分列で一致するものの数dp[i+1][j+1]
dp[i][0] = 
 = dp[0][j] = 1?

dp[i+1][j+1] = if (S[i] == T[j]) 
               if (!=) dp[i+1][j]+dp[i][j+1] - dp[i][j]

*/
ll divi = (ll)(1000000000 + 7);

int main() {
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }
    for (int i = 0; i < M; i++) {
        cin >> T[i];
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (S[i] == T[j]) {
                dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j] + 1) % divi;
            } else {
                dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j] - dp[i][j] + divi) % divi;
            }
        }
    }
    cout << (dp[N][M]+1) % divi << "\n";

}

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

int main(){
  int a,b;
  cin >>a >> b;
  int aa=0;
  int c=fmin(a,b);
  int d=fmax(a,b);
  for(int i;i<d;i++){
    aa+=c*pow(10,i);
  }
 cout << aa;
  return 0;
}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define x first
#define y second
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl '\n'


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

Measured memory_bytes: 3640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: i32,
        k: i32,
        x: i32,
        y: i32,
    }
    let mut ans = 0;
    if n <= k{
        ans += n*x;
    }else{
        ans += k*x;
        ans += (n-k)*y;
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
// Coordinate compression

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
 
#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)

int a[100010],n,k;
int dp[100010];

int fun(int x)
{
  if(x>n)return 1e9;
  if(x==n)return 0;
  if(dp[x]!=-1)return dp[x];
  int ret=0;
  ret=fun(x+1)+abs(a[x+1]-a[x]);
  for(int i=2;i<=k;i++)
  ret=min(ret,fun(x+i)+abs(a[x+i]-a[x]));
  dp[x]=ret;
  return ret;
}


int solve(){     

memset(dp,-1,sizeof(dp));
cin>>n;
  k=2;
rep(i,1,n+1)cin>>a[i];
cout<<fun(1);

return 0;
}

 
signed main()
{    

    

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

 
 int t=1;                                                                                                                  
 //cin>>t;
    while(t--)
     {
      solve();
     }
    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#define N 10005
#include <vector>
#include <cstdlib>
using namespace std;

typedef long long ll;
ll n, i, a[10];
vector<ll> ans;
string t;
void f(ll p, ll q) {
	if (p == 4) {
		if (q == 7) {
			for (i = 0; i < 3; i++) {
				cout << t[i];
				if (ans[i] == 0) cout << "-";
				else cout << "+";
			}
			cout << t[3] << "=" << '7';
			exit(0);
		}
		return;
	}
	ans.push_back(0);
	f(p + 1, q - a[p]);
	ans.pop_back();
	ans.push_back(1);
	f(p + 1, q + a[p]);
	ans.pop_back();
}
int main()
{
	cin >> t;
	for (i = 0; i < t.size(); i++) a[i] = t[i]- '0';
	f(1, a[0]);
    return 0;
}


Measured memory_bytes: 256