akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

long double a;
long double b;
void input(){
    fast_io();
    cin >> a >> b;
}

int solve(){
    int B = b*100;
    long double ans = a*b;
    // DBG(ans)
    // DBG(a)
    // DBG(b)
    // DBG(B)
    // DBG(ans)
    // string t = to_string(ans);
    // if(!t.empty()) t.pop_back();
    // if(!t.empty()) t.pop_back();
    // if(t.empty()) cout << 0 << endl;
    // else cout << t << endl;
    cout << (ll)ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
   int n;string s;cin>>n>>s;
   for(int i=0;i<s.size();i++){
    int t=s[i]-'A';
    t=(t+n)%26;
    s[i]='A'+t;
    
    }
   cout<<s<<endl;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
Y //= 1000

for m in range(Y // 10, -1, -1):
	for g in range((Y - m * 10) // 5, -1, -1):
		if 10 * m + 5 * g + (N - m - g) == Y:
			print(m, g, N - m - g)
			exit()
print(-1, -1, -1)

Measured memory_bytes: 64624
N, S = map(int, input().split())
MOD = 998244353
A = list(map(int, input().split()))
dp = [0]*(S+1)
dp[0] = 1
for a in A:
    for s in reversed(range(S+1)):
        if s+a<=S: dp[s+a] += dp[s]
        dp[s] *= 2
        dp[s] %= MOD
print(dp[S]%MOD)

Measured memory_bytes: 73596
void main()
{
    long n = rdElem;

    if (n == 1)
    {
        0.writeln;
        return;
    }

    long[long] cnt;
    for (long i = 2; i * i <= n; ++i)
    {
        while (!(n % i))
        {
            ++cnt[i];
            n /= i;
        }
    }
    if (n > 1) ++cnt[n];

    long m = cnt.byValue.reduce!max;

    long[] list;
    list ~= 1;
    foreach (i; 2 .. m+1)
    {
        list ~= list[$-1] + i;
        if (list[$-1] > m) break;
    }

    long result;
    foreach (x; cnt.byValue)
    {
        long num;
        foreach (y; list)
        {
            if (x >= y) ++num;
        }
        result += num;
    }

    result.writeln;
}

enum long mod = 10L^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 2720
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll A,B,C,D,E,F,K,G,H,L,M,N,P,Q,R,W,X,Y,Z;
string S,T;
vector<ll> V;

ll cme;

ll modpow(ll b, ll e, ll m){  // bのe乗のmod m を返す
  if (e == 0) return 1;
  cme = modpow(b, e / 2, m);
  cme = (cme * cme) % m;
  if (e % 2 == 1) cme = (cme * b) % m;
  return cme;
}

int main(){
  cin >> N ;
  while(N>0){
    N/=2;
    K++;
  }
  G=1;
  rep(i,K){
    G*=2;
  }
  cout << G-1 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt(); //n曲
		String[] s = new String[n]; //曲名
		int[] t = new int[n]; //曲の長さ
		
		for(int i = 0; i < n; i++) {
			s[i] = stdIn.next();
			t[i] = stdIn.nextInt();
		}
		String x = stdIn.next(); //寝てしまった曲の名前
		int cnt = 0;
		for(int i = 0; i < n; i++) {
			if(s[i].equals(x)) {
				for(int j = i+1; j < n; j++) {
					cnt+= t[j];
				}
				break;
			}
		}
		
		System.out.println(cnt);
		
		
	}

}


Measured memory_bytes: 24148
#include <iostream>
#include <queue>
#include <cstring>

using namespace std;

const int dx[] = {0, 1, 0, -1};
const int dy[] = {-1, 0, 1, 0};

class state {
public:
    int tx, ty;
    int kx, ky;
    int time;
    state(int a, int b, int c, int d, int e) {
        tx = a;
        ty = b;
        kx = c;
        ky = d;
        time = e;
    }
};

int h, w;
int grid[52][52];
bool memo[52][52][52][52];
int tx, ty, kx, ky;

void solve()
{
    int ans = -1;
    state s(tx, ty, kx, ky, 0);
    queue<state> q;
    
    memset(memo, 0, sizeof(memo));

    q.push(s);
    memo[ty][tx][ky][kx] = true;

    while (!q.empty()) {
        state now = q.front();
        q.pop();

        if (now.time >= 100)
            break;
        if (now.tx == now.kx && now.ty == now.ky) {
            ans = now.time;
            break;
        }

        for (int i = 0; i < 4; i++) {
            int ntx = now.tx + dx[i];
            int nty = now.ty + dy[i];
            int nkx = now.kx + dx[(i + 2) % 4];
            int nky = now.ky + dy[(i + 2) % 4];

            if (ntx < 1 || ntx > w)
                ntx = now.tx;
            if (nty < 1 || nty > h)
                nty = now.ty;
            if (nkx < 1 || nkx > w)
                nkx = now.kx;
            if (nky < 1 || nky > h)
                nky = now.ky;
            if (grid[nty][ntx] != 0) {
                ntx = now.tx;
                nty = now.ty;
            }
            if (grid[nky][nkx] != 0) {
                nkx = now.kx;
                nky = now.ky;
            }
                
            if (memo[nty][ntx][nky][nkx] == true)
                continue;
            state next(ntx, nty, nkx, nky, now.time + 1);
            q.push(next);
            memo[nty][ntx][nky][nkx] = true;
        }
    }
    if (ans == -1 || ans >= 100)
        cout << "NA" << endl;
    else
        cout << ans << endl;
}

int main()
{
    while (cin >> w >> h, w || h) {
        cin >> tx >> ty >> kx >> ky;
        for (int y = 1; y <= h; y++)
            for (int x = 1; x <= w; x++) 
                cin >> grid[y][x];
        solve();
    }

    return 0;
}

Measured memory_bytes: 8676
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
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; }

int main(){
  int n; cin >> n;
  int cnt = 0;
  while(cnt < n) cnt += 1000;
  cout << cnt - n;
  return 0;
}


Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

def main():
    N, M = mi()
    l = dp2(0, 3, M)
    for i in range(M):
        p, x = mi()
        l[i][0], l[i][1], l[i][2] = p, x, i 
    l.sort(key=lambda x :(x[0], x[1]))

    ans = ['' for _ in range(M)]
    cnt = 0
    bf = 1
    for i in range(M):
        a = l[i][0]
        if a > bf:
            cnt = i
        b, c = str(i+1-cnt), l[i][2]
        ans[c] = str(a).zfill(6) + b.zfill(6)
        bf = a

    
    for a in ans:
        print(a)

if __name__ == "__main__":
    main()

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

int main(){
  int n, z, w;
  cin >> n >> z >> w;
  int a[n];
  rep(i, n) cin >> a[i];
  int ans;
  if(n == 1) ans = abs(a[0] - w);
  else{
    ans = max(abs(a[n-1]-w), abs(a[n-1] - a[n-2]));
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

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

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int main(){
    ll a, b, c, x, y; cin>>a>>b>>c>>x>>y;
    if(a+b<=2*c){
        cout << a*x + b*y << endl;
    }
    else{
        ll MIN=min(x, y);
        ll ans=MIN*c*2LL;
        x-=MIN, y-=MIN;
        ll sum=0;
        if(x>0){
            sum=min(x*a, x*2*c);
        }
        else{
            sum=min(y*b, y*2*c);
            //cout << sum << endl;
        }
        cout << ans + sum << endl;
    }
}

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

int main()
{
    int r, c;
    cin >> r >> c;
    vector<vector<int>> sheet(r+1, vector<int>(c+1));
    
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            cin >> sheet[i][j];
        }
    }
    
    for (int i = 0; i < r; i++) {
        sheet[i][c] = accumulate(sheet[i].begin(), sheet[i].end()-1, 0);
    }
    
    for (int i = 0; i <= c; i++) {
        int sum = 0;
        for (int j = 0; j < r; j++) {
            sum += sheet[j][i];
        }
        sheet[r][i] = sum;
    }
    
    for (int i = 0; i <= r; i++) {
        for (int j = 0; j <= c; j++) {
            printf("%d", sheet[i][j]);
            if (j != c) putchar(' ');
        }
        putchar('\n');
    }
}



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

using namespace std;


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 2e6 + 1, MOD = 1e9 + 7, mod = 998244353, INF = 3e17;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;


signed main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);
   string s;
   cin >> s;
   int b = 0, ans = 0, i = 0;
   while (i < s.size()) {
      while (s[i] == 'W' && i < s.size()) i++, ans+= b;
      while (i < s.size() && s[i] == 'B') i++, b++;
   }
   cout << ans;
}


