akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MAXN 109
#define MAXW 100009
ll dp[MAXN][MAXW], peso[MAXN], valor[MAXN], n;

ll solve(int aguenta, int objeto){
    if(dp[objeto][aguenta] != -1)   return dp[objeto][aguenta];
    if (objeto == n)    return dp[objeto][aguenta] = 0;

    ll npega = solve(aguenta, objeto + 1), pega = 0;
    if (aguenta - peso[objeto] >= 0)
        pega = valor[objeto] + solve(aguenta - peso[objeto], objeto + 1);
    return dp[objeto][aguenta] = max(pega, npega);
}

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int w;
    cin >> n >> w;
    rep (i, 0, n)
        cin >> peso[i] >> valor[i];
    memset(dp, -1 , sizeof dp);
    cout << solve(w, 0) << '\n';
    return 0;
}


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

int main() {
  int n;
  
  scanf("%d", &n);

  int raw_val_candidate = n / 1.08;
  int taxed_val_cadidate = raw_val_candidate * 1.08;

  if (taxed_val_cadidate == n) {
    printf("%d\n", raw_val_candidate);
    return 0;
  }

  raw_val_candidate += 1;
  taxed_val_cadidate = raw_val_candidate * 1.08;

  if (taxed_val_cadidate == n) {
    printf("%d\n", raw_val_candidate);
    return 0;
  }

  printf(":(\n");
  return 0;
}

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

using namespace std;
typedef long long ll;

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

   double n;
   cin>>n;
   n*=2;
   n*=3.14159265359;
   cout<<n<<setprecision(6)<<fixed;
 return 0;
}


Measured memory_bytes: 3800
def main():
    n = int(input())
    h_list = list(map(int, input().split()))
    ans = 0
    cnt = 0

    for i in range(n - 1):
        if h_list[i] >= h_list[i + 1]:
            cnt += 1
        else:
            ans = max(ans, cnt)
            cnt = 0

    print(max(ans, cnt))


if __name__ == "__main__":
    main()


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

int main() {
  int n, p, y, w, g;
  string arare;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arare;
    if (arare == "P") {
      p++;
    }
    else if (arare == "Y") {
      y++;
    }
    else if (arare == "W") {
      w++;
    }
    else if (arare == "G") {
      g++;
    }
  }
  if (y != 0) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string S;
    cin >> S;
    int n = S.size();
    int ans = 0;
    REP(i, n/2){
        if(S[i] != S[n-i-1])ans += 1;
    }
    pr(ans);
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
money = 1000
stock = 0
for i in range(N-1):
    if stock == 0:
        if A[i] <= A[i+1]:
            num = money // A[i]
            money -= num * A[i]
            stock += num
    else:
        if A[i] >= A[i+1]:
            money += stock * A[i]
            stock = 0
if stock != 0:
    money += stock * A[N-1]
    stock = 0
print(money)

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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	int a,b,c;
	cin >> a >> b >> c;
	map <int,int> mp;
	mp[a]++;
	mp[b]++;
	mp[c]++;
	cout <<  (mp[5] == 2 && mp[7] == 1 ? "YES":"NO");
	return 0;
}

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

#define int long long

signed main(){

  int N, M;

  cin>>N>>M;

  if(N == 1) N = 3;
  if(M == 1) M = 3;
  
  cout<<(N-2)*(M-2)<<endl;

  return 0;
}


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

int N, W;
int v[1001];
int w[1001];
int dp[101][10001];

int dfs(int i, int j){
    int res;
    if(dp[i][j] >= 0) return res = dp[i][j];
    if(i == N) res = 0;
    else if(j < w[i]) res = dfs(i + 1, j); //ここ代入し忘れてた
    else res = max(dfs(i + 1, j), dfs(i + 1, j - w[i]) + v[i]);
    //dp[i][j] = res;
    return dp[i][j] = res;
}

int main(){
    cin >> N >> W;
    for(int i=0; i < N; i++) cin >> v[i] >> w[i];

    //dp_tableの初期化
    for(int i=0; i < 101; i++) for(int j=0; j < 10001; j++) dp[i][j] = -1;


    cout << dfs(0, W) << endl;
    return 0;
}



