akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

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

	if (a <= x && b >= x-a)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.Array.IArray

main :: IO ()
main = do
  ns <- map read . lines <$> getContents :: IO [Int]
  mapM_ (print . solve) ns

solve :: Int -> Int
solve n = go (takeWhile (<= n) primes)
  where
    go [] = 0
    go (x:xs) = (if isPrime x && isPrime (n+1 - x)
                   then 1
                   else 0) + go xs

isPrime :: Int -> Bool
isPrime n = primeArray ! n 

primeArray :: Array Int Bool
primeArray = accumArray (||) False (1, 100001)
           (zip (takeWhile (<= 100001) primes)
            (repeat True))

primes = 2:f [3] [3,5..]
  where
    f (x:xs) ys = let (ps, qs) = span (< x^2) ys in
      ps ++ f (xs ++ ps) [z | z <- qs, mod z x /= 0]

Measured memory_bytes: 8804
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,i,g=0;
	cin>>k;
	int b[52];
	for(i=0;i<k;i++)
	cin>>b[i];
		for(i=0;i<k;i++)
		{
		if((i+1)!=b[i])
		g++;
	}
	if(g==2||g==0)
	cout<<"YES";
	else
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

int main() {
	int N, P; cin >> N >> P;
	int od = 0; int ev = 0;
	for (int i = 0; i < N; i++) {
		int ips; cin >> ips;
		if (ips % 2 == 0)ev++;
		else od++;
	}
	Int ans = 1;
	for (int i = 0; i < N; i++) {
		ans *= 2;
	}
	if (od == 0) {
		if (P)print(0);
		else print(ans);
	}
	else {
		ans /= 2;
		print(ans);
	}


	return 0;
}

Measured memory_bytes: 384
#1:初期化
N, K = map(int,input().split())
h = list(map(int, input().split()))
inf = float("inf")
dp = [inf]*(N) #Kが100までなので余分に入れて安全！

#2:初期値
dp[0] = 0

#3:dp実行部(配るDP)
for i in range(N):
    for k in range(1,min(N-i-1,K)+1):
        dp[i+k] = min(dp[i+k], dp[i] + abs(h[i] - h[i+k]))
        #print(dp,i,k)

#4:出力
print(dp[N-1])


Measured memory_bytes: 55008
import java.io.*;
import java.util.Arrays;
import java.util.stream.IntStream;

public class Main {
  public static void main(String[] args) {
    new Main().run();
  }

  private void run() {
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

      final int MAX = 100000;
      int n = Integer.parseInt(in.readLine());

      int[] table = new int[MAX+1];
      in.lines()
        .limit(n)
        .map(s -> s.split(" "))
        .map(a -> Arrays.stream(a).mapToInt(Integer::parseInt).toArray())
        .forEach(a -> IntStream.rangeClosed(a[0],a[1])
          .forEach(i -> table[i] = 1)
        );

      final int ans = Arrays.stream(table).sum();
      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

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

int main() {
  while(true) {
    int n;
    cin >> n;
    if(n == 0) break;
    int result = 0;
    for(int i = 0; i < n; ++i) {
      int x, y, h, weight;
      cin >> x >> y >> h >> weight;
      int size;
      size = x + y + h;
      vector<int> resultCandidits(2);
      resultCandidits[0] = (
          (size <= 60) ? 0 :
          (size <= 80) ? 1 :
          (size <= 100) ? 2 :
          (size <= 120) ? 3 :
          (size <= 140) ? 4 :
          (size <= 160) ? 5 :
          6
      );
      resultCandidits[1] = (
          (weight <= 2) ? 0 :
          (weight <= 5) ? 1 :
          (weight <= 10) ? 2 :
          (weight <= 15) ? 3 :
          (weight <= 20) ? 4 :
          (weight <= 25) ? 5 :
          6
      );
      int answers[] = {600, 800, 1000, 1200, 1400, 1600, 0};
      result += answers[max(resultCandidits[0], resultCandidits[1])];
    }
    cout << result << endl;
  }
  return 0;
}

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

#define long long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define sz(x) (int)x.size()
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,v) memset(a,v,sizeof(a))
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define INF 0x3f3f3f3f//infinity for integers
#define JJ ios_base::sync_with_stdio(0); cin.tie(0)//input fast
#define MOD 1000000007
#define hash(n) unordered_map<int,int>mp(n)

