akhauriyash/Code-Regression huggingface dataset:
// This is the start of  template//
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long int
#define vll vector<int>
#define pb push_back
#define pll pair<int,int>
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
void input(){
#ifndef ONLINE_JUDGE 
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout); 
#endif
}
#define INF LONG_LONG_MAX
#define mod 1000000007
#define array(a,n) vll a(n); rep(i,0,n) cin>>a[i];
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define cases int t; cin>>t; while(t--)
#define printall(a) rep(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;
//my template ends//
string s,temp,ans;
map<string,int>m;
int32_t main()
{
	ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	input();
  	double n,d,ans=0;
  	cin>>n>>d;
  	rep(i,0,n)
  	{
  		double x,y;
  		cin>>x>>y;

  		if(sqrt(x*x+y*y)<=d)
  			ans++;
  	}
  	cout<<ans<<endl;
  
    return 0;
}



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

int n;
long a[100];

long sub(long x) {
  long sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += (x - a[i]) * (x - a[i]);
  }
  return sum;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  long avg = 0;
  for (int i = 0; i < n; ++i) avg += a[i];
  avg /= n;
  cout << min(sub(avg), sub(avg + 1)) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int GCD(int a,int b){
	int r=a%b;
	if(r==0) return b;
	return GCD(b,r);
}
int main(){
	int a,b,g,l;
	while(scanf("%d%d",&a,&b)!=EOF){
		g = GCD(a,b);
		l = (a/g)*b;
		printf("%d %d\n",g,l);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,a,b;
	scanf("%d %d %d ",&n,&a,&b);
	int c[3];
	memset(c,0,sizeof(c));
	while(n--) {
		int t;
		scanf("%d ",&t);
		if(t <= a) {c[0]++;} else if(t <= b) {c[1]++;} else {c[2]++;}
	}
	printf("%d\n",min(min(c[0],c[1]),c[2]));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N,W;
    cin>>N>>W;
    vc<pair<ll, ll>> J(N);
    rep(i,N){
        ll w, v;
        cin >> w >> v;
        J[i] = {w, v};
    }

    ll w1 = J[0].first;
    rep(i, N) J[i].first -= w1;

    ll ans = 0;
    repe(K,1,N+1){
        if (W < K * w1) continue;

        ll Wd = min(K*3, W - K * w1);
        vvc<ll> dp(K + 1, vl(Wd + 1)); //k個選び、重さWkであるときの最大価値
        rep(i,N){
            ll w,v;
            tie(w, v) = J[i];

            repr(k, K){
                rep(j,Wd+1){
                    if(j>=w)
                        dp[k + 1][j] = max(dp[k + 1][j], dp[k][j - w] + v);
                }
            }
        }

        rep(k, K) chmax(ans, *max_element(all(dp[k + 1])));
    }

    cout << endl;
    cout << ans << endl;

}

Measured memory_bytes: 544
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
#define chmax(x,y) (x = max(x, y))
void solve(); int main() { solve(); return 0; }

void solve() {
  int k, a, b;
  cin >> k >> a >> b;
  loop(i,a,b+1) {
    if (i%k==0) { cout << "OK" << endl; return; }
  }
  cout << "NG" << endl;
}


Measured memory_bytes: 3600
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    char a[11];
    int i,num=0,b[100],k=0,max=0;
    scanf("%s",a);
    for(i=0;a[i]!=0;i++)
    loop :switch(a[i])
    {
        case 'A':num++;i++;goto loop;
        case 'C':num++;i++;goto loop;
        case 'G':num++;i++;goto loop;
        case 'T':num++;i++;goto loop;
        default :b[k++]=num;num=0;break;
    }
    for(k=k-1;k>=0;k--)
    if(max<b[k])
        max=b[k];
    printf("%d",max);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int DP[1005][10005];

int main() {
    int H, N;
    cin>>H>>N;
    int A[N], B[N];
    for(int i=0;i<N;++i){
        cin>>A[i]>>B[i];
    }
    for(int i=0;i<=H;++i){
        if(i%A[0]==0){
            DP[0][i] = i/A[0]*B[0];
        }
        else{
            DP[0][i] = (i/A[0]+1)*B[0];
        }
    }
    for(int i=1;i<N;++i){
        for(int j=0;j<=H;++j){
            if(j>=A[i]) DP[i][j] = min(DP[i-1][j], DP[i][j-A[i]] + B[i]);
            else DP[i][j] = min(DP[i-1][j], B[i]);
        }
    }
    /**
    for(int i=0;i<N;++i){
        for(int j=0;j<=H;++j){
            cout<<DP[i][j]<<" ";
        }
        cout<<endl;
    }
    **/
    cout<<DP[N-1][H]<<endl;
}



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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s[5] - '0' > 0 || s[6] - '0' > 4) {
        puts("TBD");
    } else {
        puts("Heisei");
    }
    return 0;
}

