akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        a: i32,
        b: i32,
    }
    println!("{}", if a < 10 && b < 10 { a * b } else { -1 })
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	for(int i = 1; i <= n; i++){
		int k = i * 1.08;
		if(k == n){
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/03  Problem: code-festival-2016-ex-final_c / Link: https://cf16-exhibition-final.contest.atcoder.jp/tasks/cf16_exhibition_final_c?lang=en  ----- */
/* ------問題------

チーターと不正者がニムをすることになりました。 このゲームでは、N 個の石の山を使います。 最初に i 番目の山には ai 個の石があります。 チーターが先手で、交互にターンを取ります。 それぞれのターンでは、プレイヤーは一つの山を選び、その山から一個以上の石を取り除きます。 ターンが回ってきたときに操作ができなくなったプレイヤーの負けです。
しかし、ゲームが始まる前に、不正者はチーターがどのような動きをしても必ず勝つことができるように少し不正をすることにしました。 それぞれの山から、不正者は 0 個または 1 個の石を取り除き、ゲームが始まる前に食べます。 不正者が必ず勝てるようにする方法が複数通りある場合は、食べる石の個数を最小にするようにしたいです。
不正者が食べる石の個数を求めてください。 不正をしても不正者が必ず勝つようにできない場合は、-1 を出力してください。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;



int popcount2(int x) {//二進数中のbitが1の数
	int ret = 0;
	while (x) {
		x &= x - 1;
		++ret;
	}
	return ret;
}

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

	cin >> N;
	VI a(N);
	VI cnt(31, 0);
	LL res = 0;

	FOR(i, 0, N) {
		cin >> a[i];
		res ^= a[i];
		cnt[popcount2((a[i] & -a[i]) - 1)]++;
	}

	debug(res);
	FORR(i, 30, 0 - 1) {
		if (res &(1 << i)) {
			if (cnt[i]) {
				res ^= (1 << (i + 1)) - 1;
				//debug(res);
				ans++;
			}
			else {
				break;
			}
		}
	}
	if (res)ans = -1;

	cout << ans << "\n";


	return 0;
}


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define show_table(n, k, table) rep(i,n){ rep(j,k) cout << table[i][j] << " "; cout << endl;}

using namespace std;

template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 100005;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,A,B; cin >> N >> A >> B;
  if(A+B-1>N){
    cout << "-1" << endl;
    return 0;
  }
  if(B==0){
    if(A!=N) cout << "-1" ;
    else REP(i,1,N+1) cout << i << " " ;
    cout << "" << endl;
    return 0;
  }
  vi ans;
  int rest = N - A;
  int now = 0;
  rep(i,A){
    if(rest>0){
      int temp = min(rest+1,B);
      rep(i,temp){
        ans.pb(now+temp-i);
      }
      now += temp;
      rest -= temp-1;
    }else{
      ans.pb(now+1);
      now++;
    }
  }
  // for(auto u:ans) cout << u << " ";
  // cout << "" << endl;
  if(ans.size()!=N) cout << "-1";
  else for(auto u:ans) cout << u << " ";
  cout << "" << endl;
  return 0;
}

Measured memory_bytes: 3440
use proconio::*;
use std::cmp::max;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    };

    let mut dp = vec![0; n];
    dp[0] = 1000;

    for i in 2..=n {
        for j in 1..i {
            let v = dp[j - 1] / a[j - 1] * a[j] + dp[j - 1] % a[j - 1];
            dp[j] = max(v, dp[j - 1]);
        }
    }

    println!("{}", dp[n - 1]);
}


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

int G[201][201];
int c[201];
int n;

bool dfs(int u,int f){
    if(~c[u]) return c[u] != f;
    c[u] = f;
    bool ret = false;
    for (int i = 0; i < n; i++) {
        if(G[u][i]){
            ret |= dfs(i, f^1);
        }
    }
    return ret; 
}




int main(){
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            G[i][j] = s[i][j] - '0';
        }
    }
    memset(c,-1,sizeof(c));
    if(dfs(0,0)){
        puts("-1");
        return 0;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if(!G[i][j]) G[i][j] = 1<< 20;
        }
        G[i][i] = 0;
    }
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                G[i][j] = min(G[i][j],G[i][k] + G[k][j]);
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            ans = max(ans,G[i][j]);
        }
    }
    cout << ans + 1 << endl;
    return 0;
}



Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

struct point {
	int n, x, y;
};
struct edge {
	int n1, n2, w;
};
class UnionFind {
private:
	vector<int> parent, rank;
public:
	UnionFind(int n) {
		int i;
		for (i = 0; i < n; i++) {
			parent.push_back(i);
			rank.push_back(0);
		}
	}
	int root(int x) {
		if (parent[x] == x) return x;
		else return parent[x] = root(parent[x]);
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) parent[x] = y;
		else {
			parent[y] = x;
			if (rank[x] == rank[y]) rank[x]++;
		}
	}
};
int main() {
	int i, n, cnt = 0;
	cin >> n;
	vector<point> p(n);
	vector<edge> e;
	for (i = 0; i < n; i++) {
		p[i].n = i;
		cin >> p[i].x >> p[i].y;
	}
	sort(full(p), [](const point &l, const point &r) {return l.x > r.x; });
	for (i = 0; i < n - 1; i++) {
		int n1, n2;
		n1 = p[i].n;
		n2 = p[i + 1].n;
		if (n1 > n2) swap(n1, n2);
		e.push_back({ n1,n2,p[i].x - p[i + 1].x });
	}
	sort(full(p), [](const point &l, const point &r) {return l.y > r.y; });
	for (i = 0; i < n - 1; i++) {
		int n1, n2;
		n1 = p[i].n;
		n2 = p[i + 1].n;
		if (n1 > n2) swap(n1, n2);
		e.push_back({ n1,n2,p[i].y - p[i + 1].y });
	}
	UnionFind uf(n);
	sort(full(e), [](const edge &l, const edge &r) {return l.w < r.w; });
	for (i = 0; i < e.size(); i++) {
		if (uf.same(e[i].n1, e[i].n2) == false) {
			uf.unite(e[i].n1, e[i].n2);
			cnt += e[i].w;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 6132
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
 
int main(){
  ll L;
  cin>>L;
  VL A(L+1);
  rep(i,L) cin>>A[i];
  A[L]=0;
  ll dp[L+2][5]={};
  rep(i,L+1){
    dp[i+1][0]=dp[i][0]+A[i];
    dp[i+1][1]=min(dp[i][0],dp[i][1])+(!A[i]?2:A[i]%2);
    dp[i+1][2]=min({dp[i][0],dp[i][1],dp[i][2]})+(A[i]+1)%2;
    dp[i+1][3]=min({dp[i][0],dp[i][1],dp[i][2],dp[i][3]})+(!A[i]?2:A[i]%2);
    dp[i+1][4]=min({dp[i][0],dp[i][1],dp[i][2],dp[i][3],dp[i][4]})+A[i];
  }
  cout<<dp[L+1][4]<<endl;
}

Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>

using namespace std;

int main(){
    while(true){
        int n;
        cin >> n;
        if(n==0)break;
        pair<double,string> temp;
        vector<pair<double,string> > list(n,temp);
        for(int i=0;i<n;i++){
            int p,a,b,c,d,e,f,s,m;
            cin >> list[i].second >> p;
            cin >> a >> b >> c >> d >> e >> f >> s >> m;
            double sumt=a+b+c+(d+e)*m;
            list[i].first=-(f*s*m-p)/sumt;
        }
        sort(list.begin(),list.end());
        for(int i=0;i<n;i++){
            cout << list[i].second <</* list[i].first <<*/ endl;
        }
        cout << '#' << endl;
    }
    return 0;
}
            

