akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;

int main(void){
    ll n, d, a;
    cin >> n >> d >> a;
    using P = pair<ll, ll>;
    vector<P> v(n);
    rep(i,n){
        ll x, h;
        cin >> x >> h;
        h = (h-1)/a + 1;
        v[i] = {x,h};
    }
    sort(all(v));
    map<ll, ll> del;
    ll sum = 0, damage = 0;
    rep(i,n){
        ll x = v[i].first;
        ll h = v[i].second;
        while (!del.empty()) {
            ll r = del.begin()->first;
            if (x <= r) break;
            damage -= del[r];
            del.erase(del.begin());
        }
        assert(damage >= 0);
        h = max(0LL, h - damage);
        sum += h;
        damage += h;
        del[x+d*2] += h;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 15872
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int mat[100050][3];
int dp[100050][3];

int main(){
    int n,a,b,c,sol=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b>>c;
        mat[i][0]=a;
        mat[i][1]=b;
        mat[i][2]=c;
    }

    dp[0][0]=mat[0][0];
    dp[0][1]=mat[0][1];
    dp[0][2]=mat[0][2];
    for(int i=1;i<n;i++){
        dp[i][0]=mat[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=mat[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=mat[i][2]+max(dp[i-1][0],dp[i-1][1]);
    }

    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));



    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;



int main(){
    ll r,d,x;
    cin >> r >> d >> x;
    REP(i,10){
        x = r * x - d;
        cout << fixed << x << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,A,B,N,M,ans;
  ans=0;
  scanf("%d%d",&N,&M);
  int H[N],judge[N];
  for(i=0;i<N;i++){
    scanf("%d",&H[i]);
    judge[i]=0;
  }
  for(i=0;i<M;i++){
    scanf("%d%d",&A,&B);
    if(H[A-1]>H[B-1])
      judge[B-1]=1;
    else if(H[A-1]==H[B-1]){
      judge[A-1]=1;
      judge[B-1]=1;
    }
    else
      judge[A-1]=1;
  }
  for(i=0;i<N;i++){
    if(judge[i]==0)
      ans++;
  }
  printf("%d\n",ans);
  return 0;
}

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

#from collections import Counter
dic = {}
for i in range(N):
    s = list(input())
    s_uniq = list(set(s))
    s_uniq.sort()
    key = ""
    for j in range(len(s_uniq)):
        s_cnt = s.count(s_uniq[j])
        key += s_uniq[j]+str(s_cnt)
    if key in dic:
        dic[key] += 1
    else:
        dic[key] = 1

ans = 0
for v in dic.values():
    ans += v*(v-1)//2
print(ans)

Measured memory_bytes: 18488
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main()
{
  ll h, a;
  cin >> h >> a;

  auto d = h / a;
  auto m = h % a;
  auto res = m > 0 ? (d + 1) : d;

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using lli = long long int;
using ll = long long ;
using ld=long double;

 
int main(){
    string s;
    cin>>s;
    int n=s.length();
    int c=0,maxi=0;
    for(int i=0;i<n;i++){
        if(s[i]=='A' || s[i]=='G' || s[i]=='T' ||s[i]=='C' )
        c++;
        else
        c=0;
        maxi=max(maxi,c);
    }
    cout<<maxi;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=42;
ll d2[N][N][N][N],d1[N][N][N][N];
int x[N][N];char s[N];
int main(){
//  freopen("2.in","r",stdin);
//  freopen("a.out","w",stdout);
    int n,a,b,c,d,i,j;ll tmp;
    scanf("%d",&n);
    if(n==1){
        scanf("%s",s);
        putchar(s[1]);
        return 0;
    }
    n<<=1;
    for(a=1;a<=n;++a){
        scanf("%s",s+1);
        for(b=1;b<=n;++b){
            x[a][b]=s[b]^'0';
        }
    }
    /*
    for(a=1;a<=n;++a){
        for(b=1;b<=n;++b){
            printf("%d ",x[a][b]);
        }
        printf("\n");
    }
    */
    for(a=1;a<=n;++a){
        for(b=1;b<=n;++b)if(x[a][b]){
            d1[a][a][b][b]=1ll;
        }
    }
    for(a=0;a<=n;++a){
        for(b=0;b<=n;++b){
            d2[a+1][a][b+1][b]=1ll;
        }
    }
    for(d=3;d<=n;++d){
        for(a=d-1;a!=1;--a){
            for(b=a;b<=d;++b){
                for(c=d;c!=b;--c){
                    if(a!=b||c!=d){
                        tmp=0ll;
                        for(i=a;i<=b;++i){
                            for(j=c;j<=d;++j)if(x[i][j]){
                                tmp+=d2[a][i-1][i+1][b]*d2[c][j-1][j+1][d];
                            }
                        }
                        d1[a][b][c][d]=tmp;
//                      printf("d1 %d %d %d %d = %lld\n",a,b,c,d,tmp);
                    }
                    {
                        tmp=0ll;
                        for(i=a;i<=b;++i){
                            for(j=c;j<=d;++j){
                                tmp+=d1[a][i][j][d]*d2[i+1][b][c][j-1];
                            }
                        }
                        d2[a][b][c][d]=tmp;
//                      printf("d2 %d %d %d %d = %lld\n",a,b,c,d,tmp);
                    }
                }
            }
        }
    }
    tmp=0ll;
    for(i=2;i!=n;++i)if(x[1][i]){
//      printf("D2 2 %d %d %d = %lld\n",i-1,i+1,n,d2[2][i-1][i+1][n]);
        tmp+=d2[2][i-1][i+1][n];
    }
    printf("%lld",tmp);
    return 0;
}

Measured memory_bytes: 45952
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  ll n;  cin >> n;
  ll ans = n-1;
  for(ll i=1; i*i<=n; i++){
    if(n%i==0){
      ans = min(ans, i+n/i-2);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		long cnt = 0;
		for(long i = 1; i < N; i++)
			cnt += (N + i - 1) / i - 1;

		WriteLine(cnt);
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 27528
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef vector<ll> vl;typedef vector<vl> vvl;typedef pair<ll,ll> pl;typedef vector<pl> vp;const ll INF=1001001001;const ll LINF=1001001001001001001;const ll D4[]={0,1,0,-1,0};const ll D8[]={0,1,1,0,-1,-1,1,-1,0};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;}
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()

void solve(long long N, long long C, std::vector<long long> s, std::vector<long long> t, std::vector<long long> c){
    vvl a(C,vl(100005));
    rep(i,N){
        a[c[i]-1][s[i]]++;
        a[c[i]-1][t[i]]--;
    }
    vl al(100005);
    rep(i,C)rep(j,100003){
        if(a[i][j]>0)al[j-1]+=a[i][j];
        else al[j]+=a[i][j];
    }
    ll ans=0;
    rep(i,100003){
        chmax(ans,al[i]);
        al[i+1]+=al[i];
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long C;
    scanf("%lld",&C);
    std::vector<long long> s(N);
    std::vector<long long> t(N);
    std::vector<long long> c(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&s[i]);
        scanf("%lld",&t[i]);
        scanf("%lld",&c[i]);
    }
    solve(N, C, std::move(s), std::move(t), std::move(c));
}


Measured memory_bytes: 26880
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

X,K,D = LI()
X = abs(X)
sho = X // D
amari = X % D

if (sho>=K):
    saigo = X - (K*D)
    print(abs(saigo))
else:
    nokori = K - abs(sho)
    if nokori % 2 == 0:
        print(abs(amari))
    else:
        ans = min(amari+D,amari-D)
        print(abs(ans))
        

Measured memory_bytes: 9204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>
#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<llint, llint>Pii;
typedef pair<double, double>Pdd;

#define pi 3.141592653589793)
#define mod 1000000007

int main() {
	llint q, h, s, d,n;
	cin >> q >> h >> s >> d >> n;
	q *= 4;
	h *= 2;
	llint res = 0;
	if (min(q, min(h, s))*2 <= d) {
		res = n*min(q, min(h, s));
	}
	else {
		if(n%2 == 0)res = n/2*d;
		else res = (n-1)/2 * d + min(q, min(h, s));
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#endif

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

int const maxn = 3e5 + 5;

bool check(string s) {
	int n = s.size();
	for (int i = 0; i < n; i++) {
		if (s[i] != s[n - 1 - i]) return 0;
	}
	return 1;
}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	ll x; cin >> x;
	ld a = (ld)x / 3.0;
	cout << fixed; cout.precision(15);
	cout << (a * a * a) << endl;

	return 0;
}

/*
5
2 6 15 5 10

4
2 6 15 5

*/

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

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

const int MX=200005;

int par[MX],sz[MX],ans=1;

void make_set(int v)
{
    par[v]=v;
    sz[v]=1;
}

int find_set(int v)
{
    if(v==par[v]) return v;
    return par[v]=find_set(par[v]);
}

void union_set(int u,int v)
{
    int a=find_set(u);
    int b=find_set(v);
    if(a==b) return;
    if(sz[a]<sz[b]) swap(a,b);
    par[b]=a,sz[a]+=sz[b];
    ans=max(ans,sz[a]);
}

int main()
{
    int n,m,u,v;
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++) make_set(i);
    while(m--){
        scanf("%d %d",&u,&v);
        union_set(u,v);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 5336
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define eb                emplace_back
#define mp                make_pair
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   for(int i=s;i<n;i++){cout <<  V[i] ;} cout << endl;
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
using namespace std;

int main()
{
fast;
ll q=1;
//cin >> q;
while(q--)
{
    ll n,m,i,j,l,r,a,t,b,c,u,v,w,p,x,y;
    //n=m=i=j=l=r=a=t=b=c=u=v=w=p=x=y=0;
    cin >> n;
    priority_queue<dl,vector<dl>,greater<dl> > PQ;
    for(i=0;i<n;i++)
    {
        cin >> x;
        PQ.push(x);
    }
    while(PQ.size()>1)
    {
        dl x1 = PQ.top(); PQ.pop();
        dl u1 = PQ.top();PQ.pop();
        PQ.push((dl)(x1+u1)/2.0);
    }

    cout << fixed << setprecision(10) << PQ.top();


}
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n,x,bounce=1,total=0;
    scanf("%d%d",&n,&x);
    int l[n+1];
    int i;
    for(i=0;i<n;i++){
        scanf("%d",&l[i]);
        total+=l[i];
        if(total<=x){
            bounce++;
        }
    }
    printf("%d\n",bounce);
    return 0;
}


Measured memory_bytes: 128
// E - Change a Little Bit

// 解説YouTube https://www.youtube.com/watch?v=9MphwmIsO7Q

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct ModInt {
	long long val;
	constexpr ModInt(long long v = 0) noexcept : val(v % MOD) {
		if (val < 0) val += MOD;
	}
	constexpr int getmod() { return MOD; }
	constexpr ModInt operator - () const noexcept {
		return val ? MOD - val : 0;
	}
	constexpr ModInt operator + (const ModInt& r) const noexcept { return ModInt(*this) += r; }
	constexpr ModInt operator - (const ModInt& r) const noexcept { return ModInt(*this) -= r; }
	constexpr ModInt operator * (const ModInt& r) const noexcept { return ModInt(*this) *= r; }
	constexpr ModInt operator / (const ModInt& r) const noexcept { return ModInt(*this) /= r; }
	constexpr ModInt& operator += (const ModInt& r) noexcept {
		val += r.val;
		if (val >= MOD) val -= MOD;
		return *this;
	}
	constexpr ModInt& operator -= (const ModInt& r) noexcept {
		val -= r.val;
		if (val < 0) val += MOD;
		return *this;
	}
	constexpr ModInt& operator *= (const ModInt& r) noexcept {
		val = val * r.val % MOD;
		return *this;
	}
	constexpr ModInt& operator /= (const ModInt& r) noexcept {
		long long a = r.val, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % MOD;
		if (val < 0) val += MOD;
		return *this;
	}
	constexpr bool operator == (const ModInt& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const ModInt& r) const noexcept {
		return this->val != r.val;
	}
	friend constexpr ostream& operator << (ostream &os, const ModInt<MOD>& x) noexcept {
		return os << x.val;
	}
	friend constexpr ModInt<MOD> modpow(const ModInt<MOD> &a, long long n) noexcept {
		if (n == 0) return 1;
		auto t = modpow(a, n / 2);
		t = t * t;
		if (n & 1) t = t * a;
		return t;
	}
};

const int MOD = 1000000007;
using mint = ModInt<MOD>;


int C[200000];
mint ans = 0;


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

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

	sort(C, C+N);

	for (int i=0; i<N; i++) {
		int l = i;
		int r = N - 1 - i;

		ans += modpow((mint)2, l) * (modpow((mint)2, r) + modpow((mint)2, r-1) * r) * C[i];
	}

	ans *= modpow((mint)2, N);

	cout << ans << endl;

	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    string S;
    cin >> S;

    for(int i = 1; i < S.size()/2 - 1; i++) {
        //cout << i << ':' << S.substr(0,S.size()/2 - i) << ':' << S.substr(S.size()/2 - i, S.size()/2 - i) << endl;
        if(S.substr(0,S.size()/2 - i) == S.substr(S.size()/2 - i, S.size()/2 - i)) {
            cout << (S.size()/2 - i)*2 << endl;
            return 0;
        }
    }
    cout << 2 << endl;

    return 0;
}

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

set<string> dc;
int n;
vector<char> nm(9);
string p, q;
int itr, itrp, itrq;


int cst(string st, char x){
  	int count = 0;
	rep(i,st.size()){if(st.at(i) == x) count++;}
  	return count;
}

void dfs2(string st, char ch){
    st.push_back(ch);
    if(cst(st, ch) > 1) return;
 
	if(st.size() == n){
    	dc.insert(st);
//      	cout << st << endl;
      	itr++;
      	if(p == st) itrp = itr;
      	if(q == st) itrq = itr;
      	return;
    }
  
  	rep(i,n) dfs2(st, nm.at(i));

  	return;
}

void dfs(string st){
	rep(i,n) dfs2(st,nm.at(i));
	return;
}

int main() {
  	cin >> n;
  	rep(i,n){
    	char tmp;	cin >> tmp;
    	p.push_back(tmp);}
  	rep(i,n){
    	char tmp;	cin >> tmp;
    	q.push_back(tmp);}
	
  	rep(i,9){
    	nm.at(i) = (char)49+i;
//    	cout << nm.at(i) << endl;
    }
  	itr = 0;
  	dfs("");
  	
  	cout << abs(itrp - itrq) << endl;
  	
  	
}

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

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

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

    static class AFiveVariables {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            for (int i = 1; i <= 5; i++)
                if (s.nextInt() == 0) {
                    w.print(i);
                    return;
                }
        }

    }

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

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

        public int read() {

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

            if (curChar >= numChars) {

                curChar = 0;

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

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

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

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

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

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

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

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

        }

    }
}



Measured memory_bytes: 25684
#include<stdio.h>

int main(void)
{
	int i;
	char c[3][4];

	for (i = 0; i < 3; i++)
		scanf("%s", c[i]);

	for (i = 0; i < 3; i++)
		printf("%c", c[i][i]);

	printf("\n");

	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np
# import sys
# sys.setrecursionlimit(10**4)

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


A, B, T = ds_in()

print(B * (T//A))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(30);
#define ll long long
#define pi 3.14159265359
using namespace std;

int main()
{
    IOS;

    int n;
    cin>>n;
    map<string, int> m;
    while(n--){
        string s;
        cin>>s;
        m[s]++;
    }
    for(auto s : {"AC","WA","TLE","RE"}) cout<<s<<" x "<<m[s]<<'\n';

    return 0;
}

//cin>>x>>y;
//cout<<a<<b<<'\n';


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/
bool prime_test(int num) {
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    int sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0) return false;
    }

    return true;
}

/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    vi csum(1e5+10);
    for(int i = 1; i < 1e5; ++i) {
        csum[i+1] += csum[i];
        if((i&1) && prime_test(i) && prime_test((i+1)/2)) ++csum[i+1];
    }

    int Q; cin >> Q;
    rep(_, Q) {
        int l,r; cin >> l >> r;
        cout << csum[r+1] - csum[l] << '\n';
    }

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;

ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}
using namespace std;

int main() 
{
	fast;
	string o,e,tt; cin>>o>>e; string ans;
	ll t = min(o.length(),e.length()); ll k=0,p=0; 
	//dbg(o.length()); dbg(e.length()); dbg(t);
	for(ll i = 0; i < 2*t; i++)
	{
		if(i % 2 == 0)
		{
			tt = o[k];
			ans.append(tt);
			k++;
		}
		else
		{
			tt = e[p];
			ans.append(tt);
			p++;
		}
	} 
	//dbg(p); dbg(k);
	if(p != e.length())
	{
		ans.append(e.substr(p));
	}
	else if(k != o.length())
	{
		ans.append(o.substr(k));
	}
	cout << ans << endl;
  	return 0; 
}

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

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

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

    if (k%2 == 0) {
        cout << -1 << endl;
        return 0;
    }

    int i = 7;
    int ans = 1;
    while(i != 0) {
        if (i%k == 0) break;
        i %= k;
        i *= 10;
        i += 7;
        ans++;
        if (ans > 1000000) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

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


int main(){
  int L, R;
  cin >> L >> R;
 int ans = 2019;
    for (int i = L; i <= min(R, L + 2020); ++i)
        for (int j = L; j < i; ++j)
            ans = min(ans, (i % 2019) * (j % 2019) % 2019);
 
    cout << ans << '\n';
 
 
}

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

#define Bye return 0
const int MAX = 1e6+1;

void solve(){
    int n; cin>>n;
    if(n%1000 == 0) cout<<"0"<<endl;
    else cout<<1000-n%1000<<endl;
}

int main()
{
    solve();
    Bye;
}


Measured memory_bytes: 3620
W, H, N = [int(i) for i in input().split()]
top, bottom, left, right = H, 0, 0, W
for _ in range(N):
    x, y, a = [int(i) for i in input().split()]
    if a == 1:
        left = max(left, x)
    elif a == 2:
        right = min(right, x)
    elif a == 3:
        bottom = max(bottom, y)
    elif a == 4:
        top = min(top, y)
print(max(right - left, 0) * max(top - bottom, 0))

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vb = vector<bool> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

ll fast(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        y >>= 1;
    }
    return res;
}

ll inv(ll n){
    return fast(n,mod-2);
}


void pre(){



}



void solve(){

    int n;
    cin >> n;
    map<pair<ll,ll>,ll> mp;
    for(ll i=1;i<=n;i++){
        string s = to_string(i);
        int f = s[0]-'0';
        int l = s[s.size()-1]-'0';
        mp[{f,l}]++;
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        string s = to_string(i);
        int f = s[0]-'0';
        int l = s[s.size()-1]-'0';
        ans += mp[{l,f}];
    }
    cout << ans;

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

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

long long MOD=1000000007LL;

int main(){
	long long ans=1;
	int N;
	cin >> N;
	for(int i=1;i<=N;i++)ans=(ans*i)%MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    Int a; cin >> a;
    unordered_set<Int> st;
    st.insert(a);

    Int i = 1;
    while(true) {
        ++i;
        if (a%2 == 0) a = a/2;
        else a = 3*a+1;

        auto itr = st.insert(a);
        if (!itr.second) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second

using namespace std;

const long long MOD = (long long)1e9 + 7;

int n[2], q;
vector<long long> vec[2];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n[0] >> n[1] >> q;
	long long tmp;
	for (int k = 0; k < 2; k++) {
		for (int i = 0; i < n[k]; i++) {
			cin >> tmp;
			vec[k].push_back(tmp);
		}
		vec[k].push_back(-1LL * 1e10 - 1LL * 1e10);
		vec[k].push_back(1LL * 1e10 + 1LL * 1e10);
		sort(vec[k].begin(), vec[k].end());
	}
	while (q--) {
		cin >> tmp;
		long long t1, t2, v1, v2;
		int tp = lower_bound(vec[0].begin(), vec[0].end(), tmp) - vec[0].begin();
		t1 = vec[0][tp - 1];
		t2 = vec[0][tp];
		tp = lower_bound(vec[1].begin(), vec[1].end(), tmp) - vec[1].begin();
		v1 = vec[1][tp - 1];
		v2 = vec[1][tp];
		long long ans;
		ans = max(abs(t1 - tmp), abs(v1 - tmp));
		ans = min(ans, min(abs(t1 - tmp), abs(v2 - tmp)) * 2 + max(abs(t1 - tmp), abs(v2 - tmp)));
		ans = min(ans, min(abs(t2 - tmp), abs(v1 - tmp)) * 2 + max(abs(t2 - tmp), abs(v1 - tmp)));
		ans = min(ans, max(abs(t2 - tmp), abs(v2 - tmp)));
		cout << ans << "\n";
	}
	//system("pause");
	return 0;
}


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
#define rep(i,q) for(int i = 0; (q) > i; i++)
int main(){
  int n;cin>>n;
  int alp[26];
  int kekka[26];
  rep(i,26)alp[i] = 0,kekka[i] = 100;
  rep(i,n){
    string s;cin>>s;
    rep(j,s.size()){
      alp[s[j]-'a']++;
    }
    rep(i,26){
      kekka[i] = min(kekka[i],alp[i]);
      alp[i] = 0;
    }
  }
  rep(i,26){
    rep(j,kekka[i]){
      char ret = 'a'+i;
      cout << ret;
    }
  }
  cout << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
//#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head, tail, n;

void enqueue(P x)
{
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue()
{
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b){ return a<b ? a:b; }

int main()
{
  int elaps = 0, c;
  int i,q;
  P u;
  scanf("%d %d", &n, &q);
  for(i=1; i<=n; i++)
  {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n+1;

  while(head != tail)
  {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else
    {
      printf("%s %d\n",u.name, elaps);
    }
  }
  return 0;
}



Measured memory_bytes: 11888
import sys
from itertools import combinations, product


fin = sys.stdin.readline
N, A, B, C = [int(elem) for elem in fin().split()]
l_list = [int(fin()) for _ in range(N)]

min_mp = float('inf')
for flags in product(range(4), repeat=N):
    powers = [0] * 3
    num_items = [0] * 3
    for l, flag in zip(l_list, flags):
        if flag == 3:
            continue
        powers[flag] += l
        num_items[flag] += 1
    if not all(powers):
        continue
    mp = sum(
        abs(power - necessary_power) 
        for power, necessary_power in zip(powers, (A, B, C))
        ) + 10 * (sum(num_items) - 3)
    min_mp = min(mp, min_mp)
print(min_mp)

Measured memory_bytes: 48856
#include<iostream>
#include<string>
#include <vector>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
using vll = vector<ll>;
const ll MOD = 1e9 + 7;

int main() {
	int n, q;
	ll k;
	cin >> n >> k >> q;
	vi a(n);
	rep(i, q) {
		int k;
		cin >> k;
		k--;
		a[k]++;
	}
	rep(i, n) {
		if (k - (q - a[i]) > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  float x;
  cin>>x;
  int left = floor(x);
  int right = ceil(x);
  if(left==right&&right==1)
    cout<<0<<endl;
  else if(left==right&&right==0)
    cout<<1<<endl;
}



Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define pcnt(n) __builtin_popcount(n)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const double PI = acos(-1);

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    char a,b,c;
    cin>>a>>b>>c;
    cout<<a<<(char)('B'+'R'-b)<<c<<endl;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <cstdio>
#include <functional>
#include <vector>

#define int long long
#define dotimes(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

signed main() {
  int n = rint();
  vector<vector<int> > edges(n);
  dotimes(i, n) {
    int u = rint() - 1;
    int k = rint();
    edges[u].reserve(k);
    dotimes(j, k)
      edges[u].emplace_back(rint() - 1);
    sort(edges[u].begin(), edges[u].end());
  }
  int d[n], f[n];
  fill(d, d + n, 0);
  fill(f, f + n, 0);
  int t = 1;
  function<void(int)> rec;
  rec = [&](int u) {
    if (d[u])
      return;
    d[u] = t++;
    for (auto v : edges[u])
      rec(v);
    f[u] = t++;
  };
  dotimes(u, n) {
    rec(u);
    printf("%lld %lld %lld\n", u+1, d[u], f[u]);
  }
  return 0;
}



Measured memory_bytes: 2740
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	var i int
	if sc.Scan() {
		if num, err := strconv.Atoi(sc.Text()); err == nil {
			i = num
		}
	}
	return i
}

func nextString() string {
	var s string
	if sc.Scan() {
		s = sc.Text()
	}
	return s
}

func main() {
	var blackMap = map[int]map[int]int{
		1: map[int]int{},
		2: map[int]int{},
		3: map[int]int{},
		4: map[int]int{},
		5: map[int]int{},
		6: map[int]int{},
	}

	sc.Split(bufio.ScanWords)
	height, width, k := nextInt(), nextInt(), nextInt()
	var count int
	for i := 0; i < height; i++ {
		mark := nextString()
		for j, c := range mark {
			if string([]rune{c}) == "#" {
				blackMap[i+1][j+1] = 1
			}
		}
	}

	n := width + height
	// 11111
	for bits := 0; bits < (1 << uint64(n)); bits++ {
		var heightMap = make(map[int]bool)
		var widthMap = make(map[int]bool)
		var kcount int
		for i := 0; i < n; i++ {
			if (bits>>uint64(i))&1 == 1 {
				if i < height {
					heightMap[i+1] = true
				} else {
					widthMap[i+1-height] = true
				}
			}
		}
		for i := 0; i < height; i++ {
			if heightMap[i+1] == true {
				continue
			}
			for j := 0; j < width; j++ {
				if widthMap[j+1] == true {
					continue
				}
				// [height][width]
				if blackMap[i+1][j+1] == 1 {
					kcount++
				}
			}
		}
		if kcount == k {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 1780
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>

using namespace std;

int SolveCSub(int pay, int digit, const bool hate[10], int N){
  if(digit <= 0){
    if(pay >= N) return pay;
    else return 100000;
  }

  int iret = 100000;
  for(int i = 0; i < 10; i++){
    if(hate[i] && !(i == 0 && pay == 0)) continue;
    int a = SolveCSub(pay + i * digit, digit/10, hate, N);
    if (a < iret) iret = a;
  }
  return iret;
}

void SolveC(){
  bool hate[10] = {false};
  int N, K;
  cin >> N >> K;
  for(int i = 0; i < K; i++){
    int a;
    cin >> a;
    hate[a] = true;
  }

  cout << SolveCSub(0,100000,hate, N) << endl;
}

//int dp[100001];
int main(){
  SolveC();
/*
  const int kDiv = 1000000007;
  int H, W, A, B;
  cin >> H >> W >> A >> B;

  dp[0] = 1;
  for(int y = 0; y < H-A; y++)
    for(int x = 0; x < W; x++)
      dp[x+1] = (dp[x+1] + dp[x]) % kDiv;

  for(int y = 0; y < A; y++)
    for(int x = B; x < W; x++)
      dp[x+1] = (dp[x+1] + dp[x]) % kDiv;
  cout << dp[W-1] << endl;
*/
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main( String[] args ) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }

 		int count = 0;
        for (int i = 1; i < arr.length - 1; i++) {
            if ((arr[i - 1] < arr[i] && arr[i] < arr[i + 1]) || (arr[i - 1] > arr[i] && arr[i + 1] < arr[i])) {
                count++;
            }
        }

        System.out.println(count);
    }
}


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

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

 int v[n];
 int w[n];

 for(int i=0;i<n;i++){
	cin>>v[i]>>w[i];
 }

 int DP[n+1][W+1];

 for(int j=0;j<=W;j++){
	DP[0][j]=0;
 }

 for(int i=1;i<=n;i++){
	for(int j=0;j<=W;j++){
		if(j<w[i-1]){
			DP[i][j]=DP[i-1][j];
		}else{
			if(DP[i-1][j]>DP[i][j-w[i-1]]+v[i-1]){
				DP[i][j]=DP[i-1][j];
			}else{
				DP[i][j]=DP[i][j-w[i-1]]+v[i-1];
			}
		}
	}
 }
 cout<<DP[n][W]<<endl;
return 0;
}

Measured memory_bytes: 7016
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

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


N, M = list(map(int, sys.stdin.buffer.readline().split()))
A = list(map(int, sys.stdin.buffer.readline().split()))

ans = N - sum(A)
if ans >= 0:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 27552
s = str(input())


a, b = 0, 0

for i in range(len(s)-1):
    if s[i] == s[i+1]:
        a, b = i+1, i+2
        break
    elif i < len(s)-2:
        if s[i] == s[i+2]:
            a, b = i+1, i+3
            break
        
if a == 0:
    print(-1, -1)
else:
    print(a, b)

Measured memory_bytes: 9232
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b,a%b));
}

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



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    double n,x=100,sum=0;
    cin>>n;
    while(n>x){
        x=floor(x*1.01);
        sum++;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3808
import itertools
 
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

l = list(range(1,n+1))
dic = {}

for i,j in enumerate(itertools.permutations(l)):
    dic[j] = i+1
print(abs(dic[p]-dic[q]))

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

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; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

const int mod=1000000007;

int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> a(m);
    rep(i,m){
        int tmp0,tmp1;
        cin>>tmp0>>tmp1;
        a[i]=(make_pair(tmp1,tmp0));
    }
    sort(a.begin(),a.end());
    int now=0;
    int ctr=0;
    rep(i,m){
        if(now>a[i].second)continue;
        now=a[i].first;
        ctr++;
    }
    cout<<ctr<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main (void)
{
  int t[3],i,j,x;

  for(i=0;i<3;i++)
	{
	  scanf("%d",&t[i]);
	}
  for(i=0;i<2;i++)
	{
	  for(j=i+1;j<3;j++)
		{
	      if(t[i]<t[j])
            {
            x = t[i];
	 	    t[i] = t[j];
		    t[j] = x;
		    }
        }
    }
  printf("%d",t[1]+t[2]);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define ll long long
#define pii pair<int,int> 
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
int inf=1000001000;
ll INF=100000000000000000;
ll MOD=1000000007;
//g++ code.cpp   ./a.out 
 
int main() {
    int n,k;
    cin >> n >> k;
    vector<int> h(n); rep(i,n) cin >> h[i];
    sort(h.begin(),h.end());
    ll ans=0;
    rep(i,n-k){
        ans+=h[i];
    } 
    cout << ans << endl;
}



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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define all(a) (a).begin(), (a).end()

int main() {
	int a, b;
	while (cin >> a >> b && a + b > 0)
		cout << min(a, b) << " " << max(a, b) << endl;

	return 0;
}


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

using namespace std;

int n[1000]={};
long long a[1000][1000]={};
long long ans = 10000000000;

int main(){
    int s=0;
    while(1){
        scanf("%d",&n[s]);
        if(n[s] == 0){
            break;
        }
        for(int i=0;i<n[s];i++){
           scanf("%lld",&a[s][i]); 
        }
        s++;
    }

    int times =s;
    int sub;
    for(int i=0;i<s;i++){
        sort(a[i],a[i]+n[i]);
        for(int j=0;j<n[i]-1;j++){
            sub = abs(a[i][j] - a[i][j+1]);
            if(ans >= sub){
                ans = sub;
            }
        }
        cout << ans << endl;
        ans = 1000000000;
    }
    

    return 0;
}


Measured memory_bytes: 4256
// By Shreehari Bodas

#include <bits/stdc++.h>

using namespace std;

int main(){

	int x,y; cin>>x>>y;

	if(y%2!=0) cout<<"No";
	else{
		if(y>=2*x && y<=4*x) cout<<"Yes";
		else cout<<"No";
	}

	return 0;
} 

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

int main()
{
  int n, x;
  scanf("%d %d", &n, &x);
  
  int res = 1, d = 0;
  for (int i = 0; i < n && d < x; ++i)
  {
   int l;
    scanf("%d", &l);
    d += l;
    if (d <= x)
      ++res;
  }
  printf("%d", res);
  
  return 0;
}

Measured memory_bytes: 128
n = gets.to_i

i = 1
loop do
  x = i
  if (x % 3).zero?
    print " #{i}"
  else
    loop do
      if x % 10 == 3
        print " #{i}"
      else
        x /= 10
        next unless x.zero?
      end
      break
    end
  end
  i += 1
  break if i > n
end
puts


Measured memory_bytes: 6868
sp = gets.chomp
t = gets.chomp
pattern = t.chars.map { |c| "\[\?#{c}\]" }.join
pattern = Regexp.new('(.*)' + pattern)
res = sp.sub!(pattern, '\1' + t)
sp.gsub!('?', 'a')

if res.nil?
  puts 'UNRESTORABLE'
else
  puts sp
end

Measured memory_bytes: 1788