akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define N 100
int main()
{
  int i,v,j,num,A[N];
    scanf("%d",&num);
  
  for(i=0; i<num; i++){
    scanf("%d",&A[i]);
  }
  for(i=0; i<num-1; i++){
    printf("%d ", A[i]);
    }
    printf("%d\n",A[num-1]);
    
   for (i=1; i<=num-1; i++) {
    v  =  A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
       A[j+1]=A[j];
       j--;
       A[j+1]=v;
         }
       
       for(j=0; j<num-1; j++){
           printf("%d ", A[j]);
       }
     printf("%d\n", A[num-1]);
      }
    return 0;
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  int h,w;cin >> h >> w;
  vector<string> a(h);
  rep(i,h){
    string k;cin >> k;
    a[i] = k;
  }
  const int dx[8]={-1,0,1,-1,1,-1,0,1};
  const int dy[8]={1,1,1,0,0,-1,-1,-1};
  rep(i,h){
    rep(j,w){
      if(a[i][j]=='#') continue;
      int num = 0;
      for(int d=0;d<8;d++){
        const int ni = i + dy[d];
        const int nj = j + dx[d];

        if(ni<0||h<=ni) continue;
        if(nj<0||w<=nj) continue;
        if(a[ni][nj]=='#') num++;
      }
      a[i][j] = char(num+'0');
    }
  }
  for(int i=0;i<h;i++) cout << a[i] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;

template<int N, typename T, T M>
struct ModFact {
    T fact[N + 1];
    T ifact[N + 1];
    constexpr ModFact() : fact(), ifact() {
        fact[0] = 1;
        for (int i = 0; i < N; ++i)
            fact[i + 1] = (fact[i] * (i + 1)) % M;
        ifact[N] = power(fact[N], M - 2);
        for (int i = N - 1; i >= 0; --i)
            ifact[i] = (ifact[i + 1] * (i + 1)) % M;
    }
    constexpr T power(T a, T b) {
        T r = 1;
        while (b > 0) {
            if ((b & 1) != 0) r = (r * a) % M;
            a = (a * a) % M;
            b >>= 1;
        }
        return r;
    }
    constexpr T comb(T n, T r) {
        return (((fact[n] * ifact[r]) % M) * ifact[n - r]) % M;
    }
};
 
ModFact<200000, ll, MOD> fact;

