akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

typedef struct {
	int id;
	int time;
} TEAM;

TEAM team[1080000];

int cmp(TEAM *A, TEAM *B)
{
	return (A->time - B->time);
}

int main(void)
{
	int i, n, j;
	int m, s;
	
	while (scanf("%d", &n), n){
		memset(team, 0, sizeof(team));
		
		for (i = 0; i < n; i++){
			scanf("%d", &team[i].id);
			
			for (j = 0; j < 4; j++){
				scanf("%d %d", &m, &s);
				
				team[i].time += m * 60 + s;
			}
		}
		
		qsort(team, n, sizeof(TEAM), cmp);
		
		printf("%d\n%d\n%d\n", team[0].id, team[1].id, team[n-2].id);
	}
	
	return (0);
}

Measured memory_bytes: 9128
n=int(input())
l=list(map(int,input().split()))
l.sort()
num=[0]*(max(l)+2)
for i in range(n):
    num[l[i]]=i
for i in range(1,len(num)):
    if num[i]==0:
        num[i]=num[i-1]
ans=0
num3=l[n-1]
for i in range(n-2):
    for j in range(i+1,n-1):
        ans+=max(0,num[min(num3,l[i]+l[j]-1)]-j)
print(ans)


Measured memory_bytes: 70988
program scoring
    implicit none
    integer(8)::D,C(26),last(26,365),last_sim(26,365),i,j,k,vmax,tbest,dadd,i_calc,vbest,add_best
    integer(8),allocatable::S(:,:),T(:),Tans(:),V(:)

    !入力
    read*,D,C
    allocate(S(26,D))
    allocate(T(D))
    allocate(Tans(D))
    allocate(V(D))
    read*,S
    T=0
    V=0
    last=0
    last_sim=0

    !貪欲法
    do dadd=0,26
        T=0
        V=0
        last=0
        last_sim=0
        !今日の日付+dadd日目のパラメータを使用して満足度を計算する
        do i=1,D
            i_calc=min(i+dadd,D)
            do j=1,26
                !得点の初期化
                if(i==1)V(i)=0
                if(i>1)V(i)=V(i-1)

                !lastの初期化
                if(i==1)last(:,i)=0
                if(i>1)last(:,i)=last(:,i-1)

                last(j,i)=i
                V(i)=V(i)+S(j,i_calc)
                
                do k=1,26
                    V(i)=V(i)-C(k)*(i-last(k,i))
                end do

                if(j==1)then
                    vmax=V(i)
                    tbest=j
                else if(V(i)>=vmax)then
                    vmax=V(i)
                    tbest=j
                end if
            end do
            if(i==1)last(:,i)=0
            if(i>1)last(:,i)=last(:,i-1)
            T(i)=tbest
            last(tbest,i)=i
        end do
        if(dadd==0.or.V(D)>vbest)then
            add_best=dadd
            vbest=V(D)
            Tans(:)=T(:)
        end if
        !if(dadd==0)print'(i0)',vbest
    end do
    !print'(i0)',vbest

    do i=1,D
        print'(i0)',Tans(i)
    end do
end program scoring

Measured memory_bytes: 3108
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

// 奇数回反転するものだけカウントする
// n == 1 and m == 1の時
// 1
// n == 1 or m == 1の時
// max(n, m)-2;
// n == 2 or m == 2のとき
// 0
// n >= 3 and m >= 3の時
// 四隅: 偶数(4)
// 枠: 偶数(6)
// その他: 奇数(9)
int main() {
  ll n, m; in(n),in(m);
  if (n == 1 and m == 1) {
    print(1);
    return 0;
  }
  
  if (n == 1 or m == 1) {
    print(max(n, m)-2);
    return 0;
  }
  
  if (n == 2 or m == 2) {
    print(0);
    return 0;
  }
  
  print((n-2)*(m-2));
  return 0;
}


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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(10)





void solve() {

	string s;
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		s += to_string(i);
	}
	string A, B;
	for(int i = 0; i < n; i++) {
		char ch;
		cin >> ch;
		A += ch;
	}
	for(int i = 0; i < n; i++) {
		char ch;
		cin >> ch;
		B += ch;
	} 	
	int a = -1, b = -1;
	int cnt = 0;
	while(a == -1 || b == -1) { 	
		if(s == A) {
			a = cnt;
		}
		if(s == B) {
			b = cnt;
		}
		cnt++;
		next_permutation(s.begin(), s.end());
	}
	cout << abs(a - b) << "\n";
	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	
	solve();

	return 0;
}



Measured memory_bytes: 3712
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>




int n,k,d,t;
bool b[16],vld;





