akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define tii tuple<int,int,int>
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}
int main(){
    ll x=lin();
    ll a=x%100;
    ll b=x/100;
    if(a <= 5*b)cout<<1<<endl;
    else cout<<0<<endl;
}


Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline

def belman(egdes, N, start, end):
    INF = int(1e18)
    cost = [INF] * N
    cost[start] = 0
    fin = False
    count = 0
    while True:
        no_change = True
        for edge in egdes:
            from_, to_, d = edge
            tmp = cost[from_] + d
            if cost[to_] > tmp:
                no_change = False
                cost[to_] = tmp
        count += 1
        if no_change:
            fin = True
            break
        elif count > N+1:
            break
    
    if fin:
        return -cost[end]
    else:
        return "inf"

def bfs(link, N, start):
    q = deque()
    check = [False] * N
    q.append(start)
    check[start] = True
    used = {start}
    while len(q) > 0:
        node = q.popleft()
        for next_ in link[node]:
            if not check[next_]:
                check[next_] = True
                q.append(next_)
                used.add(next_)
    return used
        

def main():
    N, M = map(int, input().split())

    link = [[] for i in range(N)]
    rlink = [[] for i in range(N)]
    edges = []

    for i in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        link[a].append(b)
        rlink[b].append(a)
        edges.append((a, b, -c))
    
    use_nodes = bfs(link, N, 0) & bfs(rlink, N, N-1)
    use_edges = [(a, b, c) for a, b, c in edges if a in use_nodes and b in use_nodes]
    print(belman(use_edges, N, 0, N-1))

if __name__ == "__main__":
    main()


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  int sum=0;
  for(int i =1;i<N;i++){
    cin >> A[i];
  }
  
  vector<int> B(N);
  
  for(int i=1;i<N;i++){
    B[A[i]-1]++;
  }

  for(int i=0;i<N;i++){
    cout << B[i] << endl;
  }
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
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;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

vector<vector<int>> G(111111);
vector<bool> visited(111111, false);
vector<int> ans0, ans1;
bool fin = false;
bool dfs(int V, int T)
{
  if (fin) return false;
  if (visited.at(V)) return false;
  visited.at(V) = true;

  if (T == 0) ans0.push_back(V);
  else ans1.push_back(V);

  bool fin0 = true;
  for (int i = 0; i < G.at(V).size(); i++)
  {
    if (dfs(G.at(V).at(i), T)) fin0 = false;
  }
  if (fin0) fin = true;

  return true;
}

signed main()
{
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++)
  {
    int a, b;
    cin >> a >> b;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  
  dfs(1, 0);
  visited.at(1) = false;
  fin = false;
  dfs(1, 1);

  int L0 = ans0.size(), L1 = ans1.size();
  cout << L0 + L1 - 1 << endl;
  cerr << L0 << " " << L1 << endl;
  for (int i = L1 - 1; i > 0; i--)
  {
    cout << ans1.at(i) << " ";
  }
  for (int i = 0; i < L0; i++)
  {
    cout << ans0.at(i);
    if (i == L0 - 1) cout << endl;
    else cout << " ";
  }
}

Measured memory_bytes: 13172
<?php
fscanf(STDIN, "%d %d %d", $N, $K, $Q);
$A = array();
for ($n=0; $n<$N; $n++){
    $A[$n] = $K - $Q;
}
for ($q=0; $q<$Q; $q++){
    fscanf(STDIN, "%d", $tmp);
    $A[$tmp-1]++; 
}
foreach ($A as $a){
    echo $a > 0 ? "Yes\n" : "No\n";
}

Measured memory_bytes: 18420
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n, h[maxn], dp[maxn];
int solve() {
    int i;
    dp[0] = 0; dp[1] = abs(h[0] - h[1]);
    for(i = 2; i < n; i++)
        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
    return dp[n - 1];
}
int main() {
    int i;
    scanf("%d", &n);
    for(i = 0; i < n; i++)
        scanf("%d", &h[i]);
    printf("%d\n", solve());
    return 0;
}

Measured memory_bytes: 1024
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
int N,A,B;
int main() {
    cin>>N>>A>>B;
    int C=0;
    int R=0;
    for(int i=1;i<N+1;i++){
    	if(i<10)C=i;
    	if(i>9 && i<100)C=(i/10)+(i%10);
    	if(i>99 && i<1000)C=(i/100)+((i%100)/10)+((i%100)%10);
    	if(i>999 && i<10000)C=(i/1000)+((i%1000)/100)+((i%100)/10)+(i%10);
    	if(i>9999 && i<100000)C=(i/10000)+((i%10000)/1000)+((i%1000)/100)+((i%100)/10)+(i%10);
    	if(A<=C && C<=B)R+=i;
    }

    cout<<R<<endl;
    return 0;
}


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

