akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


//void warshall_floyd(int n){
//    for(int k=0;k<n;k++){
//        for(int i=0;i<n;i++){
//            for(int j=0;j<n;j++){
//                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
//            }
//        }
//    }
//}

int main() {
    int n; cin >> n;
    vector<ll>cnt = {0,0,0,0,0};
    int p[10] = {0,0,0,0,0,0,1,1,1,2};
    int q[10] = {1,1,1,2,2,3,2,2,3,3};
    int r[10] = {2,3,4,3,4,4,3,4,4,4};
    for(int i = 0;i < n;i++){
        string s;cin >> s;
        if(s[0] == 'M') cnt[0]++;
        if(s[0] == 'A') cnt[1]++;
        if(s[0] == 'R') cnt[2]++;
        if(s[0] == 'C') cnt[3]++;
        if(s[0] == 'H') cnt[4]++;
    }
    ll ans = 0;
    for(int i = 0; i < 10; ++i) {
      ans += cnt[p[i]] * cnt[q[i]] * cnt[r[i]];
    }
    cout << ans;
 }



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

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<ld,ld> id;

#define FOR(i, a, b) for(int i=(a); i<=(b); i++)
#define ROF(i, a, b) for(int i=(a); i>=(b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define FILL(x, n, v) fill(x, x+n, v);
#define ALL(x) x.begin(), x.end()
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define f first
#define s second
#define ins insert
#define e emplace
#define eb emplace_back
#define ef emplace_front
#define p push
#define pf push_front
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ft front
#define bk back
#define pp pop
#define ppb pop_back
#define ppf pop_front

#define db cout<<"YEET\n";
#define ct(x) cout<<x<<'\n';

const ll MOD = 1e9+7; //998244353
const ll MAXN = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);

int main(){
    FAST
    ll n, k, q;
    cin >> n >> k >> q;
    vector<ll> values;
    set<ll> sorted;
    values.pb(0);
    FOR(i,1,n){
        ll x;
        cin >> x;
        values.eb(x);
        sorted.ins(x);
    }

    ll ans = INF;
    for (auto limit : sorted){
        vector<ll> newvec, fin;
        FOR(i,1,n){
            if (values[i] < limit){
                sort(ALL(newvec));
                ll sz = (ll)(newvec.size())-k;
                FOR(j,0,sz) fin.pb(newvec[j]);
                newvec.clear();
            } else newvec.pb(values[i]);
        }

        sort(ALL(newvec));
        ll sz = (ll)(newvec.size())-k;
        FOR(i,0,sz) fin.pb(newvec[i]);

        if (fin.size() >= q) {
            sort(ALL(fin));
            ll diff = fin[q-1] - fin[0];
            ans = min(ans, diff);
        }
    }
    cout << ans;
}

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

public class Main {

    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
            out.flush();
        }
    }

    void solve(InputReader in, PrintWriter out) {
        char[] s = in.next().toCharArray();
        int changeFB = 0;
        int changeFW = 0;
        for (int i = 0; i < s.length; i++) {
            if (i % 2 == 0) {
                if (s[i] == '0') {
                    changeFB++;
                } else {
                    changeFW++;
                }
            } else {
                if (s[i] == '0') {
                    changeFW++;
                } else {
                    changeFB++;
                }
            }
        }

        out.println(Math.min(changeFB, changeFW));
    }
}

class InputReader implements AutoCloseable {
    private final Scanner sc = new Scanner(System.in);

    String next() {
        return this.sc.next();
    }

    int nextInt() {
        return Integer.parseInt(this.sc.next());
    }

    long nextLong() {
        return Long.parseLong(this.sc.next());
    }

    double nextDouble() {
        return Double.parseDouble(this.sc.next());
    }

    @Override
    public void close() {
        this.sc.close();
    }
}

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

class Main {
    public static void main (String [] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        //--------------------------START WRITING HERE-----------------------------

        StringTokenizer st = new StringTokenizer(f.readLine());

        int L = Integer.parseInt(st.nextToken());
        int R = Integer.parseInt(st.nextToken());
        int d = Integer.parseInt(st.nextToken());

        int counter = 0;
        for(int i = L; i <= R; i++)
        {
            if(i%d==0)counter++;
        }

        out.println(counter);

        out.close();
    }
}

Measured memory_bytes: 32552
use std::io;
use std::str::FromStr;
use std::cmp;


fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut it = buf.split_whitespace().map(|n| u64::from_str(n).unwrap());
    let (a, b, c) = (it.next().unwrap(), it.next().unwrap(), it.next().unwrap());

    let mx = cmp::max(cmp::max(a, b), c);
    if (a + b + c - mx) == mx {
        println!("Yes");
    } else {
        println!("No");
    }

}


