akhauriyash/Code-Regression huggingface dataset:
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn enum_pat(x: i64, n: usize, m: i64, cur: &mut Vec<i64>) -> Vec<Vec<i64>>{
    if cur.len() == n{
        return vec![cur.clone()];
    }

    let mut res = vec![];

    for i in x..=m{
        cur.push(i);
        let mut tmp = enum_pat(i, n, m, cur);
        res.append(&mut tmp);
        cur.pop();
    }

    return res;
}

fn main(){
    let line = read_as_vec::<usize>();
    let (n, m, q) = (line[0], line[1] as i64, line[2]);

    let mut x: Vec<(usize, usize, i64, usize)> = vec![];
    for _ in 0..q{
        let line = read_as_vec::<usize>();
        x.push((line[0]-1, line[1]-1, line[2] as i64, line[3]));
    }

    let mut tmp = vec![];
    let pats: Vec<Vec<i64>> = enum_pat(1, n, m, &mut tmp);

    let mut ans = 0;
    for pat in pats{
        let mut cur_ans = 0;
        for (a, b, c, d) in &x{
            if pat[*b] - pat[*a] == *c{
                cur_ans += d;
            }
        }
        ans = cmp::max(ans, cur_ans);
    }

    println!("{}",  ans);
}


Measured memory_bytes: 13160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n%10==9 | n/10==9){
			System.out.println("Yes");
		} else{	
		System.out.println("No");
		}
		}
	}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

void solve() {
    int n;
    cin >> n;

    ll ans = 0;
    vector<vector<ll>> l(n + 1), r(n + 1);

    rep(i, n) {
        ll a, b, c;
        cin >> a >> b >> c;
        ans += min(b, c);
        if(b < c) r[a].push_back(c - b);
        if(b > c) l[a - 1].push_back(b - c);
    }

    priority_queue<ll> pq;
    FORR(i, n) {
        for(ll x : l[i])
            pq.push(x);
        if(!pq.empty()) {
            ans += pq.top();
            pq.pop();
        }
    }

    while(!pq.empty())
        pq.pop();

    rep(i, n) {
        for(ll x : r[i])
            pq.push(x);
        if(!pq.empty()) {
            ans += pq.top();
            pq.pop();
        }
    }

    cout << ans << "\n";
}

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

    int t;
    cin >> t;
    while(t--) {
        solve();
    }

    return 0;
}

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


int main(){
	string s1,s2;
	cin>>s1>>s2;
	int len = 0;
	int n = s1.length();
	rep(i,n){
		if(s1[i] == s2[i]){
			len++;
		}
	}
	cout<<len<<endl;


	return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin>>N;
	vector<int> A(N),LMA(N,-INF),RMI(N,INF);
	rep(i,0,N)
	{
		cin>>A[i];
		A[i]--;
	}
	rep(i,0,N)
	{
		chmax(LMA[i],A[i]);
		if(0<i)chmax(LMA[i],LMA[i-1]);
	}
	rrep(i,0,N)
	{
		chmin(RMI[i],A[i]);
		if(i<N-1)chmin(RMI[i],RMI[i+1]);
	}

	bool ok=true;
	rep(i,0,N-1)
	{
		if(A[i]==i&&A[i+1]==i+1)
		{
			if(LMA[i]>A[i]||RMI[i+1]<A[i+1])
			{
				ok=false;
			}
		}
		if(A[i]!=i&&A[i+1]!=i+1)
		{
			if(RMI[i]<A[i]||LMA[i+1]>A[i+1])
			{
				ok=false;
			}
		}
		if(A[i]>i&&LMA[i]>A[i])
		{
			ok=false;
		}
		if(A[i]<i&&RMI[i]<A[i])
		{
			ok=false;
		}
	}

	if(ok)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,k;
signed main(){
    cin>>n>>k;
    int cnt=0;
    while(n){
        n/=k;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int H, W, h, w;
    cin>>H>>W>>h>>w;
    cout<<H * W - H * w - h * W + h * w<<endl;

    return 0;
}


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

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  int A,B;
  A=x-a,B=x-b;
  if(A<0)
    A*=-1;
  if(B<0)
    B*=-1;
  if(A<B)
    cout << "A" << endl;
  else
    cout << "B" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>=k;i--)
int main(){
    long long a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>=k){
        cout<<k<<endl;
    }
    else if(a+b>=k){
        cout<<a<<endl;
    }
    else{
        cout<<2*a+b-k<<endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n-1;i>s;i--)
#define rep_re(i,s,n)for(ll i = n-1;i>=s;i--)
ll MOD = 998244353;

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

	if (x > a* a* b / 2)//half of the volums
	{
		theta = atan(2 * (a * a * b - x) / (a * a * a));
	}
	else 
	{
		theta = atan((a * b * b) / (2 * x));
	}

	double PI = 3.1415926535;

	printf("%.10f", (theta*180)/PI);

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    map<int,int>mp;
    rep(i,n){
        int a; cin>>a;
        mp[a]++;
    }
    for(auto&p:mp)p.second--;
    int cnt=0;
    for(auto&p:mp){
        cnt+=p.second;
    }
    int ans=0;
    if(cnt%2==0)ans=n-cnt;
    else ans=n-cnt-1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
constexpr Int MOD = 1e9 + 7;
int main()
{
    int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    Int all = 1, odd = 1;
    for (auto a : A) {
        all *= 3;
        odd *= (a % 2 ? 1 : 2);
    }
    cout << all - odd << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Arrays;
public class Main{
    private static int euclid(int m, int n) {
        if(n==0){
            return m;
        }
        else{
            return euclid(n, m%n);
        }
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int result = 0;
 
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= n; j++) {
                for(int k = 1; k <= n; k++) {
                    result += euclid(j,euclid(k,i));
                }
            }
        }
        System.out.println(result);
    


    }
}