int main() {
    ll H, W, A, B, ans = 0;
    ios::sync_with_stdio(false);
    cin.tie(0);
	cin >> H >> W >> A >> B;
    ll a = H-A-1;
    ll c = A-1;
    REP(i, W-B) {
        ans += fact.comb(a+B+i,a)*fact.comb(c+W-B-1-i,c);
        ans %= MOD;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
 
 
int main(){
    ll n, k;
    cin >> n >> k;
    vector<pll> dt(n);
    for(int i = 0; i < n; i++){
        cin >> dt[i].second >> dt[i].first;
    }
 
    sort(dt.begin(),dt.end());
    reverse(dt.begin(),dt.end());
    //寿司は価値，種類の順に管理
 
    map<ll,ll> eat;
    ll val = 0; //食べた寿司の価値
    //価値の高い順にk個食べるとする，種類と食べた数をmapで管理
    for(int i = 0; i < k; i++){
        eat[dt[i].second]++;
        val += dt[i].first;
    }
    ll pd = k;
    ll pu = k-1;
    ll diverse = ll(eat.size());    //現在の種類数
 
    ll ans = val + diverse*diverse;
    while(pu!=-1 && pd!=n){
        while(eat[dt[pd].second] > 0){  //食べてない種類の寿司で価値の高いものを食べる
            pd++;
            if(pd==n)break;
        }
        while(eat[dt[pu].second] == 1){ //2個以上食べた種類で価値の低いものを捨てる
            pu--;
            if(pu==-1)break;
        }
        if(pu==-1 || pd==n){break;}
        val += dt[pd].first;
        eat[dt[pd].second]++;
        val -= dt[pu].first;
        eat[dt[pu].second]--;
        diverse++;
        ans = max(ans, val + diverse*diverse);
      
        pu--;
    }
    cout << ans << endl;
 
 
    return 0;
 
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    LL n, a, b;
    cin >> n >> a >> b;

    cout << (n / (a+b) * a) + min(n % (a+b), a) << '\n';

    return 0;
}


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

const int MAX_N = 10000;

int main() {
  int N;
  std::string s[MAX_N];

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

  int cnt[4] = {}, ans = 0;
  for(int i = 0; i < N; ++i) {
    std::string S = s[i];
    int n = S.length();

    for(int j = 1; j < n; ++j) {
      if(S[j - 1] == 'A' and S[j] == 'B') ++ans;
    }

    if(S[0] == 'B' and S[n - 1] == 'A') ++cnt[0];
    else if(S[0] == 'B' and S[n - 1] != 'A') ++cnt[1];
    else if(S[0] != 'B' and S[n - 1] == 'A') ++cnt[2];
    else ++cnt[3];
  }

  if(cnt[0] > 0 and cnt[1] == 0 and cnt[2] == 0) ans += cnt[0] - 1;
  else ans += cnt[0] + std::min(cnt[1], cnt[2]);

  std::cout << ans << std::endl;
}


Measured memory_bytes: 768
#include <iostream>

int main() {
	int A, B, K;
	std::cin >> A >> B >> K;

	int count = 0;
	int result;
	for(int i = 100; i >= 1; i--) {
		if(A % i == 0 && B % i == 0) {
			count++;
			if(count == K) {
				result = i;
				break;
			}
		}
	}

	std::cout << result << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://abc061.contest.atcoder.jp/tasks/abc061_d>
問題文============================================================
 N 頂点 M 辺の重み付き有向グラフがあります。
 i(1≦i≦M) 番目の辺は 頂点 ai から 頂点 bi を重み ci で結びます。
 このグラフと駒を利用して、次の1人ゲームを行います。
 
 最初、駒を頂点 1 に置いて、プレイヤーのスコアを 0 とします。
 プレイヤーは、次の条件で駒を繰り返し移動させることができます。
 
 頂点 ai に駒があるとき、i 番目の辺を利用して頂点 bi に移動する。移動後にプレイヤーのスコアが ci 加算される。
 
 頂点 N に駒があるときのみ、ゲームを終了できます。
 なお、与えられる有向グラフの上で頂点 1 から頂点 N に移動できることは保障されています。
 
 プレイヤーがゲーム終了時のスコアを出来るだけ大きくするような行動を取ったとき、ゲーム終了時のスコアはいくつになるでしょうか?
 ゲーム終了時のスコアをいくらでも大きくできる場合は inf と出力してください。
=================================================================

解説=============================================================
 
 ベルマンフォード法
 
 コストの符号を反転させた値を辺とすれば、ゲーム終了のスコアが特定の値になる場合は
 その答えは -1 * dist[0->V-1] となる。
 
 ゲーム終了時のスコアをいくらでも大きくできる場合に関して、
 閉路が0 -> V-1 へのルートに関係ない部分でできる場合があるので、その判定に注意
 
================================================================
*/
class Bellman_ford {
public:
    struct edge {
        ll u;
        ll v;
        ll cost;
        edge() {}
        edge(ll u, ll v, ll c) :u(u), v(v), cost(c) {}
    };
    
    ll V;
    vector<vector<edge> > G;
    vector<ll> dist;
    Bellman_ford(ll V) :V(V) {
        G.resize(V);
    }
    
    void add_edge(ll u, ll v, ll cost, bool undirected = false) {
        G[u].push_back(edge(u, v, cost));
        if (undirected) {
            G[v].push_back(edge(v, u, cost));
        }
    }
    
    bool calc_dist(ll s) {
        dist.assign(V,LINF);
        dist[s] = 0;
        
        for (int i = 0; i < V;i++) {
            bool updated = true;
            for (int v = 0; v < V;v++) {
                for (int j = 0; j < (int)G[v].size();j++){
                    edge& e = G[v][j];
                    if (dist[e.v] > dist[v] + e.cost) {
                        dist[e.v] = dist[v] + e.cost;
                        updated = false;
                        if (i == V - 1 && e.v == V-1) return true; // 負閉路
                    }
                }
            }
            if(updated) return false;
        }
        return false;
    }
    
    inline ll get_dist(ll v) const { return dist[v]; }
};
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N,M; cin >> N >> M;
    Bellman_ford Bf(N);
    for(int i = 0; i < M;i++){
        ll a,b,c; cin >> a >> b >> c; a--; b--;
        Bf.add_edge(a, b, -c);
    }
    
    if(Bf.calc_dist(0)){
        cout << "inf" << endl;
    }else{
        cout << -Bf.get_dist(N-1) << endl;
    }
	return 0;
}


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

int dp1[5010][5010] = {};
int dp2[5010][5010] = {};

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

    int a;
    vector<int> vec;
    for(int i = 0;i < n;i++){
        cin >> a;
        vec.push_back(a);
    }

    dp1[0][0] = 1;
    for(int i = 1;i <= n;i++){
        for(int j = 0;j <= k;j++){
            dp1[i][j] = dp1[i-1][j] || (j-vec[i-1] >= 0 ? dp1[i-1][j-vec[i-1]] : false);
        }
    }

    dp2[n][0] = 1;
    for(int i = n-1;i >= 0;i--){
        for(int j = 0;j <= k;j++){
            dp2[i][j] = dp2[i+1][j] || (j-vec[i] >= 0 ? dp2[i+1][j-vec[i]] : false);
        }
    }


    int ans = 0;
    for(int i = 0;i < n;i++){
        int rui[5010] = {};
        for(int j = 0;j <= k;j++){
            rui[j+1] = rui[j] + dp2[i+1][j];
        }

        int j;
        for(j = 0;j <= k;j++){
            if(dp1[i][j] && (rui[k-j] - rui[max(k-vec[i]-j, 0)]) > 0 ){
                break;
            }
        }

        if(j > k){
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 196224
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cstring>
#include <climits>

#define int long long
//typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)

#define MOD 1000000007

using namespace std;

int N, A, B;
int h[100010];

bool C(int k)
{
    int rest_A = k;

    rep(i,N) {
        if (h[i] <= B * k) return true;

        double x = 1.0 * (h[i] - B * k) / (A - B);
        x = ceil(x);
        if ((int)x > rest_A) return false;
        rest_A -= (int)x;    //マイナスするのはkじゃない！！！
    }
    return true;
}

signed main()
{
#ifdef LOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    cin >> N >> A >> B;
    rep(i,N) cin >> h[i];

    sort(h, h + N, greater<int>());

    //rep(i,N) cout << h[i] << endl;
    //cout << (C(5) ? "True" : "False") << endl;

    int lb = 0, ub = 1000000010;
    while (ub - lb > 1) {
        int mid = (lb + ub) / 2;
        if (!C(mid)) lb = mid;
        else ub = mid;
    }

    cout << lb + 1 << endl;

    /*
    A = 3;
    B = 1;
    int k = 7;
    int h = 14;
    double x = 1.0 * (h - B * k) / (A - B);
    cout << "AAA = " << x << endl;
    cout << "ceil = " << ceil(x) << endl;
    */
}


Measured memory_bytes: 1024
N,sum1 = map(int,input().split())

A = 10000
B = 5000
C = 1000

def memuA():
	for i in range(N+1):
		for j in range(N+1 - i):
			if i*A + j*B + (N-i-j)*C == sum1:
				return [i,j,(N-i-j)]
	return [-1,-1,-1]

print(*memuA())

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

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

typedef tuple<int, int, int> T;

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

    int n, m; cin >> n >> m;
    vector<T> pyid(m);
    vector<int> year[n+1];
    for(int i=0; i<m; ++i){
        int p, y; cin >> p >> y;
        pyid[i] = make_tuple(p, y, i+1);
        year[p].push_back(y);
    }

    for(int i=1; i<=n; ++i) sort(year[i].begin(), year[i].end());
    
    for(int i=0; i<m; ++i){
        int p, y, id;
        tie(p, y, id) = pyid[i];

        auto itr = lower_bound(year[p].begin(), year[p].end(), y);
        int rank = itr-year[p].begin()+1;
        printf("%06d%06d\n", p, rank);
    }
    
    return 0;
}



Measured memory_bytes: 8192
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	string str;
	cin >> str;
	int size = str.size();
	int now = 0;
	int ans = 0;
	for(int i=0;i<size;++i){
		if( str[i] == 'T' ){
			if( now ){
				--now;
			}else{
				++ans;
			}
		}else{//'S'
			++now;
		}
	}
	cout << ans + now << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 720
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<fstream>
using namespace std;
typedef long long ll;
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    fast_io;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    
    int n;
    cin >> n;

    vector<ll> a(n, 0);

    ll sum = 0;
    for (int i = 0; i < n; i++)
        cin >> a[i];

    sort(a.begin(), a.end(), greater<int>());
    for (int i = 1; i < n; i++)
        sum += a[i / 2];

    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 4448
def m(L,R):
 global c;c+=len(L)+len(R)
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 return R+T[::-1]
def d(A):s=len(A)//2;return m(d(A[:s]),d(A[s:]))if len(A)>1 else A
c=0
input()
print(*d(list(map(int,input().split()))))
print(c)


Measured memory_bytes: 63912
import sys
input=sys.stdin.readline
d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
    sub=list(map(int,input().split()))
    s.append(sub)

last=[-1]*26

for i in range(d):
    m=-10**9
    change=-1
    for j in range(26):
        temp=0
        temp+=s[i][j]
        for k in range(26):
            if k!=j:
                temp-=c[k]*(i-last[k])
        if temp>m:
            m=temp
            change=j
    print(change+1)


Measured memory_bytes: 68724
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}


ll i,j,k,ii,jj;
ll n,m;
ll a,b,c,d,e,g,h,r;
ll l,ans,num;
ll x[500005],y[500005],z[500005];
bool dame,flag;
char s[500005],t[500005];
bool used[500005];

int main(){
    cin >> n;
	for(i=0;i<n;i++){
		cin >> x[i];
		y[i] = x[i];
	}
	sort(x,x+n);
	sort(y,y+n);
	reverse(x,x+n);
	for(j=32;j>=0;j--){
		num = (1 << j);
		//p(num);
		for(i=0;i<n;i++){
			if(used[i])continue;
			a = num - x[i];
			b = lb(y,y+n,a+1) - lb(y,y+n,a);
			if(b >= 1){
				c = lb(y,y+n,a) - lb(y,y+n,-1);
				c = n - 1 - c;
				c -= (b - 1);
				while(i == c){
					c++;
				}
				while(used[c] && x[c+500] == a && used[c + 500]){
					c += 500; 
				}
				while(used[c]){
					c++;
				}
				while(i == c){
					c++;
				}
				if(!used[c] && x[c] == a){
					used[c] = true;
					used[i] = true;
					ans++;
					//pe(i);p(c);
				}
			}
		}
	}
	p(ans);


    return 0;
}

Measured memory_bytes: 33024
#include <iostream>
int main(){
    int a,b;
    char op;
    while(true){
        std::cin >> a >> op >> b;
        if(op == '?') break;
        if(op == '+') {
            std::cout << a+b << std::endl;
            continue;
        }
        if(op == '-'){
            std::cout << a-b << std::endl;
            continue;
        }
        if(op == '*'){
            std::cout << a*b << std::endl;
            continue;
        }
        if(op == '/'){
            std::cout << a/b << std::endl;
            continue;
        }
    }
    return 0;
}


Measured memory_bytes: 3128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
	
		int n = new Scanner(System.in).nextInt();
		int money = 100000;
		for(int i = 0;i<n;i++){
			money *= 1.05;
			money = (money + 999) /1000 * 1000; 
		}
		System.out.println(money);
	}

}

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

