akhauriyash/Code-Regression huggingface dataset:
/*input
16
*/ 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=1e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=INF64;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int main(){
    int n;
    cin>>n;
    int x=n%10;
    if(x==3) cout<<'b';
    else if(x==0 or x==1 or x==6 or x==8) cout<<'p';
    else cout<<'h';
    cout<<"on";
}

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

int main() {

    int a,b,c,x,ans(0);

    cin >> a >> b >> c >> x;

    for(int i = 0; i <= a;i++){
        for(int j = 0; j <= b;j++){
            for(int k = 0;k <= c;k++){
                if(x == (i*500 + j*100 + k*50)){
                    ans++;
                }
            }
        }
    }

    cout << ans;


}

   

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back

void solve(){
    string s; cin >> s;
    bool flag = true;
    REP(i, s.size()-1){
        if(s[i] == s[i+1]) flag = false;
    }
    if(flag) cout << "Good" << endl;
    else cout << "Bad" << endl;
}

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

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

int main() {
	char c;
	string ans;
	cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		ans = "vowel";
	}
	else {
		ans = "consonant";
	}
	cout << ans << endl;
}

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

int main()
{
    int a, b, sum=0, temp=0;

    cin >> a>>b;
    if(b<10){
        sum = a * 10 + b;
    }
    else if(b<100){
        sum = a * 100 + b;
    }
    else{
        sum = a * 1000 + b;
    }
    temp = sqrt(sum);
    temp *= temp;
    if(temp==sum){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    //cout << sum << endl;
    //cout << sqrt(sum)  << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
const int INF = 1001001001;
vector<int> to[100005];
 
int main() {
  int n, m;
  cin >> n >> m;
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
 
  queue<int> q;
  vector<int> dist(n, INF);
  vector<int> pre(n, -1);
  dist[0] = 0;
  q.push(0);
  while (!q.empty()) {
    int v = q.front(); q.pop();
    for (int u : to[v]) {
      if (dist[u] != INF) continue;
      dist[u] = dist[v]+1;
      pre[u] = v;
      q.push(u);
    }
  }
 
  cout << "Yes" << endl;
  rep(i,n) {
    if (i == 0) continue;
    int ans = pre[i];
    ++ans;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 10760
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

typedef long long ll;
ll n, ba, a[N], tr[N * 8];

ll se1(ll p, ll q) {
	ll re = 0;
	while (p < q) {
		if (p % 2 == 1) re += tr[p], p++;
		if (q % 2 == 0) re += tr[q], q--;
		p /= 2; q /= 2;
	}
	if (p == q) re += tr[p];
	return re;
}

void se2(ll p) {
	for (; p; p /= 2) {
		tr[p] = tr[p * 2] + tr[p * 2 + 1];
	}
}

bool f(ll p) {
	ll i, j = ba + n - 1, s = 0;
	for (i = 0; i < ba * 2; i++) tr[i] = 0;
	for (i = 0; i < n; i++) {
		tr[j]++;
		se2(j / 2);
		if (a[i] < p) j--;
		else j++;
		s += se1(ba, j);
	}
	return s >= (n * (n + 1) / 2 + 1) / 2;
}

int main()
{
	ll i, l, r, m;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
	}
	for (ba = 1; ba < n * 2; ba *= 2);
	l = 0; r = 1e9;
	while (l < r) {
		m = (l + r + 1) / 2;
		if (f(m)) l = m;
		else r = m - 1;
	}
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 7168
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <stdlib.h>
int main(void)
{
	int k,l;
	scanf("%d",&k);
	assert(1<=k&&k<=pow(10,6));
	if(k%7==0)
	{
		l=9*(k/7);
	}
	else
	{
		l=9*k;
	}
	int a=1;
	int i;
	if(l%2==0 ||l%5==0)
	{
		printf("-1\n");
	}
	else
	{
		
		for(i=1;i<=l;i++)
		{
			a=a*10;
			a=a%l;
			if(a==1)
			{
				break;
			}
		}
		printf("%d",i);
	}
	return 0;
}

Measured memory_bytes: 1736
#include<stdio.h>
int main(){
int a[100],b[100],i=0;
do{
scanf("%d %d",&a[i],&b[i]);
i++;
}while(a[i-1]!=0||b[i-1]!=0);
for(int x=0;x<i-1;x++){
for(int y=0;y<a[x];y++){
if(y==0||y==a[x]-1){
for(int z=0;z<b[x];z++){
printf("#");
}
}
else{
for(int z=0;z<b[x];z++){
if(z==0||z==b[x]-1)printf("#");
else printf(".");
}
}
printf("\n");
}
printf("\n");
}
}

Measured memory_bytes: 1000
// Shift-JIS（シフトジス）

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

int gcd(long long a, long long b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

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

int main()
{
    int N, D;
    cin >> N >> D;
    int X[N][D];
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < D; j++)
        {
            cin >> X[i][j];
        }
    }

    long long d;
    int y, z, ans = 0;
    for (int i = 0; i < N - 1; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            d = 0;
            for (int k = 0; k < D; k++)
            {
                y = X[i][k];
                z = X[j][k];
                d += (y - z) * (y - z);
            }
            if (floor(sqrt(d)) == sqrt(d))
            {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'i' || c == 'u'|| c == 'e' || c == 'o')
    cout << "vowel" << endl;
  
  else
    cout << "consonant" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
//const int N = 1e5 + 5;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    int n,ans = 0;
    cin>>n;
    string str;
    cin>>str;
    for(int i = 0; i <= n - 3; ++i)
        if(str.substr(i,3) == "ABC") {
            ++ans;
            i += 2;
        }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  int n,m;
  scanf("%d%d",&n,&m);
  n -= m;
  int s = m*1900+n*100;
  rep(i,m) s *= 2;
  cout<<s<<endl;
  return 0;
}






















Measured memory_bytes: 256
#include <cmath>
#include <functional>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector <int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  if (a[n-1]>a[0]+1){
    cout<<"No\n";
    return 0;
  }
  int l = 0, r = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == a[0]) {
      l++;
    } else {
      r++;
    }
  }
  for (int it = 0; it < 2; it++) {
    int min_unique = l + (r != 0);
    int max_unique = l + r / 2;
    if (min_unique <= (it ? a[n - 1] : a[0] + 1) && (it ? a[n - 1] : a[0] + 1) <= max_unique) {
      cout << "Yes\n";
      return 0;
    }
    if (r == 0) swap(l, r);
  }
  cout << "No\n";
}


