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

typedef struct tagPoint{
	double x,y;
} Point;

int main(void){
	while( 1 ){
		Point po1, po2, qo, po;
		Point p1, q, p;
		
		if( EOF == scanf("%lf,%lf,%lf,%lf,%lf,%lf", &po1.x,&po1.y,&po2.x,&po2.y,&qo.x,&qo.y) ) break;

		/* move to the origin */
		p1.x = po2.x - po1.x; p1.y = po2.y - po1.y;
		q.x  = qo.x  - po1.x; q.y  = qo.y  - po1.y;

		if( p1.y == 0 ){
			p.x = q.x;
			p.y = -q.y;
		}else{
			p.x = ( 2*p1.x*p1.y*q.y + q.x*(pow(p1.x,2.0) - pow(p1.y,2.0)) ) / ( pow(p1.x,2.0) + pow(p1.y,2.0) );
			p.y = ( p1.y*q.y + p1.x*q.x - p1.x*p.x) / p1.y;
		}

		po.x = p.x + po1.x;
		po.y = p.y + po1.y;

		printf("%lf %lf\n", po.x, po.y);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
using namespace std;
int N;
main()
{
	cin>>N;
	long ans=0,cummin=0,cumsum=0;
	for(int i=0;i<N;i++)
	{
		long x,s;
		cin>>x>>s;
		cummin=min(cummin,cumsum-x);
		cumsum+=s;
		ans=max(ans,cumsum-x-cummin);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f[100001],a[100001];
int main()
{
    int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(i=2;i<=n;i++)
	{
		if(i==2)
		{
			f[i]=abs(a[i]-a[i-1])+f[i-1];
			continue;
		}
		f[i]=min(abs(a[i]-a[i-1])+f[i-1],abs(a[i]-a[i-2])+f[i-2]);
	}
	printf("%d",f[n]);
	return 0;
}

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

typedef vector<int> V;

int N, A, B, C;
V l(8);

int sum(V a, V b, V c) {
    int ans = 1e9, cnt = 0;
    int sum_a = A, sum_b = B, sum_c = C;
    for (int i = 0; i < a.size(); i++) {
        sum_a -= a[i];
        if (i > 0) cnt++;
    }
    for (int i = 0; i < b.size(); i++) {
        sum_b -= b[i];
        if (i > 0) cnt++;
    }
    for (int i = 0; i < c.size(); i++) {
        sum_c -= c[i];
        if (i > 0) cnt++;
    }
    if (a.size() && b.size() && c.size()) {
        ans = abs(sum_a) + abs(sum_b) + abs(sum_c) + 10 * cnt;
    }
    return ans;
}

int dfs(int turn, V a, V b, V c) {
    int ans = 1e9;
    if (turn == N) return (ans, sum(a, b, c));
    V tmp_a = a, tmp_b = b, tmp_c = c;
    tmp_a.push_back(l[turn]);
    tmp_b.push_back(l[turn]);
    tmp_c.push_back(l[turn]);
    turn++;
    ans = min({dfs(turn, a, b, c), dfs(turn, tmp_a, b, c),
               dfs(turn, a, tmp_b, c), dfs(turn, a, b, tmp_c)});
    return ans;
}

int main() {
    cin >> N >> A >> B >> C;
    for (int i = 0; i < N; i++) {
        cin >> l[i];
    }
    V a, b, c;
    cout << dfs(0, a, b, c) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, K, mod;
void Add(int &x, int y) { (x += y) >= mod ? x -= mod : x; }
int f[202][202];
void solve1() {
    K /= 2, f[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= K; ++j) Add(f[i][0], f[i - 1][j]);
        for (int j = 0; j < K; ++j) Add(f[i][j + 1], f[i - 1][j]);
    }
    int res1 = 0, res2 = 0;
    for (int i = 0; i <= K; ++i) Add(res1, f[n / 2][i]);
    for (int i = 0; i <= K; ++i) Add(res2, f[(n + 1) / 2][i]);
    printf("%d\n", 1ll * res1 * res2 % mod);
}
int g[502][202][202];
void solve2() {
    int t;
    g[0][0][0] = 1;
    for (int i = 2; i - K <= n; i += 2) {
        for (int j = 0; j <= n; ++j)
            for (int k = 0; k < K + 2; ++k) Add(g[i][0][0], g[i - 2][j][k]);
        if (i <= n)
            for (int j = 0; j <= n; ++j)
                for (int k = 0; k < K + 2; ++k)
                    Add(g[i][j + 1][0], g[i - 2][j][k]);

        if (i - K >= 1)
            for (int j = 0; j <= n; ++j) {
                for (int k = 1; k <= K; ++k)
                    Add(g[i][0][k + 1], g[i - 2][j][k]);
                Add(g[i][0][0], g[i - 2][j][0]);
            }

        if (i <= n && i - K >= 1)
            for (int j = 0; j <= n; ++j)
                for (int k = 0; max(k, j + 1) <= K; ++k)
                    Add(g[i][j + 1][max(k + 1, j + 2)], g[i - 2][j][k]);

        t = i;
    }
    int res = 0;
    for (int j = 0; j <= n; ++j)
        for (int k = 0; k < K + 2; ++k) Add(res, g[t][j][k]);
    printf("%d\n", res);
}
int main() {
    scanf("%d%d%d", &n, &K, &mod);
    (K & 1) ? solve2() : solve1();
    return 0;
}

Measured memory_bytes: 48128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

const int INF = 1e8;

int dist[100][100];
int a[1000], b[1000], c[1000];

int main(void) {
    int i, j, k;
    int n, m;
    cin >> n >> m;
    REP (i,n) REP (j,n) dist[i][j] = INF;
    REP (i,m) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
        dist[a[i]][b[i]] = c[i];
        dist[b[i]][a[i]] = c[i];
    }
    REP (k,n) REP (i,n) REP (j,n) dist[i][j] = min(dist[i][j],dist[i][k] + dist[k][j]);
    int ans = 0;
    REP (i,m) if (dist[a[i]][b[i]] < c[i]) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
group1 = [1, 3, 5, 7, 8, 10, 12]
group2 = [4, 6, 9, 11]

x, y = map(int, input().split())

if (x in group1 and y in group1) or (x in group2 and y in group2) or (x == y == 2):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9080
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <map>
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-10;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll maxn = 1e6 + 5;

int main(){
	int n;
	cin>>n;
	cout<<(n+1)/2;
	return 0;
}

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

int main(){
    int N, K; cin >> N >> K;
    if(K > (N-1)*(N-2)/2 ) {cout << -1 << endl; return 0;}

    int num = (N-1)*(N-2)/2 -K;

    cout << N-1+num << endl;
    for(int i=0; i<N-1; i++){
        cout << i+1 << " " << N << endl;
    }

    for(int i=1; i<=N-2; i++){
        for(int j=i+1; j<=N-1; j++){
            if(num>0){
                cout << i << " " << j << endl;
                num--;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    sort(ALL(a), greater<>());
    ll pth = a[p-1], sump = 0, ppos = -1;
    REP(i, n) if(a[i] <= pth) sump++;

    map<ll,ll> cnt;
    REP(i, n) cnt[a[i]]++;
    dump(cnt);

    ll idx = 0;
    vector<PII> vp(cnt.size());
    for(auto i: cnt) vp[idx++] = i;

    REP(i, vp.size()) if(vp[i].first == pth) ppos = i;
    if(ppos == 0) {
        cout << n << endl;
        return 0;
    }

    vector<ll> sc(cnt.size());
    REP(i, vp.size()) sc[i] = (m-vp[i].first) * vp[i].second;
    vector<ll> rui(sc);
    FOR(i, 1, vp.size()) rui[i] += rui[i-1];
    dump(sc);
    dump(rui);

    vector<ll> num(cnt.size());
    REP(i, cnt.size()) num[i] = vp[i].second;
    FOR(i, 1, cnt.size()) num[i] += num[i-1];
    dump(num);

    ll sum = 0, ret = 0;
    ll all = 0;
    ll pos = 0;
    REP(i, vp.size()) {
        sum += vp[i].second;
        all = vp[i].first; 
        chmax(pos, i+1);
        while(pos < (ll)vp.size() && all+sc[pos]/vp[pos].second >= m) pos++;
        ll can = num[num.size()-1]-num[ppos] + sum;
        dump(i, vp[i], can);
        if(vp[i].first >= pth) {
            ret += vp[i].second;
            continue;
        }
        if(vp[i].first + m < pth) continue;
        if(can >= v) {
            ret += vp[i].second;
            dump("ok");
        } else {
            // (v-can)問 を M人 → sump-sum問に振り分ける
            // i.first + m 点以下になるようにする
            // [i+1, pos) → m側
            ll tmp = (num[pos-1] - num[i]) * m;
            // [pos, pth] → sc側
            tmp += rui[ppos] - rui[pos-1] + (num[ppos] - num[pos-1]) * all;
            dump(tmp, (v-can)*m);

            if(tmp >= (v-can)*m) {
                ret += vp[i].second;
                dump("okb");
            }
        }
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
int L, N;

long myfunc(int n, long x[]){
    long a = x[n + (N - n + 1)/2 - 1];
    long b = x[n - 1];
    long c = L - x[N - ((N - n + 1)/2)];
    return  a - 2 * b - c;
}

long keisan(long x[], int z[]){
    long y[N + 1];
    y[0] = x[0];
    for(int i = 1; i < N; i++){
        y[i] = x[i] - x[i-1];
    }
    y[N] = L - x[N-1];

    long len1 = 0;
    for(int i = 0; i < N + 1; i++){
        len1 += y[i] * z[i];
    }

    long ans = len1;
    for(int i = 1; i < N / 2 + 1; i++){
        len1 += myfunc(i, x);
        if(len1 > ans)
            ans = len1;
    }
    return ans;
}

void keisan2(int z[]){
    for(int i = 0; i < N / 2 + 1; i++){
        z[i] = N - i * 2;
    }
    for(int i = 0; i < (N - 1) / 2 + 1; i++){
        z[N - i] = N -1 - i * 2;
    }
}


int main() {
    cin >> L >> N;
    long X[N];
    for(int i = 0; i < N; i++){
        cin >> X[i];
    }

    int Z[N + 1];
    keisan2(Z);
    long ans = keisan(X, Z);

    //ここから逆

    long X1[N];
    for(int i = 0; i < N; i++){
        X1[i] = L - X[N - i -1];
    }
    long ans2 = keisan(X1, Z);
    if(ans2 > ans)
        ans = ans2;

    cout << ans << "\n";
}


Measured memory_bytes: 5760
#include <stdio.h>

int main(){
	int k, s;
	scanf("%d %d", &k, &s);
	int count = 0;
	
	for(int x = 0; x <= k; x++){
		for(int y = 0; y <= k; y++){
			int num = s - (x + y);
            if (0 <= num && num <= k) {
                count++;
            }
        }
    }
    
    printf("%d", count);
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))

// #define DEBUG

#ifdef DEBUG
#define dump(...) fprintf(stderr, __VA_ARGS__)
#else
#define dump(...)
#endif

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;

const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};


ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}

random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    vi a(n); for(auto& e : a) cin >> e;

    int res = 0, diff = 0;
    vi bord = {4, 8, 12, 16, 20, 24, 28, 32};
    vi used(bord.size());
    for(auto& e : a){
        e /= 100;
        [&]{
            rep(i, (int)bord.size()){
                if(e < bord[i]){
                    if(not used[i]){
                        res++;
                    }
                    used[i] = true;
                    return;
                }
            }
            diff++;
        }();
    }
    if(res == 0) res = 1, diff--;

    cout << res << " " << res + diff <<  endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
#include <stack>
#include <deque>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>

#define ll int
#define ld long double
#define endl '\n'
#define maxN 201
#define maxM 1000001
#define oo 1000000000000000001
#define Mod 1000000007
#define pii pair<ll,ll>
#define piii pair<ll,pii>
#define fi first
#define se second
#define sefi se.fi
#define sese se.se

#define pc putchar
#define gc getchar

using namespace std;
int n;
string s[maxN];
vector<int> f[maxN];
deque<int> DQ;
int t[maxN];
int cntk= 0;
int ans[maxN];
int b[maxN];

int Check(int u)
{
	fill_n(&b[0],sizeof(b)/sizeof(b[0]),0);

	DQ.push_back(u);
	int cnt=1;
	b[u]=1;
	while(!DQ.empty())
	{
		int u = DQ.front();
		//cout<<u<<endl;
		DQ.pop_front();
		for(int i=0;i<f[u].size();i++)
		{
			int v=f[u][i];
			if(b[v]==0)
			{
				b[v]=b[u]+1;
				//cout<<"*"<<v<<" "<<b[v]<<endl;
				cnt=max(cnt,b[v]);
				DQ.push_back(v);
			}
			else
			{
				if(b[v]!=b[u]-1&&b[v]!=b[u]+1)
					return -1;
			}
		}
	}
	return cnt;
}
void DFS(ll u)
{
	for(int i=0;i<f[u].size();i++)
	{
		if(t[f[u][i]]==0)
		{
			t[f[u][i]]=cntk;
			DFS(f[u][i]);
		}
	}
}
void Solve()
{
	int Tans=-1;
	fill_n(&t[0],sizeof(t)/sizeof(t[0]),0);
	for(int i=0;i<n;i++)
	{
		if(t[i]==0)
		{
			cntk++;
			t[i]=cntk;
			DFS(i);
		}
	}
	fill_n(&ans[0],sizeof(ans)/sizeof(ans[0]),-1);
	for(int i=0;i<n;i++)
		ans[t[i]]=max(ans[t[i]],Check(i));
	//cout<<"ans"<<Check(4);
	//for(int i=0;i<n;i++)
	//	cout<<t[i]<<" ";
	int Ans = 0;
	for(int i=1;i<=cntk;i++)
	{
		if(ans[i]!=-1)
			Ans+=ans[i];
		else
		{
			cout<<-1;
			return;
		}
	}
	cout<<Ans;
}

void Enter()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>s[i];
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(s[i][j]=='1')
				f[i].push_back(j);
	/*
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<f[i].size();j++)
			cout<<f[i][j]<<" ";
		cout<<endl;
	}
	*/
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // freopen("/Users/quanghuy/Desktop/Input.inp","r", stdin);
    // freopen("/Users/quanghuy/Desktop/Output.out","w", stdout);
    //freopen("Input.inp","r",stdin);
    //freopen("Output.out","w",stdout);

	Enter();    
    Solve();
}



Measured memory_bytes: 640
#include<stdio.h>

int main(){
  int k,a,b,x,y;

  scanf("%d",&k);
  scanf("%d %d",&a,&b);

  if(a % k == 0){
    x = a / k;
  }else{
    x = a / k + 1;
  }
  y = b / k;

  if(y - x >= 0){
    printf("OK\n");
  }else{
    printf("NG\n");
  }

  return 0;
}


Measured memory_bytes: 1660
import math
A, B, H, M = map(int,input().split())
t = 60*H + M
tb = (6*t)%360
ta = (360*t/(12*60))%360
c = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(ta-tb)))
print(c)

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  vector<P> p;
  int dir;
  if (a[0] <= a[1]) {
    p.push_back(P(-1, 0));
    dir = 1;
  } else {
    dir = -1;
  }
  for (int i = 1; i < n - 1; i++) {
    if (dir == 1 && a[i] > a[i + 1]) {
      p.push_back(P(dir, i));
      dir = -1;
    } else if (dir == -1 && a[i] < a[i + 1]) {
      p.push_back(P(dir, i));
      dir = 1;
    }
  }
  dump(p);
  ll ans = 1000;
  {
    ll cash = 1000;
    ll qty = 0;
    rep(i, p.size()) {
      if (p[i].first == 1) {
        cash += a[p[i].second] * qty;
        qty = 0;
      }
      if (p[i].first == -1) {
        qty = cash / a[p[i].second];
        cash -= a[p[i].second] * qty;
      }
      dump(qty, cash);
    }
    if (qty) {
      cash += a[n - 1] * qty;
    }
    dump(cash);
    maxs(ans, cash);
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 3604
#include<cstdio>
using namespace std;
int main(){
    int n;
    long a[100000],b[100000],ans=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%ld %ld",&a[i],&b[i]);
    }
    for(int i=n-1;i>=0;i--){
        ans+=(b[i]-(a[i]+ans)%b[i])%b[i];
    }
    printf("%ld\n",ans);
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N; cin >> N; 
    int h[N];
    for(int i = 0; i < N; i++) cin >> h[i];
    for(int i = N-2; i > -1; i--){
        if(h[i] > h[i+1]) h[i] -= 1;
    }
    bool F = true;
    for(int i = 0; i < N-1; i++){
        if(h[i] > h[i+1]) F = false;
        
    }
    if(F || N == 1) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder {
    class Program {
        static void Main(string[] args) {
            string[] buf = Console.ReadLine().Split(' ');
            int digit = int.Parse(buf[0]);
            int max = int.Parse(buf[1]);

            List<int> testcaseS = new List<int>();
            List<int> testcaseM = new List<int>();

            for (int i=0; i < max; i++) {
                buf = Console.ReadLine().Split(' ');
                testcaseS.Add(int.Parse(buf[0]));
                testcaseM.Add(int.Parse(buf[1]));
            }

            int startRange = 0;
            int endRange=0;

            if(digit == 1) {
                startRange = 0;
                endRange = 10;
            }else if (digit == 2) {
                startRange = 10;
                endRange = 100;
            }else if(digit == 3) {
                startRange = 100;
                endRange = 1000;
            }

            bool checkF;

            for(int i=startRange; i < endRange; i++) {

                if (max == 0) {
                    Console.WriteLine(startRange);
                    return;
                }

                checkF = false;
                List<char> target = new List<char>(i.ToString().ToCharArray());

                for (int j = 0; j < max; j++) {
                    if (int.Parse(target[testcaseS[j]-1].ToString()) == testcaseM[j]) {
                        checkF = true;
                    } else {
                        checkF = false;
                        break;
                    }
                }
                if (checkF) {
                    Console.WriteLine(i);
                    return;
                }
            }

            Console.WriteLine(-1);


        }

    }

}


Measured memory_bytes: 11220
d={"N":0,"W":0,"S":0,"E":0}
s=raw_input()
for i in xrange(len(s)):
    d[s[i]]+=1
if((d["N"]==0 and d["S"]==0) or (d["N"]>0 and d["S"]>0)) and ((d["E"]==0 and d["W"]==0) or (d["E"]>0 and d["W"]>0)):
    print "Yes"
else: print "No"

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

int main()
{
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    
    long long ans = 1LL << 60;
    for (int i = 0; i < 100001; i++) {
        long long t = 2 * c * i + max(x - i, 0) * a + max(y - i, 0) * b;
        ans = min(ans, t);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const int N = 2e6+5;
int h,w;
int dec(int x, int y){
    return x*w+y;
}
int getx(int s){
    return s/w;
}
int gety(int s){
    return s%w;
}


int g[N];
int d[N];
int vis[N];
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int k;
    cin>>h>>w>>k;
    int x,y,xx,yy;
    cin>>x>>y>>xx>>yy;
    x--;y--;xx--;yy--;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            char c;
            cin>>c;
            if(c=='.')g[dec(i,j)] = 1;
            else g[dec(i,j)] = -1;
        }
    }
    int s = dec(x,y);
    int en = dec(xx,yy);
    queue<int> q;
    d[s] = 0;
    vis[s]  = 5;
    q.push(s);
    while(!q.empty()){
        int node = q.front();
        q.pop();
        int nx = getx(node);
        int ny = gety(node);
        for(int i=1;i<=k;i++){
            if(nx+i>=h)break;
            int trt = dec(nx+i,ny);
            if(g[trt]==-1)break;
            if(k>500 and (vis[trt]==1 or vis[trt]==2))break;;
            if(vis[trt])continue;
            vis[trt] = 1;
            d[trt] = d[node]+1;
            q.push(trt);
        }
        for(int i=1;i<=k;i++){
            if(nx-i<0)break;
            int trt = dec(nx-i,ny);
            if(g[trt]==-1)break;
            if(k>500 and (vis[trt]==1 or vis[trt]==2))break;
            if(vis[trt])continue;
            vis[trt] = 2;
            d[trt] = d[node]+1;
            q.push(trt);
        }
        for(int i=1;i<=k;i++){
            if(ny+i>=w)break;
            int trt = dec(nx,ny+i);
            if(g[trt]==-1)break;
            if(k>500 and (vis[trt]==3 or vis[trt]==4))break;;
            if(vis[trt])continue;
            vis[trt] = 3;
            d[trt] = d[node]+1;
            q.push(trt);
        }
        for(int i=1;i<=k;i++){
            if(ny-i<0)break;
            int trt = dec(nx,ny-i);
            if(g[trt]==-1)break;
            if(k>500 and (vis[trt]==3 or vis[trt]==4))break;;
            if(vis[trt])continue;
            vis[trt] = 4;
            d[trt] = d[node]+1;
            q.push(trt);
        }
    }
    if(vis[en])cout<<d[en]<<endl;
    else cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 15664
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
#define SZ(x) ((ll).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define repe(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll k, a, b;
  cin >> k >> a >> b;

  bool ok = false;
  for(ll i = a; i <= b; i++){
    if(i % k == 0) ok = true;
  }
  if(ok) cout << "OK" << endl;
  else cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
signed main(){
  int N; cin>>N;
  vi A(N),B(N);
  rep(i,0,N) cin>>A[i]>>B[i];
  reverse(ALL(A));
  reverse(ALL(B));
  int ans=0;
  rep(i,0,N){
    A[i]+=ans;
    ans+=(B[i]-A[i]%B[i])%B[i];
  }
  cout<<ans<<endl;
  }


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

#define mp make_pair
#define pb push_back
#define int long long

using namespace std;
const int inf = 1e18;
const double EPS = 0.00000001;
const int mod = 1000000007;

signed main(){
    int n,a;
    cin >> n;
    vector<pair<int,int> > v;
    for(int i = 0;i<n;i++){
        cin >> a;
        v.push_back(mp(a,i));
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++){
        cout << v[i].second+1 << " ";
    }
}


Measured memory_bytes: 5320
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
using namespace std;
int main(){
 long long hy,wx,i,j;
 queue<long long>quex,quey;
 scanf("%lld%lld ",&hy,&wx);
 char a[1005][1005];//配列はx,yの順に入れる
 for(i=1;i<=hy;i++){
  for(j=1;j<=wx+1;j++){
   scanf("%c",&a[j][i]);
  // printf("i %d j %d %c\n",i,j,a[j][i]);
   if(a[j][i]=='#'){
    quex.push(j);quey.push(i);
   }
  }
 }
 long long num[1005][1005]={0};
 long long u,v,ans=0;
  
 while(!quex.empty()){
  u=quex.front();
  v=quey.front();
 // printf("\nu %d v %d\n",u,v);
  quex.pop();quey.pop();
   
  if(a[u-1][v]=='.'){
     a[u-1][v]='#';
     num[u-1][v]=num[u][v]+1;
     ans=num[u-1][v];
     quex.push(u-1);quey.push(v);
    }
   
  if(a[u+1][v]=='.'){
     a[u+1][v]='#';
     num[u+1][v]=num[u][v]+1;
     ans=num[u+1][v];
     quex.push(u+1);quey.push(v);
    }
   
  if(a[u][v-1]=='.'){
     a[u][v-1]='#';
     num[u][v-1]=num[u][v]+1;
     ans=num[u][v-1];
     quex.push(u);quey.push(v-1);
    }
   
  if(a[u][v+1]=='.'){
     a[u][v+1]='#';
     num[u][v+1]=num[u][v]+1;
     ans=num[u][v+1];
     quex.push(u);quey.push(v+1);
    }
  
 }
  
 printf("%lld\n",ans);
return 0;}


Measured memory_bytes: 25504
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int[] a = new int[5];
        for(int i=0 ; i<5; i++) {
            a[i] = sc.nextInt();
        }
        for(int i=0 ; i<5; i++) {
            if(a[i] == 0) {
                System.out.println(i+1);
            }
        }

    }

}

Measured memory_bytes: 35712
use std::cmp;

const INF: u32 = 1e7 as u32;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let s = sc
        .chars()
        .into_iter()
        .map(|c| c as usize - 'a' as usize)
        .collect::<Vec<_>>();
    let n = s.len();

    let mut dp = 0;
    let mut min = vec![INF; 1 << 26];
    min[0] = 0;
    let mut hash = 0;
    for i in 0..n {
        dp = INF;
        hash ^= 1 << s[i];
        for i in 0..26 {
            let palindrome_prefix = 1 << i;
            let suffix = hash ^ palindrome_prefix;
            dp = cmp::min(dp, min[suffix] + 1);
        }
        dp = cmp::min(dp, min[hash] + 1);
        min[hash] = cmp::min(min[hash], dp);
    }

    println!("{}", dp);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 268540
module Dsu : sig
    type t

    val make   : int -> t
    val merge  : t -> int -> int -> int
    val same   : t -> int -> int -> bool
    val leader : t -> int -> int
    val size   : t -> int -> int
end = struct
    type t = int * int array

    let make n =
        n, Array.make n (-1)

    let rec leader ((n, parent_or_size) as dsu) a =
        if parent_or_size.(a) < 0 then a else
            let r = leader dsu parent_or_size.(a) in
            let () = parent_or_size.(a) <- r in
            r

    let merge ((n, parent_or_size) as dsu) a b =
        let x = leader dsu a in
        let y = leader dsu b in
        if x = y then x else (
            let x, y = if -parent_or_size.(x) < -parent_or_size.(y) then y, x else x, y in
            parent_or_size.(x) <- parent_or_size.(x) + parent_or_size.(y);
            parent_or_size.(y) <- x;
            x
        )

    let same dsu a b =
        leader dsu a = leader dsu b

    let size ((n, parent_or_size) as dsu) a =
        -parent_or_size.(leader dsu a)
end;;

Scanf.scanf "%d %d" (fun n q ->
    let dsu = Dsu.make n in
    for i = 1 to q do
        Scanf.scanf " %d %d %d" (fun t u v ->
            if t = 0 then ignore (Dsu.merge dsu u v) else
                Printf.printf "%d\n" @@ if Dsu.same dsu u v then 1 else 0
        )
    done
)

Measured memory_bytes: 7472
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 +10;
int arr[maxn],N,M;
int main(){
	scanf("%d%d",&N,&M);
	for(int i = 0 ; i < M ; ++i) scanf("%d",arr+i);
	if(N >= M){
		puts("0");
		return 0;
	}
	sort(arr,arr+M);
	for(int i = 1; i < M ; ++i){
		arr[i-1] = arr[i] - arr[i-1];
	}
	sort(arr,arr+M-1);
	long long sum = 0;
	for(int i = 0 ; i < M - N ; ++i) sum += arr[i];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,k,s;
int main()
{
    cin>>n>>k;
    s=1;
    for (int i=1; i<=n; ++i)
    if (s<k) s*=2;
    else s+=k;
    cout<<s;
    return 0;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    int A[N][N-1];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N - 1; j++) {
            cin >> A[i][j];
            A[i][j]--;
        }
    }
    vector<int> match_nr(N);
    set<int> que;
    for (int i = 0; i < N; i++) {
        que.insert(i);
    }
    int ans = 0;
    int match_cnt = 0;
    while (true) {
        set<int> next_que;
        for (auto i : que) {
            if (match_nr[i] >= N - 1) {
                continue;
            }
            int j = A[i][match_nr[i]];
            if (A[j][match_nr[j]] == i) {
                next_que.insert(i);
                next_que.insert(j);
            }
        }
        if (next_que.size() == 0) {
            break;
        }
        for (auto i : next_que) {
            match_cnt++;
            match_nr[i]++;
        }
        que = next_que;
        ans++;
    }
    if (match_cnt != N * (N - 1)) {
        ans = -1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if (a % 2 == 0 || b % 2 == 0){
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
  }
}

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

bool f(int x){
    int keta = 0;
    while(x){
        keta++;
        x /= 10;
    }
    return keta%2 == 1;
}

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(f(i)) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

typedef pair<int,int>   ii;
typedef pair<int,ii>   pii;
typedef vector< ii >   vii;
typedef vector< ii >   vpii;
typedef vector<int>     vi;
typedef vector< vi > 	vvi;
typedef long long int 	ll;
typedef unsigned long long int ull;

#define pb push_back

#define Add1(a,b) ady[a].pb(b)
#define Add1c(a,b,c) ady[a].pb({b,c})
#define AddS1(a,b) ady[a].insert(b)
#define AddS1c(a,b,c) ady[a].insert({b,c})

#define Add2(a,b) ady[a].pb(b), ady[b].pb(a)
#define Add2c(a,b,c) ady[a].pb({b,c}), ady[b].pb({a,c})
#define AddS2(a,b) ady[a].insert(b), ady[b].insert(a)
#define AddS2c(a,b,c) ady[a].insert({b,c}), ady[b].insert({a,c})

#define f first
#define s second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))

#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define DRT() int t; si(t); while(t--)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define TRACE

#ifdef TRACE
#define trace                    cerr << "Hola mundo" << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

const int maxn = 1e5+1;
const int maxe = 20;
const int oo = 1 << 30;

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

    long long sol = n-1;
    for(long long i=2;i<=(int)sqrt(n);i++){
        if(i*(n/i)==n)
            sol = min(sol,(i-1)+(n/i)-1);
    }

    cout<<sol;
}


Measured memory_bytes: 384
#include<stdio.h>
#define N 100
#define M 2000000
 
int main(void) {
 
  int n,a[N],m[N][N];
  int i,j,k,l,q;
 
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d%d",&a[i],&j);
 
  a[n] = j;;
  for(i=1;i<=n;i++)
    m[i][i] = 0;
   
  for(l=2;l<=n;l++) {
    for(i=1;i<=n-l+1;i++) {
      j = i + l - 1;
      m[i][j] = M;
      for(k=i;k<=j-1;k++) {
    q = m[i][k] + m[k+1][j] + a[i-1] * a[k] * a[j];
     
    if(m[i][j] > q)
      m[i][j] = q;
      }
    }
  }
  printf("%d\n",m[1][n]);
 
 return 0;
}

Measured memory_bytes: 636
'use strict'

function main(s) {

  const input = s.replace(/\n/g, '').split('');
  const result = [];
  input.forEach(x => {
    if(x === 'B') {
      result.pop();
    } else {
      result.push(x);
    }
  });
  console.log(result.join(''));
}

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


Measured memory_bytes: 7372
#include <bits/stdc++.h>
 
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std;  
    
    
    
    int main() {
     
     string s;
     int q;
     cin >> s >> q;
     
     string com;
     int a,b;
     string p;
     
     rep(i,q){
     	cin >> com >> a >> b;
     	if(com == "print"){
     		cout << s.substr(a,b-a+1) << '\n';
     		
     	} else if(com == "reverse"){
     		int d = a;
     		int c = b;
     		for(int j = 0; j < (b-a+1)/2; j++){
     		    char t = s[d];
     			s[d] = s[c];
     			s[c] = t;
     			c--;d++;	 
     		}
     		
     	} else{
     		cin >> p;
     		rep(j,p.size()){
     			s[a] = p[j];
     			a++;
     		}
     		
     	} 
     }
      
     return 0;
    }
    


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

using namespace std;

int n, k, a[55], sum[55];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen(".inp", "r", stdin);
    cin >> n >> k;
    for(int i=1 ; i<=n ; ++i) cin >> a[i], sum[i]=sum[i-1]+a[i];
  
            
      set <int > S;
    long long ans=0;
    for(int lef=0; lef<min(n, k+1) ; ++lef) {
        if(lef>0) S.insert(a[lef]);
        set <int > S2;
        S2=S;
        for(int rig=0 ; rig<=min(n-lef, k-lef) ; ++rig) {
            if(rig>0) S2.insert(a[n-rig+1]);
            long long res=sum[lef]+sum[n]-sum[n-rig];
            int cnt=0;
            for(auto val:S2) {
                if(cnt+lef+rig==k||val>0) break;
                ++cnt; res-=val;
            }
            ans=max(ans, res);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
prime_five = []
for i in range(3, 55555):
	j = 2
	while j ** 2 <= i:
		if i % j == 0:
			break
		j += 1
	else:
		if i % 5 == 1:
			prime_five.append(i)

n = int(input())
ans = []

for i in range(n):
	ans.append(str(prime_five[i]))

print(' '.join(ans))

Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    ll ans = n*(n+1)*(n+1)/2-n*(n+1)*(2*n+1)/6;
    //cout << ans << endl;
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        if(a > b) swap(a, b);
        ans -= ll(a)*(n-b+1);
        //cout << a*(n-b-1) << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <stdio.h>

int main(void){
	int sx,sy,tx,ty;
	scanf("%d",&sx);
	scanf("%d",&sy);
	scanf("%d",&tx);
	scanf("%d",&ty);
	for(int i=0;i<ty-sy;i++) printf("U");
	for(int i=0;i<tx-sx;i++) printf("R");
	for(int i=0;i<ty-sy;i++) printf("D");
	for(int i=0;i<tx-sx;i++) printf("L");
	printf("L");
	for(int i=0;i<ty-sy+1;i++) printf("U");
	for(int i=0;i<tx-sx+1;i++) printf("R");
	printf("D");
	printf("R");
	for(int i=0;i<ty-sy+1;i++) printf("D");
	for(int i=0;i<tx-sx+1;i++) printf("L");
	printf("U");
		
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

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

int main() {
    constexpr int maxv = 1000;
    
    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    REP(i, N) cin >> w[i] >> v[i];
    
    vector<vector<ll>> dp(N + 1, vector<ll>(N * maxv + 1, INF));
    dp[0][0] = 0;
    REP(i, N) REP(j, N * maxv) {
        if (dp[i][j] == INF) continue;
        chmin(dp[i + 1][j], dp[i][j]);
        if (j + v[i] <= N * maxv) chmin(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
    }
    ll ans = 0;
    REP(i, N * maxv + 1) {
        if (dp[N][i] <= W) chmax(ans, (ll)i);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 83184
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  string s;
  cin>>s;
  string t = "2019/04/30";
  if(s <= t){
    cout<<"Heisei"<<endl;
  }else{
    cout<<"TBD"<<endl;
  }
  return 0;
}


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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
const ll zero=0;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

map<ll,ll> factoring(ll n){ 
  ll buf=n;
  map<ll,ll>ret;
  ll i,j;
  for(i=2;buf!=1&&i*i<=n;i++){
    for(j=0;buf%i==0;j++){
      buf/=i;
    }
    if(i>0)ret.emplace(i,j);
  }
  if(buf!=1)ret.emplace(buf,1);
  return ret;
}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  bool judge = true;
  ll n,p;cin>>n>>p;
  map<ll,ll>q=factoring(p);
  //cout<<q.size()<<endl;
  res=1;
  for(auto z:q){
    for(i=0;i<z.se/n;i++)res*=z.fi;
  }
  cout<<res<<endl;

  return 0;
}

Measured memory_bytes: 52864
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            var a = cin.ReadInt();
            var b = cin.ReadInt();
            var c = cin.ReadInt();
            if (a <= c && c <= b) WriteLine("Yes");
            else WriteLine("No");
        }
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret;}
    }
}



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

int main(){
    int n;
    cin >> n;
    cout << n*(n+1)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int n;
vector<vector<int> > graph(100001);
vector<bool> ischecked(100001, false);
vector<long long int> stonenum(100001);

bool cansolve(int node)
{
	if(graph[node].size() == 1) return true;
	ischecked[node] = true;
	long long int sum = 0;
	vector<int> v;
	for(int i = 0; i < graph[node].size(); i++){
		int child = graph[node][i];
		if(ischecked[child]) continue;
		if(cansolve(child)) {
			sum += stonenum[child];
			v.push_back(stonenum[child]);
		} else {
			return false;
		}
	}
	int pairnum = 0;
	while(v.size() > 1){
		sort(v.begin(), v.end());
		int s = v.size();
		if(v[0] == v[s - 1]){
			pairnum += s / 2;
			break;
		}
		pairnum += v[s - 2];
		v[s - 1] -= v[s - 2];
		v.erase(v.begin() + s - 2);
	}
	if(stonenum[node] > sum) {
		return false;
	} else if(stonenum[node] == sum) {
		return true;
	} else if(sum - stonenum[node] <= pairnum){
		stonenum[node] -= sum - stonenum[node];
		return true;
	}
	return false;
}

int main()
{
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> stonenum[i];
	}
	int a, b;
	for(int i = 0; i < n - 1; i++){
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	if(n == 2){
		if(stonenum[0] == stonenum[1]) cout << "YES" << endl;
		else cout << "NO" << endl;
		return 0;
	}
	int root = 0;
	while(root < n && graph[root].size() > 1) root++;
	ischecked[root] = true;
	if(cansolve(graph[root][0]) && stonenum[graph[root][0]] == stonenum[root]) cout << "YES" << endl;
	else cout << "NO" << endl;
	// cout << stonenum[0] << endl;
	return 0;
}

Measured memory_bytes: 19072
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,k,ans=0,bpos;cin>>n>>m>>k;
  lvector A(n),B(m),SA(n+1,0),SB(m+1,0);
  rep(i,n) cin>>A[i];rep(i,m) cin>>B[i];
  rep(i,n) SA[i+1]=A[i]+SA[i];
  rep(i,m) SB[i+1]=B[i]+SB[i];
  for(ll apos=0;apos<=n;++apos) {
    if(SA[apos]>k) break;
    bpos=upper_bound(ALL(SB),k-SA[apos])-SB.begin();
    ans=max(ans,apos+bpos-1ll);
  }
  print(ans);
  return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  ll a, b;
  cin >> a >> b;
  REP(i, max(a, b)) { cout << min(a, b); }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256