int main() {
  
  string S;
  cin >> S;
  
  if(S[0] =='A'&& S[1] =='A'&& S[2] =='A' || S[0] =='B'&& S[1] =='B'&& S[2] =='B') {
    cout << "No" <<endl;
  }
  
  else {
    cout << "Yes" <<endl;
  }
  
  return 0;
}


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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

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; }

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int ok[1000001];

int main(){
    ok[100] = ok[101] = ok[102] = ok[103] = ok[104] = ok[105] = 1;
    for( int i = 200; i < 1000001; i++ ){
        if( ok[i - 100] || ok[i - 101] || ok[i - 102] || ok[i - 103] || ok[i - 104] || ok[i - 105] ){
            ok[i] = 1;
        }
    }

    int x; cin >> x;
    cout << ok[x] << endl;
}

/*
38

*/

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

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

    if (S.at(2) == S.at(3) && S.at(4) == S.at(5))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	int ans = 0;
	for (int i = 1; i < N; i++) {
		string x, y;
		x = S.substr(0, i);
		y = S.substr(i);
		//cout << x << ' ' << y << endl;

		vector<char> v;
		int cnt = 0;
		for (int j = 0; j < x.size(); j++) {
			char ch = x.at(j);
			if ((count(y.begin(), y.end(), ch)) &&
				(count(v.begin(), v.end(), ch) == 0)) {
				cnt++;
				v.push_back(ch);
			}
		}

		ans = max(ans, cnt);
	}

	cout << ans << endl;
}

