akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using db = double;
using ll = long long;
using vi = vector <int>;
#define op operator
#define pb push_back

const db eps = 1e-6L;
int sgn(db a, db b = 0) {
	a -= b;
	return (a > eps) - (a < -eps);
}

const int N = 33;
int n, m; db d;
int device[N];
int capacity[N], full_capacity[N];
int speed[N];
db wait_time[N], full_wait_time[N];
db pos[N];

int burn[N];

int cnt;
db timer, last_collect_time;

const db inf = 1e10L;
int goal;
db check(int i) {
	if(sgn(wait_time[i]) > 0) return wait_time[i];
	if(!capacity[i]) return (pos[i] - d) / speed[i];
	if(goal != -1) return abs(pos[i] - goal * d) / speed[i];
	if(sgn(pos[i], d) != 0) return (pos[i] - d) / speed[i];
	return inf;
}

void solve(int i, db t) {
	if(sgn(wait_time[i]) > 0)
		wait_time[i] -= t;
	else if(!capacity[i]) {
		pos[i] -= speed[i] * t;
		if(sgn(pos[i], d) == 0) {
			wait_time[i] = full_wait_time[i];
			capacity[i] = full_capacity[i];
			last_collect_time = max(last_collect_time, timer + t + wait_time[i]);
		}
	} else if(goal != -1) {
		pos[i] += sgn(goal * d - pos[i]) * speed[i] * t;
		if(sgn(pos[i], goal * d) == 0) {
			wait_time[i] = full_wait_time[i];
			int collect = min(capacity[i], device[goal]);
			//cout << capacity[i] << ' ' << device[goal] << '\n';
			capacity[i] -= collect;
			device[goal] -= collect;
			cnt += collect;
		}
	} else if(sgn(pos[i], d) != 0) {
		pos[i] -= speed[i] * t;
		if(sgn(pos[i], d) == 0 && capacity[i] != full_capacity[i]) {
			wait_time[i] = full_wait_time[i];
			capacity[i] = full_capacity[i];
			last_collect_time = max(last_collect_time, timer + t + wait_time[i]);
		}
	}
}

int main() {
	cout << fixed << setprecision(9);
	ios :: sync_with_stdio(0);

	while(cin >> n >> m && n && m) {
		cin >> d;
		for(int i = 1; i <= n; i ++)
			cin >> device[i];
		cnt = device[1]; device[1] = 0;
		timer = last_collect_time = 0;

		for(int i = 1; i <= m; i ++) {
			cin >> full_capacity[i] >> speed[i] >> full_wait_time[i] >> pos[i];
			capacity[i] = full_capacity[i];
			wait_time[i] = 0;
			pos[i] *= d;
		}

		int k, tx, ty, tz; cin >> k >> tx >> ty >> tz;
		burn[k] = tx;
		for(int i = k + 1; i <= n; i ++)
			burn[i] = (i - k) * ty + tx;
		for(int i = 1; i < k; i ++)
			burn[i] = (k - i) * tz + tx;

		for(;;) {
			//cout << "------\n";
			goal = -1;
			for(int i = 1; i <= n; i ++)
				if(device[i]) goal = i;
			db nxt = inf;
			//cout << goal << ' ' << timer << '\n';
			//for(int i = 1; i <= n; i ++) cout << device[i] << ' '; cout << '\n';
			for(int i = 1; i <= n; i ++)
				if(sgn(burn[i], timer) > 0)
					nxt = min(nxt, burn[i] - timer);
			for(int i = 1; i <= m; i ++) {
				nxt = min(nxt, check(i));
			}

			if(nxt != inf)
				for(int i = 1; i <= m; i ++)
					solve(i, nxt);
			else
				break;

			timer += nxt;
			for(int i = 1; i <= n; i ++)
				if(sgn(burn[i], timer) == 0) device[i] = 0;
		}
		cout << cnt << ' ' << last_collect_time << '\n';
	}

	return 0;
}

Measured memory_bytes: 3288
#include<stdio.h>

int main(void){
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a<=b && b<=c){
		printf("%d %d %d\n",a,b,c);
	}else if(a<=c && c<=b){
		printf("%d %d %d\n",a,c,b);
	}else if(b<=a && a<=c){
		printf("%d %d %d\n",b,a,c);
	}else if(b<=c && c<=a){
		printf("%d %d %d\n",b,c,a);
	}else if(c<=a && a<=b){
		printf("%d %d %d\n",c,a,b);
	}else if(c<=b && b<=a){
		printf("%d %d %d\n",c,b,a);
	}
	return 0;
}

Measured memory_bytes: 596
N = int(input())
h = list(map(int, input().split()))

dp = [0] * N
dp[N-2] = abs(h[N-2]-h[N-1])

if N > 2:
    for i in range(N-3, -1, -1):
        dp[i] = min(abs(h[i]-h[i+2])+dp[i+2], abs(h[i]-h[i+1])+dp[i+1])

print(dp[0])