Measured memory_bytes: 720
def main():
    def calc(v, w, i, j, ans):
        if v > 0:
            i[0] += 1
        elif v < 0:
            j[0] += 1
        else:
            if w > 0:
                ans[0] = min(ans[0], w)
                i[0] += 1
            else:
                j[0] += 1

    n = int(input())
    inf = 10**10
    ans = [inf]
    u_list, d_list, l_list, r_list = [], [], [], []
    for _ in range(n):
        x, y, d = input().split()
        x, y = int(x), int(y)
        if d == "D":
            d_list.append((x, y))
        elif d == "R":
            r_list.append((x, y))
        elif d == "L":
            l_list.append((x, y))
        else:
            u_list.append((x, y))
    ld, lr, ll, lu = len(d_list), len(r_list), len(l_list), len(u_list)
    # 1→u,d
    u_list.sort(key=lambda x: (x[0], x[1]))
    d_list.sort(key=lambda x: (x[0], x[1]))
    i, j = [0], [0]
    while(i[0] < lu and j[0] < ld):
        x, y = u_list[i[0]]
        p, q = d_list[j[0]]
        v = p-x
        w = (q-y)*5
        calc(v, w, i, j, ans)
    # 2→r,l
    r_list.sort(key=lambda x: (x[1], x[0]))
    l_list.sort(key=lambda x: (x[1], x[0]))
    i, j = [0], [0]
    while(i[0] < lr and j[0] < ll):
        x, y = r_list[i[0]]
        p, q = l_list[j[0]]
        v = q-y
        w = (p-x)*5
        calc(v, w, i, j, ans)
    # 3→u,l
    u_list.sort(key=lambda x: (x[0]-x[1], x[0]))
    l_list.sort(key=lambda x: (x[0]-x[1], x[0]))
    i, j = [0], [0]
    while(i[0] < lu and j[0] < ll):
        x, y = u_list[i[0]]
        p, q = l_list[j[0]]
        v = (p-q)-(x-y)
        w = (p-x)*10
        calc(v, w, i, j, ans)
    # 4→d,l
    d_list.sort(key=lambda x: (x[0]+x[1], x[0]))
    l_list.sort(key=lambda x: (x[0]+x[1], x[0]))
    i, j = [0], [0]
    while(i[0] < ld and j[0] < ll):
        x, y = d_list[i[0]]
        p, q = l_list[j[0]]
        v = (p+q)-(x+y)
        w = (p-x)*10
        calc(v, w, i, j, ans)
    # 5→u,r
    u_list.sort(key=lambda x: (x[0]+x[1], -x[0]))
    r_list.sort(key=lambda x: (x[0]+x[1], -x[0]))
    i, j = [0], [0]
    while(i[0] < lu and j[0] < lr):
        x, y = u_list[i[0]]
        p, q = r_list[j[0]]
        v = (p+q)-(x+y)
        w = (x-p)*10
        calc(v, w, i, j, ans)
    # 6→d,r
    d_list.sort(key=lambda x: (x[0]-x[1], -x[0]))
    r_list.sort(key=lambda x: (x[0]-x[1], -x[0]))
    i, j = [0], [0]
    while(i[0] < ld and j[0] < lr):
        x, y = d_list[i[0]]
        p, q = r_list[j[0]]
        v = (p-q)-(x-y)
        w = (x-p)*10
        calc(v, w, i, j, ans)
    if ans == [inf]:
        print("SAFE")
    else:
        print(ans[0])