Measured memory_bytes: 640
s=str(input())
hantei0=True
hantei1=True

for i in range(len(s)):
  if i%2==0 and s[i]=='L':
    hantei0=False
  elif i%2==1 and s[i]=='R':
    hantei1=False
    
if hantei0==True and hantei1==True:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Control.Monad         (replicateM)
import qualified Data.ByteString.Char8 as BC
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  n <- readLn
  ss <- replicateM n getLine
  m <- readLn
  ts <- replicateM m getLine
  print $ solve ss ts

solve :: [String] -> [String] -> Int
solve ss ts = maximum $ 0 : map score ss where
  score s = count ss - count ts where
    count = length . filter (== s)


Measured memory_bytes: 636
mod = 10**9+7
def inpl(): return [int(i) for i in input().split()]
N, A, B, C, D = inpl()
fac = [1 for _ in range(N+1)]
for i in range(N):
    fac[i+1] = (i+1)*fac[i] %mod
inv = [1 for _ in range(N+1)]
for i in range(2,N+1):
    inv[i] = (-(mod//i) * inv[mod%i]) %mod    
facinv = [1 for _ in range(N+1)]
for i in range(N):
    facinv[i+1] = inv[i+1]*facinv[i] %mod
facinvp = [facinv]
for i in range(N-1):
    p = facinvp[-1]
    q = [p[i]*facinv[i]%mod for i in range(N+1)]
    facinvp.append(q)
    
dp = [[0 for _ in range(N+1)] for _ in range(B+1)]
dp[A-1][0] = 1

for i in range(A-1,B):
    for j in range(N+1):
        dp[i+1][j] = dp[i][j]
        for k in range(C,1+min(D, j//(i+1))):
            x = j - k*(i+1)
            dp[i+1][j] += fac[j]*facinv[x]*facinvp[k-1][i+1]*facinv[k]*dp[i][x]%mod
        dp[i+1][j] %= mod
print(dp[B][N])

Measured memory_bytes: 134108
// 問題の URL を書いておく
// 

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <numeric>
#include <regex>
using namespace std;

//#define ENABLE_PRINT

template<typename T>
T Input()
{
    T v;
    cin >> v;
    return v;
}

template<typename T>
vector<T> InputVector(int n)
{
    vector<T> v(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    return v;
}

template<typename T>
void InputArray(T* begin, int n)
{
    for(int i = 0; i < n; ++i)
    {
        cin >> begin[i];
    }
}

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

int main(int, const char**)
{
    string t;
    cin >> t;
    string o = t;
    for(size_t i = 0; i < o.size(); ++i)
    {
        if(o[i] == '?')
        {
            o[i] = 'D';
        }
    }
    cout << o << endl;
    return 0;
}


Measured memory_bytes: 3924
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

const int INF = 900000;

int main(){
    int n;
    cin >> n;
    int a[50][30] = {0};
    rep(i,n){
        string s;
        cin >> s;
        rep(j,s.size()){
            a[i][s[j] - 'a']++;
        }
    }
    rep(i,26){
        int cnt = INF;
        rep(j,n){
            cnt = min(cnt, a[j][i]);
        }
        rep(j,cnt){
            cout << static_cast<char>('a' + i);
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int lli;
typedef pair<lli, lli> pll;
const lli mod = 998244353;
const lli inf = 1e18;

//区間max
struct segmentTree{
    vector<lli> node;
    int n;
    
    segmentTree(vector<lli> v){
        int s = v.size();
        n = 2;
        while(n < s) n *= 2;
        node = vector<lli>(2*n -1, -inf);
        for(int i=0; i<s; i++){
            node[i +n-1] = v[i];
        }
        for(int i=n-2; i>=0; i--){
            node[i] = max(node[2*i +1], node[2*i +2]);
        }
    }
    segmentTree(){}
    
    void Set(lli val, int pos){
        int idx = n-1 + pos;
        node[idx] = val;
        do{
            idx = (idx -1)/2;
            node[idx] = max(node[2*idx +1], node[2*idx +2]);
        }while(idx != 0);
    }
    lli Get(int l, int r){
        if(l == r) return -inf;
        return _get(l, r, 0, 0, n);
    }
    lli _get(int l, int r, int k, int cl, int cr){
        if(l <= cl && cr <= r){
            return node[k];
        }
        if(r <= cl || cr <= l){
            return -inf;
        }
        int m = (cl +cr)/2;
        return max(_get(l, r, 2*k+1, cl, m), _get(l, r, 2*k+2, m, cr));
    }
};

int main(){
    int n;
    cin >> n;
    vector<pll> xd(n);
    for(int i=0; i<n; i++){
        cin >> xd[i].first >> xd[i].second;
    }
    sort(xd.begin(), xd.end());
    vector<lli> x(n),d(n);
    for(int i=0; i<n; i++){
        x[i] = xd[i].first;
        d[i] = xd[i].second;
    }

    vector<lli> dp(n+1, 0);
    dp[n] = 1;
    segmentTree seg(vector<lli>(n, 0));
    for(int i=n-1; i>=0; i--){
        int toidx = lower_bound(x.begin(), x.end(), x[i]+d[i]) -x.begin();
        seg.Set(toidx, i);
        int newtoidx = seg.Get(i, toidx);
        seg.Set(newtoidx, i);
        dp[i] = (dp[i+1] +dp[newtoidx]) %mod;
    }
    cout << dp[0] << endl;
    return 0;
}

Measured memory_bytes: 13696
#include<iostream>
using namespace std;
int n;
double t[6]={165.0,170.0,175.0,180.0,185.0,9999999.9};
int cnt[6];
double in;
int main(){
  for(int i=0;i<6;i++)cnt[i]=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>in;
    for(int j=0;j<6;j++){
      if(in<t[j]){cnt[j]++;break;}
    }
  }
  for(int i=0;i<6;i++){
    cout<<i+1<<':';
    for(int j=0;j<cnt[i];j++){
      cout<<'*';
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#include<stdio.h>

#define H 255

int main()
{
  int heap[H];
  int a,i;

  scanf("%d", &a);
  for(i=1;i<=a;i++) scanf("%d", &heap[i]);

  for(i=1;i<=a;i++)
  {
    printf("node %d: ",i);
    printf("key = %d, ",heap[i]);
    if(i/2 != 0)   printf("parent key = %d, ",heap[i/2]);
    if(2*i <= a)   printf("left key = %d, ",heap[2*i]);
    if(2*i+1 <= a) printf("right key = %d, ",heap[2*i+1]);
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
int main(){long long n,m=0,i;
cin>>n;
long long a[n];
for(i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%2==0){
        if((a[i]%3)!=0&&(a[i]%5)!=0)
        m=1;
    }
}if(m==1)
cout<<"DENIED";
else
cout<<"APPROVED";

    return 0;
  
}


Measured memory_bytes: 256
#include <iostream>

#define int long long

const int LIMIT=1e9+7;

using namespace std;

signed main(){
    int n=0;
    cin >> n;
    int res=1;
    for(int i=2;i<=n;i++){
        res*=i;
        if(res>=LIMIT){
            res%=LIMIT;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll A,B,C;
    cin >>A>>B>>C;
    
    cout << min({A*B,B*C,A*C})/2 << endl;


    return 0;
    

}

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

typedef long long ll;

const int MAXV = 1e5 + 10;
const int MAXN = 1e3 + 10;
const ll INF = 1e13;

ll dp[MAXV];
int N,W,V,wi[MAXN],vi[MAXN];

int main(){

	cin >> N >> W;
	for(int i = 1;i<=N;i++){
		cin >> wi[i] >> vi[i];
		V += vi[i];
	}

	for(int i = 1;i<=V;i++) dp[i] = INF;
	dp[0] = 0;
	
	for(int item = 1;item<=N;item++){
		int w = wi[item], v = vi[item];
		for(int i = V;i>=v;i--){
			dp[i] = min(dp[i],dp[i - v] + w);
		}
	}

	for(int i = V;i>=0;i--){
		if(dp[i] <= W){
			cout << i << endl;
			break;
		}
	}

	return 0;

}

Measured memory_bytes: 4384
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int N;
	cin >> N;
	vector<int> V(N), C(N);
	for(int i = 0; i < N; i++)	cin >> V[i];
	for(int i = 0; i < N; i++)	cin >> C[i];

	vector<int> A(N);
	int sum = 0;
	for(int i = 0; i < N; i++){
		if(V[i] - C[i] >= 0)
			sum += V[i] - C[i];
	}

	cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>

#define rep(i,p,n) for(int i=p;i<n;i++)
#define lli long long int
#define vi vector<int> 

using namespace std;

int max(int x, int y) {
	int a;
	(x > y) ? a = x : a = y;
	return a;
}

int min(int x, int y) {
	int a;
	(x < y) ? a = x : a = y;
	return a;
}


int main() {
	string s;
	cin >> s;
	int sum = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '1')sum++;
	}

	cout << sum << endl;

	return 0;
}


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

int main(){
	int H, n;	cin >> H >> n;
	int total = 0;
	for (int i = 0; i < n; ++i){
		int x;	cin >>  x;
		total += x;
	}
	if(H <= total)	cout << "Yes" << endl;
	else 			cout << "No"  << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
Plist = list(map(int,input().split()))
count = 0
for i in range(N-2):
    a1 = Plist[i]
    a2 = Plist[i+1]
    a3 = Plist[i+2]
    b1 =  (a1 < a2 and a2 < a3) 
    b2 =  (a3 < a2 and a2 < a1) 
    if b1 or b2:
        count += 1
print( count )

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

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

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  startupcpp();
  ll a,b;
  cin>>a>>b;
  cout<<a-b+1<<endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC102.A
{
    class Program
    {
        static void Main ()
        {
            int n = int.Parse (Console.ReadLine ());
            Console.WriteLine (n % 2 == 0 ? n : n * 2);
        }
    }
    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner ()
        {
            s = new string[0];
            i = 0;
        }

        public string Next ()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine ();
            while (st == "") st = Console.ReadLine ();
            s = st.Split (cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next ();
            i = 0;
            return s[i++];
        }

        public int Nextint ()
        {
            return int.Parse (Next ());
        }
        public int[] Arrayint (int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint () + add;
            }
            return Array;
        }

        public long NextLong ()
        {
            return long.Parse (Next ());
        }

        public long[] ArrayLong (int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong () + add;
            }
            return Array;
        }

        public double NextDouble ()
        {
            return double.Parse (Next ());
        }

        public double[] ArrayDouble (long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble () + add;
            }
            return Array;
        }

        public decimal NextDecimal ()
        {
            return decimal.Parse (Next ());
        }

        public decimal[] ArrayDecimal (long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal ();
            }
            return Array;
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

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

    ll ans = inff;
    ll q = 0;
    for (int i = 0; i <= 100000; i++) {
        ans = min(ans, i*2*c + (max(q, x-i)*a) + (max(q, y-i)*b));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
*/#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
/*namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
*/#define lli long long int
#define uli unsigned long long int
#define INF 999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> S;
  N=S.size();
  lli dp[114514][4];
  rep(i,0,114514)rep(j,0,4)dp[i][j]=0;
  dp[0][0]=1;
  if(S[0]=='A')dp[0][1]=1;
  else if(S[0]=='?'){
    dp[0][0]=3;
    dp[0][1]=1;
  }
  rep(i,1,N){
    if(S[i]!='?'){
      dp[i][0]=dp[i-1][0];
      if(S[i]=='A')dp[i][1]=(dp[i-1][1]+dp[i-1][0])%mod;
      else dp[i][1]=dp[i-1][1];
      if(S[i]=='B')dp[i][2]=(dp[i-1][2]+dp[i-1][1])%mod;
      else dp[i][2]=dp[i-1][2];
      if(S[i]=='C')dp[i][3]=(dp[i-1][3]+dp[i-1][2])%mod;
      else dp[i][3]=dp[i-1][3];
    }
    else{
      dp[i][0]=dp[i-1][0]*3%mod;
      dp[i][1]=(dp[i-1][1]*3+dp[i-1][0])%mod;
      dp[i][2]=(dp[i-1][2]*3+dp[i-1][1])%mod;
      dp[i][3]=(dp[i-1][3]*3+dp[i-1][2])%mod;
    }
  }
  /*rep(i,0,4){
    rep(j,0,N)cout << dp[j][i] << " ";
    Out("");
  }*/
  Out(dp[N-1][3]);
}

Measured memory_bytes: 7344
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N = 1e5 + 5;
#define int long long int

int32_t main() {
    IOS ;
    // int t ; cin >> t ; while(t--) {}
    string a, b ; cin >> a >> b ; 
    int n1 = a.length(), n2 = b.length() ; 
    
    int res = n2 ;
    for(int i=0; i<=(n1-n2); i++) {
        int cnt = 0 ;
        for(int j=0; j<n2; j++) {
            if(a[i+j] != b[j]) cnt++ ; 
        }
        res = min(res, cnt) ;
    }
    
    cout << res ; 
    return 0 ;
}


Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
using namespace std;
typedef unsigned long long ll;
int main(){
  int n,val,num,inindex;
  vector<int> Index;
  map<int,ll> List;
  while(true){
    scanf("%d",&n);
    if(n == 0)break;
    List.clear();
    Index.clear();
    for(int i=0;i<n;i++){
      scanf("%d %d %d",&inindex,&val,&num);
      if(!List[inindex]){
	Index.push_back(inindex);
      }
      List[inindex]+=val*num;
    }
    bool NAf=true;
    for(int i=0;i<Index.size();i++){
      if(List[Index[i]] >= 1000000){
	printf("%d\n",Index[i]);
	NAf=false;
      }
    }
    if(NAf)printf("NA\n");
  }

  return 0;
}

Measured memory_bytes: 0
// AOJ 1311: Test Case Tweaking
// 2018.1.13 bal4u

#include <stdio.h>
#include <string.h>

#define QMAX 100000
typedef struct { int t, s, d; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && (que[l].t < que[i].t ||
		(que[l].t == que[i].t && que[l].d < que[i].d)))
		min = l; else min = i;
	if (r < qsize && (que[r].t < que[min].t ||
  		(que[r].t == que[min].t && que[r].d < que[min].d))) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t, int d)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t, que[i].d = d;
	while (i > 0 && (que[min = PARENT(i)].t > que[i].t ||
					 que[min].t == que[i].t && que[min].d > que[i].d)) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

int to[101][101], dt[101][101], hi[101];
char used[101][101];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int dijkstra(int n, int c, int start, int goal)
{
	int i, s, t, d, e, t2, ans;

	memset(used, 0, sizeof(used));
	qsize = 0;
	ans = n;
	enq(start, 0, 0);
	while (qsize) {
		s = que[0].s, t = que[0].t, d = que[0].d, deq();
		if (s == goal) {
			if (d < ans) ans = d;
			continue;
		}
		if (d >= ans || used[s][d]) continue;
		used[s][d] = 1;
		for (i = 0; i < hi[s]; i++) {
			e = to[s][i];
			t2 = t+dt[s][i];
			enq(e, t, d+1);
			if (t2 <= c) enq(e, t2, d);
		}
	}
	return ans;
}

int main()
{
	int n, m, c, f, k;
	
	while (n = in()) {
		m = in(), c = in();
		memset(hi, 0, sizeof(hi));

		while (m--) {
			f = in()-1, k = hi[f]++;
			to[f][k] = in()-1, dt[f][k] = in();
		}
		printf("%d\n", dijkstra(n, c, 0, n-1));
	}
	return 0;
}


Measured memory_bytes: 1976
function Main(inp) {
    var input = inp.split('\n')[0].split(' ').map(function(n) {
        return Number(n);
    });
    var start = Math.max(input[0], input[2]);
    var end = Math.min(input[1], input[3]);
    var overlap = Math.max(0, end - start);
    console.log(overlap);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
#include<queue>
#include<map>

using namespace std;
const int MAX = 200;

class Stack {
    private:
        int S[MAX] = {0};
        int sp = -1;

    public:
        void init();
        void push(int x);
        int pop();
        bool isEmpty();
        bool isFull();
};

void Stack::init(){
    sp = -1;
}

void Stack::push(int x){
    if(isFull()){
        sp++;
        S[sp] = x;
    } else {
        cout << "入れられません" << endl;
        return;
    }
}

int Stack::pop(){
    if(isEmpty()){
        int retval = S[sp];
        sp--;
        return retval;
    } else {
        cout << "中身がありません" << endl;
        return NULL;
    }
}

bool Stack::isEmpty(){
    if(sp  >=  0) return true;
    else return false;
}

bool Stack::isFull(){
    if(sp+1 < MAX) return true;
    else {
        cout << "オーバーフロー" << endl;
        return false;
    }
}


int main(){
    Stack stack;

    int a, b;
    char input[100];

    while(scanf("%s", input) != EOF){
        switch (input[0]){
            case '+':
                a = stack.pop();
                b = stack.pop();
                stack.push(a+b);
                break;
            case '-':
                a = stack.pop();
                b = stack.pop();
                stack.push(b-a);
                break;
            case '*':
                a = stack.pop();
                b = stack.pop();
                stack.push(a*b);
                break;
            default:
                stack.push(atoi(input));
                break;
        }
    }

    cout << stack.pop() << endl;
}


Measured memory_bytes: 3208
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            Set<Integer> a = new HashSet<>();
            for (int i = 0; i < m; i++)
                a.add(in.nextInt());

            long[] dp = new long[n + 1];
            dp[0] = 1;
            long mod = 1_000_000_007;
            for (int i = 0; i < n; i++) {
                if (a.contains(i))
                    continue;
                if (!a.contains(i + 1))
                    dp[i + 1] = (dp[i] + dp[i + 1]) % mod;
                if (i < n - 1 && !a.contains(i + 2))
                    dp[i + 2] = (dp[i] + dp[i + 2]) % mod;
            }
            out.println(dp[n]);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
            this.bufPointer = 0;
            this.bufLength = 0;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int nextInt() {
            int n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

    }
}



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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, K;
    cin >> N >> K;
    ll res = 0;
    for(int b=K+1; b<=N; b++){
        res += (N/b)*(b-K);
        if(N%b>=K) res += (N)%b-K + (K==0? 0:1);
    }
    cout<<res<<endl;

    return 0;
}

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

int main()
{
	int A,B,C,D;
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> D;
	int ans = max(A * B, C * D);
	cout<<ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
typedef long long ll;
const int V_MAX = 1e5;
const ll INF = 1e15;

int main(){
  int N, W;
  cin >> N >> W;
  ll w[N], v[N];
  rep(i, N) cin >> w[i] >> v[i];
  vector<vector<ll>> dp(N+1, vector<ll>(V_MAX+1, INF));
  dp[0][0] = 0;
  rep(i, N){
    rep(j, V_MAX+1){
      if(j - v[i] >= 0) dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]]+w[i]);
      else dp[i+1][j] = dp[i][j];
    }
  }
  int ans;
  for(int i = V_MAX; i >= 0; i--){
    if(dp[N][i] <= W){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define debug(x_) cerr << #x_ << ":" << x_ << endl;
#define debug2(x__) for(auto a__ : x__) cerr << a__ << " "; cerr << endl;
#define debug3(x___ , sx___) rep(i, sx___) cerr << x___[i] << " "; cerr << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    map<char, int> mp_s, mp_t;
    int now_num = 'a';
    for (auto &&c : s) {
        if (mp_s.find(c) == mp_s.end()) {
            mp_s[c] = now_num;
            now_num++;
            c = mp_s[c];
        } else {
            c = mp_s[c];
        }
    }
    now_num = 'a';
    for (auto &&c : t) {
        if (mp_t.find(c) == mp_t.end()) {
            mp_t[c] = now_num;
            now_num++;
            c = mp_t[c];
        } else {
            c = mp_t[c];
        }
    }
    Yes(s == t);
    cerr << s << endl << t << endl;
    return 0;
}


Measured memory_bytes: 916
#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(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    REP(i,3){
	int h[2];
	int m[2];
	int s[2];
	cin >> h[0] >> m[0] >> s[0];
	cin >> h[1] >> m[1] >> s[1];
	int time = 0;
	time += h[1] * 3600 + m[1] * 60 + s[1];
	time -= h[0] * 3600 + m[0] * 60 + s[0];
	cout << time / 3600;
	time %= 3600;
	cout << " " << time / 60;
	time %= 60;
	cout << " " << time << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import sys
import numpy as np
from numba import njit

def main(N, S, dp):
    ans = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            dp[i,j] = min(j - i, dp[i - 1,j - 1] + 1) if S[i] == S[j] else 0
        ans = max(ans, np.max(dp[i]))
    return ans


if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', 'i8(i8,i8[:],i8[:,:])')(main)
    # b1: bool, i4: int32, i8: int64, double: f8, [:], [:, :]
    cc.compile()
else:
    from my_module import main
    N = int(input())
    S = np.array([ord(_) for _ in input()])
    dp = np.zeros((N + 1, N + 1), dtype=int)
    print(main(N, S, dp))


Measured memory_bytes: 208628
#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)
using namespace std;

int main() {
  int64_t N, W;
  cin >> N >> W;
  vector<int64_t> w(N + 1), v(N + 1);
  rep1(i, N) cin >> w.at(i) >> v.at(i);

  vector<vector<int64_t>> dp(N + 1, vector<int64_t>(W + 1, 0));

  rep1(i, N) {
    rep(j, W + 1) {
      if (j < w.at(i)) {
        dp.at(i).at(j) = dp.at(i - 1).at(j);
      } else {
        int64_t a = dp.at(i - 1).at(j - w.at(i)) + v.at(i);
        int64_t b = dp.at(i - 1).at(j);
        dp.at(i).at(j) = max(a, b);
      }
    }
  }

  cout << dp.at(N).at(W) << endl;
  return 0;
}


Measured memory_bytes: 80256
using System;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            int S = cin.NextInt();
            int W = cin.NextInt();
            if (S > W)
            {
                Console.WriteLine("safe");
            }
            else
            {
                Console.WriteLine("unsafe");
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 27492
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, t int
	fmt.Scan(&n, &t)

	foods := make([]Food, n)
	var a, b int
	for i := 0; i < n; i++ {
		fmt.Scan(&a, &b)
		foods[i] = Food{a, b}
	}
	sort.Slice(foods, func(i, j int) bool {
		return foods[i].a < foods[j].a
	})

	ans := 0
	dp := [3001][3001]int{}
	for i := 0; i < n; i++ {
		food := foods[i]
		for j := 0; j < t; j++ {
			dp[i+1][j] = max(dp[i+1][j], dp[i][j])
			nj := j + food.a
			if t <= nj {
				continue
			}
			dp[i+1][nj] = max(dp[i+1][nj], dp[i][j]+food.b)
		}
		ans = max(ans, dp[i][t-1]+food.b)
	}
	fmt.Println(ans)
}

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

// Food .
type Food struct {
	a, b int
}


Measured memory_bytes: 74812
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  int w = tx - sx;
  int h = ty - sy;

  rep(i, h) printf("U");
  rep(i, w) printf("R");
  rep(i, h) printf("D");
  rep(i, w) printf("L");
  printf("L");
  rep(i, h + 1) printf("U");
  rep(i, w + 1) printf("R");
  printf("DR");
  rep(i, h + 1) printf("D");
  rep(i, w + 1) printf("L");
  printf("U\n");
}


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

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

  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
let n = read_int ()
let ss = Array.(to_list @@ init n @@ fun _ -> read_line ())
let m = read_int ()
let ts = Array.(to_list @@ init m @@ fun _ -> read_line ())
let f u = List.(length (filter ((=) u) ss) - length (filter ((=) u) ts))
let _ = List.fold_left (fun a s -> max a @@ f s) 0 ss |> Printf.printf "%d\n"

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

int main() {
  int A, B;
  cin >> A >> B;
  int C = A;
  int sum = 0;
  for (int i = 0; i < (B - A + 1); i++) {
    int D = C % 10;
    int E = (C / 10) % 10;
    int G = (C / 1000) % 10;
    int H = (C / 10000) % 10;
    if (D == H && E == G) {
      sum++;
    }
    C++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
import itertools
import math
N = int(input())
P_tuple = tuple(map(int, input().split()))
Q_tuple = tuple(map(int, input().split()))

for index, p in zip(range(math.factorial(N)), itertools.permutations(range(1, N + 1))):
    if p == P_tuple:
        a = index + 1
    if p == Q_tuple:
        b = index + 1

print(abs(a - b))

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

using namespace std;
using i64 = long long int;
using ui64 = unsigned long long int;

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

int main()
{
    int t,d,l;
    while(cin >> t >> d >> l,t){
        vector<int> v(t);
        for(int i=0;i<t;i++)cin >> v[i];
        vector<bool> iw(t+d+2,false);
        auto it = iw.begin();
        for(int i=0;i<t;i++,it++){
            if(v[i] >= l)fill(it,it+d,true);
        }
        int res = 0;        
        for(int i=0;i<t-1;i++){
            if(iw[i])res++;
        }
        cout << res << endl;
    }
}




Measured memory_bytes: 3496
#include <iostream>
using namespace std;
int main(){

  int a,b,c1=0,c2=0,c3=0;

  while(cin>>a>>b,a){

  b-=a;

  c1=b/1000;
  b=b%1000;
  c2=b/500;
  b=b%500;
  c3=b/100;

  cout<<c3<<" "<<c2<<" "<<c1<<endl;
  }
  return 0;

}

Measured memory_bytes: 3104