Measured memory_bytes: 3608
/*/**/

#include <bits/stdc++.h>

using namespace std;

int a[222];

int main() {
	int n;
	cin >> n;
	for(int i = 0; i < 2 * n; i++ ) {
		cin >> a[i];
	}
	sort(a, a + 2 * n);
	int ans = 0;
	for(int i = 0; i < 2*n; i += 2) {
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt(),b=sc.nextInt(),ab=sc.nextInt(),x=sc.nextInt(),y=sc.nextInt();
        if(ab*2>a+b){
          System.out.println(a*x+b*y);
        }else if(x>y&&ab*2<a){
          System.out.println(ab*2*x);
        }else if(x<y&&ab*2<b){
          System.out.println(ab*2*y);
        }else if(x>y){
          System.out.println(ab*2*y+a*(x-y));
        }else if(x<y){
          System.out.println(ab*2*x+b*(y-x));
        }else{
          System.out.println(ab*2*x);
        }


    }
}

Measured memory_bytes: 21844
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    ll x = N % 10;
    if (x == 3)
    {
        OUT("bon");
    }
    else if (x == 0 or x == 1 or x == 6 or x == 8)
    {
        OUT("pon");
    }
    else
    {
        OUT("hon");
    }
}

Measured memory_bytes: 3600
def function(a, b)
	min_a = a / 0.08
	max_a = (a + 1) / 0.08
	range_a = (min_a.ceil)...max_a
	min_b = b / 0.1
	max_b = (b + 1) / 0.1
	range_b = (min_b.ceil)...max_b
	return -1 if !range_a.member?(min_b.ceil) && !range_b.member?(min_a.ceil)

	(min_a.ceil > min_b.ceil) ? min_a.ceil : min_b.ceil