int main(int argc, char const *argv[])
{
	int h,w,n,sh,sw;
	string s,t;
	cin>>h>>w>>n>>sh>>sw>>s>>t;
	--sh;--sw;
	reverse(s.begin(), s.end());
	reverse(t.begin(), t.end());
	int l=0,r=w,u=0,d=h;
	for (int i = 0; i < n; ++i)
	{
		if (t.at(i)=='L')
		{
			r=min(w,r+1);
			if (r==l)
			{
				cout<<"NO\n";
				return 0;
			}
		}
		else if (t.at(i)=='R')
		{
			l=max(0,l-1);
			if (r==l)
			{
				cout<<"NO\n";
				return 0;
			}
		}
		else if (t.at(i)=='U')
		{
			d=min(h,d+1);
			if (u==d)
			{
				cout<<"NO\n";
				return 0;
			}
		}
		else if (t.at(i)=='D')
		{
			u=max(0,u-1);
			if (u==d)
			{
				cout<<"NO\n";
				return 0;
			}
		}
		if (s.at(i)=='L')
		{
			++l;
			if (r==l)
			{
				cout<<"NO\n";
				return 0;
			}
		}
		else if (s.at(i)=='R')
		{
			--r;
			if (r==l)
			{
				cout<<"NO\n";
				return 0;
			}
		}
		else if (s.at(i)=='U')
		{
			++u;
			if (u==d)
			{
				cout<<"NO\n";
				return 0;
			}
		}
		else if (s.at(i)=='D')
		{
			--d;
			if (u==d)
			{
				cout<<"NO\n";
				return 0;
			}
		}
	}
	if (l<=sw&&sw<r&&u<=sh&&sh<d)
	{
		cout<<"YES\n";
	}
	else
	{
		cout<<"NO\n";
	}
	return 0;
}


Measured memory_bytes: 904
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll a, b, c; cin >> a >> b >> c;
  ll x, y; cin >> x >> y;
  ll ans = 1e18;
  chmin(ans, max(x, y) * 2 * c);
  if(x < y) chmin(ans, x * 2 * c + (y - x) * b);
  if(x > y) chmin(ans, y * 2 * c + (x - y) * a);
  chmin(ans, a * x + b * y);
  cout << ans << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 256
// Try AtCoder
// author: Leonardone @ NEETSDKASU
package main

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

var scn = bufio.NewScanner(os.Stdin)

func getInts() []int {
	scn.Scan()
	xs := strings.Split(scn.Text(), " ")
	res := make([]int, len(xs))
	for i, x := range xs {
		res[i], _ = strconv.Atoi(x)
	}
	return res
}

func main() {
	n := getInts()[0]
	tree := make([][]int, n+2)
	dist := make(map[int64]int64)
	for i := 1; i < n; i++ {
		xs := getInts()
		a, b, c := xs[0], xs[1], int64(xs[2])
		tree[a] = append(tree[a], b)
		tree[b] = append(tree[b], a)
		dist[int64(a)*1e11+int64(b)] = c
		dist[int64(b)*1e11+int64(a)] = c
	}
	ys := getInts()
	q, k := ys[0], ys[1]
	flags := make([]bool, n+1)
	dists := make([]int64, n+1)
	flags[k] = true
	temp1 := []int{k}
	for len(temp1) > 0 {
		sz := len(temp1) - 1
		v := temp1[sz]
		temp1 = temp1[:sz]
		d := dists[v]
		for _, w := range tree[v] {
			if flags[w] {
				continue
			}
			flags[w] = true
			dists[w] = d + dist[int64(v)*1e11+int64(w)]
			temp1 = append(temp1, w)
		}
	}
	for i := 0; i < q; i++ {
		xs := getInts()
		x, y := xs[0], xs[1]
		fmt.Println(dists[x] + dists[y])
	}
}


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

int main()
{
    ll count = 0;
    ll n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        if (i % 3 == 0 && i % 5 == 0)
        {
            continue;
        }
        else if (i % 3 == 0)
        {
            continue;
        }
        else if (i % 5 == 0)
        {
            continue;
        }
        else
        {
            count += i;
        }
    }
    cout << count;
}

Measured memory_bytes: 3632
def main():
    import sys
    input = sys.stdin.readline

    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(d)]
    t = [int(input()) for _ in range(d)]
    last = [0 for _ in range(26)]
    score = 0

    for di in range(1, d + 1):
        ti = t[di - 1]
        score += s[di - 1][ti - 1]

        last[ti - 1] = di

        for j, cj in enumerate(c, 1):
            score -= cj * (di - last[j - 1])

        print(score)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9216