main()

Measured memory_bytes: 120176
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    cout << n - m + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void d_m_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

char grid[1002][1002];

int power(int n, int x)
{
	if (x == 0)
		return 1;

	int small = power(n, x / 2) % mod;
	small = (small * small) % mod;

	if (1 & x)
		small = (n * small) % mod;

	return small;
}

bool isPowerOfTwo(int n)
{
	return n && (!(n & (n - 1)));
}

int numberOfPaths(int h, int w)
{
	int dp[h + 1][w + 1];
	memset(dp, 0, sizeof dp);

	dp[h][w] = 1;

	for (int i = h; i >= 1; i--)
	{
		for (int j = w; j >= 1; j--)
		{
			if (i == h && j == w)
				continue;
			if (grid[i][j] == '#')
				dp[i][j] = 0;
			else {
				if (i != h)
					dp[i][j] = (dp[i + 1][j] + dp[i][j]) % mod;
				if (j != w)
					dp[i][j] = (dp[i][j] + dp[i][j + 1]) % mod;
			}
		}
	}

	return dp[1][1];
}

double dp[3005][3005];

double solve(double *arr, int i, int x)
{
	if (x == 0)
		return 1;
	if (i == 0)
		return 0;
	if (dp[i][x] >= -0.9)
		return dp[i][x];

	return dp[i][x] = arr[i] * solve(arr, i - 1, x - 1) + (1 - arr[i]) * solve(arr, i - 1, x);
}

int32_t main()
{
	//d_m_c();

	int n;
	cin >> n;

	double arr[n + 1];
	memset(dp, -1, sizeof dp);

	for (int i = 1; i <= n; i++)
		cin >> arr[i];

	cout << fixed << setprecision(10) << solve(arr, n, (n + 1) / 2);

	return 0;
}