void solve()
{
	for(int i=0;i<10;i++)b[i]=0;
	cin>>n>>k;
	for(int i=1;i<=k;i++)
	{
		cin>>d;
		b[d]=1;
	}
	for(int i=n;;i++)
	{
		t=i;
		vld=1;
		for(;t;)
		{
			d=t%10;
			t/=10;
			if(b[d])vld=0;
		}
		if(vld)
		{
			cout<<i<<"\n";
			return;
		}
	}
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>                                                      
using namespace std;
int main()
{
  int N;
  int L;
  cin >> N >> L;
  vector<int> taste(N);
  vector<int> sum(N);
  for(int i=0; i<N; i++){
    taste.at(i)=L+i;
  }
  int all_sum=0;
  for(int i=0; i<N; i++){
    all_sum+=taste.at(i);
  }
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(i!=j){
        sum.at(i)+=taste.at(j);
      }
    }
  }
  vector<int> d(N);
  for(int i=0; i<N; i++){
    d.at(i)=abs(all_sum-sum.at(i));
  }
  int min=300;
  int number=0;
  for(int i=0; i<N; i++){
    if(d.at(i)<min){
      min=d.at(i);
      number=i;
    }
  }
  cout << sum.at(number) << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#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##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int N;
vector<string> S;

vector<int> depth;
queue<int> que;

int main() {
    cin >> N;
    S.resize(N);
    rep(i, N) cin >> S[i];

    int ans = 0;

    rep(r, 0, N) {
        depth.assign(N, -1);
        bool ng = false;

        que.push(r);
        depth[r] = 1;

        while (!que.empty()) {
            int v = que.front();
            que.pop();

            for (int u = 0; u < N; ++u) {
                if (S[v][u] == '0') continue;
                if (depth[u] != -1) {
                    if (abs(depth[u] - depth[v]) != 1) {
                        ng = true;
                        break;
                    }
                }
                else {
                    depth[u] = depth[v] + 1;
                    que.push(u);
                }
            }

            if (ng) break;
        }

        if (ng) {
            while (!que.empty()) que.pop();
        }
        else {
            int s = *max_element(all(depth));
            ans = max(ans, s);
        }
    }

    write(ans ? ans : -1);
}

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

int main (void){
    int N,K;
    cin >> N >> K;
    vector<int> d;
    vector<vector<int>> A;
    d.resize(K);
    A.resize(K, vector<int>());
    REP(i,K){
        cin >> d[i];
        A[i].resize(d[i]);
        REP(j,d[i]){
            cin >> A[i][j];
        }
    }
    int cnt = 0;
    for(int i=1;i<=N;i++){
        bool have = false;
        for(auto v:A){
            for(auto p:v){
                if(p == i) have = true;
            }
        }
        if(!have) cnt++;
    }

    cout << cnt << endl;

}

Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i,N) cin >> a[i];
  sort(a.begin(), a.end());
  map<int, int> mp;
  REP(i,N){
    mp[a[i]]++;
  }
  int ct = 0;
  for(auto y = mp.begin(); y != mp.end(); y++){
    if(y->first < y->second){
      ct += y->second - y->first;
    }else if(y->first > y->second){
      ct += y->second;
    }
  }
  cout << ct << endl;
  return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	string S, T;
	cin >> S >> T;
	int N = S.size();

	int n[100001][26];

	int tugi[26];
	rep(i, 26) tugi[i] = -1;
	for (int i = N - 1; i >= 0; i--) {
		int c = S[i] - 'a';
		tugi[c] = i;
	}
	for (int i = N - 1; i >= 0; i--) {
		rep(j, 26) n[i][j] = tugi[j];
		int c = S[i] - 'a';
		tugi[c] = i;
	}


	int OK = 1;
	ll kotae = 0;
	int k = N - 1;
	rep(i, (int)T.size()) {
		int c = T[i] - 'a';
		int k2 = n[k][c];
		if (k2 == -1) {
			OK = 0;
			break;
		}

		if (k2 > k) kotae += k2 - k;
		else kotae += k2 - k + N;
		k = k2;
	}

	if (OK) co(kotae);
	else co(-1);

	Would you please return 0;
}

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