Measured memory_bytes: 3040
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define siz(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
void cmps(vector<int>&v,int &i){
	i=lower_bound(all(v),i)-v.begin();
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N;
vector<int>G[200005];
int co[200005];
int wh;
void dfs(int x,int p){
	if(co[x]>0)wh++;
	for(int i:G[x])if(i!=p){
		co[i]=co[x]*-1;
		dfs(i,x);
	}
}
signed main(){
	cin>>N;
	rep(i,N-1){
		int a,b;cin>>a>>b;a--;b--;
		G[a].pb(b);G[b].pb(a);
	}
	vector<int>num[3];
	REP(i,N+1)num[i%3].pb(i);
	co[0]=1;dfs(0,0);
	if(wh<=num[0].size()+num[1].size()&&wh>=num[1].size()){
		rep(i,N){
			if(co[i]>0){
				if(num[1].size()){
					cout<<num[1].back()<<" ";
					num[1].pop_back();
				}else {
					cout<<num[0].back()<<" ";
					num[0].pop_back();
				}
			}else {
				if(num[2].size()){
					cout<<num[2].back()<<" ";
					num[2].pop_back();
				}else {
					cout<<num[0].back()<<" ";
					num[0].pop_back();
				}
			}
		}
	}else {
		if(wh<num[1].size())rep(i,N)co[i]*=-1;
		rep(i,N){
			if(co[i]>0){
				if(num[1].size()){
					cout<<num[1].back()<<" ";num[1].pop_back();
				}else if(num[2].size()){
					cout<<num[2].back()<<" ";num[2].pop_back();
				}else {
					cout<<num[0].back()<<" ";num[0].pop_back();
				}
			}else {
				cout<<num[0].back()<<" ";num[0].pop_back();
			}
		}
	}
}


Measured memory_bytes: 20460
using System;
using System.Collections.Generic;
using System.Linq;

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var abt = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = abt[0];
            var b = abt[1];
            var t = abt[2];

            var time = a;
            var ans = 0;

            while(time < t + 1)
            {
                ans += b;
                time += a;
            }
            Console.WriteLine(ans);
        }
    }
}


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