Measured memory_bytes: 52208
#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define me0(a) memset(a,0,sizeof(a))
#define me1(a) memset(a,-1,sizeof(a))
#define op freopen("in.txt", "r", stdin)
#define op1 freopen("C:\\acm\\Cproj\\in.txt","r",stdin);
#define pr freopen("C:\\acm\\Cproj\\out.txt","w",stdout)
#define pr2 freopen("C:\\acm\\Cproj\\std.txt","w",stdout)
#define pii pair<int,int>
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long LL;
template <class T>
void read(T &val) { T x = 0; T bz = 1; char c; for (c = getchar(); (c<'0' || c>'9') && c != '-'; c = getchar()); if (c == '-') { bz = -1; c = getchar(); }for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48; val = x * bz; }
const int maxn = 1e6 + 11;
const int mod=1e9+7;
int n,m,x,y,t;
int a[maxn];
int main(){
    LL ans=0;
    read(n);
    fo(i,1,n) read(a[i]);
    int mx = a[1];
    fo(i,1,n){
        ans+=max(0,mx-a[i]);
        mx=max(mx,a[i]);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 4500
#include<bits/stdc++.h>
using namespace std;
int n;
long long ans;
long long c[10][10];
int main()
{
    //freopen("input.txt","r",stdin);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	string s=to_string(i);
    	c[s[0]-'0'][s[s.length()-1]-'0']++;
	}
	for(int i=0;i<10;i++)
		for(int j=0;j<10;j++)
			ans+=c[i][j]*c[j][i];
			cout<<ans;
	return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef unsigned int uint;
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

const int MX = 100055;
const int MM = 1000000007;

struct BIT{
	int t[MX];
	int read(int x){
		int r = 0;
		while(x) r = (r + t[x]) % MM, x -= x&-x;
		return r;
	}
	void update(int x, int v){
		while(x < MX) t[x] = (t[x] + v) % MM, x += x&-x;
	}
} tree;

vector<int> X, Y;
int N, M;

int main()
{
	scanf("%d%d", &N, &M);
	for(int i = 1; i <= N; i++){
		int a;
		scanf("%d", &a);
		X.push_back(a);
	}
	for(int i = 1; i <= M; i++){
		int a;
		scanf("%d", &a);
		Y.push_back(a);
	}
	vector<pii> D;
	vector<int> Cy;
	for(int x : X){
		int y = lower_bound(Y.begin(), Y.end(), x) - Y.begin();
		if(y == 0 || y == Y.size()) continue;
		D.emplace_back(x - Y[y-1], Y[y] - x);
		Cy.push_back(Y[y] - x);
	}
	sort(D.begin(), D.end());
	D.resize(unique(D.begin(), D.end()) - D.begin());
	sort(Cy.begin(), Cy.end());
	for(pii &c : D){
		c.second = upper_bound(Cy.begin(), Cy.end(), c.second) - Cy.begin() + 1;
	}
	sort(D.begin(), D.end(), [](pii l, pii r){
		return l.first < r.first || l.first == r.first && l.second > r.second;
	});

	tree.update(1, 1);
	for(int i = 0, j = 0; i < D.size(); i = j){
		for(; j < D.size(); j++){
			if(D[i].first != D[j].first) break;
			tree.update(D[j].second, tree.read(D[j].second-1));
		}
	}
	printf("%d\n", tree.read(MX-1));
}


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

#define TARO 0
#define HANAKO 1

int main(int argc, char *argv[])
{
  int score[2];
  int n, i, res;
  char card[2][100 + 3];

  score[TARO] = 0;
  score[HANAKO] = 0;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%s", card[TARO]);
    scanf("%s", card[HANAKO]);

    if ((res = strcmp(card[TARO], card[HANAKO])) < 0) score[HANAKO] += 3;
    else if (res > 0) score[TARO] += 3;
    else {
      score[TARO]++;
      score[HANAKO]++;
    }
  }

  printf("%d %d\n", score[TARO], score[HANAKO]);

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;
ll sl();

ll lcm(ll x, ll y) {
  return x / __gcd(x, y) * y;
}

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  a--;
  ll ans = 0;
  ans += b - b / c - b / d + b / lcm(c, d);
  ans -= a - a / c - a / d + a / lcm(c, d);
  cout << ans << endl;
}

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

struct init {
  init() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
  }
} init;


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn abc081_a(s: &str) -> u32 {
    let mut c = 0;
    if &s[..1] == "1" { c += 1 }
    if &s[1..2] == "1" { c += 1 }
    if &s[2..] == "1" { c += 1 }

    c
}

fn main() {
    let a = read::<String>();
    let res = abc081_a(&a);
    println!("{}", res)
}

