akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <atcoder/math>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
const int mod = 1e9+7;
const int INF = 1e9;
const int MAX = 1e6;
// const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// struct edge {int to, cost;};
// vector<edge> graph[MAX];
// bool visited[MAX];
// int dist[MAX];

int main() {
    int t;
    cin >> t;
    rep(i, t) {
        ll n, m, a, b;
        cin >> n >> m >> a >> b;
        cout << floor_sum(n, m, a, b) << endl;
    }
}

Measured memory_bytes: 3556
use std::cmp;

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

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

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

fn main() {
    input! {
        n: isize,
        w_vec: [isize; n]
    };

    let mut ans = 10000000;
    for i in 0..w_vec.len() {
        let s1 = w_vec[0..i].into_iter().fold(0, |acc, elm| acc + elm);
        let s2 = w_vec[i..].into_iter().fold(0, |acc, elm| acc + elm);
        ans = cmp::min(ans, (s1 - s2).abs());
    }
    println!("{}", ans);
}


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

int main(){
  string s;
  cin >> s;
  if(s[2]==s[3]&&s[4]==s[5]) cout << "Yes"<<endl;
  else cout << "No"<<endl;

}

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

int main () {
    int x=1;
    while(1) {
        int a;
        cin >> a;
        if(a==0) {
            break;
        } else {
            cout << "Case " << x << ": " << a << endl;
        }
        x++;
    }
    return 0;
}


Measured memory_bytes: 3000
N,K = list(map(int,input().split()))
B = K
R = N-K

MAXN = 2000+5
p = 10**9+7
MOD = p
f = [1]
for i in range(MAXN):
    f.append(f[-1] * (i+1) % MOD)