Measured memory_bytes: 27164
#include"iostream"
#include"cstdio"
#include"cmath"
#include"cstring"
#include"algorithm"
#include"stack"
#include"queue"
using namespace std;

#define read(x) scanf("%d",&x)
#define readl(x) scanf("%lld",&x)
#define ll long long 
#define ull unsigned long long
#define MAXN 5005 

ll n,k;
int p[MAXN],c[MAXN];
int po[MAXN][MAXN];
int to[MAXN];
ll maxn[MAXN][MAXN];
ll sum[MAXN][MAXN];
ll ans=0;
int maxx=-2147483647;

int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>p[i];
	for(int i=1;i<=n;i++) cin>>c[i],maxx=max(maxx,c[i]);
	for(int i=1;i<=n;i++)
	{
		int cnt=0;
		int now=i;
		po[i][0]=i;
		while(1)
		{
			if(cnt&&now==i) break;
			po[i][++cnt]=p[now];
			now=p[now];
			to[i]++;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=to[i];j++)
		{
			maxn[i][j]=max(maxn[i][j-1],sum[i][j-1]+c[po[i][j-1]]);
			sum[i][j]=sum[i][j-1]+c[po[i][j-1]];
		}
	}
//	for(int i=1;i<=n;i++)
//	{
//		for(int j=1;j<=to[i];j++) cout<<maxn[i][j]<<" ";
//		cout<<endl;
//	}
	for(int i=1;i<=n;i++)
	{
		ll uy=k/to[i],ux=k%to[i];
		ll now;
		if(uy>=1)
		{
			now=max(sum[i][to[i]]*uy+maxn[i][ux],sum[i][to[i]]*(uy-1)+maxn[i][to[i]]);
			now=max(now,maxn[i][to[i]]);
		}
		else
		{
			now=maxn[i][k];
		}
		ans=max(ans,now);
	}
	if(maxx<=0) cout<<maxx<<endl;
	else cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 492352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)
 
using namespace std;
 