Measured memory_bytes: 7048
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int r = 0;
    if(a<=b){
      swap(a, b);
    }
    while(b > 0){
      r = a % b;
      a = b;
      b = r;
    }
    System.out.println(a);
  }
  private static void swap(int x, int y){
    int z;
    z = x;
    x = y;
    y = z;
  }
}


Measured memory_bytes: 26264
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

struct Combination
{
    int maxn;
    vector<ll> fmemo;
    vector<ll> imemo;
    vector<ll> ifmemo;
    
    Combination(int maxn) : maxn(maxn){
        fmemo.resize(maxn + 1);
        imemo.resize(maxn + 1);
        ifmemo.resize(maxn + 1);
        for(ll i = 1; i <= maxn; i++){
            imemo[i] = modpow(i, MOD - 2);
        }
    }

    ll fact(ll n){
        if(n == 0) return 1;
        if(fmemo[n]) return fmemo[n];
        return fmemo[n] = n * fact(n - 1) % MOD;
    }

    ll ifact(ll n){
        if(n == 0) return 1;
        if(ifmemo[n]) return ifmemo[n];
        return ifmemo[n] = imemo[n] * ifact(n - 1) % MOD;
    }

    ll com(ll n, ll k){
        if(k > n) return 0;
        if(k == n || k == 0) return 1;
        return (fact(n) * ifact(k) % MOD) * ifact(n - k) % MOD;
    }
};