 bool find(int arr[], int start, int end, int x){
 	FOR(i,start,end){
 		if(arr[i]==x)
 			return false;
 	}
 	return true;
 }
int main() 
{ 
	JJ;
	int x, n; cin>>x>>n;
	if(n==0){
		cout<<x<<endl;
		return 0;
	}
	int arr[n];
	FOR(i,0,n){
		cin>>arr[i];
	}
	sort(arr,arr+n);
	FOR(i,0,n){
		if(arr[i]==x){
			int aagey=x+1;
			int peeche=x-1;
			while(find(arr,i+1,n,aagey)==false){
				aagey++;
			}
			while(find(arr,0,i,peeche)==false){
				peeche--;
			}
			if(abs(x-peeche)<=abs(aagey-x)){
				cout<<peeche<<endl;
				return 0;
			}
			else{
				cout<<aagey<<endl;
				return 0;
			}

		}
	}
	cout<<x<<endl;
	




	return 0;



    
} 

Measured memory_bytes: 3644
N = int(input())
L = list(map(int, input().split()))
num_list =[]
ans = 0
for i in range(N):
  for j in range(N):
    for k in range(N):
      if L[i]!=L[j] and L[j]!=L[k] and L[i]!=L[k]:
        num_list.append(L[i])
        num_list.append(L[j])
        num_list.append(L[k])
        num_list.sort()
        if num_list[0]+num_list[1] > num_list[2]:
          ans += 1
          num_list.clear()
        else:
          num_list.clear()
print(int(ans/6))


Measured memory_bytes: 9228
N,x = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A)
cnt = 0

for i in range(N):
  if i == N-1 and x > A[i]:
    break
  if x >= A[i]:
    x -= A[i]
    cnt += 1
  else:
    break
  
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
static auto faster_iostream = []() { ios::sync_with_stdio(0); cin.tie(0); return 0; }();
typedef long long ll; typedef long double db;
const int N = 1e6 + 5, M = 1e9 + 7;

// #pragma GCC optimize ("trapv")

int a[N];

int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  ll ans = 0;
  for (int i = 0; i < n - k; i++) {
    ans += a[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#define d_flag 0
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)<(b)?(b):(a))
#define abs(a) max((a),-(a))

int main(){
  int n,k;
  scanf("%d%d",&n,&k);
  int i,h[n],dp[n],j;
  
  
  for(i=0;i<min(k,n);i++){
    scanf("%d",&h[i]);
    dp[i]=abs(h[0]-h[i]);
  }
  if(d_flag)
    printf("max(%d,%d)=%d,abs(-5)=%d\n",h[0],h[1],max(h[0],h[1]),abs(-5));
  for(;i<n;i++){
    scanf("%d",&h[i]);
    dp[i]=dp[i-k]+abs(h[i-k]-h[i]);
    if(d_flag) printf("dp[%d]:%d",i,dp[i]);
    for(j=1;j<k;j++){
      int temp=dp[i-j]+abs(h[i-j]-h[i]);
      if(temp<dp[i]){
	dp[i]=temp;
	if(d_flag)printf("-> %d",dp[i]);
      }
    }
    if(d_flag)printf("\n");
  }
  if(d_flag){
    for(i=0;i<n;i++)
      printf(" %d",dp[i]);
    printf("\n");
    for(i=0;i<k;i++){
      printf("dp[%d]=abs(%d-%d)=%d\n",i,h[0],h[i],dp[i]);
    }
    for(;i<n;i++){
      printf("dp[%d]=min( ",i);
      for(j=1;j<=k;j++)
	printf("[%d+%d] ",dp[i-j],abs(h[i-j]-h[i]));
      printf(")=%d\n",dp[i]);
    }
  }
  
  printf("%d",dp[n-1]);
}


Measured memory_bytes: 896
n = gets.chomp.to_i
hs = gets.chomp.split.map(&:to_i)
dp = Array.new(n)

dp[0] = 0
dp[1] = dp[0] + (hs[1] - hs[0]).abs
2.upto(n-1) do |i|
  k = dp[i-2] + (hs[i] - hs[i-2]).abs
  l = dp[i-1] + (hs[i] - hs[i-1]).abs
  dp[i] = [k, l].min
end

puts dp[-1]

Measured memory_bytes: 11780
#include<bits/stdc++.h>
using namespace std;
map<int,int>ma;
#define ss second
#define ff first
typedef pair<int,int>pii;