Measured memory_bytes: 71040
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define mk make_pair
int main()
{
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll x=0,count=0;
  while(x==0)
  {
    if(b>=c&&count%2==0)
    {
      cout<<"Yes"<<endl;
      x=1;
    }
    else if(b<c&&count%2==0)
    {
      c-=b;
      count++;
    }
    else if(count%2!=0&&d>=a)
    {
      cout<<"No"<<endl;
      x=1;
    }
    else if(count%2!=0&&d<a)
    {
      a-=d;
      count++;
    }
  }

}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N,X;
    cin>>N>>X;
    vector<int> d(N);
    int tmp;
    rep(i,N){
        cin>>tmp;
        d.at(i)=X-tmp;
    }
    int ans =d[0];
    rep(i,N){
        ans=__gcd(ans,d[i]);
    }
    ans=max(ans ,-ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())

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

    set<int> list;
    for(int i=-1; i<=101; i++) list.insert(i);

    rep(i,n){
      int p;
      cin >> p;
      list.erase(p);
    }

    int mi = 999;
    int ans = 0;
    for(int i: list){
      if(mi > abs(x-i)){
        mi = abs(x-i);
        ans = i;
      }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(){
  multimap<string, int> M;
  int q;
  cin >> q;
  for (int i = 0; i < q; i++){
    int t;
    cin >> t;
    if (t == 0){
      string key;
      cin >> key;
      int x;
      cin >> x;
      M.insert(make_pair(key, x));
    }
    if (t == 1){
      string key;
      cin >> key;
      for (auto itr = M.lower_bound(key); itr != M.upper_bound(key); itr++){
        cout << (*itr).second << endl;
      }
    }
    if (t == 2){
      string key;
      cin >> key;
      M.erase(key);
    }
    if (t == 3){
      string L, R;
      cin >> L >> R;
      auto itr = M.lower_bound(L);
      while (1){
        if (itr == M.end()){
          break;
        }
        if (R < (*itr).first){
          break;
        }
        cout << (*itr).first << ' ' << (*itr).second << endl;
        itr++;
      }
    }
  }
}


Measured memory_bytes: 24760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

    int ans = 0;
    for(ll i=1; i*i<=n; i++)
    {
        if((n-1)%i==0)
        {
            // cout << i << ' ' << (n-1)/i << endl;
            if(i*i != n-1) ans+=2;
            else ans++;
        }
        else if(n%i==0)
        {
            ll m = n;
            while(m%i==0 && m >= i) m/=i;
            if(m%i==1)
            {
                // cout << i << endl;
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3656
package main

import "fmt"

func main()  {
	var s string
	fmt.Scan(&s)

	m := make(map[uint8]int)
	for j:=0;j<4;j++ {
		if _, ok := m[s[j]]; ok {
			m[s[j]]++
		} else {
			m[s[j]] = 1
		}
	}
	for _, v := range m {
		if v != 2 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void){

int H,W,i,j,k;

while(1){
	scanf("%d %d",&H,&W);
	if(H == 0 && W == 0)break;
	
	for(i=1;i<=H;i++){
		
		if(i%2 == 1){
			for(j=1;j<=W;j++){
				if(j%2 == 1){
					printf("%c",'#');
				}
				else{
					printf("%c",'.');
				}
			}
			printf("\n");
		}
		else{
			for(k=1;k<=W;k++){
				if(k%2 == 1){
					printf("%c",'.');
				}
				else{
					printf("%c",'#');
				}
			}
			printf("\n");
		}
		
	}
	printf("\n");
}

return 0;
}


Measured memory_bytes: 2104
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]

manzoku = 0
log = [-1] * 26
for i in range(d):
    max = 0
    maxi = 0
    for j in range(26):
        karilog = log
        kari = s[i][j]
        karilog[j] = i
        for k in range(26):
            kari -= c[k] * (i-karilog[k])
        if max < kari:
            max = kari
            maxj = j
    print(maxj+1)
    manzoku += max
    log[maxj] = i


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

int main() {
    string s;
    while(1){
        getline(cin, s);
        if(s == ".") break;
        stack<char> st;
        bool f = true;
        rep(i, 0, s.size()){
            if(s[i] == '(' || s[i] == '['){
                st.push(s[i]);
            }else if(s[i] == ')'){
                if(st.empty()){
                    f = false;
                    continue;
                }
                if(st.top() != '(') f = false;
                st.pop();
            }else if(s[i] == ']'){
                if(st.empty()){
                    f = false;
                    continue;
                }
                if(st.top() != '[') f = false;
                st.pop();
            }
        }
        if(!st.empty()) f = false;
        if(f) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}


Measured memory_bytes: 3152
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;


void main() {
    enum N = 100_000;
    auto primeList = new bool[N+1];
    auto list = iota(2, N+1).array;
    while (list.front * list.front <= N) {
        primeList[list.front] = true;
        list = list[1..$].filter!(x => x % list.front).array;
    }
    foreach (x; list) {
        primeList[x] = true;
    }
    auto Q = readln.chomp.to!int;
    int[][] ranges;
    foreach (i; 0..Q) {
        auto range = readln.split.to!(int[]);
        ranges ~= range;
    }
    auto list2 = primeList.enumerate.map!(a => a.value && primeList[(a.index+1)/2] ? 1 : 0).array;
    foreach (i; 0..list2.length-1) {
        list2[i+1] += list2[i];
    }
    foreach (range; ranges) {
        if (range[0] == 0) {
            writeln(list2[range[1]]);
        } else {
            writeln(list2[range[1]] - list2[range[0]-1]);
        }
    }
}


Measured memory_bytes: 16892
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int a=0,b=0;
for(int i=0;i<m;i++)
  	a=a*10+n;
 for(int i=0;i<n;i++)
  	b=b*10+m;
  if(b>a)
    cout<<b;
  else
    cout<<a;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
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)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

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

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    int n; cin >> n;
    string s, t; cin >> s >> t;
    string ans = "";
    rep(i, n) {
        ans += s[i];
        ans += t[i];
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		 
		int N = scan.nextInt();
		String A = scan.next();
		String B = scan.next();
 
		char[] ac = A.toCharArray();
		char[] bc = B.toCharArray();
 
		//ArrayList<String> list = new ArrayList<String>();
		StringBuilder sb = new StringBuilder();
		
 
		for(int i = 0; i< N; i++) {
			sb.append(ac[i]);
			sb.append(bc[i]);
		}
		
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 21844
a, b, c = sorted([int(i) for i in input().split()])
if ((c - a) % 2 == 0) & ((c - b) % 2 == 0):
    ans = (2*c - a - b) // 2
elif ((c - a) % 2 == 1) & ((c - b) % 2 == 1):
    ans = (2*c - a - b - 1) // 2 + 1
else:
    ans = (2*c - a - b + 1) // 2 + 1
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define N 23
#define inf (ll)1e9+1
#define warmup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int mod=1e9+7; 
int dist[N][N],h,w;
char a[N][N];

bool good(int x, int y)
{
    return (x>=1 and y>=1 and x<=h and y<=w and a[x][y]=='.');
}   

void dfs(int x,int y,int d)
{
    if(dist[x][y]>d)
    {
        dist[x][y]=d;
        
        if(good(x-1,y))
            dfs(x-1,y,d+1);
        if(good(x,y-1))
            dfs(x,y-1,d+1);
        if(good(x+1,y))
            dfs(x+1,y,d+1);
        if(good(x,y+1))
            dfs(x,y+1,d+1);
    }
}   

signed main()
{
    warmup
    
    cin>>h>>w;
    int i,j,x,y,ma=0;
    for(i=1;i<=h;++i)
        for(j=1;j<=w;++j)
            cin>>a[i][j];
    
    for(i=1;i<=h;++i)
    {
        for(j=1;j<=w;++j)
        {
            if(a[i][j]=='.')
            {
                for(x=1;x<=h;++x)
                    for(y=1;y<=w;++y)
                        dist[x][y]=inf;
                dfs(i,j,0);
                for(x=1;x<=h;++x)
                    for(y=1;y<=w;++y)
                        if(dist[x][y]<inf)
                            ma=max(ma,dist[x][y]);
            }   
        }   
    }   
    cout<<ma;
    
    
    return 0;
}


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

int main() {
  int n, m;
  std::cin >> n >> m;
  int l[m], r[m], range[2] = {0, n};
  for (int i = 0; i < m; i++) {
    std::cin >> l[i] >> r[i];
  }
  for (int i = 0; i < m; i++) {
    range[0] = std::max(range[0], l[i]);
    range[1] = std::min(range[1], r[i]);
  }
  std::cout << std::max(range[1] - range[0] + 1, 0) << "\n";
  return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
  
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int D = sc.nextInt();
    int N = sc.nextInt();
    int d = (int)Math.pow(100,D);
    
    if(D == 0 && N != 100){
      System.out.println(1*N);  
    }else if(D == 0 && N == 100){
      System.out.println(1*N + 1);  
    }else if(D >= 1 && N != 100){
      System.out.println(d*N); 
    }else if(D == 1 && N == 100){
      System.out.println(d*N + 100); 
    }else if(D == 2 && N == 100){
      System.out.println(d*N + 10000);  
    }    
  }  
}

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

int main(){
    string alfa[] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
    string c;
    cin >> c;
    int i = 0;
    while( i < 25 ){
        if( alfa[i] == c ){
            break;
        }
        i++;
    }
    cout << alfa[i + 1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
ifstream fin("date.in");
using ll = long long;
ll n, maxx, total, h;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> h;
		maxx = max(maxx, h);
		total += max((ll)0, maxx - h);
	}
	cout << total;
    return 0;
}


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

int main(){
    
    long long N;
    cin >> N;
    long long sum = 0;
    int index;
    int i = 1;
    while(true){
        sum += i;
        if(sum>N){
            index = i;
            break;
        }
        i++;
    }
    for(int i = 1; i <= index;i++){
        
        if(i == sum - N)continue;
        cout << i << endl;
    }
    
    
    
    
}

Measured memory_bytes: 256
//y09-6 ビンゴ(2回目)
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)

int main(){
    ROOP(){
        int N,M,S;
        cin >> N >> M >> S;
        if(N==0) return 0;

        int dp[50][3001];
        for(int i=0; i<50; i++){
            for(int j=0; j<3001; j++){
                dp[i][j] = 0;
            }
        }
        dp[0][0] = 1;

        for(int i=1; i<=M; i++){
            for(int j=N*N; j>=1; j--){
                for(int k=i; k<=S; k++){
                    dp[j][k] += dp[j-1][k-i];
                    dp[j][k] %= 100000;
                }
            }
        }
        cout << dp[N*N][S] << endl;

    }
    return 0;
}




Measured memory_bytes: 3684
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[] seq = new int[n];
      for(int i=0; i!=n; i++)
        seq[i] = Integer.parseInt(br.readLine());

      int cnt = shellSort(seq, n);
      System.out.println(cnt);
      StringBuilder str = new StringBuilder(n*2);
      for (int i : seq)
        str.append(i).append("\n");
      str.setLength(str.length()-1);
      System.out.println(str);
    }
  }

  public static int shellSort(int a[], int n) {
    int cnt=0;
    int m = 0;
    int k = Double.valueOf( Math.sqrt(n) ).intValue();
    int[] aG = new int[k];
    for (int i=0,d=1; d <= n; i++,d=(d*3+1)) {
      aG[i] = d; m++;
    }
    System.out.println(m);
    StringBuilder str = new StringBuilder(m*2);

    for(int i=(m-1); i!=-1; i--){
      cnt += insertionSort(a, n,aG[i]);
      str.append(aG[i]).append(" ");
    }

    str.setLength(str.length()-1);
    System.out.println(str);

    return cnt;
  }
  
  public static int insertionSort(int a[], int max, int g) {
    int cnt=0;

    for (int i=g,j=0,v=0; i < max; i++) {
      for( j=(i-g), v=a[i]; j>=0 && a[j]>v; j=j-g ) {
        a[j+g] = a[j];
        cnt++;
      }
      a[j+g] = v;
    }

    return cnt;
  }
}