Measured memory_bytes: 4352
N=int(input())
A=[]
W=input()
A.append(W)
ans=True
for i in range(N-1):
    w=input()
    if ((A[-1])[-1]!=w[0]) or (w in A):
        ans=False
    else:
        A.append(w)
else:
    print('Yes' if ans==True else 'No')

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

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

void solve(long long A, long long B){
    long long ans = -1000001;
    chmax(ans, A + B);
    chmax(ans, A - B);
    chmax(ans, A * B);
    cout << ans << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
<?php
$start = microtime(true);
list($n) = ints();
$k = 26;
$c = ints();
$last = array_fill(0, $k, 0);
for ($i = 1; $i <= $n; ++$i) {
    $s[$i] = ints();
    $max = PHP_INT_MIN;
    for ($p = 0; $p < $k; ++$p) {
        $ts = ($score[$i - 1] ?? 0) + $s[$i][$p];
        for ($q = 0; $q < $k; ++$q) {
            if ($p === $q) continue;
            $ts -= $c[$q] * ($i - $last[$q]);
        }
        if ($ts > $max) {
            $max = $ts;
            $maxp = $p;
        }
    }
    $score[$i] = $max;
    $ans[$i] = $maxp + 1;
    $last[$maxp] = $i;
}
while (true) {
    for ($i = 1; $i < 365; ++$i) {
        for ($p = 1; $p <= $k - 1; ++$p) {
            $anst = $ans;
            $anst[$i] = ($ans[$i] - 1 + $p) % 26;
            $scoret = calcScore($anst);
            $diff = $scoret - $score[365];
            if ($diff > 0) {
                $ans = $anst;
                $score[365] = $scoret;
                break;
            }
        }
        $now = microtime(true);
        if ($now - $start > 1.9) break 2;
    }
}
echo implode(PHP_EOL, $ans);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
function calcScore($ans)
{
    global $c, $s;
    $last = array_fill(0, 26, 0);
    $score[0] = 0;
    for ($i = 1; $i <= 365; ++$i) {
        $score[$i] = ($score[$i - 1] ?? 0) + $s[$i][$ans[$i]];
        $last[$ans[$i]] = $i;
        for ($q = 0; $q < 26; ++$q) {
            $score[$i] -= $c[$q] * ($i - $last[$q]);
        }
    }
    return $score[365];
}


Measured memory_bytes: 16916
N = int(input())
A = list(map(int,input().split()))
B = [0]*(N+1)
for i in range(N):
    B[i+1] = B[i]+A[i]
ans = B[-1]
for i in range(N+1):
    ans = min(abs(B[-1]-2*B[i]),ans)
print(ans)

Measured memory_bytes: 26024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;
    if(s[0]==s[1] && s[1]==s[2])
        cout<<"Yes"<<endl;
    else if(s[2]==s[1] && s[1]==s[3])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

const int MAX_N=1<<20;

int N;
vll dat(2*MAX_N);

void init(int N_){
    N=1;
    while(N<N_)N*=2;
    rep(i,2*N-1)dat[i]=INF;
}

//i番目の値(0-index)をxに変更
void update(int i,ll x){
    i+=N-1;
    dat[i]=x;
    while(i>0){
        i=(i-1)/2;
        dat[i]=min(dat[2*i+1],dat[2*i+2]);
    }
}

//[a,b)のminを求める
//kは接点の番号, l,rはその接点が持つ範囲[l,r)を表す
ll getmin(int a,int b,int k=0,int l=0,int r=-1){
    if(r<0)r=N;
    if(r<=a||b<=l)return INF;
    if(a<=l&&r<=b)return dat[k];
    else{
        ll chl=getmin(a,b,2*k+1,l,(l+r)/2);
        ll chr=getmin(a,b,2*k+2,(l+r)/2,r);
        return min(chl,chr);
    }
}

int main(){
    int n,q;cin>>n>>q;
    init(n);
    const ll tmp=INT_MAX;
    rep(i,n)update(i,tmp);
    vll ans;
    int c,x;ll y;
    rep(i,q){
        cin>>c>>x>>y;
        if(c==0)update(x,y);
        else ans.push_back(getmin(x,y+1,0,0,N));
    }
    rep(i,ans.size())cout<<ans[i]<<endl;
    //rep(i,8)cout<<dat[i]<<" ";cout<<endl;
}


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

int main() {
	long long x;cin>>x;
	long long temp=0;
	long long ans=0;
	for(long long i=0;i<=x;i++){
		temp+=i;
		if(temp>=x){
			ans=i;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

ll gcd(ll a, ll b) {
    return (b % a == 0) ? a : gcd(b % a, a);
}

ll lcm(ll a, ll b) {
    return (a / gcd(a, b)) * b;
}

int main() {
    ll A, B;
    cin >> A >> B;
    cout << lcm(A, B) << endl;
    return 0;
}

Measured memory_bytes: 256
#ABC155.B
N = int(input())
A = list(map(int,input().split()))
count = 0
for i in A:
    if i%2==0:
        if i%3 == 0 or i%5 == 0:
            pass
        else:
            count+=1
if count==0:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 2940
from collections import defaultdict
import sys
import math
from datetime import datetime
import re
import math
def sol(n, S, T):
    ans = ""
    for i in range(n):
        ans += S[i]
        ans += T[i]
    return ans





do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    # n = int(parsed_lines[0][0])
    # k = int(parsed_lines[0][1])
    S = parsed_lines[0][0]
    return S


if not do_submit:
    S = input_parse("""
    1905
    """)
    print(sol(S))

    S = input_parse("""
    0112
    """)
    print(sol(S))

    S = input_parse("""
    1700
    """)
    print(sol(S))

    S = input_parse("""
    0000
    """)
    print(sol(S))

    S = input_parse("""
    1001
    """)
    print(sol(S))



else:
    #A, B = list(map(int, input().split()))
    n = int(input())
    S, T = list(map(str, input().split()))
    # S = input()
    # T = input()
    print(sol(n, S, T))

    # S = input().strip()
    # print(sol(S))



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

using namespace std;

static std::vector<int> as;
static std::vector<int> bs;
static int n;

bool solve(int z) {
  if (z <= 0) {
    return true;
  }
  int i = z - 1;
  int j = n - 1;
  for (; i >= 0; --i, --j) {
    while (bs[j] < 0) {
      --j;
    }
    if (bs[j] > i) {
      return false;
    }
  }
  i = z - 1;
  j = n - 1;
  for (; i >= 0; --i, --j) {
    while (bs[j] < 0) {
      --j;
    }
    if (bs[j] != i) {
      continue;
    }
    bs[j] = -1;
    if (solve(z - 1)) {
      as[z - 1] = i + 1;
      return true;
    }
    bs[j] = i;
  }
  return false;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::cin >> n;
  bs.resize(n);
  for (int i = 0; i < n; ++i) {
    int b;
    std::cin >> b;
    bs[i] = b - 1;
  }
  as.resize(n);
  auto const found = solve(n);
  if (!found) {
    std::cout << -1 << std::endl;
    return 0;
  }
  for (auto const a : as) {
    std::cout << a << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

int main()
{
    ll n, h , w;
    cin >> n >> h >> w;
    int ans = 0;
    rep(i,n) {
        ll a, b; cin >> a >> b;
        if (a >= h && b >= w)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3516
N, X = map(int, input().split())
*L, = map(int, input().split())
sum_L = [0] * (N + 1)
for i in range(N):
	sum_L[i + 1] = sum_L[i] + L[i]
ans = len([j for j in sum_L if j <= X])
print(ans)


Measured memory_bytes: 3060
import std.stdio, std.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial;

void main(){
    auto ab=readln.split.map!(to!int).map!"a==1?999:a".array;
    if(ab[0]==ab[1]) writeln("Draw");
    else if(ab[0]<ab[1]) writeln("Bob");
    else writeln("Alice");
}

Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

m,d = iim()
ans = 0
for i in range(1,m+1):
    for j in range(1,d+1):
#        print('{}/{}'.format(i,j))
        d10 = j//10
        d1 = j-d10*10
        if d10 > 1 and d1 > 1 and i == d10*d1:
            ans += 1
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int x;
  cin >> x;
  vector<bool> dp(100001);
  dp[0] = true;
  for (int i = 0; i <= 100000; ++i) {
    if (100000 < i + 100) break;
    if (dp[i]) {
      dp[i + 100] = true;
      dp[i + 101] = true;
      dp[i + 102] = true;
      dp[i + 103] = true;
      dp[i + 104] = true;
      dp[i + 105] = true;
    }
  }
  cout << dp[x] << endl;
  return 0;
}

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


cnt = {}
for i in range(1,N+1):
    N_str = str(i)

    num = N_str[0]+N_str[-1]
    if N_str[-1] == '0':
        pass
    else:
        if num in cnt.keys():
            cnt[num] +=1
        else:
            cnt[num] = 1

ans = 0
for i in cnt.keys():
    try:
        cnt_inv = cnt[i[::-1]]
        ans += cnt[i] * cnt_inv
    except:
        pass
print(ans)

Measured memory_bytes: 73560
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

using namespace std;

#define li long long int
#define ld long double
const int MX1=1e5+5;
const int MX2=1e6+5;
const li inf=4e18;
const li mod=1e9+7;

li power(li a,li b){li res=1;while(b){if(b%2)res=(res*a)%mod;
a=(a*a)%mod;b/=2;}return res;}

li mmi(li a){return power(a,mod-2);}

li cntbit(li n){li cnt=0;while(n){n&=(n-1);cnt++;}return cnt;}

int a,b;
char res[105][105];

void solve(){
	cin>>a>>b;
	for(int i=1;i<=100;i++){
		for(int j=1;j<=100;j++){
			if(i<=50){
				res[i][j]='.';
			}else{
				res[i][j]='#';
			}
		}
	}
	a--;
	b--;
	for(int i=1;i<=50;i+=2){
		for(int j=1;j<=100;j+=2){
			if(b) res[i][j]='#',b--;
		}
	}
	for(int i=52;i<=100;i+=2){
		for(int j=1;j<=100;j+=2){
			if(a) res[i][j]='.',a--;
		}
	}
	cout<<"100 100\n";
	for(int i=1;i<=100;i++){
		for(int j=1;j<=100;j++){
			cout<<res[i][j];
		}
		cout<<"\n";
	}
}

int main(){
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <cassert>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <complex>
#include <bitset>
using namespace std;

#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, b, a) for(int i=(b)-1;i>=(a);--i)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define Pi 3.14159265358979
#define x0 ikjnrmthklmnt
#define y0 lkrjhkltr
#define y1 ewrgrg

typedef long long Int;
typedef unsigned long long UInt;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<Int, Int> PLL;
typedef pair<double, double> PDD;
typedef complex<double> base;

const int INF = 1000000000;
const int BASE = 1000000007;
const int MAX = 4000000 + 1;
const int MAXX = 1000000;
const int ADD = 1000000;
const int MOD = 1000000007;
const int CNT = 800;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("distance.in",  "r", stdin);
    //freopen("distance.out", "w", stdout);
    //freopen("out.txt" , "w" , stdout);
    
    
    int n;
    cin >> n;
    
    bitset<MAX> B;
    
    B[0] = 1;
    
    int s = 0;
    
    FOR(i,0,n)
    {
        int x;
        cin >> x;
        s += x;
        B = B | (B << x);
    }
    
    FOR(i,(s + 1) / 2 , MAX)
        if (B[i] == 1)
        {
            cout << i << endl;
            return 0;
        }
    
    
    
    
    
    
    return 0;
}













Measured memory_bytes: 2304
import java.util.Scanner;
 
import static java.lang.Character.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        String input = sc.nextLine();
 
        char[] output = new char[input.length()];
 
        for(int i = 0; i < input.length(); i++){
            if(isLowerCase(input.charAt(i)))
                output[i] = toUpperCase(input.charAt(i));
            else if(isUpperCase(input.charAt(i)))
                output[i] = toLowerCase(input.charAt(i));
            else output[i] = input.charAt(i);
        }
 
        System.out.println(output);
 
        sc.close();
    }
}


Measured memory_bytes: 26248
#include <stdio.h>

short prime[60005];

void p_serch(void);

int main(void)
{
	int i;
	int n;
	int min, max;
	
	p_serch();
	
	while (scanf("%d", &n) != EOF){
		
		for (i = n + 1; i <= 60000; i++){
			if (prime[i] == 0){
				min = i;
				break;
			}
		}
		for (i = n - 1; i > 0; i--){
			if (prime[i] == 0){
				max = i;
				break;
			}
		}
		
		printf("%d %d\n", max, min);
	}
	
	return (0);
	
}





void p_serch(void)
{
	int i, j;
	
	for (i = 2; i < 30000; i++){
		
		j = 2;
		while (j * i <= 60000){
			
			prime[j * i] = 1;
			j++;
		}
	}
}

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

int mod = 1e9 + 7;

int main() {
    long long N, K;
    cin >> N >> K;
    
    long long ans = 0;
    for (long long i = K; i <= N + 1; ++i) {
        long long A = (i - 1) * i / 2;
        long long B = (2 * N - i + 1) * i / 2;
        ans += B - A + 1;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <deque>

using namespace std;

const int NMAX = 2e5;

struct Line{
    long long a, b;

    long long eval(long long x)
    {
        return a * x + b;
    }
};

long long N, C;
long long h[NMAX + 5];

long long minCost[NMAX + 5];

deque <Line> dq;

bool LinesAreGood(Line l1, Line l2, Line l3)
{
    ///lines are good <=> getx(l1, l2) < getx(l2, l3)

    return (l2.b - l1.b) * (l2.a - l3.a) < (l1.a - l2.a) * (l3.b - l2.b);
}

void Insert(Line l)
{
    while(dq.size() > 1 && !LinesAreGood(dq.end()[-2], dq.end()[-1], l))
        dq.pop_back();

    dq.push_back(l);
}

double xIntersect(Line l1, Line l2)
{
    return 1.0 * (l2.b - l1.b) / (l1.a - l2.a);
}

long long QueryMin(long long x)
{
    while(dq.size() > 1 && xIntersect(dq[0], dq[1]) < x)
        dq.pop_front();

    return dq[0].eval(x);
}

int main()
{
    cin >> N >> C;

    for(int i = 1; i <= N; i++)
        cin >> h[i];

    minCost[1] = 0;

    for(int i = 2; i <= N; i++)
        {
            Insert({-2 * h[i - 1], minCost[i - 1] + h[i - 1] * h[i - 1]});
            minCost[i] = C + h[i] * h[i] + QueryMin(h[i]);
        }

    cout << minCost[N] << '\n';

    return 0;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(){
  int A,B;
  cin>>A>>B;
  string S;
  cin>>S;
  rep(i,A){
    if(S[i]=='-'){
      cout<<"No"<<endl;
      return 0;
    }
  }
  if(S[A]!='-'){
    cout<<"No"<<endl;
    return 0;
  }
  for(int i=A+1;i<A+B+1;i++){
    if(S[i]=='-'){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int N;
  long long mod = 1000000007;
  scanf("%d",&N);
  std::vector<long long> X(N), L(N);
  std::multimap<long long, long long > arm;
  for (int i=0; i<N; i++){
    scanf("%lld",&X[i]);
    scanf("%lld",&L[i]);
    arm.insert(std::make_pair(X[i]+L[i],X[i]-L[i]));
  }
  int ans = 0;
  long long set;
  for (auto const& entry: arm) {
    set = entry.first;
    ans++;
    break;
  }
  for (auto const& entry: arm) {
    if(entry.second<set){
      continue;
    }
    set = entry.first;
    ans++;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define F first
#define S second
//#define int long long

///My functions

//Constants
const int mxn = 3*1e5+5, inf = 1e9+7, mod = 1e9+7;
const long long infLL = 1e18+5;
const double EPS = 1e-9 , PI = acos(-1);

//Structs

//Variables
int n,m,Q,k,a,b,c,sum,ans,MAXans,MINans,sc,pos,acc[mxn],racc[mxn];
vector<int>v,q,ar;
bitset<mxn>flag;
bool sol ;
string s;

bool isv (){

	for( int i = 0 ; i < v.size() ; i++ ){
		if( v[i] != ar[i] ) return false ;
	}
	return true ; 

}

bool isq (){

	for( int i = 0 ; i < q.size() ; i++ ){
		if( q[i] != ar[i] ) return false ;
	}
	return true ; 
	
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> n ; 
    v.resize( n ); q.resize( n ) ;
    for( auto &i : v ) cin >> i ; 
    for( auto &i : q ) cin >> i ; 

    for( int i = 1 ; i <= n ; i++ ){
    	ar.push_back( i ) ;
    }

    do{
    	sc++ ;
    	if( isv() ) a = sc ;
    	if( isq() ) b = sc ; 

    } while( next_permutation( ar.begin(), ar.end() ) ) ;


    cout << abs( b - a ) ; 



    return 0;
}
























Measured memory_bytes: 256
while 1:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    
    sc  = m + f
    if m == -1 or f == -1:  print('F')
    elif 79 < sc:           print('A')
    elif 64 < sc:           print('B')
    elif 49 < sc:           print('C')
    elif 29 < sc:
        if 49 < r:          print('C')
        else:               print('D')
    else:                   print('F')


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



int main()
{

    int N;
    cin >> N;
    vl a(N);in(N,a);ll ans = 0;
    rep(i,N) ans += a[i]-1;
    out(ans);


    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
N=int(input())
A=list(map(int,input().split()))

A.sort()

MIN=A[0]
MAX=A[-1]

if MIN>0:
    print(sum(A)-MIN*2)
elif MAX<0:
    print(-(sum(A)-MAX*2))
else:
    M=0
    for i in range(N):
        M+=abs(A[i])
    print(M)
    

for i in range(1,N-1):
    if A[i]<0:
        print(MAX,A[i])
        MAX-=A[i]
    else:
        print(MIN,A[i])
        MIN-=A[i]

print(MAX,MIN)

Measured memory_bytes: 14016
/*
 *created by Kraken on 27-04-2020 at 11:27
 */
import java.util.*;
import java.io.*;

public class Main {
  private static final long INF = (long) 1e18 + 1;

  public static void main(String[] args) {
    FastReader sc = new FastReader();
    int n = sc.nextInt();
    long w = sc.nextLong();
    long[] weights = new long[n];
    int[] values = new int[n];
    int sum = 0;
    for (int i = 0; i < n; i++) {
      weights[i] = sc.nextLong();
      values[i] = sc.nextInt();
      sum += values[i];
    }
    long[] dp = new long[sum + 1];
    Arrays.fill(dp, INF);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
      for (int nowValue = sum - values[i]; nowValue >= 0; nowValue--) {
        dp[nowValue + values[i]] = Math.min(dp[nowValue + values[i]], dp[nowValue] + weights[i]);
      }
    }
    long res = 0;
    for (int i = 0; i <= sum; i++) {
      if (dp[i] <= w) res = Math.max(res, i);
    }
    System.out.println(res);
  }

  static class FastReader {

    BufferedReader br;

    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        }
        catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      }
      catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


Measured memory_bytes: 23124
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        long A = sc.nextLong();
        long V = sc.nextLong();
        long B = sc.nextLong();
        long W = sc.nextLong();
        long T = sc.nextLong();
        long a = 0;
        long b = Math.max(A,B)-Math.min(A,B);
        if(V*T>=b+W*T){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 35768
// abc051,b

using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int k = int.Parse(input[0]);
        int s = int.Parse(input[1]);

        int ans;

        if (s >= 2*k){
            ans = (3 * k - s + 1) * (3 * k - s + 2) / 2;
        }else if (s > k)
        {
            ans = ((3 * k - s + 2) * (s - k + 1) + (s + 1) * (2 * k - s)) / 2;
        }else
        {
            ans = (s + 1) * (s + 2) / 2;
        }

        Console.WriteLine(ans);

    }
}

Measured memory_bytes: 2648
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
s = 0
s += sum(B)

for i in range(1, len(A)):
  if A[i] == A[i-1] + 1:
    s += C[A[i-1]-1]

print(s)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)

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

int h,w;
int a[550][550];

int main() {
    cin>>h>>w;
    rep(i,h)rep(j,w)cin>>a[i][j];

    vector<p_ii> to, from;

	for(int i=0;i<h;i++){
        for(int j=0;j<w-1;j++){
            if(a[i][j]%2){
                a[i][j+1]++;
                from.push_back({i+1,j+1});
                to.push_back({i+1,j+2});
            }
        }
    }

    for(int i=0;i<h-1;i++){
        if(a[i][w-1]%2){
            a[i+1][w-1]++;
            from.push_back({i+1,w});
            to.push_back({i+2,w});
        }
    }

    cout<<to.size()<<endl;
    for(int i=0;i<to.size();i++){
        cout<<from[i].first<<" "<<from[i].second<<" "<<to[i].first<<" "<<to[i].second<<endl;
    }

	return 0;
}

Measured memory_bytes: 5356
n, k = map(int, input().split())
l = list(map(int, input().split()))
at = l[0]
ans = 0
max_i = 0
max_l = sum(l[:k])
hikaku = sum(l[:k])
if k == 1:
    a = max(l)
    print(a * (a + 1) / 2 / a)
else:
    for i in range(1, n - k + 1):
        hikaku = hikaku - at + l[i + k - 1]
        at = l[i]
        if max_l < hikaku:
            max_i = i
            max_l = hikaku
    for i in range(k):
        a = l[max_i + i]
        ans += a * (a + 1) / 2 / a
    print(ans)

Measured memory_bytes: 25604
/*
ye mera template hai
apna khud likho bc :P
*/

/*
Author : Sarvagya Agarwal
*/

#include<bits/stdc++.h>
using namespace std;

//defines
#define openin freopen("input.txt","r",stdin)
#define openout freopen("output.txt","w",stdout)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define int long long
#define mod 1000000007
#define repr(i,x,y) for (__typeof(x) i=x;i>=y;i--)
#define rep(i,x,y) for (__typeof(x) i=x;i<=y;i++)
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

/* Print pair */
template <typename T,typename S>
ostream & operator << (ostream &os , const pair<T,S> &v) {
    os << "(" ;
    os << v.first << "," << v.second << ")" ;
    return os ;
}
/* Print vector */
template <typename T>
ostream & operator << (ostream &os , const vector<T> &v) {
    os << "[" ;
    int sz = v.size() ;
    for(int i = 0 ; i < sz ; ++i) {
        os << v[i] ;
        if(i!=sz-1)os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print set */
template <typename T>
ostream & operator << (ostream &os , const set<T> &v) {
    T last = *v.rbegin() ;
    os << "[" ;
    for(auto it : v) {
        os << it  ;
        if(it != last) os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print Map */
template <typename T,typename S>
ostream & operator << (ostream &os , const map<T,S> &v) {
    for(auto it : v) {
        os << it.first << " : " << it.second << "\n" ;
    }
    return os ;
}
int power(int a , int b)
{
    int res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % mod ;
        }
        b/=2 ;
        a = (a*a) % mod ;
    }
    return res ;
}

//debug
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int32_t main()
{
    fast;
    int x ;
    cin >> x ;
    int lo = 1 , hi = 1e15 , mi , ans = 0  ;
    while(lo <= hi) {
        mi = (lo+hi)/2 ;
        int gen = 0 ;
        if(mi % 2) {
            gen += (mi/2)*5ll ;
            gen += (mi/2+1)*6ll ;
        }
        else {
            gen += (mi/2)*11ll ;
        }
        if(gen >= x) {
            hi = mi - 1 ;
            ans = mi ;
        }
        else lo = mi +  1 ;
    }
    cout << ans ;
    return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int w, a, b;
  cin >> w >> a >> b;
  int sa = abs(a - b);
  int ans = 0;
  if(sa <= w) {
    cout << ans << endl;
    return 0;
  }
  else {
    ans = sa - w;
    cout << ans << endl;
    return 0;
  }
}

Measured memory_bytes: 3608
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;


int main() {
  int n; cin>>n;
  vector<int> v(4, 0);
  vector<string> ans = {"AC", "WA", "TLE", "RE"};
  rep(i,n) {
      string s; cin>>s;
      if (s == "AC") v[0] += 1;
      if (s == "WA") v[1] += 1;
      if (s == "TLE") v[2] += 1;
      if (s == "RE") v[3] += 1;
  }
  rep(i,4) {
      cout << ans[i] << " x " << v[i] << endl;
  }
}


Measured memory_bytes: 3608
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let xor = a.iter().fold(0, |acc, x| acc ^ x);

    let mut out = Vec::new();
    for i in 0..n {
        writeln!(out, "{}", a[i] ^ xor).ok();
    }
    stdout().write_all(&out).unwrap();
}


Measured memory_bytes: 8460
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
 char str1[15],str2[15],str3[15];
 cin>>str1>>str2>>str3;
 str1[0]=toupper(str1[0]);
 str2[0]=toupper(str2[0]);
 str3[0]=toupper(str3[0]);
 cout<<str1[0]<<str2[0]<<str3[0];
 return 0;
}

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

using namespace std ;

int main () {
    long long n , i ;
        cin >> n ;
    long long a[n+10],b[n+10] ;
    for(i=0;i<n;i++){
        cin >> a[i] ;
        b[i]=a[i] ;
    }
    sort(b,b+n) ;

    for(i=0;i<n;i++){
        if (a[i]==b[n-1])
            cout << b[n-2];
        else
            cout << b[n-1] ;
        cout << endl ;
    }



}


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

int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  for (int i = 0; i < N; i++) {
    cin >> V.at(i);
  }
  vector<int> C(N);
  for (int i = 0; i < N; i++) {
    cin >> C.at(i);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (V.at(i) > C.at(i)) {
      ans = ans + V.at(i) - C.at(i);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
const lint mod=1e9+7;

int main()
{
  int x, y, z;
  cin >> x >> y >> z;

  cout << z << " " << x << " " << y << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 6e5 + 7;

int n, a[N], k, tree[4 * N];

#define m (l + r) / 2
#define lson 2 * node
#define rson 2 * node + 1

void update(int pos, int v, int l, int r, int node) {
    if (l == r) {
        tree[node] = v;
        return;
    }
    if (pos <= m) update(pos, v, l, m, lson);
    else update(pos, v, m + 1, r, rson);
    tree[node] = max(tree[lson], tree[rson]);
}

int query(int ql, int qr, int l, int r, int node) {
    if (ql <= l && qr >= r) {
        return tree[node];
    }
    int ans = 0;
    if (ql <= m) ans = max(ans, query(ql, qr, l, m, lson));
    if (qr > m) ans = max(ans, query(ql, qr, m + 1, r, rson));
    return ans;
}



int main() {
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int res = query(max(a[i] - k, 0), a[i] + k, 0, N, 1) + 1;
        ans = max(ans, res);
        update(a[i], res, 0, N, 1);
    }
    cout << ans << endl;



    
}

Measured memory_bytes: 9072
A,B,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
min = min(A)+min(B)
for i in range(M):
  x,y,c = [int(i) for i in input().split()]
  buf = A[x-1]+B[y-1]-c
  if buf<min:
    min = buf
print(min)

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

int dp[2][101][10001];
int a[101],b[101],c[101];
int main(){
    int n,C,ai,bi;
    cin>>n>>C;
    rep(i,n){
        cin>>a[i]>>b[i]>>c[i];
    }
    memset(dp,-1,sizeof(dp));
    dp[0][0][0]=0;
    rep(i,n){
        rep(j,C+1)rep(k,i*100+1){
            if(dp[0][j][k]==-1) continue;
            if(j+c[i]<=C){
                int u=max(k+a[i],dp[0][j][k]+b[i]);
                int l=min(k+a[i],dp[0][j][k]+b[i]);
                dp[1][j+c[i]][u]=max(dp[1][j+c[i]][u],l);
                u=max(k+b[i],dp[0][j][k]+a[i]);
                l=min(k+b[i],dp[0][j][k]+a[i]);
                dp[1][j+c[i]][u]=max(dp[1][j+c[i]][u],l);            
            }
            dp[1][j][k]=max(dp[1][j][k],dp[0][j][k]);
        }
        swap(dp[0],dp[1]);
        memset(dp[1],-1,sizeof(dp[1]));
    }
    int mx=0;
    rep(i,C+1)rep(j,10001)if(dp[0][i][j]!=-1) mx=max(mx,dp[0][i][j]);
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 11012
/*
  Merge Sort
   ALDS1-ALDS1_5-B
  Recursion / Divide and Conquer - Merge Sort
*/
#include <iostream>
#include <vector>

using namespace std;

int n, comparision;
const int INF = 1e9 + 1;

void Merge(vector<int> &data, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    vector<int> L(n1 + 1), R(n2 + 1);

    for (int i = 0; i < n1; ++i)
        L[i] = data[left + i];
    for (int i = 0; i < n2; ++i)
        R[i] = data[mid + i];
    L[n1] = INF;
    R[n2] = INF;

    int i = 0, j = 0;
    for (int k = left; k < right; ++k) {
        comparision++;
        if (L[i] <= R[j])
            data[k] = L[i++];
        else
            data[k] = R[j++];
    }
}

void MergeSort(vector<int> &data, int left, int right)
{
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        MergeSort(data, left, mid);
        MergeSort(data, mid, right);
        Merge(data, left, mid, right);
    }
}

int main()
{
    // Input
    cin >> n;
    vector<int> data(n);
    for (int i = 0; i < n; ++i)
        cin >> data[i];
    comparision = 0;

    // Algorithm
    MergeSort(data, 0, n);

    // Output
    for (int i = 0; i < n; ++i)
        cout << data[i] << ((i == n - 1) ? '\n' : ' ');
    cout << comparision << endl;

    return 0;
}

Measured memory_bytes: 5060
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;
/* 
int keta(int x){
    int cnt = 0;
    while(x){
        cnt += x % 10;
        x/=10;
    }
    return cnt;
}
 */

int main(){
    while(1){
        string x;
        cin >> x;
        if(x[0]=='0')break;
        int cnt = 0;
        for(int i = 0; i < x.size(); i++){
            int num = x[i]-'0';
            cnt += num;
        }
        cout << cnt << endl;

    }
 
 /*    int a = '0'-'0';
    int aa = '0' - 0;

    cout << "a:" << a << " aa:" << aa << endl; //a:0 aa:48
 */

}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Og")
#pragma GCC push_options
#pragma GCC pop_options

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    if (s[2] == s[3])
        if (s[4] == s[5])
            cout << "Yes";
        else
            cout << "No";
    else
        cout << "No";
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>
using namespace std;
int main() {
	int n;
	char color;
	string kind="Three";
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> color;
		if (color == 'Y') {
			kind = "Four";
		}
	}
	cout << kind<< endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
import math

S = int(input())
A = np.zeros(6)

if S == 10**18:
    A[2] = 10**9
    A[5] = 10**9

else:
    k = math.sqrt(S) + 1
    A[2] = int(k)
    A[5] = int(k)

    A[3] = int(k)**2 - S
    A[4] = 1
    
print(*A.astype(np.int32))

Measured memory_bytes: 12500
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
long double eps = 1e-6;
long double pi = acos(-1);



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    
    char a;
    cin>>a;
    if(a>='A' && a<='Z')cout << "A" << endl;
    else cout << "a" << endl;
}

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

int main(void){
  int A, B;
  cin >> A >> B;
  
  for(int i=0; i<10000; i++){
    //cout << (int)(i*0.08) << " " << i*0.1 << "\n";
    if((int)(i*0.08)==A && (int)(i*0.1)==B){
      cout << i;
      return 0;
    }
  }
  cout << "-1";
  return 0;
}

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

int main(){
  int n,a,b,c,d=0,e=0,f=0;
  cin >> n >> a >> b;
  r(i,n){
    cin >> c;
    if(c<=a)d++;
    else if(a<c&&c<=b)e++;
    else f++;
  }
  cout << min(d,min(e,f))<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a,b;
	cin>>a>>b;
	if(a.size()>b.size())cout<<"GREATER";
	else if(a.size()<b.size())cout<<"LESS";
	else {
		int f=0;
		for(int i=0;i<a.size();i++){
			if(a[i]==b[i])continue;
			if(a[i]>b[i]){
				cout<<"GREATER";
				f++;
				break;
			}
			else{
				cout<<"LESS";
				f++;
				break;
			}
		}
		if(!f)cout<<"EQUAL";
	}
	cout<<endl;
	return 0;
}

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

int main() {
  int K;
  cin >> K;

  string str;
  cin >> str;
  
  if (str.size() < K+1) {
    cout << str << endl;
  }
  else {
    for (int i = 0; i < K; i++) {
       cout << str.at(i);
    }
    cout << "..." << endl;
  }
}



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

using namespace std;

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

int main() {
    int n, ans = 0;
    string s;
    cin >> n >> s;
    string p;
    rep(i, 1000){
        if(i/10 == 0) p = "00"+to_string(i);
        else if(i/100 == 0) p = "0"+to_string(i);
        else if(i/100 > 0) p = to_string(i);
        int comp = 0;
        rep(j,n){
            if(s[j] == p[comp]) comp++;
            if(comp == 3){
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256