int f[100010],cnt[100010];
long long ans[100010];
pii p[100010];
int find(int x){
	return f[x]==x?x:f[x]=find(f[x]);
}

int main(){
	int n,m;scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d%d",&p[i].ff,&p[i].ss);
	for(int i=1;i<=n;i++)f[i]=i,cnt[i]=1;
	long long cur=1ll*n*(n-1)/2;
	for(int i=m;i>=1;i--){
		ans[i]=cur;
		int fx=find(p[i].ff),fy=find(p[i].ss);
		if(fx!=fy){
			cur-=1ll*cnt[fx]*cnt[fy];
			int sum=cnt[fx]+cnt[fy];
			cnt[fx]=cnt[fy]=sum;
			f[fx]=fy;
		}
	}
	for(int i=1;i<=m;i++)printf("%lld\n",ans[i]);
}

Measured memory_bytes: 3712
// abc149_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, K;
    cin >> N >> K;

    int R, S, P;
    cin >> R >> S >> P;

    string T;
    cin >> T;

    map<char, int> char2idx;
    char2idx['r'] = 0;
    char2idx['s'] = 1;
    char2idx['p'] = 2;

    vector<int> scores{R, S, P};

    ll ans = 0;
    int pre = 0;
    REP(i, K) {
        for (int idx = i; idx < N; idx += K){
            int cur = char2idx[T[idx]];
            int vic = (3 + cur - 1) % 3;

//            print(i, idx, pre, cur, vic);
            if (idx < K || vic != pre){
                ans += scores[vic];
//                print(scores[vic]);
                pre = vic;
            } else {
                if (idx + K < N){
                    int nxt = char2idx[T[idx + K]];
                    int nxt_vic = (3 + nxt - 1) % 3;
                    if (nxt_vic == pre){
                        pre = (pre + 1) % 3;
                    } else {
                        pre = 3 - pre - nxt_vic;
                    }
                }
            }
        }
    }

    print(ans);


    return 0;
}


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

typedef long long ll;

ll wt[12345], val[12345];


ll Knapsack(ll w, ll wt[], ll val[], ll n)

{

    ll k[n+1][w+1];


    for(int i = 0; i <= n; i++)

    {

        for(int j = 0; j <= w; j++)

        {

            if(i == 0 || j == 0)k[i][j] = 0;

            else if(wt[i-1] <= j)

                k[i][j] = max(val[i-1]+k[i-1][j-wt[i-1]], k[i-1][j]);

            else k[i][j] = k[i-1][j];

        }

    }

    return k[n][w];

}


int main()

{

        ll n,W;
        memset(val, 0, sizeof(val));
        memset(wt, 0, sizeof(wt));
        scanf("%lld %lld",&n, &W);
        for(int i = 0; i < n; i++)
        {

            scanf("%lld%lld",&wt[i], &val[i]);

        }
        ll ans =0;
            ans += Knapsack(W, wt, val, n);
        printf("%lld\n", ans);

    return 0;

}




Measured memory_bytes: 79360
import collections
n = int(input())
n_list = [ int(v) for v in input().split() ]
m = int(input())
m_list = [ int(v) for v in input().split() ]

n_counter, m_counter = collections.Counter(), collections.Counter()
for i in n_list:
    n_counter[i] += 1
for i in m_list:
    m_counter[i] += 1

n_counter.subtract(m_counter)
if min(list(n_counter.values())) < 0:
    ans = "NO"
else:
    ans = "YES"
print(ans)

Measured memory_bytes: 127696
#include <iostream>
using namespace std;
int main() {
	int n,a,b,p[100];
	cin >> n >> a >> b;
	int x, y, z;
	x = 0; y = 0; z = 0;
	int ans = 100;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		if (p[i] <= a)x++;
		else if (p[i] <= b)y++;
		else z++;
	}
	if (ans > x)ans = x;
	if (ans > y) ans = y;
	if (ans > z) ans = z;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader in = null;
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			while (true) {
				String[] buf = in.readLine().split(" ");
				long a = Long.parseLong(buf[0]);
				long b = Long.parseLong(buf[2]);
				long r = 0;
				if ("+".equals(buf[1])) {
					r = a + b;
				} else if ("-".equals(buf[1])) {
					r = a - b;
				} else if ("*".equals(buf[1])) {
					r = a * b;
				} else if ("/".equals(buf[1])) {
					r = a / b;
				} else if ("?".equals(buf[1])) {
					break;
				} else {
					return;
				}
				System.out.println(r);
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (in != null) {
				try {
					in.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
				
			}
		}
		
		
		
	}
}

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