end

a, b = gets.chomp.split.map(&:to_i)
puts function(a, b)


Measured memory_bytes: 1788
// AOJ 3027: OOllOll
// 2018.3.28 bal4u

#include <stdio.h>

int main()
{
	int N, i;

	scanf("%d", &N);
	if (N == 1) { puts("1"); return 0; }
	for (i = 0; (1<<i) < N; i++);
	if ((1<<i)-1 > N) i--; 
	printf("%d\n", i);
	return 0;
}


Measured memory_bytes: 2104
import java.util.Scanner;

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

		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		
		int a[] = new int[m];
		
		for (int i = 0; i < m; i++) {
			a[i] = sc.nextInt();
		}
		
		int count0 = 0;
		int countn = 0;
		
		for (int i = 0; i < m; i++) {
			if (a[i] < x){
				count0++;
			}
		}
		
		for (int i = 0; i < m; i++) {
			if (a[i] > x && a[i] < n){
				countn++;
			}
		}
		
		System.out.println(Math.min(count0, countn));
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)

using namespace std;
using ll = long long;
using ii = pair<int,int>;

bool ok(const string& s) {
  int cc = 0;
  for (char c : s) {
    if (c == '(') cc++;
    else {
      if (cc <= 0) return false;
      cc--;
    }
  }
  return cc == 0;
}

constexpr int MAXN = 5 + 1e6;
int l[MAXN], r[MAXN];

