akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define rep(i,a,b) for (i=a;i<=b;i++)
typedef long long ll;
#define maxd 1e9+7
int n;
multiset<ll> a,b;
struct node{
    int x,y;
}ball[200500];

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

ll query()
{
    return ((*a.rbegin()-*a.begin())*(*b.rbegin()-*b.begin()));
}

bool cmp(node p,node q)
{
    return ((p.x<q.x) || ((p.x==q.x) && (p.y<q.y)));
}

int main()
{
    n=read();int i;
    for (i=1;i<=n;i++)
    {
        ball[i].x=read();ball[i].y=read();
        if (ball[i].x>ball[i].y) swap(ball[i].x,ball[i].y);
        a.insert(ball[i].x);
        b.insert(ball[i].y);
    }
    ll ans=query();
    sort(ball+1,ball+1+n,cmp);
    for (i=1;i<=n;i++)
    {
        int nx=ball[i].x,ny=ball[i].y;
        a.erase(a.find(nx));b.erase(b.find(ny));
        a.insert(ny);b.insert(nx);
        ans=min(ans,query());
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 20608
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double PI=3.1415926535897932;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod

const ll DEKAI=1e9+1;
int main(){
    ll Q; cin>>Q;
    vec ans;
    rep(i,Q){
        ll a,b; cin>>a>>b;
        if(a>b) swap(a,b);
        ll K=a*b;
        K--;
        ll BIG=DEKAI,SMALL=0;
        while(BIG>SMALL+1){
            ll MID=(BIG+SMALL)/2;
            if(MID*MID<=K) SMALL=MID;
            else BIG=MID;
        }
        ll X=2*SMALL;
        if(SMALL*(SMALL+1)>K) X--;
        if(SMALL>=a) ans.pb(X-1);
        else ans.pb(X);

    }
    rep(i,Q) cout<<ans[i]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/agc011_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<ll> c(N);
  rep(i, N) { cin >> c[i]; }
  sort(c.begin(), c.end());

  vector<ll> sum(N);

  sum[0] = c[0];
  repi(i, 1, N) { sum[i] = sum[i - 1] + c[i]; }

  int j = -1;
  rep(i, N - 1) {
    ll a = sum[i] * 2;
    if (a < c[i + 1]) {
      j = i;
    }
  }

  ll ans = N - (j + 1);
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	ll N;
	cin >> N;

	auto result = 0ll;
	if (N % 2 == 0)
	{
		for (auto i = 5ll; i * 2 <= N; i *= 5)
		{
			result += N / (i * 2);
		}
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
ABCD = input()
if int(ABCD[0]) + int(ABCD[1]) + int(ABCD[2]) + int(ABCD[3]) == 7: print(ABCD[0] + "+" + ABCD[1] + "+" + ABCD[2] + "+" + ABCD[3] + "=7")
elif int(ABCD[0]) + int(ABCD[1]) + int(ABCD[2]) - int(ABCD[3]) == 7: print(ABCD[0] + "+" + ABCD[1] + "+" + ABCD[2] + "-" + ABCD[3] + "=7")
elif int(ABCD[0]) + int(ABCD[1]) - int(ABCD[2]) + int(ABCD[3]) == 7: print(ABCD[0] + "+" + ABCD[1] + "-" + ABCD[2] + "+" + ABCD[3] + "=7")
elif int(ABCD[0]) + int(ABCD[1]) - int(ABCD[2]) - int(ABCD[3]) == 7: print(ABCD[0] + "+" + ABCD[1] + "-" + ABCD[2] + "-" + ABCD[3] + "=7")
elif int(ABCD[0]) - int(ABCD[1]) + int(ABCD[2]) + int(ABCD[3]) == 7: print(ABCD[0] + "-" + ABCD[1] + "+" + ABCD[2] + "+" + ABCD[3] + "=7")
elif int(ABCD[0]) - int(ABCD[1]) + int(ABCD[2]) - int(ABCD[3]) == 7: print(ABCD[0] + "-" + ABCD[1] + "+" + ABCD[2] + "-" + ABCD[3] + "=7")
elif int(ABCD[0]) - int(ABCD[1]) - int(ABCD[2]) + int(ABCD[3]) == 7: print(ABCD[0] + "-" + ABCD[1] + "-" + ABCD[2] + "+" + ABCD[3] + "=7")
elif int(ABCD[0]) - int(ABCD[1]) - int(ABCD[2]) - int(ABCD[3]) == 7: print(ABCD[0] + "-" + ABCD[1] + "-" + ABCD[2] + "-" + ABCD[3] + "=7")
              

Measured memory_bytes: 38384
#include<iostream>
#include<queue>
#include<string>
using namespace std;

int main()
{
	int i,n,q,x,sum=0;
	string str;
	queue<string> name;
	queue<int> time;

	cin >> n >> q;

	for(i=0;i<n;i++){
		cin >> str >> x ;
		name.push(str);
		time.push(x);
	}

	while(!name.empty()){
		if((time.front() - q) > 0 ){
			x = time.front() - q;
			time.pop();
			time.push(x) ;
			str = name.front();
			name.pop();
			name.push(str);
			sum = sum + q;
		}
		if((time.front()-q) <= 0){
			sum = sum + time.front();
			cout << name.front() << ' ' << sum <<endl ;
			name.pop();
			time.pop();
		}
	}

	return 0;
}


Measured memory_bytes: 5664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    const ll inf = 1LL<<59;
    ll W, H; cin >> W >> H;
    vector<ll> p(W+1), q(H+1);
    for(int i=0; i<W; ++i) cin >> p[i];
    for(int i=0; i<H; ++i) cin >> q[i];
    p[W] = q[H] = inf;
    sort(p.begin(), p.end());
    sort(q.begin(), q.end());


    ll ans = 0;
    ll row = H+1, cul = W+1;

    int i = 0, j = 0;
    for(int loop=0; loop<H+W; ++loop){
        //printf("p[i]: %lld, q[j]: %lld\n", p[i], q[j]);
        if(p[i] <= q[j]){
            ans += p[i]*row;
            ++i;
            --cul;
        }
        else{
            ans += q[j]*cul;
            ++j;
            --row;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

#define MAX 100005
#define NIL -1

typedef struct {int p, l, r;} Node;

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if( T[u].p == NIL ) printf("root, ");
  else if( T[u].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0, c=T[u].l; c != NIL; i++, c=T[c].r) {
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

void rec(int u, int p) {
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}

int main(void) {
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;
  for(i=0;i<n;i++) {
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++) {
      scanf("%d",&c);
      if(j==0) T[v].l=c;
      else T[l].r =c;
      l = c;
      T[c].p = v;
    }
  }
  for(i=0;i<n;i++) {
    if(T[i].p == NIL) r = i;
  }
  
  rec(r,0);
  
  for(i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 6392
#include<bits/stdc++.h>
using namespace std;
int main(){
long long a,b,n;
cin>>a>>b>>n;
long long A[a];
long long mina=1000000;
for(long long i=0;i<a;i++){
    cin>>A[i];
    if(mina>A[i]){
        mina=A[i];
    }
}
long long B[b];
long long minb=1000000;
for(long long i=0;i<b;i++){
    cin>>B[i];
    if(minb>B[i]){
        minb=B[i];
    }
}
long long ans=mina+minb;
long long x,y,c;
for(long long i=0;i<n;i++){
    cin>>x>>y>>c;
    if(ans>A[x-1]+B[y-1]-c){
        ans=A[x-1]+B[y-1]-c;
    }
}
cout<<ans<<endl;
    return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong A, B;
	cin >> A >> B;

	cout << B/A + (B%A!=0) << endl;

	return 0;
}


Measured memory_bytes: 3092
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
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(a > b){a = b; return 1;} return 0;}


int main(int argc, char const* argv[])
{
  int n, q;
  cin >> n >> q;
  vector<ll> a(n+1);
  vector<ll> sum(n+1), even(n+1);
  rep(i, n){
    cin >> a[i];
    sum[i] = a[i];
    if(i > 0)sum[i] += sum[i-1];
    even[i] = a[i];
    if(i > 1)even[i] += even[i-2];
  }
  if(n % 2 == 1){
    for(int i = n - 1; i >= 0; i--)a[i+1] = a[i];
    for(int i = n - 1; i >= 0; i--)sum[i+1] = sum[i];
    for(int i = n - 1; i >= 0; i--)even[i+1] = even[i];
    a[0] = sum[0] = even[0] = 0;
    n++;
  }
  rep(i, q){
    ll x;
    cin >> x;
    int ld = 0;
    int rd = n / 2;
    while(rd - ld > 1){
      int p = (rd + ld) / 2;
      if(x < a[n-2*p] && n-2*p>0 && abs(x-a[n-2*p])>abs(x-a[n-2*p-1])){
        ld = p;
      }else if(x > a[n-p-1] && abs(x-a[n-p-1]) > abs(x-a[n-p])){
        rd = p - 1;
      }else{
        if(abs(x-a[n-2*p+1]) > abs(x-a[n-p])){
          rd = p - 1;
        }else if(n-2*p-1>=0 && abs(x-a[n-2*p-1]) <= abs(x-a[n-p-1])){
          ld = p;
        }else{
          rd = p;
          break;
        }
      }
    }
    ll res = 0;
    res = sum[n - 1] - sum[n - rd - 1];
    if(n-2*rd-1>=0)res += even[n-2*rd-1];
    cout << res << endl;
  }
	return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    
    int S;
    cin >> S;
    
    int h,m,s;
    
    h=S/3600;
    m=S%3600/60;
    s=S%60;
    cout << h <<':'<<m<<':'<<s<<endl;
}



Measured memory_bytes: 3068
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr int mod = 1e9+7;
void add(int &a,int b) {a+=b; if(a>=mod) a-=mod;}
void dec(int &a,int b) {a-=b; if(a<0) a+=mod;}
#define int long long 
int32_t main()
{
    int n;
    cin >> n;
    vector<int > a(n+10), sum(n+10);
    for(int i =1; i <= n; i++){
        cin >> a[i];
    }
    sum[1] = a[1];
    for(int i = 3; i <= n; i += 2){
        sum[i] = sum[i-2] + a[i];
    }

    vector<int > dp(n+10);
    for(int i = 2; i <= n; i++){
        if(i % 2 == 1){
            dp[i] = max(dp[i-1], dp[i-2]+a[i]);
        }else {
            dp[i] = max(sum[i-1], dp[i-2]+a[i]);
        }
    }

    cout << dp[n] << endl;
}

Measured memory_bytes: 8004
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s, t; cin >> s >> t;
    cout << t << s << endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
v=[0]*n
a=[int(input()) for _ in range(n)]
b=[int(input()) for _ in range(m)]
for i in b:
    for j in range(n):
        if a[j]<=i:
            v[j]+=1
            break
print(v.index(max(v))+1)

Measured memory_bytes: 7752
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string.h>
using namespace std;
typedef long long int llint;
int main() {
	char s[15];
	char ans[15];
	cin >> s;
	int len = 0;
	for (int i = 0;i < strlen(s);i++) {
		if (s[i] == '0' || s[i] == '1') {
			ans[len] = s[i];
			len++;
		}
		else {
			if (len == 0) {
				continue;
			}
			else {
				ans[len] = '\0';
				len--;
			}
		}
	}
	for (int i = 0;i < len;i++) {
		cout << ans[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 0; i < (o);i++)
#define rep_s(i, o) for (int i = 1; i <= (o);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

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


template<class T>
bool chmax(T &a, const T &b) { if (a < b) { return b; } return a; }

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

int main() {
    ll n; cin >> n;
    vector<ll> a(n), s(n+1);
    vector<ll> count_n(1000002);
    rep(i, n) {
        cin >> a[i]; count_n[a[i]]++;
        if (i != 0) s[i] = s[i-1] + a[i-1];
        // cout << s[i] << endl;
    }
    s[n] = s[n-1] + a[n-1];
    // cout << s[n] << endl;
    // rep(i, n+2) cout << count_n[i] << endl;

    ll q; cin >> q;
    ll sum[q] = {0};
    rep(i, q) {
        ll b, c; cin >> b >> c;
        sum[i] = s[n] + (c-b) * count_n[b];
        count_n[c] += count_n[b];
        count_n[b] -= count_n[b];
        s[n] = sum[i];
        // rep(i, n+2) cout << count_n[i] << endl;
    }

    rep(i, q) {
        cout << sum[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 13544
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

int main () {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];

  int avg = SUM(a)/n;
  int avg2 = dup(SUM(a),n);

  int ans = INF;

  int res = 0;
  rep(i,n) {
    res += (a[i]-avg)*(a[i]-avg);
  }
  int res2 = 0;
  rep(i,n) {
    res2 += (a[i]-avg2)*(a[i]-avg2);
  }

  ans = min({ans,res,res2});

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <numeric>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 2 - 170;

int main() {
    int n, h;
    cin >> n >> h;
    vector<int> v;
    int x = 0;
    for (int i = 0; i < n; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        v.emplace_back(b);
        x = max(x, a);
    }
    sort(v.begin(), v.end(), greater<>());
    partial_sum(v.begin(), v.end(), v.begin());
    int ans = INF<int>;
    for (int i = 0; i < n; ++i) {
        if(h <= v[i]){
            ans = min(ans, i+1);
            break;
        }else {
            ans = min(ans, (h-v[i]+x-1)/x+i+1);
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 892
n = int(input())
l = []
answer = "Yes"
t = 0
for i in range(n):
    a, b = map(int,input().split())
    l.append([a,b])
d=sorted(l, key=lambda x:x[1])

for j in range(n):
    t = t + d[j][0]
    if t > d[j][1]:
        answer = "No"
print(answer)


Measured memory_bytes: 39692
// https://atcoder.jp/contests/abc059/tasks/abc059_b

#include <bits/stdc++.h>
using namespace std;

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

    if (a.size() < b.size())
    {
        cout << "LESS" << endl;
        return 0;
    }

    if (a.size() == b.size())
    {
        for (int i = 0; i < a.size(); i++)
        {
            if (a[i] < b[i])
            {
                cout << "LESS" << endl;
                return 0;
            }
            else if (a[i] > b[i])
            {
                cout << "GREATER" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
        return 0;
    }

    if (a.size() > b.size())
    {
        cout << "GREATER" << endl;
        return 0;
    }
}


Measured memory_bytes: 3604
h={}
a,b,c,d,e,f=gets.split.map &:to_i
max = 0
maxe=[a*100,0]
31.times do |i|
  31.times do |j|
    g = i*a*100+j*b*100
    break if g==0
    break if g>f
    r = g / 100 * e
    3000.times do |k|
      rr = r-c*k
      rrr= rr/d
      break if rr<0
      break if g+c*k > f
      if g+c*k+rrr*d > f
        3000.times do |l|
          gg=c*k+l*d
          ggg= gg*100.0/g
          break if g+gg > f
          if e>=ggg && max < ggg
                max = ggg
                maxe= [g+gg,gg]
          end
        end
      end
      gg= c*k+rrr*d
      ggg= gg*100.0/g
      if e>=ggg && max < ggg && g+c*k+rrr*d <= f
            max = ggg
            maxe= [g+gg,gg]
      end
    end
    
    c,d = [d,c]
    3000.times do |k|
      rr = r-c*k
      rrr= rr/d
      break if rr<0
      break if g+c*k > f
      if g+c*k+rrr*d > f
        3000.times do |l|
          gg=c*k+l*d
          ggg= gg*100.0/g
          break if g+gg > f
          if e>=ggg && max < ggg
                max = ggg
                maxe= [g+gg,gg]
          end
        end
      end
      gg= c*k+rrr*d
      ggg= gg*100.0/g
      if e>=ggg && max < ggg && g+c*k+rrr*d <= f
            max = ggg
            maxe= [g+gg,gg]
      end
    end
  end
end
puts maxe.* " "

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI (6.28318530718/2.0)
#define ft first
#define sec second
#define ll long long
#define pb push_back
using namespace std;
int n;
int a[200005],b[200005];
int main()
{
	cin >> n;
	for(int i=0,x,y; i<n; i++)
	{
		cin >> x >> y;
		a[i]=(x+y); b[i]=(x-y);
	}
	sort(a,a+n);
	sort(b,b+n);
	cout << max(a[n-1]-a[0],b[n-1]-b[0]);
}


Measured memory_bytes: 5216
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  if((A+D-1)/D < (C+B-1)/B) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

#define MAX_V 1010

int V;
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}

bool dfs(int v){
  used[v]=true;
  for(int i=0;i<G[v].size();i++){
    int u=G[v][i];
    int w=match[u];
    if(w<0||!used[w]&&dfs(w)){
      match[v]=u;
      match[u]=v;
      return true;
    }
  }
  return false;
}

int bipartite_matching(){
  int res=0;
  //memset(match,-1,sizeof(match));
  for(int i=0;i<=V;i++) match[i]=-1;
  for(int v=0;v<V;v++){
    if(match[v]<0){
      //memset(used,0,sizeof(used));
      for(int j=0;j<=V;j++) used[j]=false;
      if(dfs(v)) res++;
    }
  }
  return res;
}

int N,M;

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

void solve(){
    vector<int> A(N);
    vector<int> B(M);
    for(int i=0;i<N;i++) cin>>A[i];
    for(int i=0;i<M;i++) cin>>B[i];

    for(int i=0;i<=N+M;i++){
        used[i]=false;
        G[i].clear();
    }
    V=N+M;

    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            int z=gcd(A[i],B[j]);
            if(z>1) add_edge(i,j+N);
        }
    }
    cout<<bipartite_matching()<<endl;
}

int main(){
  while (1){
      cin>>N>>M;
      if(N==0) break;
      solve();
  }
  

  return 0;
}



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

using namespace std;

template<typename T>
T myGCD(T numA, T numB) {
    if (numA < numB) swap(numA, numB);
    if (numB == 0) return numA;
    numA = numA % numB;
    return myGCD(numB, numA);
};

template<typename T>
T myLCM(T numA, T numB) {
    return numA * numB / myGCD<T>(numA, numB);
}

int main() {
    long long int a, b, c, d;
    cin >> a >> b >> c >> d;
    long long int divC = b / c - (a - 1) / c;
    long long int divD = b / d - (a - 1) / d;
    auto lcmCD = myLCM<long long>(c, d);
    long long int divCD = b / lcmCD - (a - 1) / lcmCD;
    cout << b - a + 1 - divC - divD + divCD << endl;
    return 0;
}


Measured memory_bytes: 256
import heapq
from collections import defaultdict, deque
from math import ceil, factorial, gcd
from itertools import accumulate, permutations
import sys
import bisect


sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
msi = lambda: map(str, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))


# ----------

N, M = mii()
H = lmii()
G = defaultdict(list)
for i in range(M):
    a, b = mii()
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

ans = 0
for i in range(N):
    if len(G[i]) == 0:
        ans += 1
        continue
    f = H[i]
    t_max = 0
    for to in G[i]:
        t_max = max(t_max, H[to])
    if f > t_max:
        ans += 1

print(ans)

Measured memory_bytes: 106388
#!/usr/bin/env python3

s=input()
t=input()
sl=len(s)
tl=len(t)
ans=10**18
for i in range(sl-tl+1):
    tmp=s[i:i+tl]
    cnt=0
    for j in range(tl):
        if tmp[j]!=t[j]:
            cnt+=1
    ans=min(ans,cnt)
print(ans)

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


int main(){
    int n,w;cin>>n>>w;
    pair<int, int>* wvrr;
    // int *wrr, *vrr;
    long long int** wivdp = new long long int*[w+1];

    for(int i=0;i<w+1;i++){
        wivdp[i] = new long long int[n+1];
        for(int j=0;j<n+1;j++){
            wivdp[i][j]=0;
        }
    }
    wvrr = new pair<int, int>[n];
    // wrr=new int[n];vrr=new int[n];
    for(int i=0;i<n;i++){
        cin>>wvrr[i].first>>wvrr[i].second;
    }

    // sort(wvrr,wvrr+n);

    for(int it=1;it<n+1;it++){
        for(int wt=1;wt<w+1;wt++){
            wivdp[wt][it] = wivdp[wt][it-1];
            //max value without including the item
            //wivdp[wt][it-1];
            //max value after including the item
            //wvrr[it-1].second + wivdp[wt-wvrr[it-1].first][it-1];
            if(wt-wvrr[it-1].first>=0){
                wivdp[wt][it]=max(wivdp[wt][it-1], wvrr[it-1].second + wivdp[wt-wvrr[it-1].first][it-1]  );
            }
        }
    }

    // for(int i=0;i<w+1;i++){
    //     for(int j=0;j<n+1;j++){
    //         cout << wivdp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }

    cout << wivdp[w][n];

    return 0;
}

Measured memory_bytes: 84084
<?php
$N = trim(fgets(STDIN));
//list($A,$B,$k) =  explode(" ",trim(fgets(STDIN)));
//$A =  explode(" ",trim(fgets(STDIN)));

for($i=$N;$i<10**6;$i++) {
  if (is_prime($i)) {
    printf("%d\n",$i);
    break;
  }
}

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

function prime_factors(int $n) {
    $i = 2;
    $factors = [];
    while ($i * $i <= $n) {
        if ($n % $i) $i += 1;
        else {
            $n /= $i;
            $factors[] = $i;
        }
    }
    if ($n > 1) $factors[] = $n;
    return $factors;
}
function is_prime(int $n) : bool {
    $r = true;
    if ($n < 2) $r = false;
    elseif ($n == 2 || $n == 3 || $n == 5) $r = true;
    elseif ($n & 1 == 0) $r = false;
    elseif ($n % 2 == 0 || $n % 3 == 0 || $n % 5 == 0) $r = false;
    else {
        $f = true;
        $v = 7;
        $m = intval($n ** 0.5) + 1;
        while ($v < $m) {
            if ($n % $v == 0) {
                $r = false;
                break;
            }
            $v += $f ? 4 : 2;
            $f = !$f;
        }
    }
    return $r;
}


Measured memory_bytes: 4856
n = int(input())
a = list(map(int, input().split()))

s = {}
flag = 0

for i in range(n):
    t = a[i]
    s.setdefault(t, 0)
    if s[t] == 0:
        s[t] = 1
    else:
        print("NO")
        flag = 1
        break

if flag == 0:
    print("YES")

Measured memory_bytes: 32844
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
d = defaultdict(int)
ans = 0
for i in A:
    ans += i
    d[i] += 1

T = []
result = []
for i in range(Q):
    b, c = map(int, input().split())
    before = b*d[b]
    after = c*d[b]
    ans += (after - before)
    result.append(ans)
    d[c] += d[b]
    d[b] = 0

for i in result:
    print(i)

Measured memory_bytes: 95584
n,q=map(int,input().split())
s = input()
td = [input().split() for _ in range(q)]
def f(x):
  for t,d in td:
    if s[x] == t:
      if d == "L":
        x -= 1
      else:
        x += 1
      if 0 <= x < n:
        continue
      return x < 0
def g(x):
  for t,d in td:
    if s[x] == t:
      if d == "L":
        x -= 1
      else:
        x += 1
      if 0 <= x < n:
        continue
      return x >= n
ok = -1
ng = n
while ng - ok > 1:
  mid = (ok + ng)//2
  if f(mid):
    ok = mid
  else:
    ng = mid
ans = ok + 1
ok = n
ng = -1
while ok - ng > 1:
  mid = (ok + ng) //2
  if g(mid):
    ok = mid
  else:
    ng = mid
print(n - (ans + (n - ok)))


Measured memory_bytes: 92748
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
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()
{
  int N,M;
  cin >> N >> M;
  vector<pair<int,char>> S;
  REP(i,M){
    int s;
    char c;
    cin >> s >> c;
    s--;
    S.push_back(make_pair(s,c));
  }
  int ans = -1;
  REP(i,1000){
    int flag = 1;
  	string num = to_string(i);
    if(num.size() < N)continue;
    for(auto s : S){
      if(num[s.first] != s.second){
        flag = 0;
        break;
      }
    }
    if(flag){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int n, m, pre[100005], dist[100005];
inline int find(int x){
    if(pre[x]^x) {
    	int nf = pre[x]; pre[x] = find(pre[x]); dist[x] += dist[nf];
	}
    return pre[x];
}
int main(){
	bool flag=true;
    scanf("%d%d", &n, &m);
    for(register int i=1; i<=n; ++i)pre[i]=i;
    for(register int i=1; i<=m; ++i){
        int l, r, delta;
        scanf("%d%d%d", &l, &r, &delta);
        int ll = find(l), rr = find(r);
        if(ll==rr&&dist[l]-dist[r]!=delta)flag=false;
        if(ll^rr){
            pre[ll] = rr;
            dist[ll] = delta + dist[r] - dist[l];
        }
    }
    if(flag)printf("Yes\n");
    else printf("No\n");
    return 0;
} 

Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int k, x;

signed main() {
	cin >> k >> x;
	if (x <= 500 * k)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

int main(){
    Int x;
    Int a = 100;
    int year = 0;
    cin >> x;

    while (a < x) {
        a *= 1.01;
        year++;
        // if (year % 100 == 0) cout << year << endl;
    }
    cout << year;

    return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;

vector<ll> to[100010];

int main(){
    ll n,m;cin>>n>>m;
    rep(i,0,m){
        ll x,y,z;
        cin>>x>>y>>z;
        x--;y--;
        to[x].push_back(y);
        to[y].push_back(x);
    }
    queue<ll> q;
    vector<bool> seen(n,0);
    ll cn=0;
    rep(i,0,n){
        if(seen[i]==0)cn++;
        seen[i]=1;
        if(to[i].size()==0)continue;
        q.push(i);
        while(!q.empty()){
            ll now=q.front();
            q.pop();
            for(auto nx:to[now]){
                if(seen[nx])continue;
                seen[nx]=1;
                q.push(nx);
            }
        }
    }
    cout<<cn<<endl;
    
}







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

int H,K,damage[1001],price[1001],memo[10001];

void Input(){
	cin>>H>>K;
	for(int i=0; i<K; i++){
		cin>>damage[i]>>price[i];
	}
}

void dp(){
	for(int i=0; i<=H; i++){
		if(i==0){
			memo[0]=0;
		}else{
			int minim=1e9;
			for(int j=0; j<K; j++){
				if(i<damage[j]){
					minim=min(minim,price[j]);
				}else{
					minim=min(minim,price[j]+memo[i-damage[j]]);
				}
			}
			memo[i]=minim;
		}
	}
}

void Solve(){
	dp();
	cout<<memo[H]<<'\n';
}

int main(){
	Input();
	Solve();
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

#define pll pair<ll,ll>


int main(){
  ll N,K; cin>>N>>K;
  priority_queue<pll> q;
  priority_queue<pll, vector<pll>, greater<pll> > r;
  umap<ll,ll> exist_neta;
  
  REP(count,N){
    ll t,d; cin>>t>>d;
    q.push(make_pair(d,t));
  }
  ll num_neta = 0;
  ll oishisa_base = 0;
  ll oishisa_max;
  REP(count,K){
    oishisa_base += q.top().first;
    ll t = q.top().second;
    ++exist_neta[t];
    if(exist_neta[t]==1){
      ++num_neta;
    }
    r.push(q.top());
    q.pop();
  }
  oishisa_max = oishisa_base + num_neta*num_neta;
  
  while(1){
    bool ok = false;
    // 食べる集合のうち取り出せるものを探す
    while(!r.empty()){
      if( exist_neta[r.top().second]>1 ){
        oishisa_base -= r.top().first;
        --exist_neta[r.top().second];
        r.pop();
        ok = true;
        break;
      }else{
        r.pop();
      }
    }
    if(!ok){break;}
    // 食べない集合のうち新種を探す
    while(!q.empty()){
      if( exist_neta[q.top().second]==0 ){
        oishisa_base += q.top().first;
        ++exist_neta[q.top().second];
        ++num_neta;
        q.pop();
        ok = true;
        break;
      }else{
        q.pop();
      }
    }
    if(!ok){break;}
    // 最大値を残す
    oishisa_max = max(oishisa_max, oishisa_base + num_neta*num_neta );
  }
  cout << oishisa_max << "\n";
}

Measured memory_bytes: 7408
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
int main()
{
    fast_io
    ll t,i,j,n;
    string s;
    cin>>s;
    cout<<s[0]<<s.length()-2<<s[s.length()-1]<<endl;
    return 0;
}





Measured memory_bytes: 3596
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int a,n,i;
	cin>>n>>a;
	n=n%500;
	for(i=0;i<a;i++){
		if(n==0) break;
		n=n-1;
	}
//	cout<<n<<endl;
	if(n==0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}	
	return 0;
}


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

int main(){
    int A,B,C,K;
    cin >> A >> B >> C >> K;
    if(K <= A)cout << K << endl;
    else if(K <= A + B)cout << A << endl;
    else cout << A - (K - A - B) << endl;
    return 0;
}


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

const int p = 1000000007;
int PTEN[100000];
int dp[13][100001];

int main()
{
	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	PTEN[0]=1;

	for(int i=1; i<100000; i++)
	{
		PTEN[i]=PTEN[i-1]*10;
		PTEN[i]%=13;
	}

	string S;
	cin>>S;

	int n=S.size();
	reverse(S.begin(),S.end());

	// cout << (int)S[0]-48 << endl;

	dp[0][0]=1;

	for(int i=1; i<=n; i++)
	{
		if(S[i-1] == '?')
		{
			for(int j=0; j<10; j++)
			{
				for(int k=0; k<13; k++)
				{
					dp[(k+j*PTEN[i-1])%13][i] += dp[k][i-1];
					dp[(k+j*PTEN[i-1])%13][i] %= p;
				}
			}
		}

		else
		{
			for(int k=0; k<13; k++)
			{
				int j = ((int)S[i-1]-48)*PTEN[i-1];

				dp[(k+j)%13][i] += dp[k][i-1];
				dp[(k+j)%13][i] %= p;
			}
		}
	}

	cout << dp[5][n] << endl;	
}


Measured memory_bytes: 5888
n,k,*h=map(int,open(0).read().split())
dp=[10**18]*(n+k+1)
h=h+[0]*k
dp[0]=0
for i in range(n):
  for j in range(k):
    dp[j+i+1]=min(dp[i+j+1],dp[i]+abs(h[i+j+1]-h[i]))
print(dp[n-1])


Measured memory_bytes: 59948
A, B = map(int, input().split())

def f(x):
    # 下2桁が00,01,10,11となる連続する数のxorは消滅するので考えなくてよい
    xi = (x >> 2) << 2
    xlsb2 = x & 0x3

    if xlsb2 == 0:
        return(xi)
    elif xlsb2 == 1:
        return(1)
    elif xlsb2 == 2:
        return(xi + 3)
    else:
        return(0)

print(f(A-1) ^ f(B))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int n,m,x;
  cin>>n>>m>>x;
  vector<int> A;
  rep(i,m){
    int a;
    cin>>a;
    A.push_back(a);
  }
  int l=lower_bound(A.begin(),A.end(),x)-A.begin();
  cout<<min(l,m-l)<<endl;
  return 0;
}

Measured memory_bytes: 256
import math


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


N = 100000+1
data = get_sieve_of_eratosthenes(N)
flag = [0]*(N+1)
for i in range(len(data)):
    flag[data[i]]=1

for i in range(N,2,-1):
    if i//2==0 or flag[i]!=1 or flag[(i+1)//2]!=1:
        flag[i]=0
flag[2]=0
for i in range(1,N+1,1):
    flag[i] = flag[i]+flag[i-1]

Q = int(input())

ans = []
for i in range(Q):
    l,r = map(int,input().split())
    ans.append(flag[r]-flag[l-1])

for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 84952
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		int n,k,c;
		string s;
		cin>>n>>k>>c>>s;
		s='x'+s+'x';
		int a[n+2],b[n+2];
		a[0]=0;
		b[n+1]=0;
		for(int i=1;i<=n;i++){
			int z=max(0,i-c-1);
			a[i]=a[z];
			if(s[i]=='o')
			a[i]++;
			else
			a[i]=a[i-1];
		}
		for(int i=n;i>0;i--){
			int z=min(n+1,i+c+1);
			b[i]=b[z];
			if(s[i]=='o')
			b[i]++;
			else
			b[i]=b[i+1];
		}
		
		for(int i=1;i<=n;i++){
			if(a[i-1]+b[i+1]<k)
			cout<<i<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3408
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

int N;
ll K;
ll dp[100][2];

int main()
{
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, 0, N)
    {
        cin >> A[i];
    }
    memset(dp, -1, sizeof(dp));
    dp[45][0] = 0;
    for (int d = 44; d >= 0; d--)
    {
        ll mask = 1LL << d;
        int num = 0;
        for (int i = 0; i < N; i++)
        {
            if (A[i] & mask)
                num++;
        }

        if (dp[d + 1][1] >= 0)
        {
            chmax(dp[d][1], dp[d + 1][1] + mask * max(num, N - num));
        }
        if (dp[d + 1][0] >= 0)
        {
            if (K & (1LL << d))
            {
                chmax(dp[d][1], dp[d + 1][0] + mask * num);
                chmax(dp[d][0], dp[d + 1][0] + mask * (N - num));
            }
            else
            {
                chmax(dp[d][0], dp[d + 1][0] + mask * num);
            }
        }
    }
    cout << max(dp[0][0], dp[0][1]) << endl;
}


Measured memory_bytes: 1024
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (unfoldr)

main :: IO ()
main = do
  (n : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    next :: Maybe Digits -> Maybe ([Int], Maybe Digits)
    next = fmap next'
      where
        next' :: Digits -> ([Int], Maybe Digits)
        next' = (,) <$> repair <*> succDs
  mapM_ putStrLn . map (map toLEL) . unfoldr next . Just . zeroes $ n

type Digits = [(Int, Int)]

extend :: Digits -> Digits
extend [] = (1, 0) : []
extend ds@((m, k) : _) = (max m (succ k), 0) : ds

zeroes :: Int -> Digits
zeroes 1 = []
zeroes l  = extend . zeroes . pred $ l

succDs :: Digits -> Maybe Digits
succDs [] = Nothing
succDs ((m, k) : ds) | k < m = Just ((m, succ k) : ds)
succDs (_ : ds) = extend <$> succDs ds

repair :: Digits -> [Int]
repair = (0 :) . map snd . reverse

toLEL :: Int -> Char
toLEL = toEnum . (fromEnum 'a' +)

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 2172
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

template <class T>
using vec = vector<T>;
template <class T>
using vec2 = vector<vec<T>>;
template <class T>
using vec3 = vector<vec2<T>>;

constexpr int INF = numeric_limits<int>::max();
constexpr ll INFL = numeric_limits<ll>::max();
constexpr ll MOD = 1000000007; // 10^9+7

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)

int main()
{
    int n, k;
    cin >> n >> k;

    int ret = 0;
    while (n > 0)
    {
        n /= k;
        ret++;
    }

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 3612
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	vector<string> s(3);

	for (int i = 0; i < 3; i++) {
		cin >> s[i];
	}

	LL ans = 0;
	for (int i = 0; i < n; i++) {
		set<char> set;

		for (int j = 0; j < 3; j++) {
			

			set.insert(s[j][i]);

		}

		ans += set.size() - 1;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int r,g,b;
	
	int goukei;
	
	scanf("%d %d %d",&r,&g,&b);
	
	goukei = r*100 + g*10 + b;
	
	if(goukei % 4 == 0){
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	
	return(0);
}


Measured memory_bytes: 128
#include<iostream>
#include<math.h>
int main(){
	int n;
	double Debt=100000;
	long int Debt_ans;
	std::cin >> n;
	for (int i = 0; i < n; i++){
		Debt = Debt*1.05 / 1000;
		Debt = ceil(Debt);
		Debt = Debt * 1000;
	}
	Debt_ans = Debt;
	std::cout << Debt_ans<< std::endl;
}

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

#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;


int dfs(int i, int count, int sum, int n, int k, int s) {
     if (count == k) {
         if (sum == s) return 1;
         else return 0;
     } else if (count > k) {
        return 0;
     } else {
         int ans = 0;
         for (int j = i+1; j <= n; j++) {
             ans += dfs(j, count+1, j+sum, n, k, s);
         }
         return ans;
     }
}

int main()
{
    int n,k,s;
    while (cin >> n >> k >> s, n) {
        cout << dfs(0,0,0,n,k,s) << endl;
    }
}

Measured memory_bytes: 3060