int main(){
    int n;
    cin >> n;
    vector <int> h(n+1);
    rep(i,n){
        cin >> h[i+1];
    }
    h[0]=0;
    ll ans=0;
    rep(i,n){
        if(h[i+1]>h[i]){
            ans+=h[i+1]-h[i];
        }
    }
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int N;
	cin >> N;
	int mn = INF;
	int sum = 0;
	int minus = 0;
	rep(i, N) {
		int A;
		cin >> A;
		if (A <= 0) {
			minus++;
			A *= -1;
		}
		mn = min(mn, A);
		sum += A;
	}
	if (minus % 2 == 0)cout << sum;
	else {
		sum -= 2 * mn;
		cout << sum;
	}
}

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

using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const int MOD = 1000000007;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }

int main() {
    string s;
    cin >> s;
    int n = s.size();
    rep(i, n-1){
        if(s[i]==s[i+1]){
            printf("%d %d\n", i+1, i+2);
            return 0;
        }
    }
    rep(i, n-2){
        if(s[i]==s[i+2]){
            printf("%d %d\n", i+1, i+3);
            return 0;
        }
    }
    printf("%d %d\n", -1, -1);
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	vector<int> a(n);
	for( auto &k : a ) cin >> k;
	int x = a[0];
	for( int i = 1; i < n; ++i ){
		x ^= a[i];
	}
	if( x == 0 ) cout << "Yes";
	else cout << "No";
	cout << endl;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if ((A != B && B != C) && C != A) {
    cout << "No" << endl;
  } else if ((A == B && B == C) && C == A) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3580
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
    int N, H;
    cin >> N >> H;

    vector<int> a(N);
    vector<int> b(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
    }

    sort(a.begin(), a.end(), greater<int>());
    sort(b.begin(), b.end(), greater<int>());

    int count = 0;
    for (int i = 0; i < N; i++) {
        if (b[i] <= a[0]) break;
        H -= b[i];
        count++;
        if (H <= 0) {
            cout << count << endl;
            return 0;
        }
    }

    while (H > 0) {
        count++;
        H -= a[0];
    }
    cout << count << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
   ll N;
   cin >> N;
   ll A[N];
   ll S[N + 1];
   S[0] = 0;
   map<ll, ll> log;
   log[S[0]]++;
   for (int i = 0; i < N; i++) {
      cin >> A[i];
      S[i + 1] = S[i] + A[i];
      log[S[i + 1]]++;
   }

   long long ans = 0;
   for (map<ll, ll>::iterator it = log.begin(); it != log.end(); ++it) {
      ll tmp = it->second;
      ans += tmp * (tmp - 1) / 2;
   }
   cout << ans << endl;
   return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    a[i]--;
  }
  int cnt = 0;
  rep(i, n) {
    if (a[a[i]] == i) cnt++;
  }
  cout << cnt / 2 << endl;
  return 0;
}


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

#define MAXN 1000010

vector<int> edge[MAXN];
int n,size[MAXN],u,v;

void dfs(int u,int fa)
{
	size[u]=0;
	for(auto v : edge[u])
	{
		if(v==fa)continue;
		dfs(v,u);
		size[u]^=size[v]+1;
	}
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;++i)
	{
		scanf("%d%d",&u,&v);
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	dfs(1,0);
	puts(size[1]?"Alice":"Bob");
}