void calc(int idx, const string& s) {
  int cc = 0;
  for (char c : s) {
    if (c == '(') cc++;
    else {
      cc--;
      if (cc < 0) l[idx]++, cc = 0;
    }
  }
  if (cc > 0) r[idx] = cc;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  vector<string> v;

  foi (i,0,n) {
    string s; cin >> s;
    if (!ok(s)) {
      v.push_back(s);
    }
  }

  n = (int)v.size();
  vector<int> pos,neg,en;


  foi (i,0,n) {
    calc(i, v[i]);
    //cout << "Para " << v[i] << " necesita " << l[i] << " pero da " << r[i] << '\n';
    if (r[i] >= l[i]) {
      pos.push_back(i);
    } else {
      if (r[i] == 0) en.push_back(i);
      else neg.push_back(i);
    }
  }

  sort(pos.begin(), pos.end(), [](const int& a, const int& b)->bool{
       return l[a] < l[b];
       });
  sort(neg.begin(), neg.end(), [](const int& a, const int& b)->bool{
       return r[a] > r[b];
       });

  string res;
  for (auto x : pos) res += v[x];
  for (auto x : neg) res += v[x];
  for (auto x : en) res += v[x];
  //cout << "final string=" << res << endl;
  cout << (ok(res) ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 50028
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main() {
    ll N, M;
    cin >> N >> M;
    if(N == 1 && M == 1) {
        cout << 1 << endl;
        return 0;
    }
    else if(N == 1) {
        cout << M-2 << endl;
        return 0;
    }
    else if(M == 1) {
        cout << N-2 << endl;
        return 0;
    }
    ll ans = (N-2) * (M-2);
    cout << ans << endl;

}

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

using namespace std;

#define INF 1e9

int main() {
	int N, M;
	while ( cin >> M, M ) {
		int cost[100][100]; fill(cost[0], cost[100], INF);
		set<int> s;
		for (int i = 0; i < M; ++i) {
			int a, b, c; cin >> a >> b >> c;
			cost[a][b] = cost[b][a] = c;
			s.insert(a);
			s.insert(b);
		}
		vector<int> v;
		for (set<int>::iterator it = s.begin(); it != s.end(); ++it) {
			v.push_back(*it);
		}
		N = (int)v.size();
		for (int i = 0; i < N; ++i) cost[i][i] = 0;
		for (int k = 0; k < N; ++k) {
			for (int i = 0; i < N; ++i) {
				for (int j = 0; j < N; ++j) {
					cost[v[i]][v[j]] = min(cost[v[i]][v[j]], cost[v[i]][v[k]]+cost[v[k]][v[j]]);
				}
			}
		}
		int aid = -1, asum = 0;
		for (int i = 0; i < N; ++i) {
			int sum = 0;
			for (int j = 0; j < N; ++j) {
				sum += cost[v[i]][v[j]];
			}
			if (aid < 0 || sum < asum) {
				aid = i;
				asum = sum;
			}
		}
		cout << aid << " " << asum << endl;
	}
}

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

using namespace std;
using ll = long long;


int main()
{
    int h, w; cin >> h >> w;
    vector<string> s(h + 2, string(w + 2, '#'));

    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            char c; cin >> c; s[i][j] = c;
        }
    }
    for(auto i : s)cout << i << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int n, a[200020];

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

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
int main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("input1.txt", "r", stdin);
    //     freopen("output1.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,cap;
    cin>>n>>cap;
    ll v[n+1];
    ll w[n+1];
    ll i;
    ll s=0;
    for(i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
        s=s+v[i];
    }
    ll mu=1e18;
    vector<vector<ll>> dp(n+1,vector<ll>(s+1,mu));
    for(i=0;i<=n;i++)
    {
        dp[i][0]=0;
    }
    ll j;
    ll ans=0;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=s;j++)
        {
            if(v[i]<=j)
            dp[i][j]=min(dp[i-1][j-v[i]]+w[i],dp[i-1][j]);
            else 
            dp[i][j]=dp[i-1][j];
            if(dp[i][j]<=cap)
            ans=max(ans,j);
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 80256
N = int(input())
S = []
Total = 0

for i in range(N):
    s = int(input())
    if s%10!=0:
        S.append(s)
    Total += s

if Total%10 != 0:
    print(Total)
else:
    if S:
        print(Total-min(S))
    else:
        print(0)

Measured memory_bytes: 3060
# coding: utf-8


II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def main():
    N = II()
    A = [MIL(), MIL()]
    ans = 0
    for i in range(N):
        ta = sum(A[0][:i + 1]) + sum(A[1][i:])
        ans = max(ans, ta)
    return ans


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 3064
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val (K, T)  = rd.readListInt()
    val C = rd.readIntArray().sorted()

    val CMax = C.last()
    val between = CMax-1
    val rest = C.dropLast(1).sum()

    val ans = max(between - rest, 0)
    println(ans)
}


//val rd = debug.Reader("etc", "code-festival-2016-qualc", "b", "sample-3")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readListIntCol: (Int) -> List<Int> = { N -> (0 until N).map { readInt() } }
    val readListLongCol: (Int) -> List<Long> = { N -> (0 until N).map { readLong() } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


Measured memory_bytes: 40424
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  vector<int> L(N);
  for(int i =0; i< N; i++){
    cin >> L[i];
  }
  
  int c=0;
  for(int i =0;i < N-2;i++){
    for(int j = i+1; j < N - 1; j++){
      if(L[i] == L[j]){
        continue;
      }
      
      for(int k = j+1; k < N; k++){
        if(L[j] == L[k] || L[i] == L[k]){
          continue;
        }
        
        vector<int> tmp(3);
        tmp[0] = L[i];
        tmp[1] = L[j];
        tmp[2] = L[k];
        
        int max =0;
        int index;
        for(int i_ =0; i_<3; i_++){
          if(max < tmp[i_]){
            max = tmp[i_];
            index = i_;
          }
        }
        int sum = 0;
        for(int i_ =0; i_<3; i_++){
          if(i_ != index){
            sum += tmp[i_];
          }
        }
        if(sum > max){
          c++;
        }
      }
    }
  }
  
  cout << c << endl;
  
  return 0 ;
}