import java.util.*;
public class Main {
	
		static void solve() {
			Scanner sc = new Scanner(System.in);
			int array[] = new int[5];
			int plus = 0;
			int max = 0;
			for(int  i = 0;i<array.length;i++) {
				array[i] = sc.nextInt();
				if(array[i]%10!=0) {
					plus =10 - array[i]%10;
					array[i]+=plus;
					max = Math.max(max, plus);
				}
			}
			System.out.println(array[0]+array[1]+array[2]+array[3]+array[4]-max);
			sc.close();
	}
	public static void main(String[] args) {
		solve();
	}

}


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

using namespace std;

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

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

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

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


signed main(void) {
    int n,t;
    cin >> n >> t;
    vi p(n),c(n);
    rep(i,n) cin >> p[i] >> c[i];
    int ans = INF;
    vi v(n);
    rep(i,n)v[i] = i;
    do{
        int tmp = 0;
        int sum = 0;
        rep(i,n){
            if(sum + (p[v[i]]-1) * (v[i]+1)*100 >= t){
                rep(j,p[v[i]]-1){
                    sum += (v[i]+1)*100;
                    tmp++;
                    if(sum >= t)break;
                }
                break;
            }
            sum += p[v[i]]*(v[i]+1)*100 + c[v[i]];
            tmp += p[v[i]];
            if(sum >= t)break;
        }
        //rep(i,n)cout << " " << v[i];cout << endl;
        //cout << tmp << endl;
        ans = min(ans,tmp);
    }while(next_permutation(all(v)));
    cout << ans << endl;
}


Measured memory_bytes: 256
implicit none
  integer :: a(32),k

  a=(/1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1,&
       & 51/)
  read(*,*) K
  write(*,'(i0)') a(k)
end program


Measured memory_bytes: 640
N, M = tuple(map(int, input().split()))
mod = 10**9+7
broken = set(int(input()) for _ in range(M))
dp = [0]* (N+1)

dp[0] = 1

for i in range(1, N+1):
    if (i in broken):
        continue
    if (i == 1):
        dp[i] = 1
        continue
    dp[i] = (dp[i-1] + dp[i-2]) % mod

print(dp[N])

Measured memory_bytes: 11884
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do(): 
    n=INT()
    if n<=599:
        print(8)
    elif n<=799:
        print(7)
    elif n<=999:
        print(6)
    elif n<=1199:
        print(5)
    elif n<=1399:
        print(4)
    elif n<=1599:
        print(3)
    elif n<=1799:
        print(2)
    else:
        print(1)
if __name__ == '__main__':
    do()

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main() {
    long long N,A,B;
    cin >> N >> A >> B;
    long long C = A + B;
    long long res = A * (N / C);
    long long R = N % C;
    res += min(A,R);
    cout << res << endl;

    return 0;
}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < n; i++)
#define REP(n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using INT64 = long long;
using UINT64 = unsigned long long;