Measured memory_bytes: 256
#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()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr 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)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int a, b;
	cin>>a>>b;
	if(a<=5){
		cout<<0<<'\n';
	}
	else if(a<=12){
		cout<<b/2<<'\n';
	}
	else{
		cout<<b<<'\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<cmath>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<stdio.h>
#include<queue>
using namespace std;
int sum[100001];
int main()
{
  int n;
  cin>>n;
  int maxNumber=0;
  for(int i=1;i<=n;i++)
  {
    int a;
    cin>>a;
    sum[a-1]++;
    sum[a]++;
    sum[a+1]++;
    maxNumber=max(maxNumber,a);
  }
  int ans=0;
  for(int i=1;i<=maxNumber+1;i++)
    ans=max(ans,sum[i]);
  cout<<ans<<endl;
  system("pause");
  return 0;
}

Measured memory_bytes: 888
def solve trans,m,n
  prev = Array.new(n,1.0)
  (m-1).times do
    cur = Array.new(n,0)
    n.times do |i|
      n.times do |j|
        cur[i] = [cur[i], prev[j]*trans[j][i]].max
      end
    end
    cur,prev = prev,cur
  end
  prev.max
end

loop do
  n,m = gets.chomp.split.map{|i|i.to_i}
  break if n==0
  trans = []
  n.times do
    trans << gets.chomp.split.map{|i|i.to_f}
  end
  puts "%.2f" % solve(trans,m,n)
end

Measured memory_bytes: 6176
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def divider(N):
    threshold = int(sqrt(N))
    res = defaultdict(int)
    for n in range(2,threshold+1):
        while N % n == 0:
            res[n] += 1
            N //= n
    if N > 1:
        res[N] += 1
    return res

def main():
    N = int(input())
    res = divider(N)
    #print(res)
    ans = 0
    for k,v in res.items():
        i = 1
        while True:
            if v < i:
                break
            v -= i
            i += 1
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 72720
#include<iostream>
#include<cstring>
using namespace std;
bool prime[10001];

bool make(){
  memset(prime,true,sizeof(prime));
  prime[0]=prime[1]=false;
  for(int i=0;i<10001;i++)
    {
      if(prime[i])
	for(int j=i+i;j<10001;j+=i)
	  prime[j]=false;
    }
}

int main()
{
  make();
  int n;
  for(;cin>>n,n;)
    {
      for(int i=n;;i--)
	{
	  if(prime[i]&&prime[i-2])
	    {
	      cout<<i-2<<" "<<i<<endl;
	      break;
	    }
	}
    }
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int r, c;

    cin >> r >> c;
    int rc[r + 1][c + 1];

    rep(i, r + 1)
    {
        rep(j, c + 1)
        {
            rc[i][j] = 0;
        }
    }

    rep(i, r)
    {
        rep(j, c)
        {
            cin >> rc[i][j];
            rc[i][c] += rc[i][j];
            rc[r][j] += rc[i][j];
            rc[r][c] += rc[i][j];
        }
    }

    rep(i, r + 1)
    {
        rep(j, c + 1)
        {
            cout << rc[i][j];
            if (j != c)
            {
                cout << " ";
            }
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define testing 1
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
#define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <int, int> pi;
typedef tuple<int,int,int> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 500;
const long long oo = (ll)1e18 + 500;
template <typename T> void chmax(T& a, T b) { a = max(a, b); }
template <typename T> void chmin(T& a, T b) { a = min(a, b); }
const int MAXN = 1e5+5;
#if !testing
#define cerr if(0)cout
#endif
ll dp[MAXN];

ll qexp(ll a, ll b, ll mod) {
	ll res = 1;
	a%=mod;
	while(b) {
		if(b&1)res=res*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return res;
}
int32_t main() 
{
	IAMSPEED
	ll n,k; cin >> n >> k;
	ll ans = 0;
	DEC(i,k,1) {
		dp[i] += qexp((k/i),n,MOD);
		for(int j=i*2;j<MAXN;j+=i) {
			dp[i] = (dp[i] + MOD - dp[j]) % MOD;
		}
		dp[i]%=MOD;
		ans += dp[i]*i;
		ans %=MOD;
	}
	cout << ans;
}


Measured memory_bytes: 4432
/*@author Vipen Loka*/
#include <bits/stdc++.h>
#define endl '\n'
#define ff first
#define ss second
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define deb(x) cout << #x << ':' << x << '\n';

using namespace std;
ll raise(ll n,ll p){
	ll r=1;
	while(p--){
		r*=n%mod;
		r%=mod;
	}
	return r;
}

void solve(){
	int i,j;
	ll n;
	cin >> n;
	if (n<2){
		puts("0");
		return;
	}

	ll c=raise(10,n);
	ll pa=c-raise(9,n),pb=c-raise(9,n);
	ll pab=c-raise(8,n);

	ll ans=pa+pb-pab;
	ans%=mod;
	if(ans<0)ans+=mod;

	printf("%lld\n",ans);
}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    
	int T=1;
	// cin >> T;
	while (T--){
		solve();
	}
}


Measured memory_bytes: 3708
#include<stdio.h>
int main(){
	int a,b,c;
	while(1){
		scanf("%d %d %d",&a,&b,&c);
		if(a==-1&&b==-1&&c==-1)break;
		if(a==-1||b==-1)printf("F\n");
		else if(a+b>=80)printf("A\n");
		else if(a+b>=65)printf("B\n");
		else if(a+b>=50)printf("C\n");
		else if(a+b>=30){
			if(c>=50)printf("C\n");
			else printf("D\n");
		}else printf("F\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const ll INF = 1001001001;
const ll MOD = 1e9 + 7;

int main(){
  map<ll, ll> mp;
  ll n, m;
  cin >> n >> m;
  rep(i, n){
    ll a;
    cin >> a;
    mp[-a]++;
  }
  rep(i, m){
    ll b, c;
    cin >> c >> b;
    mp[-b] += c;
  }
  ll ans = 0;
  for(pair<ll, ll> x : mp){
    n -= x.second;
    if(n < 0){
      ans -= x.first * (x.second + n);
      break;
    }else{
      ans -= x.first * x.second;
    }
  }
  cout << ans <<endl;
}
    

Measured memory_bytes: 16108
import sys
input = sys.stdin.readline
def main():
    X, K, D = map(int, input().split())
    M = abs(X)%D
    S = abs(X)//D
    C = K - S 
    if C < 0:
        ans = abs(X) - K*D
    else:
        if M <= abs(M-D):
            if C%2 == 0:
                ans = M
            else:
                ans = abs(M - D)
        else:
            C -= 1
            if C%2 != 0:
                ans = M
            else:
                ans = abs(M - D)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; i++)
using p = pair<int,int>;
int main(){
    int h,w;
    long long m;
    cin >> h >> w >> m;
    vector <int> xx(h);
    vector <int> yy(w);
    set <p> s;
    rep(i,m){
        int x,y;
        cin >> x >> y;
        --x; --y;
        xx[x] += 1;
        yy[y] += 1;
        s.emplace (x,y);
    }
    int mx = 0;
    int my = 0;
    rep(i,h) mx = max(mx,xx[i]);
    rep(i,w) my = max(my, yy[i]);
    int ans = mx + my;
    vector<int> xm,ym;
    rep(i,h){
        if (xx[i] == mx) xm.push_back(i);
    }
    rep(i,w){
        if (yy[i] == my) ym.push_back(i);
    }
    for (int j : xm) for (int k : ym){
        if (s.find({j,k}) == s.end()){
            cout << ans << endl;
            return 0;
        }
    }
    ans -= 1;
    cout << ans << endl;
}

Measured memory_bytes: 23788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

using Graph = vector<vector<int>>;

int main(){
	string s;
	cin >> s;
	rep(i, s.length()) cout << "x";
	cout << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000000
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::string S, T;

  std::cin >> S >> T;

  int s = S.size(), t = T.size(), cm = INF;

  for (int i = 0; i <= s - t; i ++) {
    int c = 0;
  
    for (int j = 0; j < t; j ++)
      if (S[j + i] != T[j])
        c ++;

    cm = std::min(c, cm);
  }

  std::cout << cm << std::endl;

  return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
long long int K, P, r, ans;
int main()
{
    cin >> K;
    P = 100;
    while(true)
    {
        P = P + (P/100);
        ans++;
        if(P>=K)
            break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
N = int(input())
A_list = list(map(int, input().split()))
 
calculator = 0
pluc_index = 0
minus_index = -1
for i in range(N):
    if calculator <= 0:
        calculator += A_list[pluc_index]
        pluc_index += 1
    else:
        calculator -= A_list[minus_index]
        minus_index -= 1
if calculator<0:
  print(-calculator)
else:
  print(calculator)

Measured memory_bytes: 26764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  int a; cin >> a;
  cout << a+a*a+a*a*a << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

// template from zscoder

int d[10];

bool br(int x)
{
    int y = x%10;
    if(d[y]==1)return false;
    x/=10;
    //cout << x << " " << y << endl;
    if(x>0)br(x);
    else return true;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    ll n,k;
    cin >> n >> k;
    int p;
    for(int i = 0; i < k; i++)
    {
        cin >> p;
        d[p]++;
    }
    bool f = false;
    while(!f)
    {
        //cout << n << endl;
        if(br(n))
        {
            f = true;
            cout << n << endl;
        }
        else n++;
    }
}

Measured memory_bytes: 256
#include <stdio.h>


int main() {
    int n;
    int even = 0;
    int divs = 0;
    scanf("%d", &n);
    for(int i=0; i<n; i++) {
        int temp;
        scanf("%d", &temp);
        if(temp%2==0) {
            even++;
            if(temp%3==0 || temp%5==0) {
            divs++;
        }
        }
        
    }
    
    if(even==divs) {
        printf("APPROVED");
    } else {
        printf("DENIED");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>

using namespace std;

//long long MOD = 1000000007;

int main()
{
    unsigned long long n;
    std::cin >> n;

    unsigned long long sum = (n - 1ULL) * n / 2ULL;
    std::cout << sum << std::endl;
    return 0;
}




Measured memory_bytes: 256
package main

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

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

// sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()
	a := make([]int, n+1)
	for i, _ := range a {
		a[i] = readInt()
	}
	b := make([]int, n)
	for i, _ := range b {
		b[i] = readInt()
	}

	ans := 0
	for i := 0; i < n; i++ {
		left := min(a[i], b[i])
		ans += left
		a[i] -= left
		b[i] -= left

		right := min(a[i+1], b[i])
		ans += right
		a[i+1] -= right
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5120
from itertools import combinations_with_replacement

n,m,q = map(int,input().split())
a = [list(map(int,input().split())) for i in range(q)]
com = list(combinations_with_replacement(range(1,m + 1), n))
max_ = 0

for v in com:
    
    tot = 0
    for u in a:
        if v[u[1] - 1] - v[u[0] - 1] == u[2]:
            tot += u[3]
    if tot > max_:
        max_ = tot
        
print(max_)

Measured memory_bytes: 21624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    string s, t;
    cin >> s;
    cin >> t;
    int m = s.size();
    int n = t.size();

    int mincount = m;
    for (int i = 0; i < m - n + 1; i++) {
        int count = 0;
        for (int k = 0; k < n; k++) {
            if (t[k] != s[i + k]) {
                count++;
            }
        }
        if (mincount > count) {
            mincount = count;
        }
    }
    cout << mincount << endl;
    return 0;
}

Measured memory_bytes: 3632
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func Sum(A []int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}

func DFS(T, ST *[][]int, u, v int) int {
  N := len((*T))
  for _, adj := range (*T)[v] {
    if adj == u { continue }
    d := DFS(T, ST, v, adj)
    (*ST)[v] = append((*ST)[v], d)
  }
  s := Sum((*ST)[v]) + 1
  if u != -1 {
    (*ST)[v] = append((*ST)[v], N - s)
  }
  return s
}

const p = 1000000007
const p2 = 500000004

func main() {
  N := NextInt()
  T := make([][]int, N)
  for i := 1; i < N; i++ {
    AB := NextIntVec()
    A, B := AB[0] - 1, AB[1] - 1
    T[A] = append(T[A], B)
    T[B] = append(T[B], A)
  }
  ST := make([][]int, N)
  DFS(&T, &ST, -1, 0)
  B := make([]int, N + 1)
  B[0] = 1
  for i := 0; i < N; i++ {
    B[i + 1] = B[i] * p2 % p
  }
  ans := 0
  for _, S := range ST {
    cnt := p2 + (len(S) - 1) * B[N]
    for _, s := range S {
      cnt -= B[N - s]
    }
    if cnt < 0 { cnt += (-cnt / p) * p }
    if cnt < 0 { cnt += p }
    ans += cnt
  }
  Write(ans % p)
  Output()
}


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

int main() {
  int64_t N, A, B;
  cin >> N >> A >> B;
  
  int64_t pairs=0;
  int64_t mod;
  
  pairs = N/(A+B);
  mod = N%(A+B);
  
  if(mod >= A) cout << A*pairs+A;
  else cout << A*pairs+mod;
  

}

Measured memory_bytes: 256
H,W,D=map(int, input().split())
A=[()]*(H*W+1)
for i in range(H):
    for j,a in enumerate(map(int, input().split())):
        A[a]=(i,j)
Q=int(input())
LR=[tuple(map(int, input().split())) for _ in range(Q)]

def distance(a,b): return abs(a[0]-b[0]) + abs(a[1]-b[1])

dist=[0]*(H*W+1)
for o in range(1,D+1):
    for i in range(o+D,H*W+1,D):
        dist[i]=dist[i-D]+distance(A[i],A[i-D])

for L,R in LR:
    print(dist[R]-dist[L])

Measured memory_bytes: 73428
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                void solve(){
                    ll x;
                    cin>>x;
                    if(x >= 30)
                        cout<<"Yes\n";
                    else
                        cout<<"No";
                }
                int main(){ 
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                //cout<<"Case #"<<i<<": ";
                                solve();
                         }
        return 0; 
}         
 
 

Measured memory_bytes: 3652
if __name__ == "__main__":
    N = int(input())
    M = []
    A = []
    R = []
    C = []
    H = []
    for i in range(N):
        buf = str(input())
        if buf[0] == 'M':
            M.append(buf)
        elif buf[0] == 'A':
            A.append(buf)
        elif buf[0] == 'R':
            R.append(buf)
        elif buf[0] == 'C':
            C.append(buf)
        elif buf[0] == 'H':
            H.append(buf)
    M_cnt = len(M)
    A_cnt = len(A)
    R_cnt = len(R)
    C_cnt = len(C)
    H_cnt = len(H)
#    obj = {'M':M_cnt, 'A':A_cnt, 'R':R_cnt, 'C':C_cnt, 'H':H_cnt}
    cnt =  M_cnt * A_cnt * R_cnt + \
           M_cnt * A_cnt * C_cnt + \
           M_cnt * A_cnt * H_cnt + \
           M_cnt * R_cnt * C_cnt + \
           M_cnt * R_cnt * H_cnt + \
           M_cnt * C_cnt * H_cnt + \
           A_cnt * R_cnt * C_cnt + \
           A_cnt * R_cnt * H_cnt + \
           A_cnt * C_cnt * H_cnt + \
           R_cnt * C_cnt * H_cnt
    print(cnt)

Measured memory_bytes: 10352
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>


using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 

long long int odddp[2030]={},evendp[2030]={},res=0;
long long int N,M;


int main()
{
    cout << fixed << setprecision(18);
    cin>>N>>M;
    IFYes((N*M)%2==1);

}    


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}


int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int_fast64_t N, M;
	cin >> N >> M;
	vector<int_fast64_t> A(N);
	REP(i, N) cin >> A[i];
	unordered_map<int_fast64_t, int_fast64_t> mp;
	int_fast64_t sum = 0,res = 0;
	mp[0]++;
	REP(i, N){
		sum += A[i];
		sum %= M;
		res += mp[sum];
		mp[sum]++;
	}
	cout << res << endl;
}


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

int main() {
	int K, T;
	cin >> K >> T;
	int m = 0;
	rep(i, T) {
		int a;
		cin >> a;
		if (m < a) m = a;
	}
	cout << max(2 * m - K - 1, 0) << endl;
	return 0;
}

Measured memory_bytes: 256
function main()
	N=parse(Int,readline())
	A=Pair{Int,Int}[]
	id=0
	for a=map(x->parse(Int,x),split(readline()))
		id+=1
		push!(A,a=>id)
	end
	sort!(A)
	reverse!(A)
	dp=zeros(Int,N+1,N+1)
	for i=1:N,j=1:i
		k=N+1-(i-j)
		dp[j+1,k]=max(dp[j+1,k],dp[j,k]+A[i].first*abs(A[i].second-j))
		dp[j,k-1]=max(dp[j,k-1],dp[j,k]+A[i].first*abs(A[i].second-(k-1)))
	end
	ans=0
	for i=1:N+1
		ans=max(ans,dp[i,i])
	end
	println(ans)
end
main()


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

int main()
{
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  for (int i=0;i<n;i++)
    cin>>a[i];
  int dp[n];
  dp[0]=0;
  for(int i=1;i<n;++i)
  {
    dp[i]=INT_MAX;
    for(int j=1;j<=k&&j<=i;j++)
      dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
  }
  cout<<dp[n-1]<<endl;
  return 0;
}
    

Measured memory_bytes: 1024
from collections import Counter
import math

N = int(input())
def prime_factors(n):
    """Returns all the prime factors of a positive integer"""
    factors = []
    d = 2
    while n > 1:
        while n % d == 0:
            factors.append(d)
            n /= d
        d = d + 1
        if d*d > n:
            if n > 1: factors.append(int(n))
            break
    return factors


def count_moves(exponents):
    num = 0
    for ex in exponents:
        num += math.floor(0.5*(math.sqrt(8*ex+1) - 1))

    return num


pf = prime_factors(N)
pf = Counter(pf)
exponents = list(pf.values())
ans = count_moves(exponents)

print(ans)


Measured memory_bytes: 9548
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	long long a, b, n;
	cin >> a >> b >> n;
	
	auto calc = [&](long long x) {
		return (a*(x%b)-((a%b)*x)%b)/b;
	};

	
	cout << max(calc(min(n,b-1)), calc(min(n,a%b?b/(a%b):1)));


	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int n; cin >>n;
  vector<int> a(n); rep(i, n) cin >>a[i];
  int sum = 0;
  rep(i, n){
    sum += a[i]; a[i] *= n;
  }
  int res = 0;
  int sub = abs(a[0] - sum);
  for (int i=1; i<n; i++){
    if (sub > abs(a[i] - sum)){
      res = i;
      sub = abs(a[i] - sum);
    }
  }
  cout <<res <<endl;
}

Measured memory_bytes: 256
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>> 
#define vi vector<int>
#define vpii vector<pair<int,int>> 
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>> 
#define pii pair<int,int> 
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>

ld pie=3.141592653589793238462643383279;
int mod=1e9+7;

struct point{
  ld x,y;
};

vvi mat_mul(vvi mat1,vvi mat2){
  vvi ret;
  f(i,0,2){
    vi xx;
    f(j,0,2){
      int r=0;
      f(k,0,2) r=(r+(mat1[i][k]*mat2[k][j])%mod)%mod;
      xx.pb(r%mod);
    }
    ret.pb(xx);
  }
  return ret;
}

vvi mat_exp(vvi mat,int p){
  vvi iden={{1,0},{0,1}};
  while(p!=0){
    if(p&1) iden=mat_mul(iden,mat);
    p/=2; 
    mat=mat_mul(mat,mat);
  }
  return iden;
}


int myexp(int p){
  p++;
  int r=1;
  int val=2;
  while(p!=0){
    if(p&1){
      r*=val;
    }
    val*=val;
    p/=2;
  }
  r-=2;
  return r;
}


int fact[2000005];
int infact[2000005];
 
int inv(int a){
  int y=mod-2;
  int r=1;
  while(y!=0){
    if(y&1){
      r*=a; r%=mod;
    }
    y/=2; a*=a; a%=mod;
  }
  return r;
}
 
int po(int a,int y){
  int r=1;
  while(y!=0){
    if(y&1){
      r*=a; r%=mod;
    }
    y/=2; a*=a; a%=mod;
  }
  return r; 
}
 
void facto(){
  fact[0]=1;
  f(i,1,2000005) {fact[i]=i*fact[i-1]; fact[i]%=mod;}
  f(i,0,2000005) infact[i]=inv(fact[i]); 
}
 
int nck (int n,int k){
  if(k<0 || k>n) return 0;
  int ret=fact[n]; ret*=infact[k]; ret%=mod;
  ret*=infact[n-k]; ret%=mod;
  return ret;
}
  
void mymul(int arr[],int num){
  int carry=0;
  f(i,0,100){
    arr[i]=arr[i]*num+carry;
    carry=arr[i]/10;
    arr[i]%=10;
  }
}

map<int,int> mp;

int myfun(int val){
  auto it = mp.lower_bound(val);
  if(it==mp.begin()) return 0;
  --it; 
  return it->second;
}

void myerase(int val,int key){
 
}

int32_t main(){ 
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  int a,b; cin>>a>>b;
  cout<<(a+b+1)/2;
  return 0; 
}
// check for overflows dummy !!!

Measured memory_bytes: 3652
import sys
input = sys.stdin.readline
def myAnswer(N:int,guidebook:dict) -> None:
   ans = sorted(guidebook.items())
   for _,ary in ans:
      tmp = sorted(ary.items(),reverse=True)
      for t in tmp:
         print(t[1])
      

def modelAnswer():
   tmp=1
def main():
   N = int(input())
   guidebook = {}
   for n in range(N):
      s,p = map(str,input().split())
      if(s in guidebook.keys()):
         guidebook[s][int(p)]=n+1
      else:
         guidebook[s]={int(p):n+1}
   myAnswer(N,guidebook)


if __name__ == '__main__':
   main()

Measured memory_bytes: 3064
n=int(input())
import math
ans=10**12
i=0
while i*i<=n:
  i+=1
  if n%i!=0:
    continue
  j=n/i
  ans=min(ans, i+j-2)
if ans ==10**12:
  print(n-1)
else:
  print(int(ans))


Measured memory_bytes: 64124
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int h, w;
	cin >> h >> w;
	char a[101][101];
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			cin >> a[i][j];
		}
	}
	for (int i = -1;i <= h;i++) {
		for (int j = -1;j <= w;j++) {
			if (i == -1 || i == h || j == -1 || j == w) {
				cout << "#";
			}
			else {
				cout << a[i][j];
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

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

//Work

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

   
//-----------------------------------------------------------------------------------------------------------//

    READV(H);
    READV(N);
    pll A[N];
    FORI(i,0,N)
    {
        READ(A[i].fi);
        READ(A[i].se);
    }
    vecl X(H+1,inf);
    X[0]=0;
    FORI(i,1,H+1)
    {
        FORI(j,0,N)
        {
            if(A[j].fi>i)
            {
                X[i]=min(X[i],A[j].se);
            }
            else
            {
                X[i]=min(X[i],X[i-A[j].fi]+A[j].se);
            }
        }
    }
    cout<<X[H]<<endl;

//-----------------------------------------------------------------------------------------------------------//


    
    return 0;
}

Measured memory_bytes: 384
// D - Flat Subsequence
#include <bits/stdc++.h>
using namespace std;

#include <atcoder/segtree>
int op(int a, int b){ return max(a,b); } // 処理
int e(){ return 0; } // 単位元
using MONOID = int;
using SEG_T = atcoder::segtree<MONOID, op, e>;
#define SEGT_MAX 300001

int main(){
	int n, k; cin>>n>>k;
	SEG_T seg(SEGT_MAX);
	for(int i=0; i<n; ++i){
		int a; cin>>a;
		int l = max(0, a - k);
		int r = min(a + k + 1, SEGT_MAX);
		int longest = seg.prod(l, r); // [l,r)
		seg.set(a, longest + 1);
	}
	cout<< seg.all_prod() <<endl;
}


Measured memory_bytes: 8500
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N, K = MI()
A = LMI()

from math import log2


class Doubling(object):

    def __init__(self, N, K, next0):
        """
        ダブリングのメモ構築 O(NlogK)
        :param N: 解の存在空間の大きさ
        :param K: K個先までのステップを考慮する
        :param next0: i番目の要素の1個先の番号を要素として持つリスト
                      次の要素が存在しない場合には-1を要素として保持する
        """
        next = [[0] * N for _ in range(int(log2(K)) + 1)]
        next[0] = next0
        for k in range(int(log2(K))):
            for i in range(N):
                if next[k][i] == -1:
                    # 2^k個次に要素が無い時、当然2^(k+1)個次にも要素はない
                    next[k + 1][i] = -1
                else:
                    # i番目の要素の2^(k+1)個次の要素 := next[k][i](i番目の要素の2^k個次の要素)の2^k個先
                    next[k + 1][i] = next[k][next[k][i]]
        self.next = next

    def query(self, p, K):
        """
        p番目の要素のK個次の要素を求める O(logK)
        """
        for i in reversed(range(int(log2(K)) + 1)):
            if p == -1:
                break
            if (K >> i) & 1:
                p = self.next[i][p]
        return p


d = Doubling(N, K, [a - 1 for a in A])
print(d.query(0, K) + 1)


Measured memory_bytes: 175688
#include<bits/stdc++.h>
#define fi        first
#define se        second
#define pb        push_back
#define PI        acos(-1)
#define LC(a)     ((a<<1))
#define RC(a)     ((a<<1)+1)
#define MID(a,b)  ((a+b)>>1)
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS()     std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<ll,ll>   PLL;
typedef pair<ll,int>  PLI;
const int INF = 0X3F3F3F3F;
const int MIN = -(1<<30);
const ll N = 1e5+7;
const ll mod = 1e9+7;
inline void solve()
{
	ll n,k;cin>>n>>k;
	ll ans = 0;
	for(ll i=k;i<=n+1;i++)
	{
		ans = (ans+(n+n-i+1)*i/2-(i-1)*i/2+1)%mod; 
	}
	cout<<ans<<endl;

}
int main()
{
	IOS();
 solve();
	return 0;
}




Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main() {
  int K, S;
  cin >> K >> S;
  int x, y, z;
  int ans = 0;
  for(x = 0; x <= K; x++) {
    for(y = 0; y <= K; y++) {
      z = S - x - y;
      if(z <= K and z >= 0) ans++;
    }
  }
  cout << ans << endl;
}


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

int main(){
  int N,loop;
  cin >> N;
  double A,ans;
  for(loop=0;loop<N;loop++){
    cin >> A;
    A=1/A;
    ans+=A;
  }
  ans=1/ans;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	if N%digitSum(N) == 0 {
		fmt.Fprintln(wtr, "Yes")
	} else {
		fmt.Fprintln(wtr, "No")
	}

	wtr.Flush()
}

func digitSum(n int) int {
	res := 0
	for n > 0 {
		res += n % 10
		n /= 10
	}
	return res
}


Measured memory_bytes: 640