Measured memory_bytes: 104492
#include<iostream>
#include<cstdio>
#include<deque>
#include<algorithm>
#include<sstream>

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

using namespace std;

typedef long long ll;

long long extgcd(long long a,long long b,long long& x,long long& y) {
  long long d = a;
  if(b != 0){
    d = extgcd(b,a%b,y,x);
    y -= (a/b)*x;
  }
  else
    x = 1,y = 0;
  return d;
}

long long mod_inv(long long a,long long m) {
  long long x,y;
  extgcd(a,m,x,y);
  return (m+x%m)%m;
}

long long mod_mul(long long x,long long y,long long p) {
  return ((((x*(y>>20))%p)<< 20)%p + x*(y&((1<<20)-1)))%p;
} 

ll modmultiply(ll a,ll b,ll c) {
  ll x = 0,y = a%c; 
  while(b > 0) {
    if(b%2 == 1) x = (x+y)%c; 
    y = (y*2)%c;
    b /= 2; 
  }
  return x%c;
}

ll modpow(ll x, ll y, ll mod) {
    ll ret = 1;// ret = x^y%mod;
    while(y) {
        if(y&1)
            //ret = (ret*x)%mod;
            ret = modmultiply(ret, x, mod);
        //x = (x*x)%mod;
        x = modmultiply(x, x, mod);
        y >>= 1;
    }
    return ret;
}