int main(void)
{
    IOS
    const int M = 5;
    INT64 n; cin >> n;
    vector<INT64> v(M);
    REP(M) cin >> v[i];

    INT64 min = v[0];
    FOR(i,1,M) {
        if (min > v[i]) min = v[i];
    }
    INT64 ans = n / min;
    if (n % min != 0) ans++;
    ans += M-1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		int sum = 0;
		for (int i = 0; i < s.length(); i++) {
			String ss = s.substring(i, i+1);
			int a = Integer.parseInt(ss);
			sum += a;
		}

		if (N % sum == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23124
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		double N = stdIn.nextDouble();
		int count = 0;
		while(N > 1.0)
		{
			N /= 3;
			++count;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 12000
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int inputNumber = sc.nextInt();
        
        char[] markChar = {'S', 'H', 'C', 'D'};
        boolean[][] judgeCard = new boolean[4][13];
        
        MarkCard mc = new MarkCard();
        for(int i = 0; i < inputNumber; i++){
            char inputMark      = sc.next().charAt(0);             //文字入力
            int inputRankNumber = sc.nextInt();                 //1~13まで入力
            judgeCard[mc.checkMark(inputMark)][inputRankNumber-1] = true;
        }

        for(int markCount = 0; markCount < 4; markCount++){
            for(int rankCount = 0; rankCount < 13; rankCount++){
                //falseのものを出力する
                if(!judgeCard[markCount][rankCount]){               
                    System.out.print(markChar[markCount] + " " + (rankCount+1) + "\n");
                }
            }
        }
    }
}

class MarkCard{
    public int checkMark(char inputMark){
        switch(inputMark){
            case 'S':
                return 0;
            case 'H':
                return 1;
            case 'C':
                return 2;
            case 'D':
                return 3;
        }
        return -1;
    }
}


Measured memory_bytes: 26180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
struct DAG{
    int V;
    vector<vector<int>> G;
    vector<int> in;
    DAG(int V):V(V),G(V),in(V){}
    void add_edge(int f,int t){
        G[f].push_back(t);
        in[t]++;
    }
    vector<int> topological_sort(){
        vector<int> res;
        stack<int> st;
        for(int i=0;i<V;i++){
            if(!in[i]){
                st.push(i);
            }
        }
        while(st.size()){
            int t=st.top();st.pop();
            res.push_back(t);
            for(int i=0;i<G[t].size();i++){
                if(!(--in[G[t][i]])){
                    st.push(G[t][i]);
                }
            }
        }
        return res;
    }
};
int main(){
    int V,E;
    cin>>V>>E;
    E+=V-1;
    DAG G(V);
    vvi inv(V);
    REP(i,E){
        int f,t;
        cin>>f>>t;
        f--;t--;
        G.add_edge(f,t);
        inv[t].pb(f);
    }
    auto tops=G.topological_sort();
    vi topl(V);
    REP(i,V){
        topl[tops[i]]=i;
    }
    vi ans(V,-1);
    REP(i,V){
        int v=tops[i];
        int x=-1;
        int vx=-1;
        REP(j,inv[v].size()){
            if(chmax(x,topl[inv[v][j]])){
                vx=inv[v][j];
            }
        }
        ans[v]=vx+1;
    }
    REP(i,V){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 13436
#include<iostream>
using namespace std;
int main()
{
    int n,m,a[100005],b[100005];
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>a[i]>>b[i];
    }
    int x=1,y=n;
    for(int i=0;i<m;i++)
    {
        x=max(x,a[i]);
        y=min(y,b[i]);
    }
    int sum=y-x+1;
    if(sum<0)
    {
        cout<<"0"<<endl;
    }
    else
    {
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n,d;
  cin>>n>>d;
  int tc=0;
  while(n--){
    long long int x,y;
    cin>>x>>y;
    long long int dis= x*x+y*y;
    if(dis<=(d*d)){
      tc++;
    }
  }
  cout<<tc<<endl;
}

Measured memory_bytes: 3632
# AtCoder Beginner Contest 146
# F - Sugoroku
# https://atcoder.jp/contests/abc146/tasks/abc146_f
import sys
N, M = map(int, input().split())
*S, = map(int, input())
S.reverse()

i = 0
ans = []
while i < N:
    for m in range(M, 0, -1):
        if i+m <= N and S[i+m] == 0:
            i += m
            ans += [m]
            break
    else:
        print(-1)
        sys.exit()

print(*ans[::-1])


Measured memory_bytes: 7056
local n, m = io.read("*n", "*n")
local i = 1
local ret = 1
local mma = math.max
while true do
  if m % i == 0 then
    local j = m // i
    if n <= j then ret = mma(ret, i) end
    if n <= i then ret = mma(ret, j) end
  end
  if m < i * i then break end
  i = i + 1
end
print(ret)


Measured memory_bytes: 760
N,M=map(int,input().split())
a=[0]*(N+2)
b=[0]*(M+2)
c=[0]*(M+2)
a[0]=0
a[1]=1
a[2]=1
for i in range(3,N+2):
    a[i]=a[i-1]+a[i-2]
if M==0:
    print(a[N+1]%1000000007)
else:
    b[0]=-1
    b[M+1]=N+1
    way=1
    for i in range(1,M+1):
        b[i]=int(input())
        c[i]=b[i]-b[i-1]-1
        way=(way*a[c[i]])%1000000007
    c[M+1]=b[M+1]-b[M]-1
    way=(way*a[c[M+1]])%1000000007
    print(way)

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

long long n, m, a, t, s, num, i;
int main()
{
	cin >> n >> m >> t;
	for (i = 1; i < n; i++) {
		scanf ("%lld", &a);
		num = max(0LL, t + a - m);
		s += num;
		t = max(a - num,0LL);
	}
    cout << s;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x) { return mrand() % x; }
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a%mod; a = a * a%mod; }return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
// head
const int MAXN = 100000+5;
int par[MAXN];
int height[MAXN];//rank

//initialize n elements
void init(int n)
{
    for(int i=0;i<n;++i)
    {
        par[i]=i;
        height[i]=0;
    }
}

//find the root of tree
int find(int x)
{
    if(par[x]==x)
        return x;
    else
        return par[x] = find(par[x]);
}

//union x and y to one set
void unite(int x,int y)
{
    x = find(x);
    y = find(y);
    if(x==y) return;

    if(height[x] < height[y])
        par[x] = y;
    else
    {
        par[y] = x;
        if(height[x] == height[y]) height[x]++;
    }
}

//if x in the same set of y
bool same(int x, int y)
{
    return find(x) == find(y);
}

vi fri[MAXN],blo[MAXN];
int fcnt[MAXN];
int vis[MAXN];
int scnt[MAXN];
int ans[MAXN];
int t;

void dfs(int u) {
    vis[u] = 1;
    for(int v:fri[u]) {
        if(!vis[v]) {
            unite(u,v);
            dfs(v);
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
#ifdef RG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
#endif
    int n,m,k;
    cin>>n>>m>>k;
    init(n+1);
    int u,v;
    rep(i,0,m) {
        cin>>u>>v;
        fri[u].push_back(v);
        fri[v].push_back(u);
        fcnt[u]++;
        fcnt[v]++;
    }
    rep(i,0,k) {
        cin>>u>>v;
        blo[u].push_back(v);
        blo[v].push_back(u);
    }

    rep(i,1,n+1) {
        if(!vis[i]) dfs(i);
    }
    
    rep(i,1,n+1) {
        scnt[find(i)]++;
    }

    rep(i,1,n+1) ans[i] = scnt[find(i)];

    rep(i,1,n+1) {
        for(int v:blo[i]) {
            if(same(i,v)) ans[i]--;
        }
    }

    rep(i,1,n+1) {
        if(i>1) cout<<" ";
        cout<<ans[i] -fcnt[i]-1;
    }
    cout<<endl;

    return 0;
}


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

using namespace std;
vector<long long> factors;
#define ll long long


#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

template<typename T>
int BS(vector<T> &mas, T val)
{
	int l, r;
	l = 0;
	r = mas.size() - 1;
	while (r - l > 1)
	{
		int mid = l + (r - l) / 2;
		if (mas[mid] < val)
		{
			l = mid;
		} else
			r = mid;
	}
	if (mas[r] == val)
		return r;
	if (mas[l] == val)
		return l;
	return -1;
}

template<typename T>
int UBS(vector<T> &mas, T val)
{
	int l, r;
	l = 0;
	r = mas.size() - 1;
	while (r - l > 1)
	{
		int mid = l + (r - l) / 2;
		if (mas[mid] < val)
		{
			l = mid;
		} else
			r = mid;
	}

	if (mas[l] >= val)
		return l;
	if (mas[r] >= val)
		return r;
	return -1;
}

ll mod(ll a, ll m)
{ return (a + (abs(a) / m) * m + m) % m; }


int main()
{
	ios_base::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	double a,b;
	cin >> a >>b;
	cout << setprecision(15)<<a / b << '\n';
	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);
       int H=sc.nextInt();
       int W=sc.nextInt();
       int field[][]=new int [H][W];
       int h=sc.nextInt();
       int w=sc.nextInt();

       for(int i=0;i<h;i++) {
    	   for(int j=0;j<W;j++) {
    		   field[i][j]=1;
    	   }
       }
       for(int i=0;i<H;i++) {
    	   for(int j=0;j<w;j++) {
    		   field[i][j]=1;
    	   }
       }
       int ans=0;
       for(int i=0;i<H;i++) {
    	   for(int j=0;j<W;j++) {
    		   if(field[i][j]==0)ans++;
    	   }
       }
    	   System.out.println(ans);
    }
    }

Measured memory_bytes: 23764
from collections import Counter


N = int(input())
A = map(int, input().split())
edge = Counter(A)

cand = [a for a in edge.keys() if edge[a] >= 2]
cand.sort(reverse=True)

e1 = e2 = 0
if len(cand) >= 1:
    if edge[cand[0]] >= 4:
        e1 = e2 = cand[0]
    elif len(cand) > 1:
        e1 = cand[0]
        e2 = cand[1]

print(e1 * e2)


Measured memory_bytes: 24096
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main(){
    int N, M;
    cin >> N >> M;
    ll n = 1900 * M + (N - M) * 100;
    cout << (int)(n * pow(2, M)) << endl;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int a, b; cin >> a >> b;
  cout<<(a+b<10?to_string(a+b):"error")<<endl;

  return 0;
}


Measured memory_bytes: 256
use std::io::*;

fn main() {
    let s = read_v();

    let mut count = 0;

    let mut ch = false;
    let mut ans = 0;

    for c in s.into_iter() {
        if c == 'A' {
            ch = true;
        }
        if ch {
            count += 1;
            if c == 'Z' {
                ans = count;
            }
        }
    }

    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    writeln!(out, "{}", ans);
}
fn read_v() -> Vec<char> {
    let s = stdin();
    let b = s.bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    b
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
const int M=300000;//M=1e6+100;
typedef long long int ll;
using namespace std;

ll n,x;
set<ll> s;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		s.insert(x);
	}
	if(s.size()==n)
	{
		cout<<"YES";
	} else cout<<"NO";
}

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

int func(string T,string U){
  int count=0;
  for(char C='a';C<='z';C++){
    bool t=false;
    bool u=false;
    for(int i=0;i<T.size();i++){
      if(T.at(i)==C){
        t=true;
      }
    }
    for(int i=0;i<U.size();i++){
      if(U.at(i)==C){
        u=true;
      }
    }
    if(t && u){
      count++;
    }
  }
  return count;
}
    
 
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int maxcount=0;
  for(int i=1;i<N;i++){
    string T=S.substr(0,i);
    string U=S.substr(i,N-i);
    int count=func(T,U);
    maxcount=max(count,maxcount);
  }
  cout << maxcount << endl;
}
  

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