Measured memory_bytes: 35328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
typedef pair<int, int> P;
const int MAX_N = 10000;
const int MAX_L = 100000000;
const int MAX_SQRT_B = 10000;
const int INF = 1000000000;
typedef int64_t ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
	int N, M, C;
	cin >> N >> M >> C;

	vector<int> B(M+1);
	vector<vector<int> > A(N+1, vector<int>(M+1));
	for (int i = 1; i <= M; i++)
	{
		cin >> B.at(i);
	}
	int cnt = 0;
	for (int j = 1; j <= N; j++)
	{
		int ans = C;
		for (int i = 1; i <= M; i++)
		{
			cin >> A.at(j).at(i);
			ans += A.at(j).at(i) * B.at(i);
		}
		if (ans > 0)cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

main()
{
    ll n; cin>>n;

    for(ll a=1;a<=3500;a++)for(ll b=1;b<=3500;b++)
    {
        ll t=n*a*b,s=4*a*b-n*(a+b);
        if(s!=0)if(t%s==0)if(t/s>0)
        {
            printf("%lld %lld %lld\n",a,b,t/s);
            return 0;
        }
    }
}

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

button = []

for i in range(N):
    button.append(int(input()))

count = 1
tmp = button[0]
while 1:
    if tmp == 2:
        print(count)
        exit()
    if count >= N:
        break
    tmp = button[tmp - 1]
    count += 1

print(-1)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

ll gcd(ll a, ll b){
	return b==0 ? a : gcd(b, a%b);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t;
	ll a, b, c, d;
	cin>>t;
	bool can;
	REP(i, t){
		can=false;
		cin>>a>>b>>c>>d;
		if(a>=b && b<=d){
			if(c>=b-1){
				can=true;
			}
			else{
				ll g=gcd(b, d);
				if(c>=b-g+a%g){
					can=true;
				}
			}
		}
		cout<<(can ? "Yes" : "No")<<'\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

void mod( ll &n, ll m=MOD ){ n%=m,n+=m,n%=m; }

const int MAXN = 1e5+5;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

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

    int f = 0, mx = h[0];
    for(int i=1;i<n;i++)
    {
        if( mx > h[i] + 1 )
        {
            f = 1;
            break;
        }
        mx = max(mx,h[i]);
    }
    if( f ) cout<<"No\n";
    else cout<<"Yes\n";

    return 0;
}

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


tree=input().split()
tree.insert(0,"error")

for i in range(1,n+1):
    print(f"node {i}: key = {tree[i]}, ",end="")
    if(i!=1):
        print(f"parent key = {tree[i//2]}, ",end="")
    try:
        print(f"left key = {tree[2*i]}, ",end="")
    except:
        print()
        continue
    try:
        print(f"right key = {tree[2*i + 1]}, ")
    except:
        print()


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

int main()
{
   int n,k;
   cin>>n>>k;
   int arr[n];
   for(int i=0;i<n;i++){
       cin>>arr[i];
       
   }
   sort(arr,arr+n);
  long sum=0;
  for(int i=0;i<k;i++){
  sum+=arr[i];}
   cout<<sum;
   
   return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int a, b;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b;
  if(a >= 13){
    cout << b;
  }else if(a >= 6){
    cout << b/2;
  }else{
    cout << 0;
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <stdio.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	
	if (a - (b * 2) > 0) {

		printf("%d", a - (b * 2));	
	}
	else {
		printf("%d", 0);
	}
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;

int main() {
  int K;
  string S;
  cin >> K >> S;
  if (S.length() <= K) {
    cout << S << endl;
  } else {
    cout << S.substr(0, K) << "..." << endl;
  }
}

Measured memory_bytes: 3620
import sys
from collections import Counter
readline = sys.stdin.readline
N = int(readline())
inf = 10**9+7
arr = [inf]*26

for _ in range(N):
    S = readline().strip()
    SC = Counter(S)
    for i in range(26):
        arr[i] = min(arr[i], SC[chr(97+i)])

ans = []
for i in range(26):
    ans.extend([i+97]*arr[i])
print(''.join(map(chr, ans)))  

Measured memory_bytes: 39280
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include <ios>
#include <iomanip>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef tuple<ll,ll,ll> Tl;

int atcoder(){
    //入力
    ll a,b,c;
    cin >> a >> b >> c;
    if(a==b&&b==c) cout << "1";
  else if(a==b||b==c||c==a) cout << "2";
  else cout << "3";
    return 0;
}

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


Measured memory_bytes: 256
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))

d = {1:0}
pre_a = 0
a = 1
c = 0
while K:
    K -= 1
    next_a = A[a]
    c += 1
    if next_a in d:
        idx = d[next_a]
        n = len(d)
        K %= (n - idx)
        K += 1
        break
    else:
        d[next_a] = c
        pre_a = a
        a = next_a

while K:
    pre_a = a
    a = A[a]
    K -= 1

print(a)

Measured memory_bytes: 32204
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>
#include <map>
#include <string>
#include <climits>
#include <set>
#include <sstream>
#include <utility>
#include <ctime>
#include <cassert>
#include <fstream>
using namespace std;
typedef long long LL;
#define MS(A) memset(A, 0, sizeof(A))
#define MSV(A,a) memset(A, a, sizeof(A))
#define MAX(a,b) ((a >= b) ? (a) : (b))
#define MIN(a,b) ((a >= b) ? (b) : (a))
#define ABS(a) (((a) > 0) ? (a) : (-a))
#define MP make_pair
#define PB push_back
#define getcx getchar_unlocked
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))