#define MR_MAX 50
bool MillerRabin(long long v) {
  if( v == 2 ) return true;
  if( v < 2 || !(v&1LL) ) return false;
  srand((unsigned int)time(NULL));
  long long d = v - 1;
  while( ( d & 1LL ) == 0 ) d >>= 1LL;
  for(int i=0;i<MR_MAX;++i) {
    long long a = rand() % (v-2) + 1LL;
    long long t = d;
    long long y = modpow(a,t,v);
    while( t != v-1LL && y != 1LL && y != v-1LL ) {
      y = ( y * y ) % v;
      t <<= 1LL;
    }
    if( y != v-1LL && ( t & 1LL ) == 0  ) return false;
  }
  return true;
}

//abba
//abccba

int n,c;
bool dfs(int rem,deque<int> &num) {
  if( rem <= 0 ) {
    ll v = 0;
    rep(i,(int)num.size())  v *= 10LL, v += num[i];
    v *= 10LL, v += c;
    rep(i,(int)num.size()) v *= 10LL, v += num[(int)num.size()-1-i];
    if( MillerRabin(v) ) {
      cout << v << endl;
      return true;
    }
    return false;
  }
  int end_v = ( rem == n ) ? 1 : 0;
  for(int v=9;v>=end_v;--v) {
    num.push_back(v);
    if( dfs(rem-1,num) ) return true;
    num.pop_back();
  }
  return false;
}