constexpr char BR = '\n';


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

int main()
{
    int N, T;
    io >> N >> T;
    vi A(N), B(N);
    for (int i = 0; i < N; i++)
        cin >> A[i] >> B[i];

    vvi dp1(N+1, vi(T));
    vvi dp2(N+1, vi(T));
    for (int t = 1; t < T; t++)
    {
        for (int i = 0; i < N; i++)
        {
            if (t < A[i])
                dp1[i+1][t] = dp1[i][t];
            else
                dp1[i+1][t] = max(dp1[i][t-A[i]]+B[i], dp1[i][t]);
        }
        for (int i = N; i > 0; i--)
        {
            if (t < A[i-1])
                dp2[i-1][t] = dp2[i][t];
            else
                dp2[i-1][t] = max(dp2[i][t-A[i-1]]+B[i-1], dp2[i][t]);
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < T; j++)
        {
            ans = max(ans, B[i] + dp1[i][j] + dp2[i+1][T-j-1]);
        }
    }
    io << ans << BR;
}


Measured memory_bytes: 74044
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 1005;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  unordered_set<int>st;
  int n;
  cin>>n;
  int cur = 0;
  int cnt = 0;
  while(1){
    cur = (cur * 10 + 7)%n;
    cnt++;
    if(cur==0){
      cout<<cnt<<endl;
      break;
    }
    if(st.find(cur)!=st.end()){
      cout<<-1<<endl;
      break;
    }
    st.insert(cur);
  }
  return 0;
}