int main() {	

	LL n, i, arr[100001], ans = 1 ,flag = 0, z = 0;

	cin>>n;
	for(i = 0 ; i < n; i++) {
		cin>>arr[i];
		if(arr[i] == 0) {
			z=1;
		}
	}

	sort(arr, arr+n);

	ans = arr[0];

	if(ans == 0) {
		cout<<0<<endl;
		return 0;
	}

	for(i = 1 ; i < n; i++) {


		if(arr[i] > INFL/ans) {
			cout<<-1<<endl;
			return 0;
		}

		ans = ans * arr[i];
	}

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

Measured memory_bytes: 4420
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s;
  int a = 700;
  cin >> s;
  if (s[0] == 'o') a += 100;
  if (s[1] == 'o') a += 100;
  if (s[2] == 'o') a += 100;
  cout << a <<endl;
  return 0;
}

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

int main() {
  int N;
  long sum, min = 1000000;
  cin >> N;
  vector<int> X(N);
  for (int i = 0; i < N; i++) cin >> X.at(i);
  for (int p = 0; p <= 100; p++) {
    sum = 0;
    for (int x : X) {
      sum += pow(x - p, 2);
    }
    if (sum < min) min = sum;
  }
  cout << min << endl;
}

Measured memory_bytes: 256
a = input().split()

W = int(a[0])
H = int(a[1])
x = int(a[2])
y = int(a[3])
r = int(a[4])

if x-r < 0:
    print ("No")
elif x + r > W:
    print ("No")
elif y-r < 0:
    print ("No")
elif y+r > H:
    print ("No")
else:
    print ("Yes")

Measured memory_bytes: 7728
n,k = map(int,raw_input().split())
v = map(int,raw_input().split())
best = 0
for i in xrange(min(n,k+1)):
	for j in xrange(min(n+1-i,k+1-i)):
		take = v[0:i]+v[n-j:]
		rid = k-i-j
		take = sorted(take)
		temp = sum(take)
		for x in xrange(min(rid,len(take))):
			if take[x] < 0:
				temp -= take[x]
		if temp > best:
			best = temp
print best

Measured memory_bytes: 2692
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define INPUT(X) cin >> X
#define OUTPUT(X) cout << X << endl
#define REPEAT(i,n) for(int i=0;i<n;i++ )

using namespace std;

typedef unsigned long long int ull;