typedef long long ll;
 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	int n;
	cin >> n;
 
	queue<int> a[n];
	rep(i, n) rep(j, n-1){
		int x;
		cin >> x;
		x--;
		a[i].push(x);
	}
 
	queue<int> q;
	rep(i, n) q.push(i);
 
	int cnt = 0;
	bool updated = true;
 
	queue<int> q2;
	while(updated){
		updated = false;
		vector<bool> used(n, false);
		while(q.size() > 0){
			int i = q.front();
			q.pop();
			if(!used[i] && !a[i].empty()){
				int j = a[i].front();
				if(!used[j] && !a[j].empty() && a[j].front() == i){
					// cout << cnt << "," << i << "," << j << endl;
					updated = true;
					a[i].pop();
					a[j].pop();
					q2.push(i);
					q2.push(j);
					used[i] = true;
					used[j] = true;
				}
			}
		}
 
		if(updated) cnt++;
		swap(q, q2);
	}
 
	rep(i, n){
		if(!a[i].empty()){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << cnt << endl;
}

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

int main(){
	int n, m;
  	cin >> n >> m;
  
  	if(m == n) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 200009
using namespace std;
typedef long long ll;
int main()
{
//    freopen("in.txt", "r", stdin);

    int a,b,c,d;
    cin>>a>>b>>c>>d;

    bool fr=1;
    while(true)
    {
        if(fr)
        {
            c-=b;
            if(c<=0)
            {
                puts("Yes");
                return 0;
            }
            fr=0;
        }
        else
        {
            a-=d;
            if(a<=0)
            {
                puts("No");
                return 0;
            }
            fr=1;
        }
    }
//    main();

    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
double pi = 3.1415926535;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    int m,d;
    cin >> n >> m >> d;
    int x = (n-d)*2;
    if(d==0) x/=2;
    double ans = (double)x*((double)m-1);
    ans /= ((double)n*(double)n);
    printD(ans);
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


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

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

//テ」ツδ榲」ツつッテ」ツδュテ・ツョツ堙ァツセツゥ
#define ALL(v) (v).begin(),(v).end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); ++i)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define SORT(x) sort(begin(x),end(x))
#define SELECT_SORT(x, n) sort(begin(x),begin(x)+n)
#define SWAP(type, a, b) do {type tmp = a; a = b; b = tmp;} while (0)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))

//テ・ツョツ堙ヲツ閉ー
#define INF 2000000000000
#define MAX 10

//DEBUGテァツ板ィ
#define BAR() cout << "----------------------------" << endl;
#define DUMP(v) (cerr << #v << ": " << v << endl)
#define PRINT(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

int main()
{
	int n, m;
	vector<int> log;
	while(true){
		cin >> n >> m;
		if(!n && !m){break;}
		vector<int> log(n+m+1);
		log[0] = 0;
		rep(i, n+m){
			cin >> log[i+1];
		}
		SORT(log);
		//PRINT(log);
		int ans=0;
		REP(i, 1, n+m+1){
			ans = max(log[i]-log[i-1],ans);
			//DUMP(ans);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1292
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf=1<<29;
const int M=26;

int n;
string s;

int dp[200001][M+1];

int main(){
	cin>>s;
	n=s.size();
	for(int i=0;i<=n;i++) fill(dp[i],dp[i]+M+1,inf);
	map<int,int> m;
	int res=inf,S=0;
	dp[0][M]=0;
	m[0]=0;
	for(int i=0;i<n;i++){
		int c=s[i]-'a';
		S^=1<<c;
		dp[i+1][M]=dp[i][c];
		for(int j=0;j<M;j++){
			int T=S^(1<<j);
			if(m.find(T)!=m.end()){
				int I=m[T];
				for(int k=0;k<=M;k++) dp[i+1][j]=min(dp[i+1][j],dp[I][k]+(k!=M||I==0?1:0));
			}
		}
		m[S]=i+1;
	}
	for(int i=0;i<=M;i++) res=min(res,dp[n][i]);
	cout<<res<<endl;
}

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

int main(){
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; ++i){
        cin >> A[i];
    }
    
    sort(A, A+N, greater<int>());
    cout << A[0]-A[N-1] << endl;
    return 0;
}


Measured memory_bytes: 256
let S = stdin.ReadLine() |> int
let l = S / 100
let r = S % 100

if 1 <= l && l <= 12 then
    if 1 <= r && r <= 12 then "AMBIGUOUS"
    else "MMYY"
elif 1 <= r && r <= 12 then "YYMM"
else "NA"
|> stdout.WriteLine


Measured memory_bytes: 11220
#include <stdio.h>
const int SIZE = 100;
int data[SIZE];
int sp= 0;


int top(){
 return data[sp-1];
}
void pop(){
 sp--;
}

void push(int v){
 data[sp] = v;
 sp++;
}

int main(){
 int v;
 while(scanf("%d", &v) != EOF){
  if(v != 0){
   push(v);
  }
  if(v == 0){
   printf("%d\n", top());
   pop();
  }
 }
 return 0;
}

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

using namespace std;
int n;
int a[100005];
int main()
{
    scanf("%d" , &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d" , &a[i]);
        a[i]--;
    }
    int res = 0;
    for(int i = 0; i < n; i++)
    {
        if(a[i] == i)
        {
            res++;
            swap(a[i] , a[i + 1]);
        }
    }
    printf("%d\n" , res);
    return 0;
}


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

using namespace std;
using ll = long long;

struct r{
    string name;
    int score, id;
};

bool cmp(r a, r b){
    if(a.name == b.name){
        if(a.score == b.score){
            return a.id < b.id;
        }
        return a.score > b.score;
    }
    return a.name < b.name;
}

int main(){
    int n;
    while(cin >> n){
        vector<r>v(n);
        for(int i = 0; i < n; i++){
            cin >> v[i].name >> v[i].score;
            v[i].id = i+1;
        }
        sort(v.begin(), v.end(), cmp);
        for(int i = 0; i < n; i++){
            cout << v[i].id << "\n";
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,b) for(int i=1;i<=b;i++)
#define drep(i,b) for(int i=b;i>=1;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pr pair<int,int>
#define ff first
#define ss second
#define int long long
#define endl '\n'
using namespace std;
const int N=2e5+5;
const int mod=1e9+7;
int n,m,k,t,x,y,z;

void solve(int ans=0) {
    string s;
    cin>>n>>s;
    rep(i,min(n,(int)s.size())) cout<<s[i-1];
    if(n<s.size()) cout<<"...";
    cout<<endl;
}

#undef int
int main() {
    ios::sync_with_stdio(false);
    //int T;cin>>T;
    //while(T--)
        solve();
}


Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1e9+7, MAX = 1e9, larg = 1e5, INF = -1e9;
int A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
int max_value = 0, max_index = 0;
int min_value = MAX, min_index = 0;
int sum = 0;

typedef pair<int, int> Pa;
typedef long long ll;

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    cout << a[0]+a[1]+a[2]*10;  
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    string s;
    int w;
    cin >> s >> w;
    string res = "";
    rep (i, s.size()) {
        if (i % w == 0) res += s[i];
    }
    cout << res << endl;
    
    return 0;
}



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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b; cin>>a>>b;
  if(a>9||b>9) cout<<-1<<endl;
  else cout<<a*b<<endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		Arrays.setAll(h, i -> sc.nextInt());
		
		long[] dp = new long[n];
		dp[0] = 0;
		dp[1] = Math.abs(h[0] - h[1]);
		for (int i = 2; i < n; i++) {
			dp[i] = Math.min(dp[i - 2] + Math.abs(h[i - 2] - h[i])
							, dp[i - 1] + Math.abs(h[i - 1] - h[i]));
		}
		
		System.out.println(dp[n - 1]);
 		
		sc.close();
	}
}



Measured memory_bytes: 51376
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;

int main() {
    int N,M;

    cin >> N >> M;

    vector<int> X;

    for(int i = 0; i < M; i++){
        int x;
        cin >> x;

        X.push_back(x);
    }

    sort(X.begin(), X.end());

    vector<int> D;

    for(int i = 0; i < M - 1; i++){
        D.push_back(X[i+1] - X[i]);
    }

    sort(D.begin(), D.end());
    
    int sum = 0;

    for(int i = 0; i < M-N; i++){
        sum += D[i];
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1400
# -*- coding: utf-8 -*-
import math
import collections

def combinations_count(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    counter = 0
    a_c = collections.Counter(A)
    for v in a_c.values():
        counter += combinations_count(v,2)

    for a in A:
        print(counter-a_c[a]+1)

if __name__ == "__main__":
    main()


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

using namespace std;

int main (void) {
	int n;
	cin >> n;
	int a[n];
	int cnt;
	int ans = 0;
	
	for (cnt = 0; cnt < n; cnt++){
		cin >> a[cnt];
		}
		
	for (cnt = 0; cnt < n; cnt++){
		ans = ans + a[cnt] - 1;
		}
		
	cout << ans << "\n";
	
	return 0;
	}


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

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

	for (int i = 0; i < S.size(); i++) {
		if (S[i] != S[K - 1]) {
			S.replace(i, 1, 1, '*');
		}
	}
	cout << S << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
 
typedef long long ll;
 
using namespace std; 
 
#define REP(inc, bgn, end) for (int inc = bgn; inc < end; inc++)

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> ans(n);
    REP(i, 0, n) {
        cin >> a[i];
        ans[a[i]-1] = i + 1;
    }
    REP(i, 0, n) {
        cout << ans[i] << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    string T;
    cin >> T;
    rep(i, T.size()) {
        if(T[i]=='?') T[i] = 'D';
    }

    cout << T << endl;

    return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main(){
  ll n, m;
  cin >> n >> m;
  ll x, y;
  vll ball(n, 1), red(n, 0);
  red[0] = 1;
  REP(i, m){
    cin >> x >> y;
    x--;
    y--;
    ball[x]--;
    ball[y]++;
    if(red[x] && !red[y]) red[y]++;
    if(red[x] && !ball[x]) red[x] = 0;
  }
  ll ans = 0;
  REP(i, n){
    if(red[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
S = str(input())
s = 0
count = 0
for i in reversed(range(len(S))):
    if S[i] != "/":
        s += int(S[i]) * 10**(len(S)-i-count-1)
    else:
        count += 1
    
if s <= 20190430:
    print("Heisei")
else:
    print("TBD")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int a;
  cin>>a;
  int a1=0;
  a1=a/500;
  a%=500;
  int a2;
  a2=a/5;
  cout<<a1*1000+a2*5<<endl;
  

}


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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = n / (a + b);
    ll res = ans * (a + b);
    res = n - res;
    ans *= a;
    ans += min(res, a);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
import bisect
import sys
import math
from collections import deque
from heapq import heappush, heappop

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29

DIV = (10**9) + 7
#DIV = 998244353

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    X = iRaw()

    ans=8-(X-400)//200
    print(ans)

main()


Measured memory_bytes: 67428
#include <iostream>
#include <math.h>
#include <string>

using namespace std;
int main()
{
    string a;
    cin>>a;

    if(a[0] == a[1] && a[1]==a[2]){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }
    return 0;
}

Measured memory_bytes: 3632
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)
c=0
if(b[n-1]-b[0]>1):
    print('No')
elif(b[n-1]-b[0]==0):
    if(1<=b[0]<=n//2 or b[0]==n-1):
        print('Yes')
    else:
        print('No')
else:
    for i in range(n-1):
        if(b[i]<b[i+1]):
            c=i
            break
    if(c==n-2):
        print('No')
    elif(c+1<=b[0]<=c+(n-c-1)//2):
        print('Yes')        
    else:
        print('No')

Measured memory_bytes: 14092
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

int modpow(int a, int p) {
	if (p == 0)return 1;
	if (p % 2 == 0) {
		int halfP = p / 2;
		int half = modpow(a, halfP);
		return half * half%mod;
	}
	else {
		return a * modpow(a, p-1) % mod;
	}
}

signed main(void) {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int ret=0;
	rep(i,60){
		int zero = 0;
		rep(j,n){
			if(a[j]>>i&1)zero++;
		}
		int now = zero * (n-zero)%mod;
		now*=modpow(2,i);
		now%=mod;
		ret+=now;
		ret%=mod;
	}
	print(ret);
}

Measured memory_bytes: 5600
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int N;
  string s;
  cin >> N >> s;
  ll r = 0, g = 0, b = 0;

  for(char c : s){
    if (c == 'R') r++;
    if (c == 'G') g++;
    if (c == 'B') b++;
  }

  ll total = r * g * b;
   
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      int k = 2 * j - i; 
      if (k >= N) break;
      if ((s[i] != s[j]) && (s[i] != s[k]) && (s[j] != s[k])) total--; // 全部違う場合は解になるため候補から外す
      // printf("%d %d %d\n", j, j + i, j + 2*i);
    }
  }
  
  cout << total << endl;

}


Measured memory_bytes: 3632
//tanzim bin nasir
#include<bits/stdc++.h>
typedef long long ll;
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    else
    gcd(b,a%b);
}
ll lcd(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
int main()
{
    ll n,a[200005],mx=0,ans=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]<mx)
        {
            ans=ans+mx-a[i];

        }
        else
        mx=a[i];
    }
    cout<<ans<<endl;
}



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

using namespace std;

int main(){ 
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;    
    cout << min(a + b, 2 * c) * min(x, y) + min(a, 2 * c) * max(0, x - y) + min(b, 2 * c) * max(0, y - x) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n;string s;
  cin>>n>>s;
  ll a=0,b=0,c=0;
  rep(i,n){
    if(s[i]=='R')
      a++;
    if(s[i]=='G')
      b++;
    if(s[i]=='B')
      c++;
  }
  ll sum1=a*b*c;
  ll sum2=0;
  rep(i,n){
    for(int j=i+1;j<n;j++){
      if(s[i]==s[j])
        continue;
      int k=2*j-i;
      if(s[i]==s[k]||s[j]==s[k]||k>=n)
        continue;
        sum2++;
    }
  }
  cout<<sum1-sum2<<endl;
}


Measured memory_bytes: 3644
#define _USE_MATH_DEFINES

#include<bits/stdc++.h>

typedef long long ll;

using namespace std;

int main() {
	int n,m,x;
	cin >> n>>m>>x;
	vector<int> prices;
	vector<vector<int>> understandings;

	for (int i = 0; i < n; i++) {
		int price;
		cin >> price;
		prices.push_back(price);
		vector<int> understanding_of_a_book;
		for (int j = 0; j < m; j++) {
			int understanding;
			cin >> understanding;
			understanding_of_a_book.push_back(understanding);
		}
		understandings.push_back(understanding_of_a_book);
	}

	int min_price = 10000000;
	
	for (int bit=0; bit < (1<<n); bit++) {
		bool goal_achieved = true;
		int current_price = 0;
		vector<int> current_understandings(12);
		for (int book_id=0; book_id < n; book_id++) {
			if (bit & (1 << book_id)) {
				current_price += prices[book_id];
				for (int algorithm_id = 0; algorithm_id < m; algorithm_id++) {
					current_understandings[algorithm_id] += understandings[book_id][algorithm_id];
				}
			}	
		}

		for (int algorithm_id = 0; algorithm_id < m; algorithm_id++) {
			if (current_understandings[algorithm_id] < x) {
				goal_achieved = false;
				break;
			}
		}
		if (!goal_achieved) {
			continue;
		}
		min_price = min(min_price, current_price);
	}

	if (min_price == 10000000) {
		cout << "-1" << endl;
	} else {
		cout << min_price << endl;
	}

	return 0;
}


Measured memory_bytes: 3644
using System;
    class Program
    {
     
        static void Main(string[] args)
            {
            int X = int.Parse(Console.ReadLine());
            int X1=X / 500;
            int X2 = (X - 500*X1) / 5;
            int T = (1000 * X1) + (5 * X2);
            Console.WriteLine(T);
            Console.ReadLine();



            }
        }


Measured memory_bytes: 13140
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();

        int count = 0;

        for (int i = 0; i <= a; i++) {
            for (int j = 0; j <= b; j++) {
                for (int k = 0; k <= c; k++) {
                    if (x == 500*i + 100*j + 50*k) count++;
                }
            }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 35720
package main

import (
  "fmt"
)

func main() {
  var n int
  var honflg, ponflg bool
  hon := []int{2,4,5,7,9}
  pon := []int{0,1,6,8}

  fmt.Scanf("%d", &n)

  for _, v := range hon {
    if n%10 == v {
      honflg = true
    }
  }

  for _, v := range pon {
    if n%10 == v {
      ponflg = true
    }
  }

  if honflg {
    fmt.Println("hon")
  } else if ponflg {
    fmt.Println("pon")
  } else {
    fmt.Println("bon")
  }
}

Measured memory_bytes: 1816
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n, k) for (int i = n; i < k; i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(24) << fixed << p << endl;
#define vi vector<int>
#define printv(v)                      \
    for (int i = 0; i < v.size(); i++) \
        P(v[i]);
#define printt(a, b) cout << a << " " << b << endl;
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dx8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int MOD = 1e9 + 7;

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b; //先に割り算をして掛けられる数を小さくして掛け算を行う
}

bool pairCompare(const pair<int, int> &firstElof, const pair<int, int> &secondElof)
{
    return firstElof.second < secondElof.second;
}

void solve()
{
    int a,b;
    cin >> a >> b;
    P(b % 2 == 0 && b >= 2 * a && b <= 4 * a ? "Yes" : "No");
}

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


Measured memory_bytes: 3592
#include<iostream>

int main(){
    int N, M, X;
    std::cin >> N >> M >> X;
    int leftCost = 0, rightCost = 0;
    for(int i = 0; i < M; i++){
        int a;
        std::cin >> a;
        if(a < X) leftCost++;
        else if(a > X) rightCost++;
    }

    std::cout << std::min(leftCost, rightCost) << std::endl;
    return 0;
}


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

#define endl "\n"

int n;
int arr[200005];
long long int INF = 1e18 + 7;

long long int cal(int idx)
{
    long long int sum = 0;
    for(int i=idx;i<n;i+=2)
        sum += arr[i];
    return sum;
}


long long int dp[200005][2][2][2];

long long int kil_even(int idx, int ls, int ds, int ts)
{
    if(idx == n)
        return 0;
        
    if(dp[idx][ls][ds][ts] != -1)
        return dp[idx][ls][ds][ts];
    dp[idx][ls][ds][ts] = -INF;
    if(!ls)
    {
        if(!ds)
            dp[idx][ls][ds][ts] = max(dp[idx][ls][ds][ts], kil_even(idx+1, 0, 1, ts));
        dp[idx][ls][ds][ts] = max(dp[idx][ls][ds][ts], kil_even(idx+1, 1, ds, ts) + arr[idx]);
    }
    else
    {
        dp[idx][ls][ds][ts] = max(dp[idx][ls][ds][ts], kil_even(idx+1, 0, ds, ts));
    }
    return dp[idx][ls][ds][ts];
}

long long int kil(int idx, int ls, int ds, int ts)
{
    if(idx == n)
    {
        if(ds == 1)
            return 0;
        return -INF;
    }
    if(dp[idx][ls][ds][ts] != -1)
        return dp[idx][ls][ds][ts];
    dp[idx][ls][ds][ts] = -INF;
    if(!ls)
    {
        if(!ds)
            dp[idx][ls][ds][ts] = max(dp[idx][ls][ds][ts], kil(idx+1, 0, 1, 0));
        if(ds == 1 && ts == 0)
            dp[idx][ls][ds][ts] = max(dp[idx][ls][ds][ts], kil(idx+1, 0, 1, 1));
        dp[idx][ls][ds][ts] = max(dp[idx][ls][ds][ts], kil(idx+1, 1, ds, ts) + arr[idx]);
    }
    else
    {
        dp[idx][ls][ds][ts] = max(dp[idx][ls][ds][ts], kil(idx+1, 0, ds, ts));
    }
    return dp[idx][ls][ds][ts];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;

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

    memset(dp, -1, sizeof dp);

    if(!(n&1))
        cout<<max(cal(1), kil_even(1 ,1, 0, 0) + arr[0])<<endl;
    else
        cout<<kil(0, 0, 0, 0)<<endl;

    return 0;
}


Measured memory_bytes: 32528
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class K
{
	static void Main()
	{
		var I = ReadLine().Split().Select(int.Parse).ToArray();
		int N = I[0], A = I[1], B = I[2];
		if (C(A ^ B) % 2 < 1) WriteLine("NO");
		else WriteLine("YES\n" + string.Join(" ", G(N, A, B)));
	}
	static IEnumerable<int> G(int N, int A, int B)
	{
		if (N < 2) return new[] { A, B };
		var p = new int[N];
		int o = N - 1, z = 0;
		for (var i = 0; i < N; i++) p[i] = ((B ^ A) & 1 << i) > 0 ? o-- : z++;
		B = ((1 << (N - z)) - 1) << z;
		var l = new List<int>();
		var M = 1 << (N - 1);
		for (var i = 0; i < M; i++) l.Add(i ^ i >> 1);
		foreach (var i in G(N - 1, 1 << (N - 2), B ^ M)) l.Add(i ^ M);
		return l.Select(x =>
		{
			var s = A;
			for (var j = 0; j < N; j++) s ^= (x >> p[j] & 1) << j;
			return s;
		});
	}
	static int C(int n)
	{
		n = (n & 0x55555555) + (n >> 1 & 0x55555555);
		n = (n & 858993459) + (n >> 2 & 858993459);
		n = (n & 252645135) + (n >> 4 & 252645135);
		n = (n & 16711935) + (n >> 8 & 16711935);
		return (n & 65535) + (n >> 16 & 65535);
	}
}


Measured memory_bytes: 26588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private int A, B;
    public void Solve()
    {
        var line = Console.ReadLine().Split(' ');
        A = int.Parse(line[0]);
        B = int.Parse(line[1]);
        int ans = A + B;
        if (ans < 10)
        {
            Console.WriteLine(ans);
        }
        else
        {
            Console.WriteLine("error");
        }
    }
}



Measured memory_bytes: 13140
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    string s;
    cin>>s;
    int q;
    deque<char> qq;
    rep(i,s.size()){
        qq.push_back(s[i]);
    }

    bool f = true;
    cin>>q;
    rep(i,q){
        int a;
        cin>>a;
        if(a==1){
            f=!f;
        }else{
            int b;
            char c;
            cin>>b>>c;
            if(f){
                if(b==1){
                    qq.push_front(c);
                }else{qq.push_back(c);}
            }else{
                if(b==2){
                    qq.push_front(c);
                }else{qq.push_back(c);}
            }
        }
    }


    if(f) {
        while (!qq.empty()) {
            cout << qq.front();
            qq.pop_front();
        }
        cout<<endl;
    }else{
        while(!qq.empty()){
            cout<<qq.back();
            qq.pop_back();
        }
        cout<<endl;
    }




    return 0;
}


Measured memory_bytes: 896
using System;

public class Potchari {
    public static void Main() {
        int n = int.Parse(Console.ReadLine());
        for (int i = 0; i < n; i++) {
            int Out = 0;
            int score = 0;
            bool[] Base = new bool[3];
            for (int j = 0; j < 3; j++) Base[j] = false;
            while (Out < 3) {
                string line = Console.ReadLine();
                switch (line) {
                    case "HIT":
                    if (Base[2]) score++;
                    Base[2] = Base[1];
                    Base[1] = Base[0];
                    Base[0] = true;
                    break;
                    case "HOMERUN":
                    for (int j = 0; j < 3; j++) {
                        if (Base[j]) {
                            Base[j] = false;
                            score++;
                        }
                    }
                    score++;
                    break;
                    case "OUT":
                    Out++;
                    break;
                }
            }
            Console.WriteLine(score);
        }
    }
}

Measured memory_bytes: 9060
import java.util.Scanner;

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

    String result = (a * b)%2 == 1 ? "Odd": "Even";
    System.out.println(result);
    sc.close();
  }
}

Measured memory_bytes: 35612
// 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)*}
    };
}

#[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, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (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")
    };
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

#[allow(unused)]
use std::ascii::AsciiExt;
#[allow(unused)]
use std::cmp::{max, min};
#[allow(unused)]
use std::collections::HashMap;

#[allow(unused)]
fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}

#[allow(unused)]
fn lcm(x: i64, y: i64) -> i64 {
    x * y / gcd(x, y)
}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        _n: usize,
        k: usize,
        s: chars,
    }

    let mut s = s;
    s[k - 1] = s[k - 1].to_ascii_lowercase();
    let s: String = s.into_iter().collect();
    println!("{}", s);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int k,x;
signed main(){
	cin>>k>>x;
	for(int i=x-k+1;i<=x+k-1;i++){
		cout<<i<<(i==x+k-1?"\n":" ");
	}
	return 0;
}


Measured memory_bytes: 256