Measured memory_bytes: 42700
import numpy as np
N, M, C = map(int, input().split())
B = np.array(list(map(int, input().split())))
res = 0
for _ in range(N):
  A = np.array(list(map(int, input().split())))
  if sum(A * B) + C > 0 : res+=1

print(res)

Measured memory_bytes: 26720
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll, pill>


using namespace std;

const ll N = 3e5;
const ll big = 1e18;
const ll block = 800;
const ll mod = 1e6;

ll n, o, b;

vector<ll> g[N];

ll cur[N];

ll a[N];

ll ans[N];

void dfs(ll v = 1,ll sz = 0, ll p = -1) {
	ll x = lower_bound(cur, cur + n + 1, a[v]) - cur;
	sz = max(x, sz);
	ll pr = cur[x];
	cur[x] = a[v];
	ans[v] = sz;
	for(auto u : g[v]){
		if(u != p)
			dfs(u, sz, v);
	}
	cur[x] = pr;
}

int main() {
	speed;
	cur[0] = -big;
	rep(1, N , 1)
		cur[i] = big;
	cin >> n;
	for(int i = 1; i <= n; i++) 
		cin >> a[i];
	rep(0, n - 1, 1) {
		cin >> o >> b;
		g[o].pb(b);
		g[b].pb(o);
	}
	dfs();
	rep(1, n + 1, 1)
		cout << ans[i] << '\n';
}

/*
0 133 14 135 28 137 42 139 56 141 70 143
*/



Measured memory_bytes: 36676
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
static const ll INF = 1e17;

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