int main(){
    int n;
    cin >> n;
    if(n == 1){
        cout << "Hello World" << endl;
    } else {
        int a,b;
        cin >> a >> b;
        cout << a+b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define pb push_back
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const int N=100;
const int W=10000;

int main(){
	string s;
	cin>>s;
	ll ss=s.size();
	stack<ll> st;
	stack<ll_pair> S2;
	FOR(i,0,ss){
		if(s[i]=='\\'){
			st.push(i);
		}else if(s[i]=='/'){
			if(st.empty())continue;
			S2.push({st.top(),i-st.top()});
			st.pop();
			while(1){
				if(S2.size()<=1)break;
				ll_pair p=S2.top();
				S2.pop();
				if(S2.top().first>p.first){
					S2.top().first=p.first;
					S2.top().second+=p.second;
				}else{
					S2.push(p);
					break;
				}
			}
		}
	}
	vector<ll> v;
	ll ans=0;
	while(not S2.empty()){
		ans+=S2.top().second;
		v.pb(S2.top().second);
		S2.pop();
	}
	cout<<ans<<endl<<v.size();
	ll vs=v.size();
	FOR(i,0,v.size()){
		cout<<" "<<v[vs-i-1];
	}
	cout<<endl;
}


Measured memory_bytes: 3252
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char c=getchar();int fh=1;
	while (!isdigit(c)){if (c=='-')fh=-1;c=getchar();}
	while (isdigit(c))x=x*10+c-'0',c=getchar();
	x*=fh;
}
int x,a[10];
int main(){
	for (int i=1;i<=6;i++){cin>>x;a[x]++;}
	for (int i=1;i<=4;i++){if (a[i]>=3){puts("NO");return 0;}}
	puts("YES");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int L[110];

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  if((a <= b && b <= c)||(b <= a && a <= c)){
    cout << a + b << endl;
  }
  
  else if((c <= b && b <= a)||(b <= c && c <= a)){
    cout << b + c << endl;
  }
  
  else if((a <= b && c <= b)){
    cout << a + c << endl;
  }
     }


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List
maxl [x] = x
maxl (x:xs) = let d = maxl xs
             in
             if x > d then x else d
count t [] = 0
count t (x:xs) = if t == x then
                    1 + count t xs
                 else
                        count t xs
main = do
        n <- read <$> getLine
        s <- replicateM n getLine
        m <- read <$> getLine
        t <- replicateM m getLine
        let d = [(count x s) - (count x t) | x <- (s++t)]
        print $ if maxl d >= 0 then maxl d else 0

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

using ll = long long;
int main()
{
    int N, K;
    int A[505];
    int sum = 0;
    int ans = 1;
    vector < int > divisor;

    cin >> N >> K;
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
        sum += A[i];
    }
    
    for ( ll i = 1; i * i <= sum; i++ ) {
        if ( sum % i == 0 ) {
            divisor.push_back(i);
            if ( i != sum / i ) divisor.push_back(sum / i);
        }
    }

    for ( int div : divisor ) {
        vector < ll > da, db;
        da.push_back(0); db.push_back(0);
        for ( int i = 0; i < N; i++ ) {
            ll dda = (A[i] + div - 1) / div * div - A[i];
            ll ddb = A[i] - A[i] / div * div;
            if ( dda > 0 ) {
                da.push_back(dda);
                db.push_back(ddb);
            }
        }
        sort(begin(da), end(da));
        sort(begin(db), end(db));
        for ( int i = 1; i < da.size(); i++ ) {
            da[i] += da[i - 1];
            db[i] += db[i - 1];
        }
        for ( int i = 0; i < da.size(); i++ ) {
            if ( da[i] == db[(int)da.size() - i - 1] && da[i] <= K ) {
                ans = max(ans, div);
            }
        }
    }

    cout << ans << endl;

    return ( 0 );
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
C = list(C.values())
C.sort()
n = len(C)
m = max(C)
S = [0]*(m+1)
b = 0
for i in range(n):
    c = C[i]
    if b<c:
        for j in range(b+1, c+1):
            S[j] = S[j-1]+(n-i)
        b = c
for i in range(1, N+1):
    ok = 0
    ng = N+1
    while ng-ok>1:
        mid = (ok+ng)//2
        if S[min(m, mid)]>=mid*i:#midが条件を満たすか
            ok = mid
        else:
            ng = mid
    print(ok)


Measured memory_bytes: 120496
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include<functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;



/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/



int main()
{
	int n;
	
	while (cin >> n, n)
	{
		vector<int> h(n + 1);
		int ans;
		
		for (int i=0; i<n+1; i++) cin >> h[i];
		for (int i=0; i<n+1; i++)
		{
			vector<int> t;
			for (int j=0; j<n+1; j++)
			{
				if (i != j) t.push_back(h[j]);
			}
			int mx = t[1] - t[0];
			int mn = t[1] - t[0];
			for (int j=1; j<n; j++)
			{
				int d = t[j] - t[j - 1];
				if (d > mx) mx = d;
				if (d < mn) mn = d;
			}
			if (mx == mn)
			{
				ans = h[i];
				break;
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int H, W;
const int MAX_HW = 500;
string a[MAX_HW];

int main(){
  cin >> H >> W;
  REP(i, H) cin >> a[i];

  char red[H][W], blue[H][W];

  REP(i, H) {
    REP(j, W) {
      red[i][j] = '.';
      blue[i][j] = '.';
    }
  }

  REP(i, H) {
    red[i][0] = '#';
    blue[i][W - 1] = '#';
  }
  for(int j = 1; j < W - 1; j++) {
    REP(i, H) {
      if(i % 2 == 0) {
        red[i][j] = '#';
      } else {
        blue[i][j] = '#';
      }
    }
  }

  REP(i, H) REP(j, W) if(a[i][j] == '#') {
    red[i][j] = '#';
    blue[i][j] = '#';
  }

  REP(i, H) {
    REP(j, W) {
      cout << red[i][j];
    }
    cout << endl;
  }
  cout << endl;
  REP(i, H) {
    REP(j, W) {
      cout << blue[i][j];
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 1536
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl

//毎回変える場所
#define N_MAX 200001
#define INF 1000000007

//問題文のとおり
int N,M,temp1,temp2;

//（現在地：index→要素：行き先）
vector<int> place[N_MAX];


int main() {
	//入力
	cin>>N>>M;
	REP(i, M) {
		cin>>temp1>>temp2; 
		place[temp1].push_back(temp2);
	}

	//1から行ける場所全てを探索
	REP(i, place[1].size()) {
		//1回目の旅行の行き先
		int first = place[1][i];
		//そこから行ける場所全て探索
		REP(i, place[first].size()) {
			//行き先にあればOK
			if (place[first][i] == N) {
				goto CLEAR;
			}
		}
	}
//FAIL
	cout<<"IMPOSSIBLE"<<endl;
	return 0;


CLEAR:
	cout<<"POSSIBLE"<<endl;
	return 0;
}

Measured memory_bytes: 8576
import bisect

n = int(input())
a = list(map(int, input().split()))
a.sort()
k = len(a)
ok = [0] * k
for i in range(k):
    if i < k - 1 and a[i] == a[i + 1]:
        ok[i] = 1
        ok[i+1] = 1;
        continue

    if a[i] < 2 * 100:
        for j in range(i + 1, k):
            if a[j] % a[i] == 0:
                ok[j] = 1
    else:   
        times = 2
        while a[i] * times <= a[-1]:
            r = bisect.bisect_left(a, a[i] * times + 1)
            l = bisect.bisect_left(a, a[i] * times)
            if r != l:
                for idx in range(l, r):
                    ok[idx] = 1
            times += 1
print(len([i for i in ok if i == 0]))
# print(ok) WAはどこ？


Measured memory_bytes: 99204
#include <iostream>
#include <string>
#include <cmath>

using namespace std;
int mylog2(int a, int k){
    int i = 0;
    int pow = a;
    for(; pow < k; pow *= 2, i++);
    return i;
}

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

    double ans = 0;
    for(int i = n; i >= 1; i--){
        //cout << i << endl;
        int rep = mylog2(i, k);
        ans += (1/pow(2, rep));
        
    }

    ans /= n;
    printf("%.10lf\n", ans);
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))

constexpr ll MOD = 1e9+7;
// constexpr int INF = 1<<25;
// constexpr ll  INF = 1LL<<50;

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T checkmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T checkmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if (e-a<=k) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }

  return 0;
}


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

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

vector<int> p;
vector<int> r;

void init(int n) {
  p.reserve(n);
  r.reserve(n);
  for (int i = 0; i < n; i++) {
    p[i] = i;
    r[i] = 0;
  }
}

int root(int x) { return p[x] == x ? x : p[x] = root(p[x]); }

bool same(int x, int y) { return root(x) == root(y); }

void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y)
    return;

  if (r[x] < r[y])
    p[x] = y;
  else {
    p[y] = x;
    if (r[x] == r[y])
      r[x]++;
  }
}

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  x.push_back(X);
  sort(x.begin(), x.end());
  vector<int> y(N);
  for (int i = 0; i < N; i++) {
    y[i] = x[i + 1] - x[i];
  }
  int ans = y[0];
  for (int i = 1; i < N; i++) {
    ans = gcd(ans, y[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

int dp_solve(const int n, const string& s){
    //x : s.size()
    //y : use cnt
    //z ; lucky number
    // bool dp[n+1][4][1000] = { };
    // vector<vector<vector<bool>>> dp(n + 1, vector<vector<bool>>(4, vector<bool>(1000, false)));
    vector<vector<bool>> dp(4, vector<bool>(1000, false));
    // dp[0][0][0] = true;
    dp[0][0] = true;
    for (auto i = 0; i < n; i++) {
        for (auto j = 2; j >= 0; j--) {
            for (auto k = 0; k <= 999; k++) {
                int index = k * 10 + (s[i] - '0');
//                cout << dp[i][j][k] << " -> " << dp[i + 1][j][k] << endl;
                // dp[i + 1][j][k] = dp[i][j][k] or dp[i + 1][j][k];
                if(index <= 999) {
//                    if(dp[j + 1][index] or dp[j][k])
//                        cout << i << " " << j << " " << k << " " << index << endl;
                    // cout << dp[j][k] << " -> " << dp[j + 1][index] << endl;
                    // dp[i + 1][j + 1][index] = dp[i][j][k] or dp[i + 1][j + 1][index];
                    dp[j + 1][index] = dp[j][k] or dp[j + 1][index];
                }
            }
        }
    }

//    // for (auto i = 0; i <= n; i++) {
//        for (auto j = 0; j <= 3; j++) {
//            for (auto k = 0; k <= 30; k++) {
//                cout << dp[j][k] << " ";
//            }
//            cout << endl;
//        }
//    //     cout << endl;
//    // }

    int cnt = 0;
    for (auto i = 0; i <= 999; i++) if(dp[3][i]) cnt++;

    return cnt;
}

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

//    int ans = 0;
//    for (auto i = 0; i <= 999; i++) {
//        vector<int> number(3);
//        int tmp = i;
//        for (auto j = 0; j < 3; j++) {
//            number[j] = tmp % 10;
//            tmp /= 10;
//        }
//        int cnt = 0;
//        for (auto k = 0; k < (int)s.size(); k++) {
//            if(s[k] - '0' == number[cnt]) cnt++;
//            if(cnt == 3) {
//                ans++;
//                break;
//            }
//        }
//    }
//
//    cout << ans << endl;

    cout << dp_solve(n, s) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys; input = sys.stdin.readline

n = int(input())
ans = 0
lis = list(map(int, input().split()))
for i in range(1, n):
	if lis[i-1]>lis[i]: ans += lis[i-1]-lis[i]; lis[i] = lis[i-1]
print(ans)

Measured memory_bytes: 92112
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for (int i = 1;; i++) {
			int x = sc.nextInt();
			if (x == 0)
				break;
			System.out.printf("Case %d: %d\n", i, x);

		}
	}

}



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

int main(){
  string s;
  cin >> s;
  
  for(int i=0; i < 3; i++){
    if(s[i] == s[i+1]){
      cout << "Bad" << endl;
      break;
    }
    if(i == 2)cout << "Good" << endl;
  }
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, k, a[15];

int bc(int x) {
	int ans = 0;
	while(x) {
		ans += x % 2;
		x /= 2;
	}
	return ans;
}

int main() {
	cin >> n >> k;
	inc(i, n) { cin >> a[i]; }
	
	LL ans = 100000000000LL, c;
	inc(i, 1 << n) { if(bc(i) == k) {
		c = 0;
		LL ma = 0;
		inc(j, n) {
			if(i & (1 << j)) {
				if(a[j] <= ma) { c += ma + 1 - a[j]; ma++; }
			}
			setmax(ma, a[j]);
		}
		setmin(ans, c);
	} }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Solver {

    public void Solve() {
        int h = sc.nextInt();
        int a = sc.nextInt();
        int cnt = 0;
        while (h > 0) {
            h -= a;
            cnt++;
        }
        System.out.println(cnt);
    }

    Scanner sc;

    Solver(Scanner in) {
        this.sc = in;
    }

}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Solver s = new Solver(sc);
        s.Solve();
        sc.close();
    }
}


Measured memory_bytes: 21844
#include<stdio.h>
int main(){
int h,m,s,S;
scanf("%d",&S);
if(S>=0 && S<=86400)
{
h=S/3600;
m=(S-3600*h)/60;
s=(S-3600*h-m*60)%60;
}
printf("%d:%d:%d\n",h,m,s);
return 0 ;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
int main() {
  int X;
  cin >> X;
  int nukeru;
  for (int a = 0; a < pow(10, 3); a++) {
    for (int b = -pow(10, 3); b < pow(10, 3); b++) {
      if (pow(a, 5) - pow(b, 5) == X) {
        cout << a << ' ' << b << endl;
        nukeru++;
        break;
      }
      if (nukeru != 0) {
        break;
      }
    }
  }
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x, c = 0, k;
    cin >> x;
    vector <long long int> v(1000, 0);
    for (int i = 1; i <= 33; i++) {
        k = i;
        for (int j = 1; j < 10; j++) {
            k *= i;
            v[c] = k;
            c++;
        }
    }
    while (x != 0) {
        for (int i = 0; i < 1000; i++) {
            if (x == v[i]) {
                cout << x << endl;
                return 0;
            }
        }
        x -= 1;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String x = sc.next();
			String y = sc.next();

			if (x.compareTo(y) < 0) {
				System.out.println("<");
			} else if (x.compareTo(y) == 0) {
				System.out.println("=");
			} else {
				System.out.println(">");
			}

		}
	}
}


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

using namespace std;

vector<int> vect(1e5+10);

vector<int> dp(1e5+10);

int main(){
	int n;
	cin>>n;
	for(int i = 1;i<=n;i++){
		cin>>vect[i];
	}
	dp[2] = abs(vect[2]-vect[1]);
	dp[3] = min(abs(vect[3]-vect[1]), abs(vect[3]-vect[2])+ dp[2]);
	for(int i = 4;i<=n;i++){
		dp[i] = min(abs(vect[i]-vect[i-2])+ dp[i-2], abs(vect[i]-vect[i-1])+ dp[i-1]);
	}
	cout<<dp[n]<<endl;

	return 0;



}

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

int main(void){
	int h,w;
	cin>>h>>w;
	string *a=new string[h];
	for(int i=0;i<h;i++) cin>>a[i];
	long long *DP=new long long[w+1];
	for(int i=0;i<=w;i++) DP[i]=0;
		DP[1]=1;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			DP[j+1]=((a[i][j]=='#')?0:((DP[j]+DP[j+1])%1000000007));
		}
	}

	cout<<DP[w]<<endl;
	
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s;
  cin >> s;
  rep(i,s.size()){
    if(i%2==0){
      if(s[i]=='L'){
        cout << "No" << endl;
        return 0;
      }
    }else{
      if(s[i]=='R'){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

struct Edge {
  int to;
  int dist;
  int cost;
  Edge() {;}
  Edge(int to, int dist, int cost) : to(to), dist(dist), cost(cost) {;}
  bool operator<(const Edge &rhs) const {
    return cost > rhs.cost;
  }
};

bool visit[110][110];
int dist[110][110];
vector<Edge> g[110];

int main() {
  int n, m, l;
  while (scanf("%d %d %d", &n, &m, &l), n|m|l) {
    REP(i, 110) { g[i].clear(); }
    REP(i, m) {
      int a, b, d, e;
      scanf("%d %d %d %d", &a, &b, &d, &e);
      a--; b--;
      g[a].push_back(Edge(b, d, e));
      g[b].push_back(Edge(a, d, e));
    }
    MEMSET(visit, false);
    MEMSET(dist, 0x0f);
    priority_queue<Edge> que;
    que.push(Edge(0, 0, 0));
    int ans = 1 << 30;
    while (!que.empty()) {
      Edge e = que.top();
      que.pop();
      if (visit[e.to][e.dist]) { continue; }
      visit[e.to][e.dist] = true;
      if (e.to == n - 1) { ans = min(ans, e.cost); }
      FORIT(it, g[e.to]) {
        int to = it->to;
        int ndist = e.dist;
        int ncost = e.cost + it->cost;
        if (visit[to][ndist]) { continue; }
        if (ncost >= dist[to][ndist]) { continue; }
        dist[to][ndist] = ncost;
        que.push(Edge(to, ndist, ncost));
      }
      FORIT(it, g[e.to]) {
        int to = it->to;
        int ndist = e.dist + it->dist;
        int ncost = e.cost;
        if (ndist > l) { continue; }
        if (visit[to][ndist]) { continue; }
        if (ncost >= dist[to][ndist]) { continue; }
        dist[to][ndist] = ncost;
        que.push(Edge(to, ndist, ncost));
      }
    }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 1496
#include <iostream>

int main()
{
	int n, r;
	char m;
	std::cin >> n;
	bool a[4][13] {};
	for (int i=0; i!=n; ++i) {
		std::cin >> m >> r;
		switch (m) {
			case 'S':
				a[0][r-1] = true;
				break;
			case 'H':
				a[1][r-1] = true;
				break;
			case 'C':
				a[2][r-1] = true;
				break;
			case 'D':
				a[3][r-1] = true;
				break;
		}
	}
	for (int i=0; i!=4; ++i) {
		for (int j=0; j!=13; ++j) {
			switch (i) {
				case 0:
					if (!a[i][j]) std::cout << 'S' << ' ' << j+1 << '\n';
					break;
				case 1:
					if (!a[i][j]) std::cout << 'H' << ' ' << j+1 << '\n';
					break;
				case 2:
					if (!a[i][j]) std::cout << 'C' << ' ' << j+1 << '\n';
					break;
				case 3:
					if (!a[i][j]) std::cout << 'D' << ' ' << j+1 << '\n';
					break;
			}
		}
	}
}

Measured memory_bytes: 3068
#include<stdio.h>

int main(){
	int N;
	scanf("%d",&N);
	int h[N];
	for(int i=0;i<N;i++)scanf("%d",&h[i]);
	int ans=0;
	
	ans+=h[0];
	for(int i=1;i<N;i++){
		if(h[i]>h[i-1])ans+=h[i]-h[i-1];
	}
	
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
// Template begins
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <queue> 
#include <string.h>
#include <string>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define fo(i,a,b) for(i=a;i<=b;i++)
#define all(v) (v).begin(),(v).end()
#define sort0(v) sort(all(v))
#define lbb(a,b,arr,x) lower_bound(arr+a,arr+b+1,x)-arr
#define ubb(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-arr
#define freq(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-lower_bound(arr+a,arr+b+1,x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define printp(x) cout << x.ff << " " << x.ss << endl
 
const ll mod=1e9+7;
#define inf 9999999999999
#define MAXN   100001 
  
// stores smallest prime factor for every number 
 
 
ll inv(ll i){if(i==1) return 1;return (mod-((mod/i)*inv(mod%i))%mod)%mod;}
 
ll gcd(ll a,ll b){if(a==0) return b;return gcd(b,b%a);}
inline void fastio(){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
// Template ends
const int MN = 2e5+7;

void solve(){
    string s,t; cin>>s>>t;
    ll ans=1e18;
    for(int i=0;i<s.length()-t.length()+1;i++){
        ll res=0;
        for(int j=i;j<i+t.length();j++){
            if(s[j]!=t[j-i]){
                res++;
            }
            
            
        }
        ans=min(res,ans);
    }
    cout<<ans<<endl;
}
int main(){
    fastio();
    //write code
    int t; t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3196
import Control.Monad

main = do
  n <- readLn :: IO Int
  s <- replicateM n getLine
  m <- readLn :: IO Int
  t <- replicateM m getLine

  print $ maximum $ map (\x -> if x<0 then 0 else x) [length (filter (==a) s) - length (filter (==a) t) | a <- s]


Measured memory_bytes: 636
/* https://atcoder.jp/contests/abc098/tasks/arc098_a */

#include <iostream>
#include <string>
#include <vector>

int solve(const int N, const std::string S)
{
  std::vector<int> cum_sum_e(N);
  int min_num = N;

  for (int i = 0; i < N; ++i) {
    char s = S.at(i);

    int cs = 0;
    if (i != 0) {
      cs = cum_sum_e.at(i-1);
    }

    if (s == 'E') {
      cs++;
    }
    cum_sum_e.at(i) = cs;
  }

  for (int i = 0; i < N; ++i) {
    int cnt_e = cum_sum_e.at(N-1) - cum_sum_e.at(i);
    int cnt_w = i - cum_sum_e.at(i-1 < 0 ? 0 : i-1);

    min_num = std::min(min_num, cnt_e+cnt_w);
  }

  return min_num;
}

int main(int argc, char *argv[])
{
  // Input
  int N;
  std::string S;

  std::cin >> N >> S;

  // Output
  std::cout << solve(N, S) << std::endl;

  return 0;
}


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

int main() {
    int x, y;

    while (true) {
        cin >> x >> y;

        if (x == 0 && y == 0) {
            break;
        }

        if (x <= y) {
            cout << x << " " << y << endl;
        } else {
            cout << y << " " << x << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3004
/*
    ahuhu :((
*/
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <queue>
#include <deque>
#include <string>
#include <cstring>
using namespace std;

#define SZ size()
#define BG begin()
#define ED end()
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define FOR(i, a, b)  for (int i = (a), _b = (b);  i< _b; ++i)
#define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define FORE(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define openfile ({freopen(TASK".inp", "r", stdin); freopen(TASK".out", "w", stdout);})

typedef vector <int> VI;
typedef pair <int, int> II;
typedef long long LL;
typedef long double LD;

const int N = (int) (200005);
const int LOGN = log2(N) + 2;
const LL MOD = (LL) (1e9 + 7);
const LL INF = (LL) 1e18;
const double PI = 2 * acos(0);
const double EPS = 1e-9;

template <typename T> inline void read(T &n) {
    n = 0; char ch; bool neg = false;
    for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') neg = !neg; n = ch - 48;
    for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar()) n = (n << 1) + (n << 3) + ch - 48; if (neg) n = -n;
}
template <typename T> inline void writee(T n) { if (n > 9) writee(n / 10); putchar(n % 10 + 48); }
template <typename T> inline void write(T n) { if (n < 0) { putchar('-'); n = -n; } writee(n); }
template <typename T> inline void writeln(T x) { write(x); putchar('\n'); }
inline long long __lcm(long long a, long long b) { return a / __gcd(a, b) * b; }
inline long long power(long long a, long long n) {
    long long r = 1;
    while (n) {
        if (n & 1) r = r * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return r;
}
inline void add(int &a, const int& b) { a = (a + b) % MOD; }
inline void sub(int &a, const int& b) { a = (a - b + MOD) % MOD; }

int n, m;
int d[N], t[N];
map <int, int> f;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &d[i]);
        f[d[i]]++;
    }
    scanf("%d", &m);
    bool ok = true;
    for (int i = 1; i <= m; i++) {
        scanf("%d", &t[i]);
        f[t[i]]--;
        if (f[t[i]] < 0) ok = false;
    }
    if (ok) cout << "YES";
    else cout << "NO";
    return 0;
}


Measured memory_bytes: 11136
N=int(input())
red=[tuple(map(int,input().split())) for _ in range(N)]
blue=[tuple(map(int,input().split())) for _ in range(N)]

blue=sorted(blue, key=lambda x: x[0])

ans=0

for b in blue:
    candi=[i for i in red if i[0]<b[0] and i[1]<b[1]]
    if candi:
        red.remove(sorted(candi, key=lambda x: x[1], reverse=True)[0])
        ans+=1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

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

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
enum FACE { TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT };
struct Dice {
  int val[6];
  Dice() {
    int v[6] = {0, 5, 1, 4, 2, 3};
    REP(i, 6) val[i] = v[i];
  }
  void roll_r(int r){
    if(r == 0) roll(TOP, LEFT, BOTTOM, RIGHT);
    if(r == 1) roll(TOP, BACK, BOTTOM, FRONT);
    if(r == 2) roll(TOP, RIGHT, BOTTOM, LEFT);
    if(r == 3) roll(TOP, FRONT, BOTTOM, BACK);
  }
  void roll(int a, int b, int c, int d){
    int tmp = val[a];
    val[a] = val[b]; val[b] = val[c];
    val[c] = val[d]; val[d] = tmp;
  }
  int to_i(){
    return val[0] * 6 * 6 + val[1] * 6 + val[2];
  }
  int color(){
    string c = "rmybgc";
    return c[val[TOP]];
  }
};


int main(){
  int W, H;
  while(cin >> W >> H && W){
    vector<string> grid(H);
    REP(y, H) cin >> grid[y];
    string v;
    cin >> v;
    int ans = 0;
    int sx = -1, sy = -1;
    REP(y, H) REP(x, W) if(grid[y][x] == '#'){
      grid[y][x] = 'w';
      sx = x, sy = y;
    }
    int dist[30][30][7][216] = {};
    memset(dist, -1, sizeof(dist));
    Dice sd;
    queue<int> qx, qy, qs;
    queue<Dice> qd;
    qx.push(sx); qy.push(sy); qs.push(0); qd.push(sd);
    dist[sy][sx][0][sd.to_i()] = 0;
    bool ng = true;
    while(!qx.empty()){
      int x = qx.front(); qx.pop();
      int y = qy.front(); qy.pop();
      int s = qs.front(); qs.pop();
      Dice d = qd.front(); qd.pop();
      //printf("x = %d y = %d s = %d c = %d\n", x, y, s, d.color());
      if(s == 6){
        cout << dist[y][x][s][d.to_i()] << endl;
        ng = false;
        break;
      }
      REP(r, 4){
        int nx = x + dx[r];
        int ny = y + dy[r];
        if(!valid(nx, ny, W, H)) continue;
        if(grid[ny][nx] == 'k') continue;
        Dice nd = d;
        nd.roll_r(r);
        if(grid[ny][nx] != 'w' && (grid[ny][nx] != nd.color() || grid[ny][nx] != v[s])) continue;
        int ns = (grid[ny][nx] == 'w') ? s : s + 1;
        if(dist[ny][nx][ns][nd.to_i()] != -1) continue;
        dist[ny][nx][ns][nd.to_i()] = dist[y][x][s][d.to_i()] + 1;
        qx.push(nx);
        qy.push(ny);
        qs.push(ns);
        qd.push(nd);
      }
    }
    if(ng) cout << "unreachable" << endl;
  }
  return 0;
}

Measured memory_bytes: 6608
a,b,c =map(int,input().split())
if a < b and a < c:
  if b > c:
    temp = b
    b = c
    c = temp 
elif b < a and b < c:
  temp = a
  a = b
  b = temp
  if b > c:
    temp = b
    b = c
    c = temp 
else:
  temp = c
  c = a
  a = temp
  if b > c:
    temp = b
    b = c
    c = temp 
print(a,b,c)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define OK { cout << "OK" << endl; return 0; }
#define NG { cout << "NG" << endl; return 0; }
#define sz(v) ((int)(v).size())
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void out(T a){cout << a << endl;}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

#define SIZE 200005
#define MOD 1000000007
 
typedef pair <int,int> P;
 
ll inv[SIZE], fac[SIZE], finv[SIZE];
void make(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<SIZE; i++)
	{
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
    return ;
}
ll comb(int a,int b){
	if(a < b) return 0;
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}



ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
	int N;cin>>N;
    if(N%1000 == 0) cout << 0 << endl;
    else cout << 1000 - N%1000 << endl;
}

Measured memory_bytes: 3628
N = int(input())
TAs = [tuple(map(int, input().split())) for _ in range(N)]

numT, numA = 1, 1
for T, A in TAs:
    m = max(-(-numT // T), -(-numA // A))
    numT, numA = m * T, m * A

print(numT + numA)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=200005;
int x,d,n;
typedef pair<ll,ll> P;
inline ll sum(int a,int b){
    return 1ll*(a+a+b-1)*b/2;
}
int main(){
    scanf("%d%d%d",&n,&x,&d);
    if(d<0)d=-d,x=-x;
    if(d==0){
        if(x==0)printf("1\n");
        else printf("%d\n",n+1);
    }
    else{
        int g=__gcd(d,x);
        g=abs(g);
        d/=g,x/=g;
        set<P> s;
        ll ans=0;
        for(int i=0;i<d;i++){
            s.clear();
            for(int j=i;j<=n;j+=d){
                //s.insert({1ll*j/d*x+sum(0,j),1ll*j/d*x+sum(n-j,j)+1});
                s.insert({1ll*j*x/d+sum(0,j),1ll*j*x/d+sum(n-j,j)+1});
            }
            ll r=-1e18;
            for(auto p:s){
                ans+=max(0ll,p.second-max(p.first,r));
                r=max(r,p.second);
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> P;

const int MAX = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int X, Y, N, M, x[MAX], y[MAX];

int main(){
    cin >> N >> M >> X >> Y;
    rep(i, N) cin >> x[i];
    rep(i, M) cin >> y[i];

    int maxX = *max_element(x, x+N);
    maxX = max(maxX, X);
    int minY = *min_element(y, y+M);
    minY = min(minY, Y);

    if(maxX < minY) cout << "No War" << endl;
    else cout << "War" << endl;
}

Measured memory_bytes: 256