Measured memory_bytes: 4352
/*
Author: Sanskar Agarwal
Nick: sanskaragarwal
Birla Institute Of Technology, Mesra
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define RF(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); i--)
#define INF 100009
#define mod 1000000007
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define test while(t--)solve();

int dp[1005][1005];
string s[1005];
int h, w;

int countPaths(int x, int y)
{
	if (x > h || y > w)
		return 0;
	if (s[x - 1][y - 1] == '#')
		return dp[x][y] = 0;
	if (x == h && y == w)
		return dp[x][y] = 1;
	if (dp[x][y] != -1)
		return dp[x][y];
	return dp[x][y] = (countPaths(x + 1, y) % mod + countPaths(x, y + 1) % mod) % mod;
}

void solve()
{
	cin >> h >> w;
	memset(dp, -1, sizeof(dp));
	for (int i = 0; i < h; ++i)
		cin >> s[i];
	cout << countPaths(1, 1) << endl;
}

int main()
{
	fast
	int t;
	// cin >> t;
	t = 1;
	test
	return 0;
}

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

const int Max1 = 100005;
const int Max2 = 50005;
int S[Max1], T[Max2];
vector<int> a;

int Binary(int S[], int T[], int ns, int nt)
{
    int sum = 0;
    for(int i=0; i<nt; i++)
    {
        int left = 0;
        int right = ns;
        int mid;
        while(left<right)
        {
            mid = (left+right)/2;
            if(T[i]>S[mid])
            {
                left = mid+1;
            }
            else if(T[i]<S[mid])
            {
                right = mid;
            }
            else
            {
                sum++;
                break;
                //a.push_back(T[i]);
                //break;
            }
        }
    }
    return sum;
}
int main()
{
    int ns, nt;
    scanf("%d", &ns);
    for(int i=0; i<ns; i++)
        scanf("%d", &S[i]);
    scanf("%d", &nt);
    for(int i=0; i<nt; i++)
        scanf("%d", &T[i]);
    //sort(S, S+ns);
    int sum = Binary(S, T, ns, nt);
    printf("%d\n", sum);
    return 0;
}



Measured memory_bytes: 3784
n = int(input())
from collections import defaultdict
dic = defaultdict(list)

for i in range(n):
    a = int(input())
    for _ in range(a):
        x,y = map(int,input().split())
        dic[i].append((x-1,y))
    
# すき間の個数
ans = 0
for i in range(2 ** n):
    bit = [0] * n
    for j in range(n):
        if ((i >> j) & 1):
            bit[j] = 1
    
    for idx, b in enumerate(bit):
        if b == 1:
            for x,y in dic[idx]:
                if bit[x] != y:
                    break
            else:
                continue
            break
    else:
        ans = max(ans, sum(bit))

print(ans)
    
    
    

Measured memory_bytes: 3444
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn is_prime(x: i32) -> bool {
    for i in 2..x {
        if i * i > x {
            break;
        }
        if x % i == 0 {
            return false;
        }
    }
    true
}

fn main() {
    input! {
        x_: i32,
    }
    let mut x = x_;
    while !is_prime(x) {
        x += 1;
    }
    println!("{}", x);
}


Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n;
    cin>>n;
    int p[n];
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(p[i]==i+1){
            swap(p[i],p[i+1]);
            ans++;
        }
    }
    cout<<ans<<endl;
}


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

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    
    int ans = 0;
    int o = min(a, k);
    ans += o;
    k -= o;
    
    o = min(b, k);
    k -= o;
    
    o = min(c, k);
    k -= o;
    ans -= o;
    
    cout << ans;
}


Measured memory_bytes: 3632
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn add(a: &mut usize, b: &usize) -> () {
    *a += *b;
    *a %= 1000000007;
}

fn solve() {
    input!(
        n: usize,
        _k: usize,
    );

    let mut dp = vec![vec![vec![0usize; 2525]; 51]; 51];

    dp[0][0][0] = 1;


    for i in 0..50 {
        for j in 0..51 {
            for k in 0..2525 {
                if k + 2*j >= 2525 {
                    continue;
                }
                let tmp = dp[i][j][k] * j;
                add(&mut dp[i+1][j][k+2*j], &tmp);
                if j as i32 -1 >= 0 {
                    let tmp = dp[i][j][k] * j * j;
                    add(&mut dp[i+1][j-1][k+2*j], &tmp);
                }
                if j+1 < 51 {
                    let tmp = dp[i][j][k];
                    add(&mut dp[i+1][j+1][k+2*j], &tmp);
                }
                let tmp = dp[i][j][k] * j;
                add(&mut dp[i+1][j][k+2*j], &tmp);
                let tmp = dp[i][j][k];
                add(&mut dp[i+1][j][k+2*j], &tmp);
            }
        }
    }
    println!("{}", dp[n][0][_k]);
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 72060
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val s = sc.next()
    val k = sc.nextInt() - 1
    val ch = s[k]
    println(s.map { if (it == ch) it else '*' }.joinToString(""))
}

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

typedef long long ll;
#define mod 1000000007

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

void solve() {
    int n, k;
    cin>>n>>k;
    vector<int> dp(k+1, 0);
    dp[0] = 0;
    vector<int> a(n);
    for(auto& e:a){
        cin>>e;
    }
    // debug(n, k, a);
    for(int i = 0; i < n; i++){
        dp[a[i]] = 1;
    }
    // debug("f");
    for(int i = 0; i <= k; i++){
        if(dp[i] == 1){
            for(int j = 0; j < n; j++){
                int ind = i+a[j];
                if(ind <= k && dp[ind] != 1){
                    dp[ind] = 0;
                }
            }
        }
        else{
            for(int j = 0; j < n; j++){
                int ind = i+a[j];
                if(ind <= k){
                    dp[ind] = 1;
                }
            }
        }
    }
    if(dp[k])
        cout<<"First\n";
    else
        cout<<"Second\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    // pre();
    while (t--)
        solve();

    return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
	int i,j,k,n,count=0;
	cin >>n>>k;
	vector<int> p(n);
	for(i=0;i<n;i++)cin >>p.at(i);
	
	sort(p.begin(), p.end());
	for(i=0;i<k;i++)count+=p.at(i);
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			String line = sc.next();
			if (line.equals("0")){
				break ;
			}
			int sum = 0;
			for(int i = 0; i < line.length(); i++){
				sum += (line.charAt(i) - '0');
			}
			System.out.println(sum);
		}
	}
}


Measured memory_bytes: 26252
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> value(4),tea(4);
    for(int i=0; i<4; i++){
        cin >> value[i];
    }
    for(int i=0; i<4; i++){
        cin >> tea[i];
    }
    int ans=1000000;
    int temp;
    for(int i=0; i<=n; i++){
        for(int j=0; j<=n; j++){
            for(int k=0; k<=n; k++){
                for(int l=0; l<=n; l++){
                    if(i*tea[0]+j*tea[1]+k*tea[2]+l*tea[3]>=n)ans=min(ans,i*value[0]+j*value[1]+k*value[2]+l*value[3]);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3108
a,b=gets.split.map(&:to_i)
puts "100 100"

fs = []
100.times{|i| fs[i] = [i < 50] * 100}

i,j=0,0
(b-1).times{
  fs[i][j]=false
  j+=2
  if j>=100
    j=0
    i+=2
  end
}
i,j=0,0
(a-1).times{
  fs[51+i][j]=true
  j+=2
  if j>=100
    j=0
    i+=2
  end
}

100.times{|i|puts fs[i].map{|b|b ? ".":"#"}.join("")}


Measured memory_bytes: 2044
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<ctime>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<bitset>
#define ll long long 
#define ull unsigned long long 
#define mem(a) memset(a,0,sizeof(a)) 
#define fio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define EXIT exit(0)
#define all(a) (a).begin(),(a).end()
//loop 
#define For(i,a,b) for(int i=(a);i<(b);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define cFor(i,a,b) for(int i=(a);i>(b);i--)
#define cFOR(i,a,b) for(int i=(a);i>=(b);i--)
#define lFor(i,a,b) for(ll i=(a);i<(b);i++)
#define lFOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define lcFor(i,a,b) for(ll i=(a);i>(b);i--)
#define lcFOR(i,a,b) for(ll i=(a);i>=(b);i--)
//debug
#define dbg(a) cout<<#a<<"="<<a<<endl
#define inthis cout<<"--------this\n"
//operator
#define pb push_back
#define ins insert
#define era erase
#define fin find 
//pair
#define pr pair
#define mkp(a,b) make_pair(a,b)
#define fi first
#define se second
//vector
#define vec vector
#define vi vector<int>
#define vii vector<vector<int>>
//map
#define mp map
////map int
#define mpii map<int,int>
#define mpib map<int,bool>
#define mpic map<int,char>
#define mpis map<int,string>
#define mpil map<int,long long>
////map long long 
#define mpll map<long long,long long>
#define mplb map<long long,bool>
#define mplc map<long long,bool>
#define mpls map<long long,string>
#define mpli map<long long,int>
////map char
#define mpci map<char,int>
#define mpcb map<char,bool>
#define mpcl map<char,long long>
////map string
#define mpsi map<string,int>
#define mpsb map<string,bool>
#define mpsl map<string,long long>
//iterator
#define ivec(a) vector<a>::iterator
#define iset(a) set<a>::iterator 
#define imp(a,b) map<a,b>::iterator

using namespace std;
/*
const int maxsize=
struct edge{
	int nod,nxt;
			
}e[maxsize<<1];
int nume=0,pa[maxsize],head[maxsize];
void add(int u,int v){
	e[++nume].nod=v;
	e[nume].nxt=head[u];
	head[u]=nume;
}
void init(){
	
}
bool vis[maxsize];
void bfs(){
	
}
void dfs(){

}
*/
const int inf=7+1e9,maxn=5+1e6;
ll dp[maxn];
ll qpow(ll a,ll p,ll mod){
	ull res=1;a%=mod;
	while(p){
		if(p&1)
			res=res*a%mod;
		a=a*a%mod;
		p>>=1;	
	}
	return res;
}
ll A=1,B=1,N=1,NA=1,NB=1;
int main(){
	fio;
	int n,a,b;
	cin>>n>>a>>b;
	ll ans=qpow(2,n,inf);
	FOR(i,2,a)
		A=A*i%inf;
	FOR(i,2,b)
		B=B*i%inf;	
	FOR(i,1,a)
		NA=NA*(n-i+1)%inf;	
	FOR(i,1,b)
		NB=NB*(n-i+1)%inf;	
	ans-=NA*qpow(A%inf,inf-2,inf)%inf;
	ans-=NB*qpow(B%inf,inf-2,inf)%inf;
	ans=(ans+inf*2)%inf;
	cout<<ans-1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#define INF 1000000000000
using namespace std;
using ll = long long;
int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    cout << a*b/2 << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>

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

using namespace std;

const double EPS=1e-8;
const double INF=1e77;

struct point{
	double x,y;
	point():x(0),y(0){}
	point(double x,double y):x(x),y(y){}
	point operator-(const point &a)const{ return point(x-a.x,y-a.y); }
	bool operator==(const point &a)const{ return abs(x-a.x)<EPS && abs(y-a.y)<EPS; }
};

inline double cross(const point &a,const point &b){ return a.x*b.y-a.y*b.x; }

enum{CCW=1,CW=-1,ON=0};
inline int ccw(const point &a,const point &b,const point &c){
	double rdir=cross(b-a,c-a);
	if(rdir> EPS) return CCW;
	if(rdir<-EPS) return CW;
	return ON;
}

inline double area(const point &a,const point &b,const point &c){
	return abs(cross(b-a,c-a))/2;
}

int n;
point P[40];

int K;
double ans;
point Q[40],Q_ans[40];
bool vis[40];

int ub;
void dfs(int i,double a){ // a: area of the polygon Q[0...i-1]
	ub++;
	if(ub>10000) return; // テヲツ慊?ゥツ?ゥティツァツ」テ」ツ?凝」ツ?ゥテ」ツ??」ツ?凝」ツ?古ァツ「ツコテ、ツソツ。テ」ツ?ァテ」ツ?催」ツ?ェテ」ツ?湘」ツ?ヲテ」ツつづ・ツ債?・ツ按?」ツ?淌」ツ?湘」ツ?陛」ツつ禿ィツェツソテ」ツ?ケテ」ツ?淌」ツつ嘉ヲツ可禿」ツ?。テ・ツ按?」ツつ?..

	if(i==K){
		if(a<ans){
			ans=a;
			memcpy(Q_ans,Q,sizeof Q);
		}
		return;
	}

	// pruning
	// テ・ツ?凖ィツ」ツ愿ァツつケテ」ツ?ョテヲツ閉ーテ」ツ?古ィツカツウテ」ツつ甘」ツ?ェテ」ツ?湘」ツ?ェテ」ツ?」テ」ツ?淌」ツつ嘉ヲツ可禿」ツ?。テ・ツ按?」ツつ?
	int m=0,next[40]; // next candidates
	rep(j,n){
		if(!vis[j]
		&& ccw(Q[i-2],Q[i-1],P[j])==CCW
		&& ccw(Q[i-1],P[ j ],Q[0])==CCW) next[m++]=j;
	}
	if(m<K-i) return;

	// pruning
	// テゥツ敖「テァツゥツ催」ツ?古、ツサツ甘」ツ?セテ」ツ?ァテ」ツ?ョテヲツ慊?・ツーツ湘」ツつ津ィツカツ?」ツ?暗」ツ?淌」ツつ嘉ヲツ可禿」ツ?。テ・ツ按?」ツつ?
	double da=INF;
	rep(j,m) da=min(da,area(Q[i-1],P[next[j]],Q[0]));
	if(ans<a+da+EPS) return;

	double res=INF;
	rep(j,m){
		Q[i]=P[next[j]];
		vis[next[j]]=true;
		dfs(i+1,a+area(Q[0],Q[i-1],Q[i]));
		vis[next[j]]=false;
	}
}

int main(){
	scanf("%d",&n);
	rep(i,n) scanf("%lf%lf",&P[i].x,&P[i].y);

	int q; scanf("%d",&q);
	int k[40],perm[40];
	rep(i,q) scanf("%d",k+i);
	{
		pair<int,int> tmp[40];
		rep(i,q) tmp[i]=make_pair(k[i],i);
		sort(tmp,tmp+q);
		rep(i,q){
			k[i]=tmp[i].first;
			perm[tmp[i].second]=i;
		}
	}

	int k_ans[40][40];
	rep(i,n) k_ans[i][0]=-1; // NA
	// k テ」ツ?ョテ・ツーツ湘」ツ?陛」ツ??ゥツ??」ツ?ォテ・ツ?ヲテァツ青?」ツ?療」ツ?ヲテ」ツ??」ツ?? テ、ツクツ?・ツコツヲ NA テ」ツ?ォテ」ツ?ェテ」ツ?」テ」ツ?淌」ツつ嘉」ツ?敕」ツつ古、ツサツ・テゥツ卍催」ツ?ッテ・ツ?ィテゥツδィ NA
	rep(i,q){
		K=k[i];

		ans=INF;
		rep(j,n) rep(k,n) if(j!=k) { // fix an edge of the polygon
			Q[0]=P[j];
			Q[1]=P[k];
			rep(l,n) vis[l]=false;
			vis[j]=vis[k]=true;

			// pruning
			// テヲツ伉偲」ツつ嘉」ツ?凝」ツ?ォテ」ツδ?」ツδ。テ」ツ?ェテァツつケテ」ツ?ッテヲツ慊?・ツ按敕」ツ?凝」ツつ嘉ィツェツソテ」ツ?ケテ」ツ?ェテ」ツ??
			rep(l,n) if(ccw(Q[0],Q[1],P[l])!=CCW || ccw(P[l],Q[0],Q[1])!=CCW) vis[l]=true;

			ub=0;
			dfs(2,0);
		}

		if(ans>INF/2) break; // NA

		int j0=0;
		vector<int> seq(K);
		rep(j,K){
			seq[j]=find(P,P+n,Q_ans[j])-P;
			if(make_pair(Q_ans[j].y,Q_ans[j].x)<make_pair(Q_ans[j0].y,Q_ans[j0].x)) j0=j;
		}
		rep(j,j0){
			seq.push_back(seq[0]);
			seq.erase(seq.begin());
		}
		rep(j,K) k_ans[i][j]=seq[j];
	}

	rep(i,q){
		int idx=perm[i];
		if(k_ans[idx][0]==-1) puts("NA");
		else{
			rep(j,k[idx]) printf("%d%c",k_ans[idx][j]+1,j<k[idx]-1?' ':'\n');
		}
	}

	return 0;
}

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

int main(int argc, char const *argv[])
{
	int k, x; cin >> k >> x;
	if (k * 500 >= x) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
x=int(input())

count=0
a_max=min(x//500,a) #500玉の最大数
for i in range(a_max+1):#ループ数は+1　(0~max枚)
  # print("i:500円玉",i)
  b_max=min((x-500*i)//100,b) #全体から500円玉の値段を引いた、残りの100玉の枚数を考える
  # print("100円玉最大数",b_max)
  for j in range(b_max+1):
    # print("i,j",i,j)
    if (x-500*i-100*j)//50<=c:
      count+=1

print(count)
  

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long n,now=0,ans=0;
string s;
int main()
{
	cin>>n;
	cin>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='I')
		now++;
		else
		if(s[i]=='D')
		now--;
		ans=max(ans,now);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<set>
using namespace std;
typedef uint64_t ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
ll N, m;
int main() {
	ll x, k = 1;
	ll ans = 0;
	scanf("%lld", &N);
	vector<ll> a(N), b(N), c(N);
	vector<ll>co(N);
	rep(i, 0, N) scanf("%lld", &x),a[i] = x;
	rep(i, 0, N) scanf("%lld", &x), b[i] = x;
	rep(i, 0, N) scanf("%lld", &x), c[i] = x;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	rep(i, 0, N) {
		auto it = upper_bound(c.begin(), c.end(), b[i]);
		co[i] = c.end() - it;
	}
	for (int i = N - 1; i != 0; i--) {
		co[i - 1] += co[i];
	}
	rep(i, 0, N) {
		auto it = upper_bound(b.begin(), b.end(), a[i]);
		if(it != b.end())ans += co[it - b.begin()];
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 3328
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
 
#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)
 
#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
using namespace std;
 
const int MX = 407;
const ll INF = 1e18;
 
ll f[MX][MX];
int a[MX];
ll s[MX];
 
int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        s[i] = s[i - 1] + a[i];
    }
 
    for (int i = 1; i <= n; i++) {
        f[i][i] = 0;
    }
 
    for (int len = 2; len <= n; len++) {
        for (int l = 1; l + len - 1 <= n; l++) {
            int r = l + len - 1;
            f[l][r] = INF;
            for (int k = l; k < r; k++) {
                f[l][r] = min(f[l][r], f[l][k] + f[k + 1][r] + s[r] - s[l - 1]);
            }
        }
    }
 
    cout << f[1][n] << "\n";
    return 0;
}


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

using namespace std;

int main (void) {
    int N;
    cin >> N;
    int a, x, y;
    vector<vector<pair<int, int>>> testimony(N); /* 各人の証言を格納する */
    for ( int i=0; i<N; i++ ) {
        cin >> a;
        for ( int j=0; j<a; j++ ) {
            /* 人iのj個目の証言 */
            cin >> x >> y;
            testimony.at(i).push_back(make_pair(x, y));
        }
    }

    /* i番目の人が正直者と仮定するときに変数 people の
     * i bit目を1とする。
     * 全員が正直者という仮定から始めて、全員の証言に矛盾
     * がなくなるまで全組み合わせを探索する。 */
    int ans = 0;
    bool consistency;
    for ( int people = (1<<N)-1; people>=0; people-- ) {
        consistency = true;
        for ( int i=0; i<N; i++ ) {
            /* すべての正直者と仮定した人の証言をチェックする */
            if ( (people >> i) & 1 ) {
                for ( pair<int, int> itr : testimony.at(i) ) {
                    if ( itr.second == 1 ) {
                        /* itr.first番目の人は正直者でなかったら矛盾 */
                        if ( !((people >> (itr.first - 1)) & 1) )
                            consistency = false;
                    }
                    if ( itr.second == 0 ) {
                        /* itr.first番目の人は不親切でなかったら矛盾 */
                        if ( (people >> (itr.first - 1)) & 1 )
                            consistency = false;
                    }
                }
            }
        }
        /* 矛盾がなければbitの値が1の数を数える */
        if ( consistency ) {
            int tmp = 0;
            for ( int i=0; i<N; i++ ) {
                if ( (people >> i) & 1 )
                    tmp++;
            }
            ans = max(ans, tmp);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
A=int(input())
B=int(input())
C=int(input())
X=int(input())

ans=0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i+100*j+50*k==X:
                ans+=1

print(ans)

Measured memory_bytes: 39536
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int num = Integer.parseInt(sc.nextLine());
        if ((num / 100) == 1){
            num = num + 800;
        }else{
            num = num - 800;
        }
        if (((num / 10) % 10) == 1){
            num = num + 80;
        }else{
            num = num - 80;
        }
        if ((num % 10) == 1){
            num = num + 8;
        }else{
            num = num - 8;
        }
    
        System.out.println(num);

    }
}

Measured memory_bytes: 21844
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  int s, w;
  cin >> s >> w;
  if (w >= s) {
    cout << "unsafe" << endl;
  } else 
    cout << "safe" << endl;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

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

int main() {
  int N, M;
  cin >> N >> M;

  int s, c;
  vector<int> sc(N, -1);

  bool flag = true;

  rep(i, 0, M) {
    cin >> s >> c;

    if (sc[s-1] == -1) { // 未指定
      sc[s-1] = c;
    } else {
      if (sc[s-1] != c) {
        flag = false;
        break;
      }
    }
  }

  if (!flag) {
    cout << -1 << endl;
    return 0;
  }

  if (N == 1) {
    if (M == 0) {
      cout << 0 << endl;
    } else {
      cout << sc[0] << endl;
    }
    return 0;
  }

  if (N == 2) {
    rep(ans, 10, 99) {
      int ten = ans / 10;
      int one = ans % 10;
      if ((ten == sc[0] || sc[0] == -1) && (one == sc[1] || sc[1] == -1)) {
        cout << ans << endl;
        return 0;
      }
    }

    cout << -1 << endl;
    return 0;
  }

  if (N == 3) {
    rep(ans, 100, 999) {
      int hun = ans / 100;
      int ten = (ans % 100) / 10;
      int one = (ans % 100) % 10;
      if ((hun == sc[0] || sc[0] == -1) && (ten == sc[1] || sc[1] == -1) && (one == sc[2] || sc[2] == -1)) {
        cout << ans << endl;
        return 0;
      }
    }

    cout << -1 << endl;
    return 0;
  }
};


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as C
import Data.List

main = sol <$> C.getLine >>= print

sol s = fst . C.foldl' cnt (0, C.head s) $ C.tail s 

cnt (n,c) c'
  | c == c'   = (n, c')
  | otherwise = (n+1, c')

Measured memory_bytes: 7548
#include<stdio.h>
#include<stdlib.h>

int compare_int(const void *a,const void *b){
    return *(int*)a - *(int*)b;
}

int main(void){
    int N;

    scanf("%d",&N);

    int n=N/3;
    int na=N%3;

    
    int a[N];
    int i;
    
    for(i=0;i<N;i++){
        scanf("%d",&a[i]); 
    }

    qsort(a,sizeof(a)/sizeof(int),sizeof(int),compare_int);

if(a[0]==a[N-1]&&a[0]==0){
    printf("Yes\n");
    return 0;
}

if(na!=0){
    printf("No\n");
    return 0;
}


    int s=a[0];
    int t=a[n];
    int l=a[N-1];
    int sa=t^l;

    if(s!=sa){
        printf("No\n");
        return 0;
    }

    if(a[0]==0&&a[n-1]==0&&a[n]==a[N-1]){
        printf("Yes\n");
    }else if(a[0]!=0&&a[0]==a[n-1]&&a[n]==a[2*n-1]&&a[2*n]==a[3*n-1]&&a[0]!=a[n]&&a[n]!=a[N-1]){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
   
    return 0;
}

Measured memory_bytes: 892
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

#define MAXN 2001

int n;
int a[MAXN*2], c[MAXN*2];
int dp[MAXN][MAXN];
int cost[2][MAXN][MAXN];

int input() {
	if (scanf("%d", &n) < 0) return 0;
	for (int i=0; i<2*n; i++) {
		char x;
		scanf(" %c %d", &x, &a[i]);
		a[i]--;
		c[i] = (x=='B');
	}
	return 1;
}

void init() {
}

long solve() {
	memset(cost, 0, sizeof(cost));
	for (int p=0; p<2*n; p++) {
		int i = a[p];
		int k = c[p];
		int d = 0;
		for (int q=0; q<p; q++) {
			int j = a[q];
			if (c[q] == k) d += j>i;
			else cost[k][i][j]++;
		}
		cost[k][i][n] = d;
		for (int j=n-1; j>=0; j--)
			cost[k][i][j] += cost[k][i][j+1];
	}
	//for (int k=0; k<2; k++) printg((int*)cost[k], n+1, n+1, MAXN);
	dp[0][0] = 0;
	for (int i=0; i<=n; i++) {
		for (int j=0; j<=n; j++) if (i||j) {
			int cc = INT_MAX;
			if (i) cc = min(cc, dp[i-1][j] + cost[0][i-1][j]);
			if (j) cc = min(cc, dp[i][j-1] + cost[1][j-1][i]);
			dp[i][j] = cc;
		}
	}
	//printg((int*)dp, n+1, n+1, MAXN);
	return dp[n][n];
}

void output(long ans) {
	printf("%ld\n", ans);
}

void cleanup() {
}

int main() {
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 47232
#include <iostream>

int main(void) {
  int n;
  int res=0;
  std::string s;
  std::cin >> n;
  std::cin >> s;
  int alphabet[26] = {};
  for(int xend=0;xend < n;xend++) {
    int tmp=0;
    for (int k=0;k < 26;k++) alphabet[k] = 0;
    for(int itr=0;itr <= xend;itr++) {
      for(int ybgn=xend+1;ybgn < n;ybgn++) {
        if(s[itr] == s[ybgn] && alphabet[s[itr]-'a']==0) alphabet[s[itr]-'a'] = 1;
      }
    }
    for (int k=0;k < 26;k++) tmp += alphabet[k];
    res = (tmp > res) ? tmp : res;
  }
  std::cout << res << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef pair <int,int> P;
vector <P> G[500];
int mem[500],used[500];

int saiki(int ima,int cost){
  
  if(used[ima]) return cost+mem[ima];
  used[ima]=1;

  int res=cost;
  for(int i=0;i<G[ima].size();i++)
    res=max(res,saiki(G[ima][i].f,cost+G[ima][i].s));

  mem[ima]=res-cost;
  return res;
}


int main(){
  int n,m;
  cin>>n>>m;
  int flg[501]={};

  for(int i=0,a,b,c;i<m;i++){
    cin>>a>>b>>c;
    G[a].push_back(P(b,c));
    flg[b]=1;
  }
  int start=-1;
  for(int i=0;i<n;i++)if(flg[i]==0) start=i;
  cout << saiki(start,0)<<endl;

  return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <string.h>
#include <string>

using namespace std;

bool get_odd(long long a[], int n) {
    for (int i=0; i<n; i++) {
        if (a[i] % 2 != 0) return true;
    }
    return false;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    long long a[n];
    for (int i=0; i<n; i++) cin >> a[i];
    
    int cnt = 0;
    while (!get_odd(a, n)) {
        for (int i=0; i<n; i++) a[i] /= 2;
        cnt++;
    }
    cout << cnt << '\n';
}

Measured memory_bytes: 3592
import math as M
def R(A): return (A[0]**2+A[1]**2)**.5
def I(i): return [map(int,raw_input().split()) for _ in [0]*i]
def C(a,b): return a>b or abs(a-b)<1e-6
def f(e1):
  tx,ty,sx,sy=e1
  x=[]
  st=[tx-sx,ty-sy]; rst=R(st)
  for e2 in WP:
    wx,wy,r=e2
    wt=[tx-wx,ty-wy]; rwt=R(wt)
    sw=[wx-sx,wy-sy]; rsw=R(sw)
    F=[rwt<r,rsw<r]
    if F==[1,0] or F==[0,1]: return 0
    elif F==[0,0]:
      a=M.pi/2-M.acos(r/rsw)
      b=M.acos(round((sw[0]*st[0]+sw[1]*st[1])/rsw/rst,4))
      if C(a,b) and C(rst**2,rsw**2-r**2): return 0
  return 1

while 1:
  n=input()
  if n==0: break
  WP=I(n)
  P=I(input())
  for e in P: print ["Safe","Danger"][f(e)]

Measured memory_bytes: 4576
#include <iostream>
#include <stdio.h>
using namespace std;
bool checkpalin(string s)
{
    int k = s.length();
    for (int i = 0; i <= (k/2); i++) if (s[i] != s[k-1-i]) return false;
    return true;
}
bool check(string s)
{
    if (!checkpalin((s))) return false;
    s = " " + s;
    int n = s.length();
    if (!checkpalin(s.substr(1, (n-1)/2))) return false;
    if (!checkpalin(s.substr((n+3)/2, n-((n+3)/2)+1))) return false;
    return true;
}
string s;
int main()
{
    //freopen("test.inp","r", stdin);
    cin >> s;
    if (check(s)) cout << "Yes"; else cout <<"No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int n,l;
vector<int> a;


void show(int m){
  FOR(i,1,m){
    cout<<i<<endl;
  }
  for(int i=n-1;i>m;i--){
    cout<<i<<endl;
  }

  cout<<m<<endl;
}


bool search(){

  rep(i,n-1){
    if(a[i]+a[i+1]>=l){
      cout<<"Possible"<<endl;
      show(i+1);
      return false;
    }
  }

  return true;
}

int main(){

  cin>>n>>l;

  a.resize(n);
  rep(i,n){
    cin>>a[i];
  }

  if(search()){
      cout<<"Impossible"<<endl;
  }

  return 0;
}


Measured memory_bytes: 1280
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
k=int(input())
ans=0
for i in range(1,k+1):
  for u in range(1,k+1):
    for y in range(1,k+1):
      ans+=gcd(i,u,y)
print(ans)



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

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x*10)+(ch^48);
	return x * f;
}

int n;

int main() {
	int i, p = 0;

	n = read();
	for(i = 1; i <= n; i++) {
		int x = read();
		if(x & 1) p++;
	}
	if(p & 1) printf("NO\n");
	else printf("YES\n");
	return 0;
}


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

using namespace std;

using llint = long long;

const int MAXN = 3e3+3;

int n, a[MAXN];
llint mem[MAXN][MAXN];
bool solved[MAXN][MAXN];

llint dp(int l, int r, bool t) {
  if (l > r) return 0;
  
  llint &ret = mem[l][r];
  if (solved[l][r]) return ret;
  solved[l][r] = 1;

  ret = t == 0 ? 
    max(dp(l+1, r, !t)+a[l], dp(l, r-1, !t)+a[r]) :
    min(dp(l+1, r, !t)-a[l], dp(l, r-1, !t)-a[r]);
  return ret;
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
  }

  printf("%lld\n", dp(0, n-1, 0));
  return 0;
}


Measured memory_bytes: 78464
public class Main {
	public static void main(String[] args) {
		java.util.Scanner sc = new java.util.Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a == 1 || b == 1) {
			if (a == b) {
				System.out.println("Draw");
			}else if (a < b) {
				System.out.println("Alice");
			}else {
				System.out.println("Bob");
			}
		}else {
			if (a < b) {
				System.out.println("Bob");
			} else if (a > b) {
				System.out.println("Alice");
			} else {
				System.out.println("Draw");
			}
		}
	}
}

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

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

  if(A>=13)
    cout << B << endl;
  else if(A>=6)
    cout << B/2 << endl;
  else
    cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
X=int(input())

if X==2:
  print(2)
  sys.exit()

for i in range(2,X):
  if X%i==0:
    break
else:
  print(X)
  sys.exit()

while True:
  X+=1
  for i in range(2,X):
    if X%i==0:
      break
  else:
    print(X)
    sys.exit()
  
  
  

Measured memory_bytes: 8956
#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 main() {
    
    int n;
    ll k;
    cin>>n>>k;
    map<int, ll>big;
    rep(i,n){
        int pa;
        ll pb;
        cin>>pa>>pb;
        big[pa]+=pb;
    }

    ll cnt = 0;
    for(int i=1;i<=100000;i++){
        cnt+=big[i];
        if(cnt>=k){
            cout<< i <<endl;
            return 0;
        }
    }
    
	return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl;
#define mod 1000000007
#define pb push_back
#define endl '\n'



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

	int n;
	cin>>n;

	int a[n];
	int b[n];

	string ini="";
	string first="";
	string second="";

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

	for(auto it:a)
	{
		first+=(it+'0');
	}

	for(auto it:b)
	{
		second+=(it+'0');
	}

	for(int i=1;i<=n;i++)
	{
		ini+=(i+'0');
	}

	int ac = 0;
	int bc =0;
	int count = 1;
	while(next_permutation(ini.begin(),ini.end()))
	{
		if(ini == first)
		{
			ac = count;
			break;
		}
		count++;
	}

	count = 1;
	sort(ini.begin(), ini.end());
	while(next_permutation(ini.begin(),ini.end()))
	{
		if(ini == second)
		{
			bc = count;
			break;
		}
		count++;
	}

	cout<<(abs(ac-bc))<<endl;



	

}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
typedef long long int LL;
const int INF=1e9+7;
int t[2005];
bool notuse[2005];
int number[2005];
int rest[2005];
vector<pair<int,int> > v1;

int check(int f,int n,int m,int q){
	int a,b,c;
	int i,j,k;
	int s=0;
	for(i=0,j=0,k=0;i<n;i++){
		if(notuse[i])number[i]=-1,rest[j]=k,j++,k=0;
		else number[i]=j,k++;
	}
	rest[j]=k;
	for(i=0,j=f;i<q;j++){
		if(j>=n)return -1;
		a=number[v1[j].second];
		if(a==-1)continue;
		if(rest[a]>=m)s=j,rest[a]--,i++;
	}
	return (v1[s].first-v1[f].first);
}

int main(){
	int n,m,q;
	int i,j,k;
	int a;
	int s=0;
	cin>>n>>m>>q;
	for(i=0;i<n;i++){
		cin>>t[i];
		v1.push_back(make_pair(t[i],i));
	}
	sort(v1.begin(),v1.end());
	s=v1[q-1].first-v1[0].first;
	for(i=0;i<n-q;i++){
		notuse[v1[i].second]=true;
		a=check(i+1,n,m,q);
		if(a==-1)break;
		if(a<s)s=a;
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 384