int main() {
  int n; cin >> n;
  vector<int> a(n);
  int onecount = 0;
  rep(i, n) {
    cin >> a[i];
    if(a[i]==1) onecount++;
  }

  int nowgcd = a[0];
  rep(i, n) nowgcd = gcd(nowgcd, a[i]);
  if(nowgcd != 1){
    cout << "not coprime" << endl;
    return 0;
  }

  if(n - onecount >= 78500){
    cout << "setwise coprime" << endl;
    return 0;
  }

  vector<bool> factorused(1000002, false);
  rep(i, n){
    if(a[i]==1) continue;
    for(int j = 2; j * j <= a[i]; j++){
      if(a[i]%j == 0){
        if(factorused[j]){
          cout << "setwise coprime" << endl;
          return 0;
        }
        while(a[i]%j==0) a[i] /= j;
        factorused[j] = true;
      }
    }

    if(a[i]!=1){
      if(factorused[a[i]]){
        cout << "setwise coprime" << endl;
        return 0;
      }
      factorused[a[i]] =  true;
      a[i] = 1;
    }
  }

  cout << "pairwise coprime" << endl;
  return 0;
}


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

int main(){
    int n;
    int m;
    int sum=0;
    cin>>n>>m;
    vector<int> v(m);
    vector<int> u(m-1);

    for(int i=0;i<m;i++)
       cin>>v.at(i);
    
    sort(v.begin(),v.end());

    for(int i=0;i<m-1;i++){
       u.at(i)=v.at(i+1)-v.at(i);
       if(u.at(i)<0)
           u.at(i)=-u.at(i);
    }

    sort(u.begin(),u.end());
    for(int i=0;i<m-n;i++){
        sum+=u.at(i);
    }
    
    cout<<sum<<endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;

const int INF = 1e9 ;
const int maxN = 1e5 + 5;

int n,m;
int a[maxN];
int b[maxN];
const int MOD = 1e9 + 7;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n);
	reverse(a+1,a+1+n);
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&b[i]);
	}
	sort(b+1,b+1+m);
	reverse(b+1,b+1+m);
	ll cnt = 1;
	int k1 = 0;
	int k2 = 0;
	for(int i = n*m;i>=1;i--)
	{
		if(a[k1+1] == i && b[k2+1] == i)
		{
			k1++;k2++;
			cnt *= 1;
			cnt %= MOD;
		}
		else if(a[k1+1] == i )
		{
			k1++;
			cnt *= k2;
			cnt %= MOD;
		}
		else if(b[k2+1] == i)
		{
			k2++;
			cnt *= k1;
			cnt %= MOD;
		}
		else
		{
			if ((ll)k1*k2 - (n*m - i) < 0)
				cnt = 0;
			else
				cnt *= ((ll)k1*k2 - (n*m - i));
			cnt %= MOD;
		}
	}
	printf("%lld\n",cnt);
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long mod2 = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
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;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

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

  vector<long long> b(N);
  long long amax = -INF;
  for (int i = 0; i < N; i++)
  {
    long long a;
    cin >> a >> b.at(i);
    chmax(amax, a);
  }

  b.push_back(amax);
  sort(b.begin(), b.end(), greater<long long>());

  long long ans = 0;
  long long dam = 0;
  for (int i = 0; i < N + 1; i++)
  {
    if (dam >= H) break;
    if (b.at(i) == amax)
    {
      ans += divCeil((H - dam), amax);
      break;
    }
    dam += b.at(i);
    ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
import heapq
n, m = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(n)]
AB.sort()
pq = []
res, i = 0, 0
for day in range(1, m + 1):
	while i < n and AB[i][0] <= day:
		heapq.heappush(pq, -AB[i][1])
		i += 1
	if pq:
		res += -heapq.heappop(pq)
print(res)

Measured memory_bytes: 72664
N = int(input())
S = input()
mod = 10**9+7
base = 1234
power = [1]*(N+1)
for i in range(1, N+1):
    power[i] = power[i-1]*base%mod
def check(m):
    dic = {}
    for i in range(N-m+1):
        s = S[i:i+m]
        if s in dic.keys():
            if dic[s]+m<=i:
                return True
        else:
            dic[s] = i
    return False
ok = 0
ng = N+1
while ng-ok>1:
    mid = (ok+ng)//2
    
    if check(mid):
        ok = mid
    else:
        ng = mid
print(ok)