Measured memory_bytes: 3632
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

x=ii()
l=1

while 1:
    if 360*l % x ==0:
        print((360*l)//x)
        exit()
    l += 1

Measured memory_bytes: 9116
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

struct murmur_hash {
    const unsigned int random = random_device{}();
    unsigned int operator()(const string& s) const {
        const unsigned int m = 0x5bd1e995;
        const int r = 24;
        unsigned int len = s.size(), h = (random ^ len);
        const char *c = s.c_str();
        while(len >= 4){
            unsigned int k = *(unsigned int*)c;
            k *= m, k = (k^(k>>r))*m, h = (h*m)^k;
            c += 4, len -= 4;
        }
        switch(len)
        {
        case 3u: h ^= (c[2] << 16);
        case 2u: h ^= (c[1] << 8);
        case 1u: h ^= c[0];
                 h *= m;
        }
        h = (h^(h>>13))*m;
        return (h^(h>>15));
    }
};

unordered_map<string, unordered_map<string, int, murmur_hash>, murmur_hash> mp[2];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    n *= 2;
    string s;
    cin >> s;
    rep(i,(1 << (n-n/2))){
        string red,blue;
        rep(j,n-n/2){
            if((i >> j) & 1){
                red.pb(s[j+n/2]);
            }else{
                blue.pb(s[j+n/2]);
            }
        }
        reverse(all(blue));
        if(len(red) <= len(blue)){
            mp[0][blue][red]++;
        }else{
            mp[1][red][blue]++;
        }
    }
    ll ans = 0;
    rep(i,(1 << n/2)){
        string red, blue;
        rep(j,n/2){
            if((i >> j) & 1){
                red.pb(s[j]);
            }else{
                blue.pb(s[j]);
            }
        }
        reverse(all(blue));
        if(len(red) >= len(blue)){
            ans += mp[0][red][blue];
        }else{
            ans += mp[1][blue][red];
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 138392
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
a=lnii()
a.sort(reverse=True)

ans=a[0]

inx=1
i=2
while i<n:
  ans+=a[inx]

  if i%2==1:
    inx+=1

  i+=1

print(ans)

Measured memory_bytes: 31432
MAX = 1000000

# 素数の表
prime_map = [True] * MAX
prime_map[0] = False
prime_map[1] = False

# n以下の素数の表
prime_num_map = [0] * MAX

for i in range(2, MAX):
    if prime_map[i]:
        prime_num_map[i] = prime_num_map[i-1] + 1
        index = 2
        n = i*index
        while n < MAX:
            prime_map[n] = False
            index += 1
            n = i*index
    else:
        prime_num_map[i] = prime_num_map[i-1]

while True:
    try:
        n = int(input())
        print(prime_num_map[n])
    except:
        exit(0)


Measured memory_bytes: 23468
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
using namespace std;
int n,l;
string a[200],b;
int main(){
	cin>>n>>l;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)b+=a[i];
	cout<<b;
	return 0;
}


Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class Knapsack01NoRepetitions {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int w = in.nextInt();
            int[] vs = new int[n];
            int[] ws = new int[n];

            for (int i = 0; i < n; i++) {
                vs[i] = in.nextInt();
                ws[i] = in.nextInt();
            }

            out.printf("%d\n", knapsack(w, vs, ws, n));
        }

        private int knapsack(int w, int[] vs, int[] ws, int n) {
            int[][] dp = new int[w + 1][n + 1];

            for (int i = 1; i < w + 1; i++) {
                for (int j = 1; j < n + 1; j++) {
                    dp[i][j] = dp[i][j - 1];

                    if (i >= ws[j - 1]) {
                        dp[i][j] = Math.max(dp[i][j], vs[j - 1] + dp[i - ws[j - 1]][j - 1]);
                    }
                }
            }

            return dp[w][n];
        }

    }
}