int main()
{
    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    Combination com(2000003);
    ll ans = ((com.com(r2 + c2 + 2, r2 + 1) - 1) + MOD - (com.com(r1 + c2 + 1, r1) - 1) + MOD -
        (com.com(r2 + c1 + 1, c1) - 1) + (com.com(r1 + c1, r1) - 1)) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 93952
# coding: utf-8
# 38
while True: 
    n = int(input())
    S = []
    if n==0:
        break
    for i in range(n):
        S.append(int(input()))
    #print(S)
    S.sort()
    #print(S)
    S.pop(0)
    S.pop()
    #print(S)

    print(sum(S)//(n-2))
    



Measured memory_bytes: 5600
fun main(args: Array<String>) {
    val s = readLine()!!
    val p = 2019
    var pow = 1
    var div = 0
    val m = IntArray(p)
    m[0] = 1
    for (i in s.length - 1 downTo 0) {
        val d = s[i] - '0'
        div = (div + pow * d) % p
        pow = (pow * 10) % p
        m[div]++
    }
    var ans = 0
    repeat(p) {
        if (m[it] > 1) {
            ans += m[it] * (m[it] - 1) / 2
        }
    }
    println(ans)
}


Measured memory_bytes: 38736
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll N, K;
    cin >> N >> K;
    vl A(N);
    rep(i, N){
        cin >> A[i];
    }
    rep(i, N-K){
        if(A[i+K] > A[i]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}


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

C_ab = [[0 for i in range(10)] for j in range(10)]
for i in range(1,N+1):
    C_ab[int(str(i)[0])][int(str(i)[-1])] += 1

count = 0
for i in range(1,10):
    for j in range(1,10):
        count += C_ab[i][j]*C_ab[j][i]

print(count)


Measured memory_bytes: 3060
#include <iostream>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    int n;  cin >> n;
    int tmp;
    if(n%2){
	tmp = n/2+1;
    }else{
	tmp = n/2;
    }
    printf("%f\n", (double)tmp/n);
}


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

int main()
{
    int N, M;
    cin>>N>>M;
    vector<int> a(M), b(M), c(M);
    for (int i=0; i<M; i++)
    {
        cin>>a[i]>>b[i]>>c[i];
        a[i]--;
        b[i]--;
    }

    int oo = 99999999;
    vector<vector<int>> D(N, vector<int>(N, oo));
    for (int i=0; i<M; i++)
    {
        D[a[i]][b[i]] = c[i];
        D[b[i]][a[i]] = c[i];
    }
    for (int i=0; i<N; i++)
        for (int j=0; j<N; j++)
            for (int k=0; k<N; k++)
                D[j][k] = min(D[j][k], D[j][i]+D[i][k]);
    int ans = 0;
    for (int i=0; i<M; i++)
        if (D[a[i]][b[i]] != c[i])
            ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int main(){
	n=read();
	m=n/100;k=n%100;
	if(k<=m*5)puts("1");
	else puts("0");
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

# 線形探索で求める
# 1 個 1 個調べて、探したいものを探す
# 答えが出るまでWhileを回す
isnext = 0
ans = 0

while isnext == 0:
    for i in range(N):
        # 偶数判定
        if A[i] % 2 == 0:
            A[i] = A[i] / 2
        # 奇数判定
        if A[i] % 2 != 0:
            isnext = 1
            break
        # 一周したよ
        if i == N-1:
            ans = ans + 1

if ans == 0:
    print(ans)
else:
    print(ans+1)




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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


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

    rep2(i,b*10,(b+1)*10){
        if(floor(i*0.08)==a&&floor(i*0.1)==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {
  string s;
  cin >> s;
  string w = "";
  for(char c:s){
    switch(c) {
      case '0':
        w += '0';
        break;
      case '1':
        w += '1';
        break;
      default:
        if ( w.size() != 0) w.pop_back();
    }
  }
  cout << w << endl;
}

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

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


int main() {
	int n, a, cnt = 0;
	double sum = 0, m;
	double judge;
	bool result = true;
	vector<long long> ranking;
	cin >> n >> m;
	rep(i, n) {
		cin >> a;
		ranking.push_back(a);
		sum += a;
	}
	judge = sum / (4 * m);
	sort(ranking.begin(), ranking.end());
	reverse(ranking.begin(), ranking.end());
	rep(i, n) {
		if (ranking.at(i) >= judge)
			cnt++;
	}
	if (cnt >= m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
n,x=map(int,input().split())
a=abs(x)
l=[]
b=0
for i in range(1,n+1):
  l.append(i+x-1)
  if abs(x+i-1)<=a:
    a=abs(x+i-1)
    b=x+i-1
ans=0
for i in l:
  ans+=i
print(ans-b)

Measured memory_bytes: 9172
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
using namespace std;

string s;
string t;
int as[100];
int at[100];

bool h(int x){
    if(as[x]<at[x]) return true;
    else if(as[x]>at[x]) return false;
    else return h(x+1);
}

int main(){
    cin>>s;
    cin>>t;
    for(int i=0;i<s.size();i++){
        as[i]=s[i];
    }
    sort(as,as+s.size());
    for(int i=0;i<t.size();i++){
        at[i]=t[i];
    }
    sort(at,at+t.size(),greater<int>());

    if(h(0)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  string s;
  cin >> s;
  int N = s.size();
  
  string ans = "No";
  for (int i = 0; i < N - 1; i++)
  {
    if (s.substr(i, 2) == "AC")
    {
      ans = "Yes";
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    int n;
    int t_point=0, h_point=0;
    char tarou[100], hanako[100];

    scanf("%d", &n);
    for(;n>0;n--){
        scanf(" %s %s", tarou, hanako);
        if(strcmp(tarou, hanako)>0){
            t_point+=3;
        }else if(strcmp(tarou, hanako)==0){
            t_point+=1;
            h_point+=1;
        }else if(strcmp(tarou, hanako)<0){
            h_point+=3;
        }
    }
    printf("%d %d\n", t_point, h_point);

    return 0;
} 


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

int main(){
    int N;
    string str;
    set<std::string> set;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> str;
        set.insert(str);
    }
    cout << set.size() << endl;
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 1001001001001001;

int main() {
    int n; cin >> n;
    ll k; cin >> k;
    ll a[n];
    rep(i,n) {
        cin >> a[i];
    }
    ll b[n+1]; b[0] = 0;
    rep(i,n) {
        b[i+1] = (b[i]+a[i])%k;
    }
    ll c[n+1];
    ll x = k;
    while (x < 1000000) {
        x *= 2;
    }
    rep(i,n+1) {
        c[i] = (b[i]+x-i)%k;
    }
    int kk = (int)min(k, (ll)n+5);
    map<ll, ll> mp;
    ll ans = 0;
    rep(i,n+1) {
        if (i-k >= 0) {
            mp[c[i-k]]--;
        }
        ans += mp[c[i]];
        mp[c[i]]++;
        
    } 

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


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

int main() {
    long long int A , B;
    cin >> A >> B ; // 0 ≤ A,B ≤ 10^9
    if(A % 2 != B % 2) cout << "IMPOSSIBLE"<< endl;
    else cout << (A + B)/2 << endl;
	return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    int2(a, b);
    while (a) {
        a++; b++;
        vvi dp(a, vi(b, 0));
        Rep(i, a) {
            string st;
            cin >> st;
            rep(j, st.size()) {
                if (st[j] == '*') {
                    dp[i][j+1]++;
                }
            }
        }
        Rep(i, a) {
            Rep(j, b) {
                dp[i][j] += dp[i][j-1];
            }
        }
        Rep(j, b) {
            Rep(i, a) {
                dp[i][j] += dp[i-1][j];
            }
        }

        int ans = 0;
        Rep(st, a) {
            rep(sz, (a-st)) {
                int l = 1, r = 1;
                while (r < b) {
                    int tmp = 0;
                    tmp = dp[st+sz][r] - dp[st+sz][l-1] - dp[st-1][r]
                        + dp[st-1][l-1];
                    while (r < b && !tmp) {
                        ans = max(ans, ((r - l + 1) * (sz+1)));
                        r++;
                        tmp = dp[st+sz][r] - dp[st+sz][l-1]
                            - dp[st-1][r] + dp[st-1][l-1];
                    }
                    l = ++r;
                }
            }
        }

        cout << ans << endl;
        cin >> a >> b;
    }

    return 0;
}

Measured memory_bytes: 5032
import java.awt.Point;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.NavigableSet;
import java.util.Scanner;
import java.util.TreeSet;
import java.util.stream.IntStream;

public class Main{
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n) {return REPS(n).map(i->getInt());}
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}

	public static void main(String[]$){
		Point st=new Point(getInt(),getInt()),go=new Point(getInt(),getInt());
		if(st.y>go.y) {
			Point buf=go;
			go=st;
			st=buf;
		}
		Comparator<Point>c=Comparator.comparingDouble(Point::getX);
		TreeSet<Point>p=new TreeSet<>(st.x<go.x?c:c.reversed());
		for(int i=getInt();i>0;--i) {
			int x=getInt(),y=getInt();
			if(st.y<=y&&y<=go.y)
				p.add(new Point(x,y));
		}
		int v=lis(p.subSet(st,true,go,true));
		System.out.println(
				(Math.abs(st.x-go.x)+Math.abs(st.y-go.y))*100L
				+v*-20
				+(v==Math.min(go.y-st.y,Math.abs(go.x-st.x))+1?
						(v+1)
						:v)
				*5*Math.PI
				);
	}
	private static int lis(NavigableSet<Point> p){
		if(p.isEmpty())return 0;
		ArrayList<Integer>l=new ArrayList<>();
		l.add(p.pollFirst().y);
		while(!p.isEmpty()){
			int y=p.pollFirst().y;
			if(l.get(l.size()-1)<y)
				l.add(y);
			else {
				int v=Collections.binarySearch(l,y);
				if(v<0)
					l.set(~v,y);
			}
		}
		return l.size();
	}
}

Measured memory_bytes: 94316
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[200001],b[200001];
int n,s,t;
int main()
{
	scanf("%d",&n);
	for(register int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	s=b[n/2];
	t=b[n/2+1];
	for(register int i=1;i<=n;++i)
	{
		if(a[i]<=s)
		{
			printf("%d\n",t);
		}
		else
		{
			printf("%d\n",s);
		}
	}
	return 0;
}

Measured memory_bytes: 3712
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

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

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int n, h, w; cin >> n >> h >> w;
  outl((n - h + 1) * (n - w + 1));
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-4;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int a;
    ld b;
    cin >> a >> b;
    ld ans = a * b;
    cout << (ll)floor(ans + eps) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3716
use proconio::input;

fn main() {
    input! {
        n: u64,
    }
    println!(
        "{}",
        (1..=n)
            .map(|i| {
                (1..=n)
                    .take_while(|x| x * i <= n)
                    .fold(0, |sum, x| sum + x * i)
            })
            .fold(0, |sum, x| sum + x)
    )
}


Measured memory_bytes: 2128
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

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

	for(int i=0;i<S.size()-1;i++)
	{
		if(S[i]==S[i+1])
		{
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << 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 al[] = new int[26];
		for(int i=0;i<26;i++){
			al[i]=0;
		}
		while(sc.hasNext()){
			String line = sc.next();
		line=line.toLowerCase();
		char[] ar = line.toCharArray();
		for(char ch: ar){
			if(Character.isLowerCase(ch)){
				al[ch-97]++;
			}
		}
		}
		for(int i=0;i<26;i++){
			System.out.printf("%c : %d\n",i+97,al[i]);
		}
	}
}

Measured memory_bytes: 26288
#include<bits/stdc++.h>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define avg(a,b) ((a)+(b))/2
#define push push_back
#define pop pop_back
#define mp make_pair
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
//#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;
ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll mymod(ll a,ll b)
{
    return ((a%b)+b)%b;
}
bool prime[200000];
vll v;
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=200000; p++) 
    { 
        if (prime[p] == true) 
        { 
            v.push(p);
            for (int i=p*p; i<=200000; i += p) 
                prime[i] = false; 
        } 
    } 
}
ll powe[60];
void power()
{
    powe[0]=1;
    REP(i,1,15)
    {
        powe[i]=2*powe[i-1];
    }
}
ll gcdExtended(ll,ll,ll *,ll *);
ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
        ll res = (x%m + m) % m;
        return res;
} 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
} 
ll fact[100005];
void factorial()
{
    fact[0]=1;
    REP(i,1,100002)
    {
        fact[i]=mymod(i*fact[i-1], num);
    }
}
void solve(ll h1,ll m1,ll h2,ll m2)
{
    ll h=h1-h2;
    ll m=m1-m2;
    if(m<0)
    {
        m+=60;
        h--;
    }
    if(h<10)
    {
        cout<<"0"<<h<<":";
    }
    else
    {
        cout<<h<<":";
    }
    if(m<10)
    {
        cout<<"0"<<m<<"\n";
    }
    else
    {
        cout<<m<<"\n";
    }
    return;
}
ll func(ll i)
{
    ll ans=1;
    for(ll k=4;k<=i;k+=2)
    {
        ans*=3;
        ans--;
    }
    return ans;
}
ll dp[1000];
void solve()
{
    dp[0]=1;
    dp[1]=2;
    REP(i,2,1000)
    {
        dp[i]=(2*dp[i-1])%num;
        if(dp[i]<0) dp[i]+=num;
        if(!(i%2))
        {
            dp[i]=(dp[i]-func(i))%num;
            if(dp[i]<0) dp[i]+=num;
        }
    }

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,count=0;
    string s;
    cin>>n>>s;
    REP(i,0,s.size()-2)
    {
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
        {
            count++;
        }
    }
    cout<<count<<"\n";
	return 0;
}


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

struct Edge {
	int to, cap, rev, isr;
};

vector<Edge>G[309]; bool used[309]; int N, M, A[1009], B[1009];

void add_edge(int u, int v, int c) {
	G[u].push_back(Edge{ v,c,(int)G[v].size(),0 });
	G[v].push_back(Edge{ u,0,(int)G[u].size() - 1,1 });
}
int dfs(int pos, int to, int fl) {
	if (pos == to) return fl;
	used[pos] = true;
	for (int i = 0; i < G[pos].size(); i++) {
		int t = G[pos][i].to;
		if (used[t] == true || G[pos][i].cap == 0) continue;

		int V = dfs(t, to, min(fl, G[pos][i].cap)); if (V == 0) continue;

		G[pos][i].cap -= V;
		G[t][G[pos][i].rev].cap += V;
		return V;
	}
	return 0;
}
int max_flow(int u, int v) {
	int flow = 0;
	while (true) {
		for (int i = 1; i <= N; i++) used[i] = false;
		int GG = dfs(u, v, 1000000007);
		if (GG == 0) break;
		flow += GG;
	}
	return flow;
}

int main() {
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		cin >> A[i] >> B[i];
		add_edge(A[i], B[i], 1);
		add_edge(B[i], A[i], 1);
	}
	int S, T; cin >> S >> T;

	int I = max_flow(S, T); vector<int>vec;
	for (int i = 1; i <= M; i++) {
		int T1 = 0, T2 = 0;
		for (int j = 0; j < G[A[i]].size(); j++) {
			if (G[A[i]][j].to == B[i] && G[A[i]][j].isr == 0) { T1 = G[A[i]][j].cap; }
		}
		for (int j = 0; j < G[B[i]].size(); j++) {
			if (G[B[i]][j].to == A[i] && G[B[i]][j].isr == 0) { T2 = G[B[i]][j].cap; }
		}
		if (T1 > T2) vec.push_back(i);
	}
	cout << I << endl;
	cout << vec.size() << endl;
	for (int i = 0; i < vec.size(); i++) cout << vec[i] << endl;
	return 0;
}


Measured memory_bytes: 3304
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
	//Implement solution here.
		int n = ni();
		int[] ary = na(n);
		int result = ary[0];
		
		for(int i = 1; i <= n - 1; i++){
			result = euclidDiv(result, ary[i]);
		}
		System.out.println(result);
	}
	
	static int euclidDiv(int a,int b){
        if(b == 0) return a;
        int mod = a%b;
        return euclidDiv(b,mod);
    }

    //Switch input source (stdin/file)
	private static Scanner scanner = new Scanner(System.in);
	public static void main(String[] args){
        String debugDataPath = System.getenv("DD_PATH");        
        if(debugDataPath != null){
            try{
                scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        }
        solve();
	}

    //Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
    //Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
    //Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
    //Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
    //Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
    //Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 46256
// Problem : A - Air Conditioner
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/**
 * @author dwij
 */

#include <bits/stdc++.h>

#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>

using namespace std;

//******* Debugging Class Template *******/
#define sim template <class c
#define ris return *this
#define dor > deb& operator<<
#define eni(x) \
    sim > typename enable_if<sizeof dud<c>(0) x 1, deb&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct deb {
#ifdef LOCAL
    ~deb() { cerr << endl; }
    eni(!=) cerr << boolalpha << i;
    ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c&) { ris; }
#endif
}
;
#define log(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// End of weird debugging stuff.

typedef long long ll;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pll pair<ll, ll>

#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(), c.end()
#define mem(a, val) memset(a, val, sizeof(a))
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define endl "\n"

void solution() {
    // deb() << log();
    int n;
    cin >> n;
    if (n >= 30)
        cout << "Yes";
    else
        cout << "No";
}

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

    int T = 1;
    // cin >> T;
    // cin.ignore(); //must be there when using getline(cin, s)
    for (int tt = 1; tt <= T; tt++) {
        // cout << "Case #" << tt << ": ";
        solution();
    }

    return 0;
}


Measured memory_bytes: 3652
<?php
	$n = trim(fgets(STDIN));
	$flag = false;
	for($i = 0; $i < 100; $i++){
		for($j = 0; $j < 100; $j++){
          if($n - $i * 4 - $j * 7 == 0)$flag = true;
    	}
    }
	echo $flag ? "Yes\n" : "No\n";

Measured memory_bytes: 4856
import java.util.*;

public class Main {
	//Implementation #1
	public static int compute_maxprofit(int n, int[] R) {
		int max = R[1] - R[0];
		for(int i = 0; i < n - 1; i++) {
			for(int j = i + 1; j < n; j++) {
				if(R[j] - R[i] > max)
					max = R[j] - R[i];
			}
		}
		return max;
	}
	
	//Implementation #2
	public static int compute_maxprofit2(int n, int[] R) {
		int max = Integer.MIN_VALUE;
		int min = Integer.MAX_VALUE;
		for(int i = 0; i < n; i++) {
			max = Math.max(max, R[i]- min);
			
			min = Math.min(R[i], min);
		}
		return max;
	}
	
	
	public static void main(String args[]) {
		Scanner k = new Scanner(System.in);
		int n = k.nextInt();
		int[] array = new int[n];
		for(int x = 0; x < n; x++) {
			array[x] = k.nextInt();
		}
		//System.out.println(compute_maxprofit(n, array));
		System.out.println(compute_maxprofit2(n, array));
	}

}



Measured memory_bytes: 70340
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <utility>
#include <algorithm>
#include <ctime>
using namespace std;

int const MAX_N = 256 * 1024;

int s[MAX_N];
multiset<int> ms;
multiset<int> ::iterator iter;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &s[i]);
	sort(s, s + n);
	for (int i = 0; i < n; i++) ms.insert(s[i]);
	int cnt = 0;
	while (!ms.empty()) {
		iter = ms.end();
		--iter;
		long long val = *iter;
		ms.erase(iter);
		int fnd = 0;
		for (int dg2 = 30; dg2 >= 1; dg2--) {
			long long rem = (1LL << (long long)dg2) - val;
			if (rem > 0) {
				iter = ms.find(rem);
				if (iter != ms.end()) {
					cnt++;
					ms.erase(iter);
					fnd = 1;
					break;
				}
			}
		}
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1234567890
#define pii pair<int,int>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x;
    cin >> x;
    if (x >= 30) cout << "Yes"; else cout << "No";
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 3648
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	var A, B, C int
	fmt.Sscanf(scanner.Text(), "%d %d %d", &A, &B, &C)

	m := max(A, B, C)
	ans := -1
	switch m {
	case A:
		ans = 10*A + B + C
	case B:
		ans = A + 10*B + C
	case C:
		ans = A + B + 10*C
	}
	fmt.Println(ans)
}

func max(ns ...int) int {
	ret := math.MinInt64
	for _, n := range ns {
		if n > ret {
			ret = n
		}
	}
	return ret
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
ll dp[110][10][2];
int main(){
  string n;
  cin >> n;
  int k;
  cin >> k;
  dp[0][0][0] = 1;
  rep(i,(int)n.size())rep(j,4)rep(K,2){
    int nx = n[i] - '0';
    rep(d,10){
      int ni = i + 1,nj = j,nk = K;
      if(d != 0)nj++;
      if(nj > k)continue;
      if(K == 0){
        if(d > nx)continue;
        if(d < nx)nk = 1;
      }
      dp[ni][nj][nk] += dp[i][j][K];
    }
  }
  ll ans = dp[n.size()][k][0] + dp[n.size()][k][1];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int cost = 700;
    
  for (int i = 0; i < 3; i++) {
    if (S.at(i) == 'o'){
      cost+=100;
    }
  }
  cout << cost << endl;
}



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

int main() {
   int N;
  cin >>N;
  int D;
  D=N;
  int s=1;
  while (N>9){
    N/=10;
    s+=1;
  }
  
  if (s==1){
    cout << D <<endl;
  }
  else { 
    int u;
    for (int w=0; 2*w+1<s; w+=1){
        u+=9*pow(10,2*w);
   }
    if (s%2==0){
      cout <<u<<endl;
    }
    else{
      cout <<u+D+1-pow(10,s-1)<<endl;
    }
  }
}
     
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }



int N;
string S;
bool checkB(int b) {
    if (b >= 0 && b < N && S[b] == 'B') return true;
    else return false;
}
int main() {
    cin >> N >> S;
    vector<int> R, G;
    for (int i = 0; i < N; ++i) {
        if (S[i] == 'R') R.push_back(i);
        else if (S[i] == 'G') G.push_back(i);
    }
    long long all = (long long)R.size() * (long long)G.size() 
        * (N - R.size() - G.size());
    long long sub = 0;
    for (auto r : R) {
        for (auto g : G) {
            if (checkB(r*2-g)) ++sub;
            if (checkB(g*2-r)) ++sub;
            if ((r+g)%2 == 0 && checkB((r+g)/2)) ++sub;
        }
    }
    cout << all - sub << endl;
}

















Measured memory_bytes: 3660
inf = float('inf')

N, T = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]

AB = sorted(AB, key=lambda x:x[0])
A = [a for a, b in AB]
B = [b for a, b in AB]

M = T + max(A)
dp = [[-inf] * (M) for _ in range(N+1)]
dp[0][0] = 0

for i in range(N):
    for t in range(M):
        if t < T:
            dp[i+1][t+A[i]] = max(dp[i+1][t+A[i]], dp[i][t] + B[i])
        dp[i+1][t] = max(dp[i+1][t], dp[i][t])

ans = max(dp[N])
print(ans)

Measured memory_bytes: 489860
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <bits/stdc++.h>

using namespace std;

class CCountOrder {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        int n;
        cin >> n;
        vector<int> p_vec(n);
        vector<int> q_vec(n);
        vector<int> base_vec(n);
        for (int i = 0; i < n; ++i) {
            cin >> p_vec[i];
            base_vec[i] = p_vec[i];
        }
        for (int i = 0; i < n; ++i) {
            cin >> q_vec[i];
        }
        int p = 0;
        sort(base_vec.begin(), base_vec.end());
        while (base_vec != p_vec) {
            next_permutation(base_vec.begin(), base_vec.end());
            p++;
        }
        int q = 0;
        sort(base_vec.begin(), base_vec.end());
        while (base_vec != q_vec) {
            next_permutation(base_vec.begin(), base_vec.end());
            q++;
        }
        cout << abs(p - q) << endl;
    }
};


int main() {
    CCountOrder solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
# from sys import stdin
# input = stdin.readline
from collections import Counter

def solve():
    x,n = map(int,input().split())
    if n != 0:
        p = set(map(int,input().split()))
    if n == 0 or x not in p:
        print(x)
        return
    else:
        for i in range(100):
            if x - i not in p:
                print(x - i)
                return
            if x + i not in p:
                print(x + i)
                return


if __name__ == '__main__':
    solve()


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

int main(){
    int n;
    cin >> n;
    vector<pair<int, int>> r(n), b(n);

    rep(i, n){
        int x, y;
        cin >> x >> y;
        r[i] = make_pair(y, x);
    }
    rep(i, n){
        int x, y;
        cin >> x >> y;
        b[i] = make_pair(x, y);
    }

    sort(r.begin(), r.end());
    sort(b.begin(), b.end());

    int cnt = 0;
    bool used[n];
    rep(i, n) used[i] = false;

    rep(i, n){
        rrep(j, n){
            if(!used[j] && b[i].first > r[j].second && b[i].second > r[j].first){
                used[j] = true;
                cnt ++;
                break;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1.0);

const int N = 3e3 + 5;;

ll n;
double p[N], dp[N][2 * N];

double solve(ll i, ll diff) {
    if (i == n) return (diff > 0);
    double& ret = dp[i][diff];
    if (ret == ret) return ret;
    ret = solve(i + 1, diff + 1) * p[i] + solve(i + 1, diff - 1) * (1 - p[i]);
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin >> n;

    for (int i = 0; i < n; ++i) 
        cin >> p[i];

    memset(dp, -1, sizeof(dp));

    cout << fixed << setprecision(10) << solve(0, 0) << endl;
}


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

int N;

int main() {
  long long d;
  scanf("%d %lld", &N, &d);
  d = d*d;
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    long long x, y;
    scanf("%lld %lld", &x, &y);
    x = x*x;
    y = y*y;
    if (x + y <= d)
      ans++;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 3840
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n = inl();
        vd p(n);
        rep(i, n) cin >> p[i];
        double dp[n + 1][n + 1]; // dp[i][j]: i枚目までで表がj枚出る確率
        rep(i, n + 1) rep(j, n + 1) dp[i][j] = 0;
        dp[0][0] = 1;
        rep(i, n) {
            rep(j, n) {
                dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
                dp[i + 1][j + 1] += dp[i][j] * p[i];
            }
        }
        double ans = 0.0;
        for (int i = n / 2 + 1; i <= n; ++i) {
            ans += dp[n][i];
        }
        cout << fixed << setprecision(10) << ans << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll h,w; cin>>h>>w;
  if(h==1 || w==1){
    cout<<1<<endl;
    return 0;
  }
  cout<<(h*w+1)/2<<endl;
}

Measured memory_bytes: 384