Measured memory_bytes: 9660
#include <iostream>
#include <cstdlib>
#include<vector>
using namespace std;
int main()
{   int i, N;
    cin >> N;
    int V[N];
    int C[N];
    int S[N];
    for(i=0;i<N;i++)cin>>V[i];
    for(i=0;i<N;i++)cin>>C[i];
    for(i=0; i<N; i++){
        S[i] = V[i] - C[i];
    }
    // S[i]が正の値についてたす
    int sum = 0;
    for(i=0; i<N; i++){
        if(S[i]>0)sum+=S[i];
    }
    cout << sum << endl;
    return 0;   
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		long N = long.Parse(Console.ReadLine());
		// スペース区切りの整数の入力
		List<int> A = Console.ReadLine().Split(' ').Select(b => int.Parse(b)).ToList();
		
		long[] cnt = new long[N + 1];
		long sum = 0;
		for(var i = 0; i < N; i++){
		    sum += (cnt[A[i]]++);
		}
		for(var i = 0; i < N; i++){
		    var ans = sum - cnt[A[i]] + 1;
		    //出力
		    Console.WriteLine(ans);
		}
		
	}
}

Measured memory_bytes: 35264
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'

void solve(){
  int n, k;
  cin >> k >> n;
  int m = 0;

  vector<int>a(n);
  forn(i,n) {
    cin >> a[i];
    if (i) setmax(m, a[i]-a[i-1]);
  }
  setmax(m, k-(a.back()-a[0]));

  cout << k - m;
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

1
322123


n - 1
0 ... (n-1) [res ... res] S - (n-1) ... S


 */

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define endl "\n"
#define sz(u) (int)(u.size())
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
void solve(){
int a,b,k;
    ull x;
    cin>>x;
    double sum=100;
    int d=0;
    while(sum<x){
        d++;
        sum*=1.01;
        sum=floor(sum);
    }
    cout<<d;
    }
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    }


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int MN = 100010;

vi g[MN];
bool vis[MN];

void dfs(int v, int ban) {
	vis[v] = 1;
	for (int to : g[v]) if (to != ban && !vis[to]) {
		dfs(to, ban);
	}
}
int main() {
	int N, M;
	cin >> N >> M;
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a].pb(b);
		g[b].pb(a);
	}
	int six = 0, four = 0;

	rep(i, N) {
		if ((int)g[i].size() % 2 == 1) {
			puts("No");
			return 0;
		}
		if ((int)g[i].size() >= 6) {
			++six;
		} else if ((int)g[i].size() == 4) {
			++four;
		}
	}

	if (six || four >= 3) {
		puts("Yes");
		return 0;
	}

	if (four < 2) {
		puts("No");
		return 0;
	}

	int s = -1;
	rep(i, N) if ((int)g[i].size() == 4) {
		s = i;
	}

	int cmp = 0;
	rep(i, N) if (i != s && !vis[i]) {
		dfs(i, s);
		++cmp;
	}

	puts(cmp == 1 ? "No" : "Yes");

	return 0;
}

Measured memory_bytes: 7040
A = [[int(x) for x in input().split()] for _ in range(3)]
N = int(input())
b = []
for _ in range(N):
    b.append(int(input()))

Chosen = []
for _ in range(3):
    Chosen.append([False] * 3)

Bingo = [
    [[0, 0], [0, 1], [0, 2]],
    [[1, 0], [1, 1], [1, 2]],
    [[2, 0], [2, 1], [2, 2]],
    [[0, 0], [1, 0], [2, 0]],
    [[0, 1], [1, 1], [2, 1]],
    [[0, 2], [1, 2], [2, 2]],
    [[0, 0], [1, 1], [2, 2]],
    [[2, 0], [1, 1], [0, 2]]
    ]

ans = False

for sample in b:
    for i in range(3):
        for j in range(3):
            if A[i][j] == sample:
                Chosen[i][j] = True

for i in range(len(Bingo)):
    if Chosen[Bingo[i][0][0]][Bingo[i][0][1]] and Chosen[Bingo[i][1][0]][Bingo[i][1][1]] and Chosen[Bingo[i][2][0]][Bingo[i][2][1]]:
        ans = True
        break

if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

int main() {
	int n, w;
	struct { int v, w; } item[101];
	cin >> n >> w;
	for (int i = 0; i <= n; i++)
		cin >> item[i].v >> item[i].w;
	int dp[101][10001] = {};
	for (int i = 0; i < n; i++)
		for (int j = 0; j <= w; j++)
			if (item[i].w <= j)
				dp[i+1][j] = max(dp[i][j], dp[i+1][j-item[i].w] + item[i].v);
			else
				dp[i+1][j] = dp[i][j];
	cout << dp[n][w] << endl;
	return 0;
}

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

ans = 'DENIED'
for Ai in A:
    if Ai % 2 > 0: continue
    #
    if Ai % 3 > 0 and Ai % 5 > 0: break
    else: continue
else:
    ans = 'APPROVED'

print(ans)

Measured memory_bytes: 3060