def nCr(n, r, mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

for i in range(1,K+1):
    if (i>R+1) or (i-1>B-1):
        print(0)
    else:
        X = nCr(R+1, i, mod=p)
        Y = nCr(B-1, i-1, mod=p)
        print(X*Y%p)

Measured memory_bytes: 74248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


class FactorialMod{
    void calc_inverse(){
        inverse[0] = 0;
        inverse[1] = 1;
        for(int i=2; i<=max_num; i++){
            inverse[i] = md-((md/i)*inverse[md%i]%md);
        }
    }

    void calc_factorial_inverse(){
        factorial[0] = factorial_inverse[0] = 1;
        for (int i=1; i<=max_num; i++) {
            factorial[i] = (factorial[i-1]*i)%md;
            factorial_inverse[i] = (factorial_inverse[i-1]*inverse[i])%md;
        }
    }

    public:
        ll max_num, md;
        vector<ll> inverse; 
        vector<ll> factorial;
        vector<ll> factorial_inverse;
        FactorialMod(ll _max_num, ll _md=MOD){
            max_num = _max_num;
            md = _md;
            inverse = vector<ll>(max_num+1);
            factorial = vector<ll>(max_num+1);
            factorial_inverse = vector<ll>(max_num+1);
            calc_inverse();
            calc_factorial_inverse();
        }

        ll combination(int n, int k){
            return (((factorial[n]*factorial_inverse[k])%md)*factorial_inverse[n-k])%md;
        }

        ll multiChoose(int n, int k){
            return combination(n+k-1, k);
        }
};

ll modpow(ll x, ll n, ll md=MOD){
    ll res=1, dig=x;
    while(n){
        if(n&1) res = res*dig%md;
        dig = dig*dig%md;
        n /= 2;
    }
    return res;
}
ll comb(ll N_, ll C_, ll mo) {
	const int NUM_=400001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}
int main(){
    ll n, m, k; cin >> n >> m >> k;
    //重複組み合わせは配列倍(n+k)にする
    ll mod = 998244353, res=0;
    FactorialMod calc_mod(n, mod);
    rep(i, k+1){
        res += m*calc_mod.combination(n-1, i)%mod*modpow(m-1, n-1-i, mod)%mod;
        res %= mod;
    }   
    cout << res << endl; 
    

}

Measured memory_bytes: 7956
import java.util.*;

class Main{
	public static void main(String []args){
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();//合計枚数
      	int Y = sc.nextInt();//合計金額
      
      for(int i = 0; i <= N; i++ ){//10000円の枚数
        	for(int x = 0; x <= N - i; x++){//5000円の枚数
              int z = N - i - x;//1000円の枚数
              int amount = i * 10000 + x * 5000 + z * 1000;
              
              if (amount == Y){
              	System.out.println(i + " " + x + " " + z);
                return;
              }
              
            }
      	}
      System.out.println("-1 -1 -1");
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int N;
  cin>>N;
  vector <int> a(N);
  for(int i = 0;i<N;i++){
    cin>>a[i];
  }
  int ans = 0;
  sort(a.begin(),a.end());
  for(int i = 0;i<N-2;i++){
    for(int k = i+1;k<N-1;k++){
      for(int p = k+1;p<N;p++){
        if((a[i]+a[k])>a[p]){
          ans++;
        }
        else{
          p = N;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h> 
int main(void)
{
	int n, x;
	int b, i, j, k, a;

	while (1) {
		scanf("%d %d", &n, &x);
		b = 0;
		if (n == 0 && x == 0) {
			break;
		}
		for (k = 1; k <= n; k++) {
			for (j = 1; j <= n; j++) {
				for (i = 1; i <= n; i++) {
					if (i == j || j == k || i == k) {
					}
					else {
						a = i + j + k;
						if (a == x) {
							b += 1;
						}
					}
				}//i
			}//j
		}//k
		printf("%d\n", b / 6);
	}
	return 0;
}


Measured memory_bytes: 2048
n = gets.strip.to_i
a =[]
i = 1
n.times do
    s, p = gets.strip.split
    p = p.to_i
    a.push({i: i, s: s, p: p})
    i += 1
end
a.sort{|a, b|
    (a[:s] <=> b[:s]).nonzero? ||
    b[:p] <=> a[:p]
}.map{|a| puts a[:i]}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n;
    string s,t;
    cin>>s>>t;
    for(i=0;i<t.size();i++){
        cout<<t[i];
    }
    for(i=0;i<s.size();i++){
        cout<<s[i];
    }
}


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

int main()
{
	int W, H, x, y;
	cin >> W >> H >> x >> y;
	cout << fixed << setprecision(1);
	cout << (ld)W * H * 0.5 << ' ' << (x * 2 == W && y * 2 == H) << endl;
	return 0;
}


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

int main(){

  int d;

  while(cin >> d){

    double ans = 0;

    for(int i=0;i<600/d;i++){
      ans += d * pow((double)i*(double)d,2.0);
    }

    cout << (int)ans << endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    int A,P; cin >> A >> P;
    cout << (A*3+P)/2 << endl;
    return 0;
}


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

int main()
{
    ll n, k;
    cin >> n >> k;
    ll t = k;
    ll c = 0;
    while(k<=n)
    {
        k *= t;
        c++;
    }
    cout << c+1;
}

Measured memory_bytes: 256
n = int(input())
scop = [] #高低差,min値
scom = []
ssum = 0

for i in range(n):
    s = input()
    sa = 0
    ms = 0
    for i in s:
        if i == "(":
            sa += 1
        else:
            sa -= 1
        if ms > sa:
            ms = sa
    if sa > 0:
        scop.append([ms,sa])
    elif not sa == ms:
        scom.append([ms,sa])
    ssum += sa

if not ssum == 0:
    print("No")
    exit()

scop.sort(reverse = True)
scom.sort()

now = 0
for i in scop:
    if now + i[0] < 0:
        print("No")
        exit()
    now += i[1]
for i in scom:
    if now + i[0] < 0:
        print("No")
        exit()
    now += i[1]

print("Yes")


Measured memory_bytes: 52584
for i in range(100000):
    a = input()
    b = a.split(" ")
    if b[1] == "+":
        print(int(b[0]) + int(b[2]))
    if b[1] == "-":
        print(int(b[0]) - int(b[2]))
    if b[1] == "*":
        print(int(b[0]) * int(b[2]))
    if b[1] == "/":
        print(int(b[0]) // int(b[2]))
    if b[1] == "?":
        break



Measured memory_bytes: 5600
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define sqr(a) ((a)*(a))
using namespace std;

const int N = 15;
int n,m,a[N][N],Cnt;

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1; i<=n; ++i) for(int j=1; j<=m; ++j) scanf("%d",&a[i][j]);
    for(int i=1; i<n; ++i) for(int u=i+1; u<=n; ++u) {
        int sum = 0, tmp;
        for(int j=1; j<=m; ++j) sum += sqr(a[i][j] - a[u][j]);
        tmp = sqrt(sum);
        if (tmp * tmp == sum) Cnt += 1;
    }
    cout << Cnt;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;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 VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)


typedef long long ll;

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

const int INF = 1e9 + 7;

#define ARRAY_MAX 100005

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


struct city {

	int ken;
	int year;
	int index;


};

bool comp(const city& a, const city& b) {

	if (a.ken == b.ken) {
		return a.year < b.year;
	}
	else {
		return a.ken < b.ken;
	}
}


int main() {


	int n, m;
	cin >> n >> m;
	vector<city> a(m);
	vector<int> cnt(n + 10, 1);
	vector<string> ans(m + 10);
	

	for (int i = 0; i < m; i++)
	{
		cin >> a[i].ken >> a[i].year;
		a[i].index = i;
	};


	sort(a.begin(), a.end(), comp);

	for (int i = 0; i < m; i++)
	{
		string k = to_string(a[i].ken);
		string y = to_string(cnt[a[i].ken]);
		for (int j = 0; j < 6-k.size(); j++)
		{
			ans[a[i].index].push_back('0');
		}
		ans[a[i].index] += k;

		for (int j = 0; j < 6 - y.size(); j++)
		{
			ans[a[i].index].push_back('0');
		}
		ans[a[i].index] += y;
		cnt[a[i].ken]++;
	}


	for (int i = 0; i < m; i++)
	{
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 9728
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[20];
int t[110];
int p[110];
int q[110];
int c[110];
int dp[2][110000];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%d",c+i);
		int b;
		scanf("%d",&b);
		for(int i=0;i<b;i++){
			scanf("%s%d%s%d",str,p+i,str,q+i);
			if(str[0]=='S')t[i]=1;
			else t[i]=0;
		}
		for(int i=0;i<110000;i++)dp[0][i]=dp[1][i]=1999999999;
		dp[0][0]=dp[1][0]=0;
		for(int i=0;i<b;i++){
			for(int j=0;j<110000;j++){
				dp[t[i]][min(109999,j+q[i])]=min(dp[t[i]][min(109999,j+q[i])],dp[t[i]][j]+p[i]);
			}
		}
		for(int i=109998;i>=0;i--){
			dp[0][i]=min(dp[0][i],dp[0][i+1]);
			dp[1][i]=min(dp[1][i],dp[1][i+1]);
		}
		long long ret=1999999999;
		for(int i=0;i<110000;i++){
			long long val=dp[0][i];
			for(int j=0;j<a;j++){
				if(i>=c[j])continue;
				val+=dp[1][c[j]-i];
			}
			ret=min(ret,val);
		}
		printf("%lld\n",ret);
	}
}

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

int main(){
    char str1[100],str2[200];
    cin>>str1;
    int i,j;
    for(i=0;str1[i]!='\0';i++) str2[i]=str1[i];
    for(j=i;str1[j-i]!='\0';j++) str2[j]=str1[j-i];
    str2[j+1]='\0';
    char match[100];
    cin>>match;
    int flg=0;
    int flgans=0;
    for(i=0;str2[i]!='\0';i++) {
        if (str2[i] == match[0]) {
            flg = 1;
            for (j = 1; match[j] != '\0';j++) {
                if (str2[i+j] != match[j]) flg = 0;
            }
            if(match[j]=='\0'&&flg==1) flgans=1;
        }
    }
    if(flgans==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int r = 0;

    vector<int> d(n - 1);
    int p = -2;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        a--;
        if (a == p + 1) d[p] = 1;
        p = a;
    }

    for (int i = 0; i < n; i++) {
        int b;
        cin >> b;
        r += b;
    }

    for (int i = 0; i < n - 1; i++) {
        int c;
        cin >> c;
        r += d[i] * c;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, s = 0; cin >> N;
    vl as(N, 0);
    REP(i, N){
        ll a; cin >> a; s += a; as[i] = s;
    }
    
    ll ret1 = 0, mv = 0;
    if(as[0] <= 0){
        mv = 1 - as[0]; ret1 += abs(mv);
    }
    FOR(i, 1, N){
        if((as[i] + mv) * (as[i - 1] + mv) >= 0){
            ll a_pre = as[i - 1] + mv;
            ll t_mv = a_pre > 0 ? -1 - (as[i] + mv) : 1 - (as[i] + mv);
            mv += t_mv; ret1 += abs(t_mv);
        }
    }
    
    ll ret2 = 0; mv = 0;
    if(as[0] >= 0){
        mv = -1 - as[0]; ret2 += abs(mv);
    }
    FOR(i, 1, N){
        if((as[i] + mv) * (as[i - 1] + mv) >= 0){
            ll a_pre = as[i - 1] + mv;
            ll t_mv = a_pre > 0 ? -1 - (as[i] + mv) : 1 - (as[i] + mv);
            mv += t_mv; ret2 += abs(t_mv);
        }
    }
    cout << min(ret1, ret2) << endstr;
    return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if( s.equals("ABC")) {
			System.out.println("ARC");
		}else {
			System.out.println("ABC");
		}
	}
}

Measured memory_bytes: 35596
#include<cstdio>
typedef long long ll;
const int maxn=100000;
int n,a[maxn+10]; ll minv=2,maxv=2;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	for(int i=n;i>=1;--i){
		minv=(minv-1)/a[i]+1; maxv=maxv/a[i];
		if(minv>maxv){
			printf("-1"); return 0;
		}
		minv=minv*a[i]; maxv=(maxv+1)*a[i]-1;
	}
	printf("%lld %lld",minv,maxv); return 0;
}

Measured memory_bytes: 512
//https://atcoder.jp/contests/abc134/tasks/abc134_b
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll N,D; cin>>N>>D;
    ll num=2*D+1;
    ll ans=(N+num-1)/num;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "";
const string NO  = "";

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

    int a, b, c;

    cin >> a >> b >> c;

    cout << (a * b) / 2 << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define F first
#define S second
#define MP make_pair
#define PB push_back

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//fast_cin();
	int n,k;
	rd2(n,k);
	string str;
	cin>>str;
	str[k-1]+=32;
	cout<<str<<endl;
	return 0;
}

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

#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n,k;
    cin >> n >> k;
    vector<double> p(n);
    rep(i,n)
    {
        cin >> p[i];
    }
    double ans = 0;

    vector<double> exp(n);
    rep(i,n)
    {
        exp[i] = (1+p[i])/2;
    }
    rep(i,k)
    {
        ans+=exp[i];
    }
    double temp = ans;
    for (int i = 0; i < n-k; i++)
    {
        temp = temp-exp[i]+exp[i+k];
        ans = max(ans,temp);
    }
    cout << setprecision(11) << ans << endl;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
//#define debug
//#define TRACE(x)

using namespace std;

typedef long long llint;

const int MAXN = 100010;

int m, n, a[MAXN], p[MAXN];
llint k;
int d[MAXN], idx[MAXN], cyc[MAXN];
vector<int> v[MAXN];

void calc_cycles() {
  memset(cyc, -1, sizeof(cyc));
  REP(i, n) {
    if (cyc[i] != -1) continue;
    int x = i;
    do {
      cyc[x] = i;
      idx[x] = (int)v[i].size();
      v[i].push_back(x);
      x = p[x];
    } while (x != i);
  }
}

int get(int x, llint K) {
  int i = cyc[x];
  return v[i][(idx[x] + K) % (int)v[i].size()];
}

int x[MAXN];

int main(void) {
  scanf("%d",&n);
  REP(i, n) {
    scanf("%d",&x[i]);
    if (i != 0) d[i-1] = x[i] - x[i-1];
  }
  scanf("%d %lld",&m,&k);
  REP(i, m) { scanf("%d",&a[i]); --a[i]; }

  REP(i, n) p[i] = i;
  REP(i, m) swap(p[a[i] - 1], p[a[i]]);

  calc_cycles();

  printf("%d\n",x[0]);
  llint curr = x[0];
  REP(i, n - 1) {
    int j = get(i, k);
    curr += d[j];
    printf("%lld\n",curr);
  }
  
  
  return 0;
}


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

int main(){
	
	vector<int> v;
	for(int i = 0; i < 3; i++) {
		int x; cin>>x;
		v.push_back(x);
	}
	cout<<v[2]<<" "; 
	cout<<v[0]<<" ";
	cout<<v[1]<<" ";
	cout<<"\n";
	
	
	
	
	
}


















Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define int long long
using namespace std;
signed main() {
    int N, K;
    cin >> N >> K;
    int A = 1;

    for (int i = 0; i < N; i++) {
        if (min(A * 2, A + K) == A * 2) {
            A = A * 2;
        }
        else {
            A = A + K;
        }
    }
    cout << A << endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    V< P<ll, ll> > dt(n);
    for (ll i = 0; i < n; i++) cin >> dt[i].second >> dt[i].first;
    sort(ALL(dt));
    reverse(ALL(dt));
    ll ans = 0, tmp = 0, ct = 0;
    map<ll, ll> ttt;

    for (ll i = 0; i < k; i++) {
        tmp += dt[i].first;
        ttt[dt[i].second]++;
        if (ttt[dt[i].second] == 1) ct++;
    }
    ans = tmp + ct * ct;

    priority_queue< P<ll, ll> > pq;
    for (ll i = 0; i < k; i++) {
        if (ttt[dt[i].second] >= 2) pq.push(make_pair(-dt[i].first, dt[i].second));
    }

    for (ll i = k; i < n; i++) {
        if (pq.empty()) break;
        if (ttt[dt[i].second] == 0) {
            P<ll, ll> q = pq.top(); pq.pop();
            while (!pq.empty() && ttt[q.second] == 1) {
                q = pq.top(); pq.pop();
            }
            if (ttt[q.second] == 1) {
                break;
            }

            ttt[q.second]--;
            tmp += q.first;
            tmp += dt[i].first;
            ttt[dt[i].second]++;
            ct++;
            chmax(ans, tmp + ct * ct);
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 6776
readline = open(0).readline
writelines = open(1, 'w').writelines
s = set()
def insert(x):
    s.add(x)
    return "%d\n" % len(s)
def find(x):
    return "%d\n" % (x in s)


C = [insert, find].__getitem__
Q = int(readline())
ans = []
for _ in range(Q):
    t, x = map(int, readline().split())
    ans.append(C(t)(x))
writelines(ans)


Measured memory_bytes: 34996
def main():
    import sys
    input = sys.stdin.readline

    N, H = map(int, input().split())

    bs = []
    a_mx = -1
    for _ in range(N):
        a, b = map(int, input().split())
        a_mx = max(a_mx, a)
        bs.append(b)

    bs = [b for b in bs if b > a_mx]
    bs.sort(reverse=True)

    ans = 0
    for b in bs:
        H -= b
        ans += 1
        if H <= 0:
            break
    if H > 0:
        ans += (H + a_mx - 1) // a_mx

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 7840
i = input()
n = int(i[-1])

if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
  print('hon')
elif n == 0 or n == 1 or n == 6 or n == 8:
  print('pon')
else:
  print('bon')

Measured memory_bytes: 9180
#include<iostream>
int main()
{
	auto powor_of_two = [](int n)
	{
		int result = 1;
		for (int i = 0; i < n; i++)
		{
			result *= 2;
		}
		return result;
	};
	for (int w; std::cin >> w;)
	{
		for (int i = 0; i < 10; i++)
		{
			int bit = w & 1;
			if (bit == 1)
			{
				std::cout << powor_of_two(i);
				w >>= 1;
				if (w != 0)
				{
					std::cout << ' ';
				}
				else
				{
					std::cout << std::endl;
					break;
				}
			}
			else
			{
				w >>= 1;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3060
// 2020-07-25 10:14:44
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));
  auto ok = [&](ll x) {
    ll cnt = 0;
    rep(i, n) {
      auto itr = lower_bound(ALL(a), x-a[i]);
      cnt += a.end() - itr;
    }
    return cnt < m;
  };
  ll l = -1, r = 1e18;
  while(l + 1 < r) {
    ll m = (l + r) / 2;
    if(ok(m)) r = m; else l = m;
  }
  ll x = r;
  vector<ll> sum(n+1, 0);
  rep(i, n) sum[i+1] = sum[i] + a[i];
  ll ans = 0;
  rep(i, n) {
    auto itr = lower_bound(ALL(a), x-a[i]);
    ans += sum[n] - sum[itr - a.begin()];
    ll cnt = a.end() - itr;
    ans += a[i] * cnt;
    m -= cnt;
  }
  ans += m * (x-1);
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 4784
#include"bits/stdc++.h"
#include<atcoder/mincostflow.hpp>
using namespace atcoder;
using namespace std;

#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pll = pair<ll, ll>;
using tp3 = tuple<ll, ll, ll>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
// ============ template finished ============
int getidx(const int M, const int i, const int j) {
    return M * i + j;
}

int main()
{
    int N, M;
    cin >> N >> M;
    vector<string> S(N);
    rep(i, N)cin >> S[i];

    const int SIZE = N * M;
    mcf_graph<int, int> graph(SIZE + 2);

    // Source, Sink付近のbuild
    rep(i, N)rep(j, M) {
        if (S[i][j] == 'o') {
            graph.add_edge(SIZE, getidx(M, i, j), 1, 0);
            S[i][j] = '.';
        }
        int manhattan = (N - 1 - i) + (M - 1 - j);
        graph.add_edge(getidx(M, i, j), SIZE + 1, 1, manhattan * 2);
    }
    // 隣接2項のbuild
    rep(i, N)rep(j, M) if (S[i][j] == '.') {
        // 右方向
        if (j + 1 < M && S[i][j + 1] == '.') {
            graph.add_edge(getidx(M, i, j), getidx(M, i, j + 1), 100, 1);
        }
        // 下方向
        if (i + 1 < N&&S[i + 1][j] == '.') {
            graph.add_edge(getidx(M, i, j), getidx(M, i + 1, j), 100, 1);
        }
    }
    graph.flow(SIZE, SIZE + 1);
    int res = 0;
    for (auto edge : graph.edges()) if (edge.from < SIZE && edge.to < SIZE) {
        res += edge.flow;
    }
    cout << res << endl;
    return 0;
}


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

#define Fast           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO             freopen("in.txt", "r", stdin)
#define FC             freopen("out.txt", "w", stdout)
#define aise           cout<<"aise"<<endl
#define pb             push_back
#define pf             push_front
#define ppb            pop_back
#define ppf            pop_front
#define mp             make_pair
#define ll             long long
#define all(x)         x.begin(), x.end()
#define mset(v, a)     memset(v, a, sizeof(v))
#define pll            pair< ll, ll >
#define pd             pair< double, double >
#define ff             first
#define ss             second
#define pi             acos(-1.0)
#define mxN            2010
#define inf            1e14
#define mod            1000000007
#define tc             ll tc;scanf("%lld",&tc);while(tc--)

//NCR iterative
/*voidcomb_table(intN)
{
    for(inti=0; i<=N; ++i)
    {
        for(intj=0; j<=i; ++j)
        {
            if(j==0or j==i)
            {
                C[i][j]=1LL;
            }
            else
            {
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}*/


//NCR recursive
/*ll dp[55][55];

ll NCR(ll n,ll r)
{

    if(n==r)
        return dp[n][r]=1;
    if(r==0)
        return dp[n][r]= 1;
    if(r==1)
        return dp[n][r]=n ;
    if(dp[n][r] != -1)
        return dp[n][r];
    return dp[n][r] = NCR(n-1,r)+NCR(n-1,r-1);
}*/

//Sieve:
/*bool Flag[1000010];
vector<ll> Prime;

void sieve()
{

    ll val=sqrt(1000010);
    for(ll i=4;i<=1000005; i+=2) Flag[i]=1;
    for(ll i=3;i <= val;i+=2)
    {

        if(Flag[i]==0)
        {

            for(ll j=i*i;j<=1000005;j+=i) Flag[j]=1;
        }
    }
    Flag[1]=1;
    for(ll i=1;i<=1000000;i++)
        if(Flag[i]==0) Prime.pb(i);
}*/


//Conversion
/*string bin(ll x)
{

    string ret;
    while(x)
    {

        ll t=x%2;
        char c;
        if(t==1)
            c='1';
        else
            c='0';
        ret.pb(c);
        x/=2;
    }
    reverse(all(ret));
    return ret;
}*/

/*ll lcm(ll x, ll y)
{

    ll ret=__gcd(x,y);
    return (x*y)/ret;
}*/

/*ll dx[]= {0,0,1,-1};
ll dy[]= {1,-1,0,0};*/

int main()
{

    double n,m,a,b;
    cin >> n >> m >> a >> b;
    double ar=(n*m)/2.0;
    printf("%.15lf ", ar);
    if(n/2.0 == (double)a && m/2.0 == (double)b) cout << 1;
    else cout << 0;
}


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

int main() {
  int N,C;
  cin >> N >> C;
  vector< vector<int> > D(C, vector<int>(C));
  REP(i,C) REP(j,C)  cin >> D[i][j];
  vector< vector< int > > c(3);
  REP(i,N) REP(j,N) {
    int a;
    cin >> a;
    c[(i+j+2)%3].push_back( --a );
  }
//  for (auto a : c[0] ) cout << a << " "; cout << endl;
//  for (auto a : c[1] ) cout << a << " "; cout << endl;
//  for (auto a : c[2] ) cout << a << " "; cout << endl;
  vector< vector< ll > > tc(3, vector<ll>(C,0) );
  REP(i,3)
    REP(j,C) {
      int cost = 0;
      for ( auto a : c[i] ) cost += D[a][j];
//      cout << i << " " << j << " : " << cost << endl;
      tc[i][j] = cost;
    }
  ll ans = 500*500*2000;
  REP(i,C) REP(j,C) REP(k,C) {
    if ( i == j || j ==  k || i == k ) continue;
    ans = min( tc[0][i] + tc[1][j] + tc[2][k], ans ) ;
  }
  
  cout << ans << endl;

}



Measured memory_bytes: 1524
import Foundation
func toTuple<T>(_ args: [T]) -> (T, T) { (args[0], args[1]) }
func readInts() -> [Int] { readLine()!.split(separator: " ").map { Int($0)! } }

let (a, b) = toTuple(readInts())
let n = b - a - 1
print(n * (n + 1) / 2 - a)

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

typedef long long ll;
const int N = 1e5 + 100;

ll n, ans, a, maxi;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	while(n--) {
		cin >> a;
		ans += (a >= maxi);
		maxi = max(maxi, a);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
ct = [None] * N
for i in range(N):
  ct[i] = list(map(int, input().split()))
ct = list(filter(lambda x: x[1] <= T, ct))
if not len(ct) > 0:
  ct.append(['TLE', 0])
ct = sorted(ct, key=lambda x: x[0])
print(ct[0][0])


Measured memory_bytes: 3060
//By Tushar Gautam
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e;++i)
#define forsn(i,s,e) for(int i = s; i < e;++i)
#define rforn(i,s) for(int i = s; i >= 0;--i)
#define rforsn(i,s,e) for(int i = s; i >= e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime ((double)clock()/CLOCKS_PER_SEC)
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=1e5+5,MOD=1e9+7;
int t,n,m,k,x,y,w;
signed main(){
	fastio;
	cin>>n>>k;
	int v[n];
	forn(i,n) cin>>v[i];
	ll fans=0;
	forn(a,k+1){
		forn(b,k+1){
			if(a+b>k or a+b>n) break;
			int rem=min(a+b,max(0,k-a-b));
			v32 val;
			ll ans=0;
			forn(i,a) val.pb(v[i]),ans+=v[i];
			forn(i,b) val.pb(v[n-i-1]),ans+=v[n-i-1];
			sort(all(val));
			fans=max(fans,ans);
			forn(j,rem){
				ans-=val[j];
				fans=max(fans,ans);
			}
		}
	}
	cout<<fans<<ln;
	return 0;
}

Measured memory_bytes: 256
def main():
    class rolling_hash():
        def __init__(self, sequence, char_list=None):
            self.sequence = sequence  # 文字列
            self.seq_size = len(self.sequence)  # 文字列の長さ
            self.mod = 2**61-1  # mod
            if char_list is None:  # 使われている文字のリスト
                self.char_list = "abcdefghijklmnopqrstuvwxyz"
            else:
                self.char_list = char_list
            self.base = len(self.char_list)+1  # 文字の種類数
            self.char_dict = {j: i+1 for i,
                              j in enumerate(self.char_list)}  # 文字と数値の対応表
            self.Hash_0start = [0]*(self.seq_size+1)  # 先頭からi-1文字目までのハッシュ値
            for i in range(self.seq_size):
                self.Hash_0start[i+1] = self.Hash_0start[i] + \
                    self.char_dict[self.sequence[i]] * \
                    pow(self.base, i, self.mod)

        def calc_hash(self, l, r):  # l文字目からr-1文字目までのハッシュ値
            return ((self.Hash_0start[r] - self.Hash_0start[l])
                    * pow(self.base, l*(self.mod-2), self.mod)) % self.mod

    n = int(input())
    s = input()
    h_s = rolling_hash(s)

    def value(num):
        h_dict = {}
        for i in range(len(s)-num+1):
            j = h_s.calc_hash(i, i+num)
            if j not in h_dict:
                h_dict[j] = i
            else:
                if i-h_dict[j] >= num:
                    return True
        return False

    def b_search(a, b, value):
        while a+1 < b:
            med = (a+b)//2
            if value(med):
                a = med
            else:
                b = med-1
        if a == b:
            return a
        elif a+1 == b:
            if value(b):
                return b
            else:
                return a

    print(b_search(0, len(s), value))


main()


Measured memory_bytes: 48476
#include <cstdio>
#include <cstdlib>
using namespace std;
char cmd[20];
struct node {
	int val;
	node *prev,*nxt;
};
node *nil;
void ins (int x) {
	node *tmp=(node *)malloc (sizeof(node));
	tmp->val=x;
	tmp->nxt=nil->nxt;
	tmp->prev=nil;
	nil->nxt->prev=tmp;
	nil->nxt=tmp;
}
node* find (int x) {
	node *cur=nil->nxt;
	while (cur!=nil&&cur->val!=x) cur=cur->nxt;
	return cur;
}
void deleteNode (node *x) {
	if (x==nil) return;
	x->prev->nxt=x->nxt;
	x->nxt->prev=x->prev;
	free(x);
}
void deleteFirst () {
	deleteNode(nil->nxt);
}
void deleteLast () {
	deleteNode(nil->prev);
}
void deletex (int x) {
	deleteNode(find(x));
}
int main () {
	int n;
	scanf ("%d",&n);
	nil=(node *) malloc(sizeof(node));
	nil->nxt=nil;
	nil->prev=nil;
	for (int i=0;i<n;i++) {
		scanf ("%s",cmd);
		if (cmd[0]=='i') {
			int tmp;
			scanf ("%d",&tmp);
			ins(tmp);
		} else if (cmd[6]=='F') deleteFirst();
		else if (cmd[6]=='L') deleteLast();
		else {
			int tmp;
			scanf ("%d",&tmp);
			deletex(tmp);
		}
	}
	node *i=nil->nxt;
	if (i!=nil) {
		printf ("%d",i->val);
		i=i->nxt;
	}
	while (i!=nil) {
		printf (" %d",i->val);
		i=i->nxt;
	}
	printf ("\n");
    return 0;
}


Measured memory_bytes: 33840
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

ll n, A[10010], S[10010], k;

vector <ll> V;

int main() {
    scanf("%lld%lld", &n, &k);
    for(int i = 1; i <= n; i++) scanf("%lld", &A[i]), S[i] = S[i - 1] + A[i];
    for(int i = 0; i <= n; i++)
        for(int j = i + 1; j <= n; j++) V.push_back(S[j] - S[i]);
    ll ans = 0;
    for(int i = 50; i >= 0; i--) {
        ans += (1ll << i);
        int tmp = 0;
        for(int j = 0; j < V.size(); j++) if((V[j] & ans) == ans) tmp++;
        if(tmp < k) ans -= (1ll << i);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 6128
from bisect import *
from collections import *

N = int(input())
# AB = [list(map(int, input().split())) for i in range(N)]
A, B = [None]*N, [None]*N
for i in range(N):
    A[i], B[i] = map(int, input().split())
A.sort()
B.sort()
if N % 2:
    a = A[N//2]
    b = B[N//2]
    ans = b-a+1
else:
    a = A[N//2-1] + A[N//2] 
    b = B[N//2-1] + B[N//2]
    ans = b-a+1
print(ans)

Measured memory_bytes: 84872
#include <iostream>
#include <stack>

using namespace std;

int main(){
    int n;
    stack<int> S;
    while(cin >> n){
        if(n){
            S.push(n);
        } else {
            cout << S.top() << endl;
            S.pop();
        }
    }
    return 0;
}

Measured memory_bytes: 1200
# coding: utf-8

import codecs
import sys

sys.stdout = codecs.getwriter("shift_jis")(sys.stdout) # ??????
sys.stdin = codecs.getreader("shift_jis")(sys.stdin) # ??\???

# ??\??¬?????????print??????????????´?????? print(u'?????????') ??¨??????
# ??\??¬?????????input??? input(u'?????????') ??§OK
# ??°?¢???????????????????????????´??????6,7???????????????????????¢??????

a = []
for i in range(10):
	n = input()
	a.append(n)

#a = [0,5,2,3,4,1]

a.sort(reverse=True)

print a[0]
print a[1]
print a[2]

Measured memory_bytes: 6620
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct edge { int to; int cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-12;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int dp[3010][3010];

int main(){
	string s,t;
	cin >> s >> t;
	for(int i = 0; i < s.size(); i++){
		for(int j = 0; j < t.size(); j++){
			if(s[i] == t[j]) dp[i+1][j+1] = dp[i][j]+1;
			else dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
		}
	}
	string ans;
	int i = s.size()-1,j = t.size()-1;
	while(i > -1 && j > -1){
		while(i != -1 && dp[i][j+1] == dp[i+1][j+1]) i--;
		while(j != -1 && dp[i+1][j] == dp[i+1][j+1]) j--;
		if(i != -1 && j != -1) ans = s[i]+ans;
		i--,j--;
	}
	/*cout << " " << t << endl;
	rep(i,s.size()+1){
		cout << s[i];
		rep(j,t.size()+1) cout << dp[i][j];
		cout << endl;
	}
	cout << dp[s.size()][t.size()] << endl;*/
	cout << ans << endl;

	return 0;
}

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

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc169/tasks/abc169_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            string result = (inputLongArray[0] * inputLongArray[1]).ToString();

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 19144
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll n;
    cin >> n;
    ll sum=0;
    for(ll i=1;i<=n;i++){
        if(i%3==0 || i%5==0) continue;
        sum += i;
    }
    cout << sum << endl;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pll = pair<ll, ll>;

#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair


template <typename T>
using vv = vector<vector<T>>;

void solve() {
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    if (x / d >= k) {
        cout << x - d * k;
    } else {
        k -= x / d;
        x -= d * (x / d);

        if (k % 2 == 0) cout << x;
        else cout << abs(x - d);
    }
}



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


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;



int32_t main()
{



	int i, j, n, m, x, ans;

	cin >> n >> m >> x;

	for (int i = 1; i <= 1000; ++i)
	{

		if (m * i >= n) {
			cout << i*x << endl;
			break;
		}

	}



}

Measured memory_bytes: 3632
#include<iostream>

using namespace std;

int main() {
	long long a, b, v, w, t;
	cin >> a >> v;
	cin >> b >> w;
	cin >> t;

	if ((v - w) * t >= abs(a - b)) {
		cout << "YES" << endl;
		return 0;
	}
	else {
		cout << "NO" << endl;
		return 0;
	}
}

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

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> c(h);
  for(int i = 0; i < h; i++) cin >> c.at(i);
  
  long long ans = 0;
  for(int bith = 0; bith < (1 << h); bith++){
    for(int bitw = 0; bitw < (1 << w); bitw++){
      int cnt = 0;
      for(int i = 0; i < h; i++){
        if(1 & (bith >> i)) continue;
        for(int j = 0; j < w; j++){
          if(1 & (bitw >> j)) continue;
          if(c.at(i).at(j) == '#') cnt++;
        }
      }
      if(cnt == k) ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
using namespace std;


int main(){
    vector<int> p;
    for(int i = 0; i < 3; i++)
    {
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
    }

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

    cout << p[0]*p[1]/2 << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <functional>

using namespace std;

int INF = 10000000;


string cast(string a,int l)
{
	int len = a.length();
	int array[8];

	for(int i = 0;i < l;i++)
	{
		if(i < len)
		{
			array[i] = a[i] - '0';
		}else
		{
			array[i] = 0;
		}
	}

	string max = "             ",min = "              ";

	sort(array,array+l,greater<int>());
	
	for(int i = 0;i < l;i++)
	{
		max[i] = array[i] + '0';
	}

	sort(array,array+l);
	
	for(int i = 0;i < l;i++)
	{
		min[i] = array[i] + '0';
	}

	

	return to_string( atoi(max.c_str()) - atoi(min.c_str()) );;

}




int main()
{
	int l;

	while(1)
	{
		string array[21];

		cin >> array[0] >> l;

		if(!l)break;

		bool flag =false;

		for(int i = 1;i < 21;i++)
		{
			array[i] = cast(array[i-1],l);

			for(int j = 0;j < i;j++)
			{
				if(array[i] == array[j])
				{
					cout << j << " ";
					cout << array[i] << " ";
					cout << i-j << endl;
					flag = true;
					break;
				}
			}
			if(flag)break;
		}
	
	}

  return 0;
}

Measured memory_bytes: 1272
inN,inT = list(map(int,input().split()))
outC = 1001
for i in range(inN):
  inCi,inTi = list(map(int,input().split()))
  if inTi <= inT and inCi < outC:
    outC = inCi

if outC != 1001:
  print(outC)
else:
  print("TLE")

Measured memory_bytes: 3060