int main()  {
  cin >> n >> c;
  if( c < 0 ) {
    if( n == 1 ) puts("11");
    else         puts(string(n*2,'9').c_str());
    return 0;
  }
  deque<int> num;
  if( !dfs(n,num) ) puts((string(n,'9')+string(1,'0'+c)+string(n,'9')).c_str());
  return 0;
}





/*
  ???????????????????¨??????????????????????????¨????????????§?????£??????????????\???????????????????????¨???n ????????§?????? 10 ??§????????????c??§0 ??§??????????????? n ????????§?????? 4 ??§?????????
 */

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ld long double
const int M = 1e9+7;

vector<int> a,b;
vector<int> ord;
vector<int> lf,ri;
stack<int> s;

int32_t main(){
	string a,b;
	int n;
	cin>>n;
	cin>>a>>b;
	int i=0,j=0;
	while(i<n && j<n){
		cout << a[i] << b[i];
		i++;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
v = gets.chomp.split.map(&:to_i)

def fetch_max(h, exclude_num: -1) 
  cnt = 0
  num = 0  # Sentinel
  h.each do |k, v|
    if k == exclude_num
      next
    end
    if v > cnt
      cnt = v
      num = k
    end
  end

  [cnt, num]
end

even = v.select.with_index { |_, i| i % 2 == 0 }
odd  = v.select.with_index { |_, i| i % 2 == 1 }

# Calculate max element of even
even_h = {}
even.each do |e|
  even_h[e] ||= 0
  even_h[e] += 1
end
max_even_cnt, max_even_num = fetch_max(even_h)

# p "even num: #{max_even_num}, even cnt: #{max_even_cnt}"

# Calculate max element of odd
odd_h = {}
odd.each do |e|
  odd_h[e] ||= 0
  odd_h[e] += 1
end
max_odd_cnt, max_odd_num = fetch_max(odd_h)

# p "odd num: #{max_odd_num}, odd cnt: #{max_odd_cnt}"

if max_even_num == max_odd_num
  if max_odd_cnt > max_even_cnt  # Use odd for this number
    max_even_cnt, max_even_num = fetch_max(even_h, exclude_num: max_odd_num)
  elsif max_odd_cnt < max_even_cnt
    max_odd_cnt, max_odd_num = fetch_max(odd_h, exclude_num: max_even_num)
  else # max_odd_cnt == max_even_cnt
    max_num = max_odd_num
    # Now, we have to use the largest next one
    even_cnt, even_num = fetch_max(even_h, exclude_num: max_num)
    odd_cnt,  odd_num  = fetch_max(odd_h, exclude_num: max_num)
    if even_cnt > odd_cnt  # even should be used as next
      max_even_cnt = even_cnt
      max_even_num = even_num
    else
      max_odd_cnt = odd_cnt
      max_odd_num = odd_num
    end
  end
end

# p "even num: #{max_even_num}, even cnt: #{max_even_cnt}"
# p "odd num: #{max_odd_num}, odd cnt: #{max_odd_cnt}"

p (n - max_odd_cnt - max_even_cnt)

Measured memory_bytes: 16020
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<ll, ll>
#define to second
#define cost first
typedef long long ll;
typedef long double ld;
using namespace std;

struct block {
	ll w, s, v;
	void read() {scanf("%lld%lld%lld", &w, &s, &v);}
};
bool cmp(block a, block b) {
	return a.s + a.w <= b.s + b.w;
}

int main()
{	
	ll i, j, k;
	ll n, mx = 20132;

	cin >> n;
	vector<block> v(n);
	for(int i = 0; i < n; i++) v[i].read();

	sort(v.begin(), v.end(), cmp);

	vector<ll> dp(mx+1, 0);

	for(block X : v) {
		for(int i = min(mx-X.w, X.s); i >= 0; i--) {
			dp[i+X.w] = max(dp[i+X.w], dp[i]+X.v);
		}
	}
	ll answer = 0;
	for(i = 0; i < dp.size(); i++) answer = max(answer, dp[i]);

	cout << answer << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h,n;
	cin>>h>>n;
	int t=0,a[n];
	for(int i=1;i<=n;i++){
		cin>>a[i];
		t+=a[i];
	}
	if(h<=t){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 640
n = int(input())
x, y, h = zip(*[map(int, input().split()) for _ in range(n)])

h_range = {}
for cx in range(0, 101):
    for cy in range(0, 101):
        h_range[(cx, cy)] = [1, 10000000000]

for i in range(n):
    for (cx, cy) in h_range.keys():
        ch_max = h[i] + (abs(cx - x[i]) + abs(cy - y[i]))
        if h[i] == 0:
            ch_min = 0
        else:
            ch_min = ch_max
        ch_range = h_range[(cx, cy)]
        h_range[(cx, cy)] = [max(ch_min, ch_range[0]), min(ch_max, ch_range[1])]

for (cx, cy) in h_range.keys():
    ch_range = h_range[(cx, cy)]
    if ch_range[0] <= ch_range[1]:
        for ch in range(ch_range[0], ch_range[1] + 1):
            print('{} {} {}'.format(cx, cy, ch))


Measured memory_bytes: 11176
#include<bits/stdtr1c++.h>
#include<list>
#include<algorithm>
using namespace std;

int main(){
    int A,B;
    cin >> A >> B;
    if ((A%3 == 1 && B%3 == 1)||(A%3 == 2 && B%3 == 2)){
        cout << "Impossible" << endl;
    }
    else{
        cout << "Possible" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	if(A==B && A!=C){
		printf("Yes\n");
	} else if (A==C && A!=B){
		printf("Yes\n");
	} else if(B==C && B!=A){
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

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

int main() {
	int n;
	int m;
	int a0,a1,a2,b0,b1,b2;
	int ans;

	cin >> n ;
	n/=2;
	rep(i, n){
		cin >> a0 >> b0 ;
		a[a0]++;
		b[b0]++;
	}
	a1=0;
	b1=0;
	m=100005;
	rep(i, m){
		if (a[i]>a1){
			a0=i;
			a1=a[i];
		}
		if (b[i]>b1){
			b0=i;
			b1=b[i];
		}
	}
	if (a0!=b0) {
		cout << 2*n-a1-b1 << endl;
		return 0;
	}
	a[a0]=0;
	b[b0]=0;
	a2=0;
	b2=0;
	rep(i, m){
		a2=max(a2,a[i]);
		b2=max(b2,b[i]);
	}
	if (a1+b2>a2+b1) cout << 2*n-a1-b2 << endl;
	else cout << 2*n-a2-b1 << endl;
	return 0;
}

Measured memory_bytes: 4416
#include <algorithm>
#include <cstring>
#include <vector>
#include <iostream>
#include <map>
 
using namespace std;

string ans;
int appar[55][27];
 
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    string str;
    cin >> str;
    for (auto it: str) {
      ++appar[i][it - 'a'];
    }
  }
 
  for (int i = 0; i < 26; ++i) {
    int minCnt = 0x3f3f3f3f;
    for (int j = 1; j <= n; ++j) {
      minCnt = min(minCnt, appar[j][i]);
    }
 
    for (int j = 1; j <= minCnt; ++j) {
      ans.push_back(i + 'a');
    } 
  }
 
  cout << ans << '\n';
  return 0;
}

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

#define ll long long

using namespace std;


int n, d;
int a[1000][1000];

int main() {
    cin >> n >> d;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= d; ++j)
            cin >> a[i][j];
    int sol = 0;
    for (int i = 1; i < n; ++i)
        for (int j = i + 1; j <= n; ++j) {
            int dist = 0;
            for (int k = 1; k <= d; ++k)
                dist += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
            if ((int)sqrt(dist) * (int)sqrt(dist) == dist)
                sol++;
        }

    cout << sol;
    return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M,Q; cin >> N >> M >> Q;
    vector<int> a(Q);
    for (int i=0;i<Q;++i) cin >> a[i],--a[i];
    reverse(a.begin(),a.end());
    vector<vector<int>> v(N);
    vector<int> nxt(M,0),idx(M,-1);
    for (int i=0;i<Q;++i){
        if (~idx[a[i]]){
            if (nxt[a[i]]>=N||v[nxt[a[i]]].size()<idx[a[i]]) continue;
            v[nxt[a[i]]++].emplace_back(a[i]);
        } else {
            idx[a[i]]=v[0].size();
            v[nxt[a[i]]++].emplace_back(a[i]);
        }
    }
    vector<int> check(M,0);
    for (int i=0;i<v[N-1].size();++i) check[v[N-1][i]]=1;
    for (int i=0;i<M;++i) if (!check[i]){
        v[N-1].emplace_back(i);
    }
    for (int i=0;i<N-1;++i){
        for (int j=0;j<v[i].size();++j){
            if (v[i][j]!=v[N-1][j]){
                cout << "No" << '\n';
                return 0;
            }
        }
    }
    cout << "Yes" << '\n';
}

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


int main() {
  int A,B;
  cin >> A >> B;

  int ref=0;
  
 // cout << A << ":"<< B << endl;
  if((A - B*2) < 0) ref =0;
  else ref = A - B*2;
  
  cout << ref << endl;
}






Measured memory_bytes: 256
function main()
  
  H1, M1, H2, M2, K = map(x -> parse(Int, x), split(readline()))
  
  time1 = 60H1 + M1
  time2 = 60H2 + M2
  
  time = time2 - time1
  
  println(time - K)
  
end

main()

Measured memory_bytes: 162736