string s;

signed main()
{
	cin >> s;
	bool C = false;
	int Cpos = 999;
	int Fpos = -1;
	bool F = false;
	rep(i,s.length()) {
		if (s[i] == 'C' && !C) {
			C = true;
			Cpos = i;
		}
		if (s[i] == 'F') {
			F = true;
			Fpos = i;
		}
	}

	if (C && F && Cpos < Fpos) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
/*  
	Come feed the rain
	Cos I'm thirsty for your love
	Dancing underneath the skies of lust
	Yeah feed the rain...
	Cos without your love my life
	Ain't nothing but this carnival of rust
    _________________________
    _________________________
    864 Hours of Solitude
    Quarantine_Day : 36
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int       ll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef pair<int, int>      pii;
typedef pair<ll, ll>		pll;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<int>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 50005
#define MOD 1000000007

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

	int n, m;
	cin>>n>>m;

	int deg[n + 5] = {0};

	REP(i, m){
		int x, y; cin>>x>>y;
		deg[x]++;
		deg[y]++;
	}
	REP(i, n) cout<<deg[i + 1]<<"\n";

	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 char s[10];
 scanf("%s",s);
 if((s[0]==s[1]&&s[1]==s[2])||(s[3]==s[1]&&s[1]==s[2])||(s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3]))
    cout<<"Yes"<<endl;
 else cout<<"No"<<endl;
   return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;
void gen() {exit(0);}

int n, k;
const int N = 1e5 + 6;
int a[N];

int main() {
    #ifdef DEBUG
    freopen("input", "r", stdin);
//    freopen("output", "w", stdout);
//    gen();
    #endif
    scanf("%d %d", &n, &k);
    int one = -1;
    forn(i, 0, n) {
        int x;
        scanf(" %d", &x);
        if (x == 1) one = i + 1;
    }
    
    int ans = 100000;
    
    int q = k - 1;
    int s = one;
    int cur = 1;
    int l = s - 1;
    int r = max(0, n - (s + k - 1));
    cur += (l / q + (l % q != 0));
    cur += (r / q + (r % q != 0));
    ans = min(ans, cur);
    
    forn(i, 1, k) {
        s = max(1, one - i);
        cur = 1;
        l = s - 1;
        r = max(0, n - (s + k - 1));
        cur += (l / q + (l % q != 0));
        cur += (r / q + (r % q != 0));
        ans = min(ans, cur);
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int A,B;

  scanf("%d%d", &A, &B);
  int K;

  if((A+B)%2 ==0){
  K = (A + B) / 2;
  printf("%d", K);
  }

  else
  printf("IMPOSSIBLE\n");

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll r, d, x;
    cin >> r >> d >> x;
    rep(i, 0, 10) {
        x = r * x - d;
        cout << x << endl;
    } 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int A,B;
  cin>>A>>B;
  cout << max(A+B,max(A-B,A*B)) << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int[] vs = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
			int N = vs[0];
			int K = vs[1];
			int[] V = Console.ReadLine().Split().Select(p => int.Parse(p)).Take(N).ToArray();

			long ans = 0;
			for (int i = 0; i <= Math.Min(N, K); i++) {
				for (int j = 0; j <= Math.Min(N, K) - i; j++) {
					if (i + j == N && j != 0) {
						break;
					}
					int[] tmp = V.Where((_, index) => index < i || N - j <= index).OrderBy(p => p).ToArray();
					long sum = 0;
					int skip = K - i - j;
					for (int k = 0; k < tmp.Length; k++) {
						if (skip > 0 && tmp[k] < 0) {
							skip--;
						} else {
							sum += tmp[k];
						}
					}
					ans = Math.Max(ans, sum);
				}
			}
			Console.WriteLine(ans);
		}
	}
}


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

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

    vector<int> a(n), b(n), c(n);
    for(int i = 0 ; i < n ; ++i){
        cin >> a[i];
    }
    for(int i = 0 ; i < n ; ++i){
        cin >> b[i];
    }
    for(int i = 0 ; i < n ; ++i){
        cin >> c[i];
    }

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

    long long ans = 0;
    for(int i = 0 ; i < n ; ++i){
        ans += (long long)(lower_bound(a.begin(), a.end(), b[i]) - a.begin()) * (long long)(c.end() - upper_bound(c.begin(), c.end(), b[i]));
    }

    cout << ans << endl;

    return 0;
}

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

// https://github.com/atcoder-live/library/blob/master/mint.cpp
const std::int64_t mod = 998244353;
struct mint {
    std::int64_t x; // typedef long long ll;
    mint(std::int64_t x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(std::int64_t t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
std::istream& operator>>(std::istream& is, const mint& a) { return is >> a.x;}
std::ostream& operator<<(std::ostream& os, const mint& a) { return os << a.x;}

const ll MAX_N = 200005;
vector<mint> a(MAX_N, 0);
vector<mint> memo(MAX_N, 0);
vector<pair<ll, ll>> ranges;

int main() {
    ll N, K; cin >> N >> K;
    for (int i = 0; i < K; ++i) {
        ll l, r; cin >> l >> r;
        ranges.emplace_back(l, r);
    }
    a[0] = 1;
    for (int n = 0; n < N; ++n) {
        if (n > 0) memo[n] += memo[n-1];
        a[n] += memo[n];
        for (const auto& [l, r] : ranges) {
            memo[min(n + l, MAX_N - 1)] += a[n];
            memo[min(n + r + 1, MAX_N - 1)] -= a[n];
        }
    }
    // for (int i = 0; i < 10; ++i) std::cout << i << "\t"; cout << endl;
    // for (int i = 0; i < 10; ++i) std::cout << a[i] << "\t"; cout << endl;
    // for (int i = 0; i < 10; ++i) std::cout << memo[i] << "\t"; cout << endl;
    cout << a[N - 1] << endl;
    return 0;
}


Measured memory_bytes: 6280
N = int(input())
A = list(map(int, input().split()))

ans = -1
flg = 1

while (flg):
    ans += 1
    for i in range(N):
        if A[i] % 2 != 0:
            flg = 0
        else:
            A[i] /= 2

print(ans)

Measured memory_bytes: 3188
a, b, c, d, e, f = gets.split.map(&:to_i)

s = []
w = []

50.times do |i|
  50.times do |j|
    tmpw = (a * i + b * j) * 100
    w.push tmpw if tmpw < f && tmpw > 0
    tmps = c * i + d * j
    s.push tmps if tmps < f
  end
end

max_pr = suma = sums = 0

w.each do |i|
  s.each do |j|
    next unless i + j <= f
    pr = j.to_f / (i + j) # 濃度
    next unless pr > max_pr && j <= e / 100.0 * i
    max_pr = pr
    suma = i + j
    sums = j
  end
end

suma = a * 100 if suma.zero?
printf("%d %d\n", suma, sums)

Measured memory_bytes: 1788
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>




int main(void){
char s[1005];


for(;;){
scanf("%s",s);
if(s[0]=='0'){break;}
int sum=0;
    for(int i=0;s[i]!='\0';i++){
        sum=sum+s[i]-'0';
    }
    printf("%d\n",sum);
}
}




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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, c;
    cin >> a >> b >> c;
    if(a > b)
    {
        swap(a, b);
        if(a > c)
            swap(a, c);
    }
    if(b > c)
    {
        swap(b, c);
        if(a > b)
            swap(a, b);
    }
    if(a > c)
    {
        swap(a, c);
        if(a > b)
            swap(a, b);
    }
    cout << a << " "  << b << " " <<  c << endl;
    
    return 0;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int h, w;
  cin >> h >> w;
  vector<vector<char>> pix(h, vector<char>(w));
  vector<vector<char>> lpix(2*h, vector<char>(w,'.'));
  
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin >> pix.at(i).at(j);
    }
  }
  
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      lpix.at(2*i).at(j) = pix.at(i).at(j);
      lpix.at(2*i+1).at(j) = pix.at(i).at(j);
    }
  }
  
  for(int i=0; i<2*h; i++){
    for(int j=0; j<w; j++){
      cout << lpix.at(i).at(j);
    }
    cout << endl;
  }
  
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define MAX 1000000

int main() {
    int64_t H; cin >> H;
    int64_t turn = 0;
    int i = 0;
    while (pow(2, i) <= H) i++;
    turn = pow(2, i) - 1;
    cout << turn << endl;
}

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

string getSubStr(string s1, string s2)
{
    string s = "";
    int len1 = int(s1.size()), len2 = int(s2.size()), index1 = 0, index2 = 0;
    while(index1 < len1 && index2 < len2)
    {
        if(s1[index1] == s2[index2])
        {
            s += s1[index1];
            index1 ++;
            index2 ++;
        }
        else if(s1[index1] < s2[index2]) index1 ++;
        else if (s1[index1] > s2[index2]) index2 ++;
    }
    return s;
}


int main()
{
    int n, tmp;
    vector<string> arr;
    string tmpStr;
    cin>>n;
    tmp = n;
    while(tmp > 0)
    {
        cin>>tmpStr;
        sort(tmpStr.begin(), tmpStr.end());
        arr.push_back(tmpStr);
        tmp--;
    }
    tmpStr = arr[0];
    for(int i = 1; i<n; i++)
    {
        tmpStr = getSubStr(tmpStr, arr[i]);
    }
    cout<<tmpStr<<endl;
    return 0;
}


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

int main(){
	double f,h,l;
	
	cin >> l;
	h = l;
	
	while(cin >> f){
		h = max(h,f);
		l = min(l,f);
	}
	
	cout << h-l << endl;
	
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    int n;
    cin >> n;
    vector<int>vn(n);
    vector<int>cn(n);
    for(int i = 0; i < n; i++){
        cin >> vn.at(i);
    }
    for(int i = 0; i < n; i++){
        cin >> cn.at(i);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(vn.at(i) - cn.at(i) > 0){
            ans += (vn.at(i) - cn.at(i));
        }
    }
    cout << ans << endl;
    solve();
    return 0;
}



Measured memory_bytes: 256
from collections import Counter
n,k=map(int,input().split())
a=list(map(int,input().split()))
x=len(set(a))
#print(x)
C=Counter(a)
ans=0
#print(C)
C2 = sorted(C.items(), key=lambda x:x[1])
#print(C2)
if k>x:
    print(0)
else:
    for i in range(x-k):
        ans+=C2[i][1]
    print(ans)

Measured memory_bytes: 48536
#include <stdio.h>

int is_triangle(int x, int y, int z)
{
  if(x >= y + z) {
    return 0;
  }
  else if(y >= z + x) {
    return 0;
  }
  else if(z >= x + y) {
    return 0;
  }
  else {
    return 1;
  }
}

int merge_sort(int l, int r, int *a)
{
  int k = (r + l) / 2;
  int x, y, z;
  int temp_a[10000];

  if(l >= r - 1) {
    return 0;
  }
  else {
    merge_sort(l, k, a);
    merge_sort(k, r, a);

    x = l;
    y = k;
    z = 0;

    while(z < r-l) {
      if(x >= k) {
        temp_a[z] = a[y];
        y++;
      }
      else if(y >= r) {
        temp_a[z] = a[x];
        x++;
      }
      else if(a[x] < a[y]) {
        temp_a[z] = a[x];
        x++;
      }
      else {
        temp_a[z] = a[y];
        y++;
      }
      z++;
    }

    for(int i = l; i < r; i++) {
      a[i] = temp_a[i-l];
    }

    return 0;
  }
  
}

int main(void)
{
  int n;
  scanf("%d", &n);
  int len[n];
  for(int i = 0;i < n;i++) {
    scanf("%d", &len[i]);
  }
  merge_sort(0, n, len);

  int sum = 0;
  for(int i = 0; i < n; i++) {
    for(int j = i+1; j < n; j++) {
      for(int k = j+1; k < n; k++) {
        if(is_triangle(len[i],len[j],len[k])) {
          sum++;
        }
        else {
          break;
        }
      }
    }
  }

  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;
    
    

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        for (int a = 1; a < 3500; a++)
        {
            for (int b = a; b < 3500; b++)
            {
                double P = (4.0 / N) - (1.0 / a) - (1.0 / b);
                if (P <= 1e-6 || P >= 2) continue;
                int c = (int)((1 / P) + 0.5);
                if (c < 1 || c >= 3501) continue;
                double num = (1.0 / a) + (1.0 / b) + (1.0 / c);
                if(Math.Abs(num - (4.0 / N)) < 1e-14)
                {
                    Console.WriteLine("{0} {1} {2}", a, b, c);
                    return;
                }
            }
        }
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13268
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next();
  var a = nexts(n+1);
  if(n === 0){
   if(a[0] === 1)return 1;
   return -1;
  }
  if(a[0])return -1;
  var INF = 4e15;
  var dp1 = Array(n+1);
  dp1[0] = 1;
  for(var i = 1; i <= n; i++){
    dp1[i] = Math.min(dp1[i-1]*2,INF);
    dp1[i] -= a[i];
    if(dp1[i] <= 0){
      if(i !== n || dp1[i] < 0)return -1;
    }
  }
  var dp2 = Array(n+1);
  dp2[n] = 0;
  var dp3 = Array(n+1);
  dp3[n] = 0;
  for(var i = n-1; i >= 0; i--){
    dp2[i] = dp2[i+1]+a[i+1];
    dp3[i] = Math.floor((dp3[i+1]+a[i+1]+1) / 2);
  }
  var ans = 0n;
  for(var i = 0; i <= n; i++){
    //console.log(i,dp1[i],dp2[i],dp3[i]);
    if(dp3[i] > dp1[i])return -1;
    ans += BigInt(Math.min(dp1[i],dp2[i]) + a[i]);
  }
  return ans.toString();
}

Measured memory_bytes: 49124
#include <iostream>
#include <cstdio>
#include <map>

using namespace std;

int main()
{
    map<int, int> ans;
    map<int, int> chk;
    char ch;
    bool flag = false, fst = true;


    while ((ch = getchar()) != EOF) {
        if (ch == '\n') 
            fst = false;
        else {
            int id;
            id = ch - '0';
            
            while ((ch = getchar()) != ',') {
                id *= 10;
                id += ch - '0';
            }
            while ((ch = getchar()) != '\n')
                ;

            ans[id]++;
            if (fst && chk.count(id) == 0) 
                chk[id]++;
            else if (!fst && chk.count(id) != 0 && chk[id] == 1) 
                chk[id]++;
        }
    }
        

    map<int, int>::iterator it = ans.begin();
    while (it != ans.end()) {
        if (chk[(*it).first] == 2)
            cout << (*it).first << " " << (*it).second << endl;
        it++;
    }

    return 0;
}

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

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

    int X, A;
    cin >> X >> A;
    if (X < A) {
        cout << 0 << '\n';
    } else {
        cout << 10 << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	int K;
	cin >> K;
	cout << (K / 2) * ((K + K % 2) / 2) << endl;

ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

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

int main(){
  ll a,b;
  cin >> a >> b;
  ll A = a;
  ll B = b;
  bool fin = 1;
  while(fin){
    if( A < B ) A += a;
    else if( A > B ) B += b;
    if( A == B ) fin = 0;
  }
  cout << A << endl;
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
//桁数判定 O(logN)
int64_t keta(int64_t n){
    int tmp=0;
    if(n==0){
        tmp=1;
    }
    else{
        while(n>0){
            n = n/10;
            //cout << n<<endl;
            tmp++;
        }
    }
    return tmp;
}

int main(){
    int64_t n;
    cin>>n;
    int ans = 100;
    for(int64_t i=1;i<=sqrt(n);i++){
        if(n%i==0){
            int64_t s = n/i;
            int f = max(keta(i),keta(s));
            if(f<ans){
                ans = f;
                //cout<<i<<","<<s<<endl;
            }
        }
    }
    cout<<ans<<endl;
}

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

int main(){
  int n,m;cin >> n >> m;
  int dest=n;
  int prev_l=1, prev_r=n;
  rep(i,m){
    int l,r; cin >> l >> r;
    if(r<prev_l||l>prev_r){
      dest=0;
      break;
    }
    dest-=max((l-prev_l),0);
    dest-=max((prev_r-r),0);
    prev_l = max(prev_l,l);
    prev_r = min(prev_r,r);
  }

  cout << dest << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

struct C{
	int n;
	char c;
	C(){}
}c[10];

int T;

bool cmp(C a,C b){return a.n<b.n;}

int f(C* c){
	int l=0,res=0;
	while(c[l].n)l++;
	if(!l)return 1;
	rep(i,l)rep2(j,i+1,l)rep2(k,j+1,l){
		if((c[i].n==c[j].n&&c[j].n==c[k].n||c[i].n==c[j].n-1&&c[j].n==c[k].n-1)
		&&c[i].c==c[j].c&&c[j].c==c[k].c){
			C d[9];
			int cur=0;
			rep(ii,9)if(ii!=i&&ii!=j&&ii!=k)d[cur++]=c[ii];
			d[cur].n=0;
			res|=f(d);
		}
	}
	return res;
}

int main(){
	cin>>T;
	while(T--){
		rep(i,9)cin>>c[i].n;
		rep(i,9)cin>>c[i].c;
		sort(c,c+9,cmp);
		cout<<f(c)<<endl;
	}
}

Measured memory_bytes: 0
def warshall_floyd(d,n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d


def main():
    INF = 10**18
    n,m,l = map(int, input().split())
    d = [ [INF]*(n+1) for _ in range(n+1) ]
    for _ in range(m):
        a,b,c = map(int, input().split())
        d[a][b] = c
        d[b][a] = c

    d = warshall_floyd(d,n+1)
    new_d = [ [INF]*(n+1) for _ in range(n+1) ]
    for a in range(n+1):
        for b in range(n+1):
            if d[a][b] <= l:
                new_d[a][b] = 1
                new_d[b][a] = 1


    new_d = warshall_floyd(new_d,n+1)
    ansl = []
    q = int(input())
    for _ in range(q):
        s,t = map(int, input().split())
        ans = new_d[s][t]
        if ans >= INF: ans = 0
        ansl.append(ans-1)

    for a in ansl: print(a)



if __name__ == "__main__":
    main()

Measured memory_bytes: 83660
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

struct Node{
	int key;
	Node *next,*prev;
};
Node *nil;
Node* listSearch(int key){
	Node *cur=nil->next;
	while(cur!=nil && cur->key!=key){
		cur=cur->next;
	}
	return cur;
}
void init(){
	nil=(Node*)malloc(sizeof(Node));
	nil->next=nil;
	nil->prev=nil;
}
void printList(){
	Node *cur=nil->next;
	int isf=0;
	while(1){
		if(cur==nil)break;
		if(isf++>0)printf(" ");
		printf("%d",cur->key);
		cur=cur->next;
	}
	printf("\n");
}
void deleteNode(Node *t){
	if(t==nil)return;
	t->prev->next=t->next;
	t->next->prev=t->prev;
	free(t);
}
void deleteFirst(){
	deleteNode(nil->next);
}
void deleteLast(){
	deleteNode(nil->prev);
}
void deleteKey(int key){
	deleteNode(listSearch(key));
}

void insert(int key){
	Node *x=(Node *)malloc(sizeof(Node));
	x->key=key;
	x->next=nil->next;
	nil->next->prev=x;
	nil->next=x;
	x->prev=nil;
}
int main(){
	int key,n,i;
	int size=0;
	char com[20];
	int np=0,nd=0;
	scanf("%d",&n);
	init();
	for(i=0;i<n;i++){
		scanf("%s %d",com,&key);
		if(com[0]=='i'){insert(key);np++;size++;
		}else if(com[0]=='d'){
			if(strlen(com)>6){
				if(com[6]=='F')deleteFirst();
				else if(com[6]=='L')deleteLast();
			}else{
				deleteKey(key);nd++;
			}
			size--;
			
	}
	}
	printList();
	 return 0;
} 


Measured memory_bytes: 34412
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ud = new HashSet<char> { 'U', 'D' };
            var s = Console.ReadLine().ToArray();
            var result = "Yes";
            for (var i = 0; i < s.Length; i++)
            {
                var c = s[i];
                if (!ud.Contains(c) && i % 2 == 0 ? c == 'L' : c == 'R')
                {
                    result = "No";
                    break;
                }
            }

            Console.WriteLine(result);

        }
    }
}

Measured memory_bytes: 26628
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        // ABC150B - Count ABC
 
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        String s = sc.next();

        char[] cs = s.toCharArray();
        int ans = 0;

        for (int i = 0; i < n - 2; i++) {
            if (cs[i] == 'A' && cs[i + 1] == 'B' && cs[i + 2] == 'C' ) {
                ++ans;
             }
        }

        System.out.println(ans);
    }
}

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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

void MAIN() {
  int n; cin >> n;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  sort(all(a), greater<int>());
  int t = n - 2, s = a[0];
  for (int i = 1; i < n; i++) {
    if (t >= 2) {
      s += a[i] * 2;
      t -= 2;
    }
    else if (t >= 1) {
      s += a[i];
      t -= 1;
    }
  }
  cout << s << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

int main(){
  int n,x,t;
  cin >> n >> x >> t;
  if(n%x==0) cout << (n/x)*t << endl;
  else cout << ((n/x)+1)*t << endl;
  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;
const int MAX=200001;

signed main(){
    int N;cin>>N;
    string S;cin>>S;
    int lsum=0,rsum=0;
    REP(i,N){
        if(S[i]==')'){
            if(rsum==0)lsum++;
            else rsum--;
        }
        else{
            rsum++;
        }
    }
    string ans="";
    REP(i,lsum)ans+='(';
    ans+=S;
    REP(i,rsum)ans+=')';
    cout<<ans<<endl;
}

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

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

  if ((n+1)/2 >= k) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#ifndef d
#define d(...)
#endif
#define st first
#define nd second
#define pb push_back
#define siz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
typedef long long LL;
typedef long double LD;
constexpr int INF=1e9+7;
constexpr LL INFL=1e18;
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

vector<int> solve(int n, int A, int B) {
	if(n == 1) return {A, B};
	auto x = A ^ B;
	x = x & (-x);
	auto l = __lg(x);
	auto f = [&](int y) {
		return ((y >> (l+1)) << l) ^ (y & (x - 1));
	};
	
	auto _A = f(A), _B = f(B);
	auto&& p = solve(n-1, _A, _A^1), q = solve(n-1, _A^1, _B);
	auto& change = (A & x ? p : q), &mv = (A & x ? q : p);
	
	auto g = [&](int y) {
		return ((y >> l) << (l+1)) ^ (y & (x - 1));
	};
	
	//cerr << "solving for: " << n << ", " << make_pair(A, B) << " converted to: " << make_pair(_A, _B) << " x, l = " << x << ", " << l << endl;
	//cerr << "received: ";
	//for(auto x:p) cerr << x << " ";
	//cerr << " and ";
	//for(auto x:q) cerr << x << " ";
	//cerr << endl;
	
	for(auto& val:change) {
		val = g(val);
		val ^= x;
	}
	for(auto& val:mv)
		val = g(val);
	
	//cerr << "converted to: ";
	//for(auto x:p) cerr << x << " ";
	//cerr << " and ";
	//for(auto x:q) cerr << x << " ";
	//cerr << endl;
	
	for(auto val:q)
		p.push_back(val);
	
	return p;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, A, B;
	cin >> n >> A >> B;
	if(__builtin_popcount(A) % 2 == __builtin_popcount(B) % 2)
		return cout << "NO\n", 0;
	
	cout << "YES\n";
	auto&& path = solve(n, A, B);
	for(auto x:path)
		cout << x << " ";
	cout << "\n";
}


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

int main() {
  int c[101][101],n;
  cin>>n;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)cin >> c[i][j];

  long long ans = 0;
  for(int i=0;i<n;i++)
    for(int j=i;j<n;j++) ans+=min(c[i][j],c[j][i]);
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=10000003,INF=1<<30;
ll inv[MAX],fac[MAX],finv[MAX];

void make(){
    
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    
    for(int i=2;i<MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll)i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
    
}

ll comb(ll a,ll b){
    if(a<b) return 0;
    return fac[a]*(finv[b]*finv[a-b]%mod)%mod;
}

ll rui(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}


int main(){
    
    make();
    
    int N;cin>>N;
    
    ll ans=rui(3,N);
    
    for(int i=N/2+1;i<=N;i++){
        ans+=2*(mod-(comb(N,i)*rui(2,N-i))%mod);
        ans%=mod;
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 234624
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

int main(){
    int m;
    cin >> m;
    m=24-m;
    cout << (24+m) << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

//prototype
void merge(int,int,int);
void mergesort(int,int);

//global
int *data, cnt=0;

int main(){
  int data_n, i;

  //input
  scanf("%d",&data_n);
  data=(int *)malloc(sizeof(int)*data_n);
  for(i=0;i<data_n;i++) scanf("%d",&data[i]);


  //mergesort
  mergesort(0,data_n);


  //output
  for(i=0;i<data_n-1;i++) printf("%d ",data[i]);
  printf("%d\n%d\n",data[i],cnt);

  free(data);  
  return 0;
}


void merge(int left,int mid,int right){
  int n1, n2, *L, *R;
  int i, j, k;

  n1=mid-left;
  n2=right-mid;

  L=(int *)malloc(sizeof(int)*(n1+1));
  R=(int *)malloc(sizeof(int)*(n2+1));

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

  L[n1]=R[n2]=INT_MAX;

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

  free(L);
  free(R);
}


void mergesort(int left,int right){
  int mid;
  
  if(left+1<right){
    mid=(left+right)/2;
    mergesort(left,mid);
    mergesort(mid,right);
    merge(left,mid,right);
  }
}



Measured memory_bytes: 5472
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  double a[n];
  string ab[n];
  double ans = 0;
  for(int i = 0;i<n;i++){
    cin >> a[i];
    cin >> ab[i];
    if(ab[i] == "JPY"){
      ans = ans + a[i];
    }
    else{
      ans = ans + 380000*a[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256