Measured memory_bytes: 31364
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int k=0,m,n,i=0,j=0,s=0,l,sum=0;
    long long arr[105][105],bb[105][1005],cc[105][105];
    cin>>n>>m>>l;

    for(i=0; i<n; i++)
    {
        for(j=0; j<m; j++)
        {
            cin>>arr[i][j];
        }
    }
    for(i=0; i<m; i++)
        for(j=0; j<l; j++)
            cin>>bb[i][j];

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < l; j++)
        {
            for (int k = 0; k < m; k++)
            {
                cc[i][j]+=arr[i][k]*bb[k][j];
            }


        }
    }
    for(i=0; i<n; i++)
    {
        for(j=0; j<l; j++)
        {
            if(j==l-1)
            cout<<cc[i][j];
            else
                cout<<cc[i][j]<<" ";
        }
        cout<<endl;


    }
}


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

int main(){
  string str;
  int cnt = 0;
  char color;
  
  cin >> str;
  
  for(int i = 0; i < str.size(); i++){
    if(i == 0){
      color = str.at(i);
      continue;
    }
    
    if(color == str.at(i)){
      if(color == '0') color = '1';
      else color = '0';
      cnt++;
    }else{
      color = str.at(i);
    }
  }
  
  cout << cnt;
}


Measured memory_bytes: 512
#include<stdio.h>


int main(){
   int a[5],b[13];
   int i,j;
   while(scanf("%d,%d,%d,%d,%d",&a[0],&a[1],&a[2],&a[3],&a[4])!=EOF){
      for(i=0;i<13;i++){b[i]=0;}
      for(i=0;i<5;i++){ b[a[i]-1]++;}
      
      for(i=0;i<13;i++){
         if(b[i]==4){
            printf("four card\n");
            goto exit;
         }
      }

      for(i=0;i<13;i++){
         for(j=0; j<13;j++){
            if(b[i]==2&&b[j]==3){
               printf("full house\n");
               goto exit;
            }else if(b[i]==2&&b[j]==2&&i!=j){
               printf("two pair\n");
               goto exit;
            }
            
         }
      }


     for(i=0;i<13;i++){
        if(b[i]==3){printf("three card\n");goto exit;}
        else if(b[i]==2){printf("one pair\n"); goto exit;}
     }

     for(i=0;i<9;i++){
        if(b[i]==1&&b[i+1]==1&&b[i+2]==1&&b[i+3]==1&&b[i+4]==1){
           printf("straight\n");
           goto exit;
        }
     }

     if(b[0]==1&&b[9]==1&&b[10]==1&&b[11]==1&b[12]==1){printf("straight\n"); goto exit;}

     printf("null\n");

     exit:;
     
   }
   return 0;
}

Measured memory_bytes: 580
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize p:i64)(list:[i64]));
    let even = list.into_iter().filter(|x| x % 2 == 0).count() as i64;
    let odd = n as i64 - even;
    if p == 1 && odd == 0 {
        0
    } else {
        let even_c = (0..even + 1).map(|x| combi(even, x)).sum::<i64>();
        if p == 0 {
            even_c
                * (0..odd + 1)
                    .filter(|x| x % 2 == 0)
                    .map(|x| combi(odd, x))
                    .sum::<i64>()
        } else {
            even_c
                * (0..odd + 1)
                    .filter(|x| x % 2 != 0)
                    .map(|x| combi(odd, x))
                    .sum::<i64>()
        }
    }.to_string()
}

fn combi(n: i64, r: i64) -> i64 {
    if r == 0 {
        1
    } else {
        (n - r + 1) * combi(n, r - 1) / r
    }
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "2 0\n1 3" => "2",
    test2: "1 1\n50" => "0",
    test3: "3 0\n1 1 1" => "4",
    test4: "45 1\n17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26" => "17592186044416",
}


Measured memory_bytes: 4352
// inputに入力データ全体が入る
function Main(input) {
  　input = Number(input)
    var num = 1000000007
    var P = 1;
    for(var i = 1; i <= input; i++){
      P *= Number(i)
      P %= num
    }
    console.log(P)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7628
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int X, Y;
//---------------------------------------------------------------------------------------------------
string solve() {
	rep(tsuru, 0, 101) rep(kame, 0, 101) {
		if (tsuru + kame == X && 2 * tsuru + 4 * kame == Y) {
			return "Yes";
		}
	}
	return "No";
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> X >> Y;
	cout << solve() << endl;
}







Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int ans=0, i, cnt=0;
    for(i=0;i<=2;i++){
        if(s[i]=='R') cnt++;
        else{
            ans=max(ans, cnt);
            cnt=0;
        }
    }
    ans=max(ans, cnt);
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 3600