int main(void) {


	string S;
	INPUT(S);
	if( (S[0] == S[1] && S[0] != S[2] && S[2] == S[3] ) ||
		(S[0] == S[2] && S[0] != S[1] && S[1] == S[3] ) ||
		(S[0] == S[3] && S[0] != S[1] && S[1] == S[2] )   ){
			OUTPUT("Yes");
		}else{
			OUTPUT("No");
		}

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

	int W ,H ,x ,y ,r;
	
	scanf("%d %d %d %d %d" ,&W ,&H ,&x ,&y ,&r);
	
	if((0<=(x-r) && (x+r)<=W && 0<=(y-r) && (y+r)<=H)){
		
		printf("Yes\n");
		
	}
	
	else{
		
		printf("No\n");
		
	}
	
	return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
    ll sum;
    
    cin>>sum;
    ll ans=INF;
    
    
    for(ll i=0;i<=sum;i++){
        ll x,y;
        x=i;
        y=sum-i;
        
        ll cnt_6=0;
        ll cnt_9=0;
        
        while(x>0){
            ll res=1;
            
            while(res*6<=x)
            res*=6;
            
            x-=res;
            
            cnt_6++;
        }
        
        while(y>0){
            ll res=1;
            
            while(res*9<=y)
            res*=9;
            
            y-=res;
            
            cnt_9++;
        }
        
        ans=min(ans,cnt_6+cnt_9);
    }
    
    cout<<ans<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

Measured memory_bytes: 3692
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  const inputArr = input.trim().split("\n");
  if (inputArr.length !== 2) {
    console.log('No')
    return;
  }
  const A = inputArr[0]
  const B = inputArr[1]
  if (A.slice(0, A.length) === B.slice(0, A.length)) {
    console.log('Yes');
    return;
  } else {
    console.log('No')
    return;
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29560
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
using ll =long long;

int main (void) {
  int N;
  int ans=2;
  cin >>N;
  while(N>=ans){
    ans*=2;
  }
  cout << ans/2;
}


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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 dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    //cout <<fixed<<setprecision(16)<< << endl;

    if(k%2)cout << -(a-b) <<endl;
    else cout << a-b <<endl;

    return 0;
}


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


int main(){
	int p, q;
	while(~scanf("%d%d", &p, &q)){
		set<int> nums;
		vector<int> ans, ms;
		p *= 10;
		for(int i = 0;i < 800;i++){
			if(nums.count(p) || p == 0)break;
			ms.push_back(p);
			nums.insert(p);
			ans.push_back(p / q);
			p %= q;
			p *= 10;
		}
		for(int i = 0;i < ans.size();i++){
			cout << ans[i];
		}                  cout << endl;
		if(p != 0){
			char x = ' ';
			for(int i = 0;i < ans.size();i++){
				if(ms[i] == p)x = '^';
				cout << x;
			}             cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1236
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

#include <iomanip>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
// #define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const ll INF = 1e17;
ll dp[100005][13];

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

signed main(void) {
  ll H, A;
  cin >> H >> A;
  ll ans;
  ans = (H-1)/A + 1;

  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
import itertools
import bisect

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A_acc = list(itertools.accumulate(A))
B_acc = list(itertools.accumulate(B))

all_a = bisect.bisect_right(A_acc, K)
all_b = bisect.bisect_right(B_acc, K)

ans = max(all_a, all_b)

for i in range(N):
    rest = K - A_acc[i]

    if rest <= 0:
        break

    b = bisect.bisect_right(B_acc, rest)

    ans = max(ans, i + b + 1)

print(ans)


Measured memory_bytes: 47520
fun main(args: Array<String>) {
  val N = readInt()
  val S = readString().toList().map { it - 'A' }.map { (it + N) % 26 }.map { 'A' + it }
  println(S.joinToString(separator = ""))
}

fun readString() = readLine()!!
fun readStrings() = readString().split(' ')
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }


Measured memory_bytes: 33840
R,G,B,N = map(int,input().split())

ans = 0

for r in range(N//R + 1) :
    for g in range((N-r)//G + 1) :
        calc = r*R + g*G
        
        if (N-calc) < 0 :
            break
        
        if (N-calc) % B == 0 :
            ans += 1
print(ans)


Measured memory_bytes: 40944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> v(5);
ll k, wow, ans = 5;

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

    cin >> k;
    for (int i = 0; i< 5; i++) cin >> v[i];

    wow = v[0];
    for (int i = 1; i< 5; i++){
        if (v[i] < wow) wow = v[i];
    }

    if (wow >= k){
        cout << ans << endl;
        return 0;
    }

    if (k % wow == 0)
        ans += (k / wow) - 1;
    else
        ans += (k/wow);
    cout << ans << endl;
    return 0;
}


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

using namespace std;


long long L[1010][1010] {0};
int main(){
  int Q;
  cin >> Q;
  for(int i = 0; i < Q; i++){
    string X, Y;
    cin >> X >> Y;
    int xlen = X.length();
    int ylen = Y.length();
    for(int i = 1; i<= xlen; i++){
      for(int k = 1; k <= ylen; k++){
	if(X[i-1] == Y[k-1]){
	  L[i][k] = 1 + L[i-1][k-1];
	}else{
	  L[i][k] = max(L[i][k-1], L[i-1][k]);
	}
      }
    }

    cout << L[xlen][ylen] << endl;
  }

}

Measured memory_bytes: 11048
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#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 <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  set<int> se;
  REP(i,n) {
    int a;
    cin >> a;
    se.insert(a);
  }
  cout << se.size() << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
use std::io;


fn main() {
    let (n, i) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    println!("{}", n - i + 1);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

/**
 * Created by labuser on 2016/04/18.
 */
public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {

        int[] a = new int[3];

        Scanner sc = new Scanner(System.in);
        String[] input = sc.nextLine().split(" ");
        a[0] = Integer.parseInt(input[0]);
        a[1] = Integer.parseInt(input[1]);
        a[2] = Integer.parseInt(input[2]);

        Arrays.sort(a);
        System.out.println(a[0] + " " + a[1] + " " + a[2]);
        //System.out.printf("%d %d %d\n", a[0], a[1], a[2]);


    }
}

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

const int movex[4] = {-1, 1, 0, 0};
const int movey[4] = {0, 0, -1, 1};

struct P{
	int x, y, l;
};

P make_P(int x, int y, int l){
	P r;
	r.x = x;
	r.y = y;
	r.l = l;
	return r;
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	
	
	int n, m;
	cin >> n >> m;
	
	vector<vector<char>> mp(n + 5);
	
	mp[0].resize(m + 5);
	
	for (int i = 1; i <= n; ++i){
//		cout << i;
		mp[i].resize(m + 5);
		for (int j = 1;j <= m; ++j){
			cin >> mp[i][j];
		}
	}
	mp[n + 1].resize(m + 5);
	
	int ans = 0;
	vector<vector<char>> mp2;
	
	for (int sx = 1; sx <= n; ++sx){
		for (int sy = 1; sy <= m; ++sy){
			if (mp[sx][sy] != '.') continue;
			mp2 = mp;
			queue<P> q;
			q.push(make_P(sx, sy, 0));
			mp2[sx][sy] = ' ';
			while (!q.empty()){
				ans = max(ans, q.front().l);
				int nx = q.front().x, ny = q.front().y;
//				cout << nx << ny << '\n';
				for (int i = 0; i < 4; ++i){
//					cout << nx + movex[i];
					if (mp2[nx + movex[i]][ny + movey[i]] == '.'){
						q.push(make_P(nx + movex[i], ny + movey[i], q.front().l + 1));
						mp2[nx + movex[i]][ny + movey[i]] = ' ';
					}
				}
				q.pop();
			}
		}
	}
	cout << ans;
}


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

using namespace std;

const int MaxN = 1e5 + 15;
const int MOD = 1e9 + 7;
const long long INF = 1e18;

vector <pair<int, int> > v;

int moveTo(int & pos, pair<int, int> p)
{
    if(pos < p.first)
    {
        int res = p.first - pos;
        pos += res;
        return res;
    }else
    if(pos > p.second)
    {
        int res = pos - p.second;
        pos -= res;
        return res;
    }else
        return 0;
}

long long solve(int f)
{

    auto cmp1 = [] (pair<int, int> a, pair<int, int> b) {return a.second < b.second;};
    auto cmp2 = [] (pair<int, int> a, pair<int, int> b) {return a.first > b.first;};

    multiset<pair<int, int>, decltype(cmp1)> s1(cmp1);
    multiset<pair<int, int>, decltype(cmp2)> s2(cmp2);

    for(auto x : v)
    {
        s1.insert(x);
        s2.insert(x);
    }

    long long ans = 0;

    int pos = 0;

    while(!s1.empty())
    {
        f = 1 - f;
        if(f == 1)
        {
            pair<int, int> p = *s1.begin();
            if(p.second < pos)
            {
                ans += moveTo(pos, p);
                s1.erase(s1.find(p));
                s2.erase(s2.find(p));
            }else
            {
                f = 0;
                pair<int, int> p = *s2.begin();
                if(p.first > pos)
                {
                    ans += moveTo(pos, p);
                    s1.erase(s1.find(p));
                    s2.erase(s2.find(p));
                }else
                    return ans + moveTo(pos, make_pair(0, 0));
            }
        }else
        {
            pair<int, int> p = *s2.begin();
            if(p.first > pos)
            {
                ans += moveTo(pos, p);
                s1.erase(s1.find(p));
                s2.erase(s2.find(p));
            }else
            {
                f = 1;
                pair<int, int> p = *s1.begin();
                if(p.second < pos)
                {
                    ans += moveTo(pos, p);
                    s1.erase(s1.find(p));
                    s2.erase(s2.find(p));
                }else
                    return ans + moveTo(pos, make_pair(0, 0));
            }
        }
    }
    return ans + moveTo(pos, make_pair(0, 0));
}

int main()
{
//    freopen("output.txt", "r", stdin);

    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    v.resize(n);

    for(auto & x : v)
        cin >> x.first >> x.second;

    cout << max(solve(1), solve(0)) << '\n';

    return 0;
}


Measured memory_bytes: 12416
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{ 
  
  int N;cin>>N;
  int X = 1000 - N%1000;
  if(X== 1000)X = 0;
  cout<<X<<endl;
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3628