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

template <typename T> T load() { T r; cin >> r; return r; }
template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; }

template <unsigned m> struct Mint {
    Mint():val(0){}
    Mint(int raw):val((raw%m+m)%m){}
    Mint(long long raw):val((raw%m+m)%m){}
    Mint(unsigned raw):val(raw%m){}
    Mint(unsigned long long raw):val(raw%m){}
    friend Mint operator+(Mint a, Mint b) { return a.val + b.val; }
    friend Mint operator-(Mint a, Mint b) { return m + a.val - b.val; }
    friend Mint operator*(Mint a, Mint b) { return 1ll * a.val * b.val; }
    friend Mint operator/(Mint a, Mint b) { return a * qpow(b, m-2); }
    friend Mint& operator+=(Mint& a, Mint b) { return a = a + b; }
    friend Mint& operator-=(Mint& a, Mint b) { return a = a - b; }
    friend Mint& operator*=(Mint& a, Mint b) { return a = a * b; }
    friend Mint& operator/=(Mint& a, Mint b) { return a = a / b; }
    friend bool operator==(Mint a, Mint b) { return a.val == b.val; }
    friend bool operator!=(Mint a, Mint b) { return a.val != b.val; }
    friend ostream& operator<<(ostream& out, Mint x) { return out << x.val; }
    unsigned val;
};

using M = Mint<1'000'000'000 + 7>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    auto n = load<int>();
    auto bounds = vector<char>(n, '_');
    bounds[0] = '>';
    for (auto i=0; i<n-1; ++i)
        bounds[i+1] = load<char>();

    auto dyn = vector<vector<M>>(n+1, vector<M>(n+1, 0));
    dyn[0][n] = 1;
    auto pre = dyn;

    for (auto i=0; i<n; ++i) {
        for (auto p=0; p<n-i+1; ++p) {
            if (bounds[i] == '<')
                dyn[i+1][p] = pre[i][p];
            else
                dyn[i+1][p] = pre[i][n-i] - pre[i][p];
        }
        pre[i+1][0] = dyn[i+1][0];
        for (auto p=1; p<=n; ++p)
            pre[i+1][p] = dyn[i+1][p] + pre[i+1][p-1];
    }

    auto total = dyn[n][0];
    cout << total << '\n';

}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
ll mod = 1000000007;
ll inf = 1e18;
int main(){

    int n;
    cin >> n;
    vector<ll> x(n),y(n);
    ll min_x=inf,min_y=inf;
    rep(i,n){
        cin >> x[i] >> y[i];
        min_x=min(min_x,x[i]);
        min_y=min(min_y,y[i]);
    }
    rep(i,n){
        x[i]-=min_x;
        y[i]-=min_y;
    }

    ll max_d=0, min_d=inf;
    rep(i,n){
        max_d=max(max_d,x[i]+y[i]);
        min_d=min(min_d,x[i]+y[i]);
    }
    ll ans1=max_d-min_d;
    max_d=0; min_d=inf;
    rep(i,n){
        max_d=max(max_d,x[i]-y[i]);
        min_d=min(min_d,x[i]-y[i]);
    }
    ll ans2=abs(max_d-min_d);

    cout << max(ans1,ans2) << endl;
    // cout << ans2 << endl;

    return 0;
}

Measured memory_bytes: 6404
#include <iostream>

using namespace std;

int main(void){
  int N;
  cin >> N;
  int a, b, c;

  a = N/100;
  b = N%100/10;
  c = N%100%10;

  while(a != b || b != c){
    N++;
    a = N/100;
    b = N%100/10;
    c = N%100%10;
  }
  cout << N << endl;


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	
  long long int n=0,w=0,i=0,j=0,y=0,z=0;
  cin >> n >> w;
  long long int val[n+1],wt[n+1],dp[n+1][w+1];
  memset(dp,0,sizeof(dp));
  for(i=0;i<n;i++){
  	cin >> wt[i] >> val[i];
  }
  for(i=1;i<=n;i++){
  	for(j=1;j<=w;j++){
    	if(wt[i-1]<=j){
        	dp[i][j] = max(dp[i-1][j -wt[i-1]]+val[i-1],dp[i-1][j]);
        }
      	else dp[i][j] = dp[i-1][j];
    }
  }
  cout << dp[n][w];
}

Measured memory_bytes: 79104
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int p = scan.nextInt();
		String a = scan.next();
		String b = scan.next();
		String c = scan.next();
		int cou = 0;
		for(int i=0;i<p;i++){
			if((a.charAt(i)==b.charAt(i))&&(b.charAt(i)==c.charAt(i))){
				cou+=0;
			}else if(a.charAt(i)==b.charAt(i)){
				cou++;
			}else if(b.charAt(i)==c.charAt(i)){
				cou++;
			}else if(a.charAt(i)==c.charAt(i)){
				cou++;
			}else{
				cou+=2;
			}
		}
		System.out.println(cou);
	}
}

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

int main () {
  int N, K, sum, i;
  cin >> N >> K;
  sum = 1;
  
  for (i = 0; i < N; i++) {
    if (sum + K < sum * 2) {
      sum += K;
    }
    else {
      sum *= 2;
    }
  }
  
  cout << sum << endl;
}

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

using namespace std;

int main()
{
	bool cond = true;
	string s;
	cin >> s;
	
	map<char, int> c;
	
	for(int i = 0; i < s.size(); c[s[i]] += 1, i++);
	
	for(int i = 0; i < s.size(); i++)
		if(c[s[i]] % 2 != 0)
		{
			cond = false;
			break;
		}
	
	if(cond)
		printf("Yes\n");
	else
	   	printf("No\n");
	   
	return 0;
}

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

using namespace std;

int main() {
    int N, X;
    int count = 0;
    int num   = 0;
    cin >> N >> X;
    int m[N];
    for (int i = 0; i < N; i++) {
        cin >> m[i];
    }
    for (int i = 0; i < N; i++) {
        X -= m[i];
    }
    sort(m, m + N);

    count = N + X / m[0];

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int a=0,i,max, min,n;
	long long int plus = 0;
	
	scanf("%d",&a);
	max = -1000000;
	min = 1000000;
	for (i=0;i<a;i++){
		scanf("%d",&n);
		if(max<n) max=n;
		if(min>n) min=n;
		plus = plus + n;
	}
	
	printf("%d %d %lld\n", min,max,plus);
	return 0;
}



Measured memory_bytes: 2104
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: i32,
    }

    let f = n/100;
    let s = n%100;

    let mut fy = false;
    let mut sy = false;

    if 1 <= s && s <= 12{
        fy = true;
    }

    if 1 <= f && f <= 12{
        sy = true;
    }
    
    if fy & sy{
        println!("AMBIGUOUS");
    }else if fy{
        println!("YYMM");
    }else if sy{
        println!("MMYY");
    }else{
        println!("NA");
    }

}


Measured memory_bytes: 2168
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int f[120][120],s[10000],sp,dis[120];
bool b[120];
const int maxdis=1000000000;
int main(){
	int n,m;
	while(scanf("%d%d",&n,&m)==2){
		if(n==0&&m==0) break;
		int i,j,k;
		for(i=1;i<=n;i++){
			for(j=1;j<=n;j++) f[i][j]=0;
		}
		int v1,v2,e;sp=0;
		for(i=0;i<m;i++) scanf("%d%d%d",&v1,&v2,&e),f[v1][v2]=e,f[v2][v1]=e,s[sp++]=e;
		sort(s,s+sp);
		int diff=maxdis;
		for(i=0;i<sp;i++){
			if(i&&s[i]==s[i-1]) continue;
			bool bb=1;
			for(j=2;j<=n;j++) b[j]=0;b[1]=1;
			for(j=2;j<=n;j++){
				if(f[1][j]>=s[i]) dis[j]=f[1][j];
				else dis[j]=maxdis;
			}
			int minind,mindis,maxd=0,mind=maxdis;
			for(j=2;j<=n;j++){
				mindis=maxdis;
				for(k=1;k<=n;k++){
					if(b[k]) continue;
					if(mindis>dis[k]&&dis[k]>=s[i]) mindis=dis[k],minind=k;
				}
				if(mindis==maxdis){bb=0;break;}
				if(maxd<mindis) maxd=mindis;
				if(mind>mindis) mind=mindis;
				b[minind]=1;
				for(k=1;k<=n;k++){
					if(b[k]) continue;
					if(dis[k]>f[k][minind]&&f[k][minind]>=s[i]) dis[k]=f[k][minind];
				}
			}
			if(!bb) break;
			if(diff>maxd-mind) diff=maxd-mind;
		}
		if(!i) puts("-1");
		else printf("%d\n",diff);
	}
	
	return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
struct Operation {
	int left, right;
	long long int cost;
};
class MinSegmentTree {
	std::vector<std::vector<long long int>> vec;
public:
	MinSegmentTree(const int size) : vec{ std::vector<long long int>(size, LLONG_MAX) } {
		while (vec.back().size() > 1) {
			vec.emplace_back(vec.back().size() / 2, LLONG_MAX);
		}
		for (auto i = 1; i < vec.size(); ++i) {
			for (auto j = 0; j < vec[i].size(); ++j) {
				vec[i][j] = std::min(vec[i - 1][j * 2], vec[i - 1][j * 2 + 1]);
			}
		}
	}
	long long int get(int from, int to) const {
		long long int result = LLONG_MAX;
		for (auto i = 0; i < vec.size(); ++i) {
			if (from % 2 == 1) {
				result = std::min(result, vec[i][from]);
				++from;
			}
			if (to % 2 == 0) {
				result = std::min(result, vec[i][to]);
				--to;
			}
			if (from > to) {
				return result;
			}
			from /= 2;
			to /= 2;
		}
		return result;
	}
	void set(int position, long long int new_value) {
		vec[0][position] = std::min(vec[0][position], new_value);
		for (auto i = 1; i < vec.size(); ++i) {
			position /= 2;
			if (position >= vec[i].size()) return;
			vec[i][position] = std::min(vec[i - 1][position * 2], vec[i - 1][position * 2 + 1]);
		}
	}
};
int main() {
	int n, m; std::cin >> n >> m;
	std::vector<Operation> operations(m); for (auto& op : operations) { std::cin >> op.left >> op.right >> op.cost; --op.left; --op.right; }
	std::sort(operations.begin(), operations.end(), [](const Operation& a, const Operation& b) {return a.right == b.right ? a.left < b.left : a.right < b.right; });
	std::vector<long long int> min_value(n, LLONG_MAX); min_value[0] = 0;
	MinSegmentTree seg(n); seg.set(0, 0);
	for (const auto& op : operations) {
		const auto min = seg.get(op.left, op.right);
		if (min != LLONG_MAX && min_value[op.right] > op.cost + min) {
			min_value[op.right] = op.cost + min;
			seg.set(op.right, op.cost + min);
		}
	}
	const auto result = min_value.back();
	if (result == LLONG_MAX) {
		std::cout << -1 << '\n';
	}
	else {
		std::cout << result << '\n';
	}
}

/*

Li to Ri の最短到達コスト + CiがRiの最短到達コスト



*/

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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

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

const double EPS = 1e-10;

typedef struct edge_def {
  int from;
  int to;
  int cost;

  edge_def(int _from, int _to, int _cost) {
    from = _from;
    to   = _to;
    cost = _cost;
  }
} edge;

const int V = 100;
int n, t;
vector<edge> es[V];
int d[V], f[V];

void dfs(int v) {
  int i;
  d[v] = ++t;
  for (i=0; i<(int)es[v].size(); i++) {
    int to = es[v][i].to;
    if (d[to] == -1) dfs(to);
  }
  f[v] = ++t;
}

int main() {
  int i, j;
  memset(d, 0xff, sizeof(d));
  memset(f, 0, sizeof(f));
  for (i=0; i<V; i++) es[i].clear();

  scanf("%d ", &n);
  for (i=0; i<n; i++) {
    int u, v, k;
    scanf("%d ", &u);
    scanf("%d ", &k);
    for (j=0; j<k; j++) {
      scanf("%d ", &v);
      es[u-1].psb(edge(u-1, v-1, 0));
    }
  }

  t = 0;
  for (i=0; i<n; i++)
    if (d[i] == -1) dfs(i);

  for (i=0; i<n; i++) 
    printf("%d %d %d\n", i+1, d[i], f[i]);

	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 2e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 30;
int n;
string s[maxx];
map <string, int> cnt;
map <string, bool> flg;
int num;

struct PP {
	string t;
	int tot;
} p[maxx];

bool cmp(PP x, PP y) {
	if(x.tot == y.tot) return x.t < y.t;
	return x.tot > y.tot;
}

void Init() {
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> s[i];
		cnt[s[i]]++;
		if(!flg[s[i]]) {
			p[++num].t = s[i];
			flg[s[i]] = 1;
		}
	}
}

int main() {
	cnt.clear();
	flg.clear();
	Init();
	for(int i = 1; i <= num; i++) p[i].tot = cnt[p[i].t];
	sort(p + 1, p + num + 1, cmp);
	for(int i = 1; i <= num; i++) {
		if(p[i].tot == p[1].tot) cout << p[i].t << endl;
		else break;
	}
	return 0;
}

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

using ll = long long;
const long long MOD = 1000000007;

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

    vector<pair<int, int>> point;
    for(int i=0;i<2*N;i++){
        int a;
        cin >> a;
        point.emplace_back(a, (int)(N <= i));
    }
    sort(point.begin(), point.end());

    int balance = 0;
    ll ans = 1;
    for(auto p : point){
        if(p.second == 0){
            if(balance < 0){
                ans = (ans * -balance) % MOD;
            }
            balance++;
        }else{
            if(balance > 0){
                ans = (ans * balance) % MOD;
            }
            balance--;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2420
N,A,B,C,D = map(int,input().split())
S = input()
if C<D:
    print('No' if ('##' in S[A-1:C]) or ('##' in S[B-1:D]) else 'Yes')
    exit()

if '##' in S[A-1:C]:
    print('No')
    exit()
for bi in range(B-1,D):
    if S[bi-1] == S[bi] == S[bi+1] == '.':
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

const int dx[4]={0,-1,0,1};
const int dy[4]={-1,0,1,0};
int h,w;
tuple<int,int,int> bfs(const vector<string> &s,int x,int y){
    vector<vector<int>> d(h,vector<int>(w,-INF));
    queue<P> q;
    q.push(make_pair(x,y));
    d[x][y] = 0;
    int ma=0;
    while(!q.empty()){
        int xi = q.front().first;
        int yi = q.front().second;
        q.pop();
        rep(i,4){
            int nx = xi + dx[i];
            int ny = yi + dy[i];
            if(nx>=0 && nx<h && ny>=0 && ny<w && d[nx][ny]==-INF &&s[nx][ny]=='.'){
                q.push(make_pair(nx,ny));
                d[nx][ny] = d[xi][yi] + 1;
                ma = max(ma,d[nx][ny]);
                //cout << d[nx][ny] << endl;
            }
        }
    }
    P res;
    rep(i,h){
        rep(j,w){
            if(d[i][j]==ma) res = make_pair(i,j);
            //cout << d[i][j] << " ";
        }
        //cout << endl;
    }
    return make_tuple(ma,res.first,res.second);
}

int main(){
    cin >> h >> w;
    vector<string> m(h);
    rep(i,h) cin >> m[i];
    int x,y;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(m[i][j]=='.'){
                x = i;
                y = j;
                break;
            }
        }
    }
    tuple<int,int,int> s = bfs(m,x,y);
    int a,b,c;
    tie(a,b,c) = s;
    s = bfs(m,b,c);
    tie(a,b,c) = s;
    s = bfs(m,b,c);
    tie(a,b,c) = s;
    cout << a << endl;
}


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

int main(){
  
int N, kazu;
  cin >> N;
int c[26][N];
  for(int i = 0;i < 26;i++){
  for(int j = 0;j < N;j++) c[i][j] = 0;
  }
  
string s;
  
  for(int i = 0;i < N;i++){
  cin >> s;
    for(int j = 0;j < s.size();j++) c[s.at(j) - '0' - 49][i]++;    
  }
  
  for(int i = 0;i < 26;i++){
  kazu = 51;
    for(int j = 0;j < N;j++){
    kazu = min(kazu, c[i][j]);
    }
    if(kazu > 0){
      while(kazu){    
        cout << (char)(i + 'a');        
        kazu--;
    }
  }
  }

  return 0;
  
}

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

using namespace std;

#define int long long

signed main(){
	int n; cin>>n;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin>>a[i];
	}
	
	int cur = 1000;
	int stock = 0;
	
	for(int i = 0; i < n; i++){
		//cout<<"CUR: "<<cur<<" "<<stock<<endl;
		if(i < n-1 && a[i] < a[i+1]){
			//buy stocks rn
			int canbuy = cur / a[i];
			stock += canbuy;
			cur -= canbuy * a[i];
		}else if(i == n-1 || (i < n-1 && a[i] > a[i+1])){
			cur += stock * a[i];
			stock = 0;
		}
	}
	cout<<cur<<endl;
	
}

Measured memory_bytes: 3540
import java.io.*;
import java.util.*;
import java.math.*;

class Main{
	static final int nbits = 64;
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		String[] str = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		BitSet[] bs = new BitSet[n];
		for(int i = 0; i < n; i++){
			bs[i] = new BitSet(nbits);
			str = br.readLine().split(" ");
			int k = Integer.parseInt(str[0]);
			for(int j = 0; j < k; j++){
				bs[i].set(Integer.parseInt(str[j + 1]));
			}
		}
		str = br.readLine().split(" ");
		int q = Integer.parseInt(str[0]);
		BitSet bs2 = new BitSet(nbits);
		for(int i = 0; i < q; i++){
			str = br.readLine().split(" ");
			int op = Integer.parseInt(str[0]);
			int m = Integer.parseInt(str[1]);
			if(op == 0){
				pw.println(bs2.get(m) ? 1 : 0);
			}else if(op == 1){
				for(int j = 0; j < nbits; j++){
					if(bs[m].get(j)) bs2.set(j);
				}
			}else if(op == 2){
				for(int j = 0; j < nbits; j++){
					if(bs[m].get(j)) bs2.clear(j);
				}
			}else if(op == 3){
				for(int j = 0; j < nbits; j++){
					if(bs[m].get(j)) bs2.flip(j);
				}
			}else if(op == 4){
				boolean flag = true;
				for(int j = 0; j < nbits; j++){
					if(!bs[m].get(j)) continue;
					if(!bs2.get(j)) flag = false;
				}
				pw.println(flag ? 1 : 0);
			}else if(op == 5){
				boolean flag = false;
				for(int j = 0; j < nbits; j++){
					if(!bs[m].get(j)) continue;
					if(bs2.get(j)) flag = true;
				}
				pw.println(flag ? 1 : 0);
			}else if(op == 6){
				boolean flag = true;
				for(int j = 0; j < nbits; j++){
					if(!bs[m].get(j)) continue;
					if(bs2.get(j)) flag = false;
				}
				pw.println(flag ? 1 : 0);
			}else if(op == 7){
				int cnt = 0;
				for(int j = 0; j < nbits; j++){
					if(!bs[m].get(j)) continue;
					if(bs2.get(j)) cnt = cnt + 1;
				}
				pw.println(cnt);
			}else{
				BigInteger sum = BigInteger.ZERO;
				BigInteger pow2 = BigInteger.ONE;
				for(int j = 0; j < nbits; j++){
					if(bs[m].get(j) && bs2.get(j)) sum = sum.add(pow2);
					pow2 = pow2.multiply(new BigInteger(String.valueOf(2)));
				}
				pw.println(sum);
			}
		}
		pw.close();
	}
}



Measured memory_bytes: 88144
#include<stdio.h>
#include<string.h>
 
#define M 1220130 /* your task*/
#define L 14
 
char H[M][L]; /* Hash Table */
 
int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}
 
int h1(long long key){ return key % M; }
int h2(long long key){ return 1 + (key % (M-1)); }
 
int h(long long key, int i){ return (h1(key) + i*h2(key)) % M ;}
 
int find(char str[]){
  int i = 0, j;
  long long k;
 
  k = getKey(str);
 
  while(1){
    j = (h1(k) + i * h2(k)) % M;
    if(H[j][0] == '\0' || i == M) return 0;
    if(strcmp(H[j],str) == 0 ) return 1;
    else i++;
  }
}
 
int insert(char str[]){
  long long i=0, j;
  long long k;
 
  k = getKey(str);
 
  while(1){
    if(i == M) break;
 
    j = h(k, i);
 
    if(H[j][0] == '\0'){
      strcpy(H[j],str);
      return j;
    }else{
      i = i+1;
    }
  }
}
 
int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
     
    scanf("%d", &n);
     
    for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
     
    if ( com[0] == 'i' ){
        insert(str);
    } else {
        if (find(str)){
        printf("yes\n");
        } else {
        printf("no\n");
        }
    }
    }
 
    return 0;
}

Measured memory_bytes: 17288
package main

import (
	"fmt"
)

func chmax(a *int64, b int64) {
	if *a < b {
		*a = b
	}
}

var t [100001]int64
var w [100]int64
var v [100]int64

func main() {
	var n, maxW int64
	fmt.Scan(&n, &maxW)

	for i := int64(0); i < n; i++ {
		fmt.Scan(&w[i], &v[i])
	}

	for i := int64(0); i < n; i++ {
		for j := maxW - w[i]; j > 0; j-- {
			if t[j] > 0 {
				chmax(&t[j+w[i]], t[j]+v[i])
			}
		}
		chmax(&t[w[i]], v[i])
	}

	result := int64(0)
	for i := int64(1); i <= maxW; i++ {
		chmax(&result, t[i])
	}

	fmt.Printf("%d\n", result)
}


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

int main(void){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    sort(v.begin(),v.end());
    double ans=v[0];
    for(int i=1; i<n; i++) ans = (ans+v[i])/2;
    printf("%.10f\n", ans);
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <deque>

using namespace std;

const int mod = 1e9 + 7;

deque<int> x, y;
long long dfs(int which, long long val) {
	auto &deq = which == 0 ? x : y;
	if (deq.size() < 2) {
		return val;
	}

	long long w = deq.back() - deq.front();

	val += w * (deq.size() - 1); // - 2 + 1
	val %= mod;
	deq.pop_front();
	deq.pop_back();
	return dfs(which, val);
}

int main() {
	int n, m, tmp;
	cin >> n >> m;

	for (int i = 0; i < n; i++) {
		cin >> tmp;
		x.push_back(tmp);
	}
	for (int i = 0; i < m; i++) {
		cin >> tmp;
		y.push_back(tmp);
	}

	long long w = dfs(0, 0);
	long long h = dfs(1, 0);

	long long ans = w * h % mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <vector>
#include <list>
#include <array>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <stdexcept>


using std::string;
using std::vector;


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// util
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

std::vector<std::string> split(const std::string& input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// user func
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


void printList(const vector<int>& list) {
    // print
    for(int i = 0; i < list.size(); i++){
        printf("%d", list[i]);
        if(i != list.size() -1){
            printf(" ");
        }
    }
    printf("\n");
}


class Task{
public:
    Task(const string& name, int time, int spend)
        : name(name), time(time), spend(spend){}
    string name;
    int time;
    int spend;
};

void solve() {
    int n, q;
    scanf("%d", &n);
    scanf("%d", &q);
    std::list<Task> tasks;
    for(int i = 0; i < n; i++){
        char name[16];
        int time;
        scanf("%s", name);
        scanf("%i", &time);
        // Task task = { name, time, 0 };
        tasks.emplace_back(string(name), time, 0);
    }

    int spend = 0;
    vector<Task> done;
    done.reserve(n);
    while(done.size() < n){
        for(auto task = tasks.begin(); task != tasks.end();){
            int t = std::min(task->time, q);
            spend += t;
            task->time -= t;
            if (task->time == 0){
                task->spend = spend;
                done.push_back(*task);
                task = tasks.erase(task);
            }else{
                task++;
            }
        }
        // for(int i = 0; i < n; i++){
        //     if(tasks[i].time == 0) continue;
        //     int t = std::min(tasks[i].time, q);
        //     spend += t;
        //     tasks[i].time -= t;
        //     if(tasks[i].time == 0 ){
        //         tasks[i].spend = spend;
        //         done.push_back(tasks[i]);
        //     }
        // }
    }
    for (auto each: done) {
        printf("%s %d\n", each.name.c_str(), each.spend);
    }
}


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


Measured memory_bytes: 8288
import java.awt.geom.Point2D;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {	
	Scanner in = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}

	public Main(){		
		while(in.hasNext())new AOJ0035();
	}
	
	class AOJ0035{
		public AOJ0035() {
			Point2D point[] = new Point2D[4];
			String input[] = in.nextLine().split(",");
			for(int i=0;i<4;i++)point[i]=new Point2D.Double(Double.parseDouble(input[i*2]),Double.parseDouble(input[i*2+1]));
			boolean sw=true;
			int memo = right_left(point[0],point[2],point[1]);
			for(int i=0;i<4;i++)if(right_left(point[i],point[(i+2)%4],point[(i+1)%4])!=memo)sw=false;
			if(sw)System.out.println("YES");
			else System.out.println("NO");
		}
		//外積
		double cross(Point2D p1,Point2D p2){
			return p1.getX()*p2.getY()-p1.getY()*p2.getX();
		}
		
		int right_left(Point2D a,Point2D b,Point2D target){ //a-bの直線はtargetの右か左か
			Point2D q = new Point2D.Double(b.getX()-a.getX(),b.getY()-a.getY());
			Point2D r = new Point2D.Double(target.getX()-a.getX(),target.getY()-a.getY());
			if(cross(q, r)>0)return -1;//左側
			else if(cross(q,r)<0)return 1;//右側
			else return 0;//重なっている
		}
		
	}
		
}

Measured memory_bytes: 17180
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <limits>

using ll = long long;
using namespace std;
int gcd(int x,int y){
    if(y==0)return x;
    return gcd(y,x%y);
}
int main(){
    ll a,b,c,k;
    cin >>a >> b >> c >> k;
    if(k%2==1){
        cout<<b-a<<endl;
    }else{
        cout<<a-b<<endl;
    }
}

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

#define all(x) 		 (x).begin(),(x).end()
#define mp     		 make_pair
#define pb 				 push_back
#define fi 				 first
#define se 				 second
#define sz(x) 		 ((int)(x).size())
#define rep(x,y,z) for(int x=y;x<z;x++)
#define per(x,z,y) for(int x=z-1;x>=y;x--)
#define trav(y,x)  for(auto& y:x)
#define pii 			 pair<int,int>
#define vi 				 vector<int>

int dbg = 0;
#define cri   		 if(0)
#define shame 		 cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
const int N = 2e5 + 1;
const int lg = 20;
const ll mod = 0xfffff;


void solve() {
  string s, r;
  cin >> s;
  int n = sz(s);
  r = s; reverse(all(r));

  bool mk = s == r;
  string s1 = s.substr(0, (n - 1) / 2);
  string r1 = s1; reverse(all(r1));

  string s2 = s.substr((n + 3) / 2 - 1, n - ((n + 3) / 2) + 1);
  string r2 = s2; reverse(all(r2));

  mk &= (s1 == r1 && s2 == r2);
  cout << (mk ? "Yes" : "No") << "\n";
}

int main() {
  // freopen("input.in", "r", stdin);
  // freopen("input.out", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// cout<<setprecision(15);
	// int t; cin>>t; while(t--)
	solve();
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int f(int a){
  if(a == 1)return 300000;
  if(a == 2)return 200000;
  if(a == 3)return 100000;
  else return 0;
}
  
int main(){
  int x,y;
  cin  >> x>>y;
  int ans = f(x)+f(y)+(x==1&&y==1)*400000;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

d,t,s = map(int, input().split())

temp = d/s

if (temp <= t):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9084
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	n = II()
	ch = False
	for i in range(n+1):
		if(n==int(i * 1.08)):
			print(i)
			ch = True
			break
	if ch==False:
		print(":(")


if __name__ == '__main__':
	main()

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

int main() {
  int N, i;
  cin >> N;
  vector<int> a(3 * N);
  for (i = 0; i < 3 * N; i++) cin >> a.at(i);
  
  sort(a.begin(), a.end());
  int64_t M = 0;
  for (i = 0; i < N; i++) M += a.at(N + 2 * i);
  
  cout << M << endl;
}


Measured memory_bytes: 4240
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

from collections import Counter

n,k = li()
a = li()

a_ltk = [ai for ai in a if ai < k]
a_ltk.sort(reverse=True)
need = {ai:False for ai in a_ltk}

# 貪欲に足していく
for i in range(len(a_ltk)):
    cur = 0
    stack = []
    for j in range(i,len(a_ltk)):
        cur += a_ltk[j]
        stack.append(a_ltk[j])
        if cur >= k:
            for key in set(stack):
                if need[key]:
                    continue
                else:
                    need[key] = True
            stack.pop()
            cur -= a_ltk[j]

                
cnt = Counter(a_ltk)
ans = 0

for k,v in need.items():
    if not v:
        ans += cnt[k]
        
print(ans)

Measured memory_bytes: 46428
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = 1e9 + 7;

int n, m, k, u[300009], v[300009], cnt[300009], cnt2[300009];
set<int> dat[300009];
int mx;
set<int> cand;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m >> k;
	for (int i = 0; i < k; i++) {
		cin >> u[i] >> v[i];
		dat[v[i]].insert(u[i]);
		mx = max(mx, (int)dat[v[i]].size());
		cnt[u[i]]++;
	}
	for (int i = 1; i <= m; i++) {
		if (dat[i].size() == mx)
			cand.insert(i);
	}
	for (int i = 0; i < k; i++) {
		if (cand.count(v[i])) {
			cnt2[u[i]]++;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int tmp = cnt[i] + mx - 1;
		if (cnt2[i] < cand.size()) tmp++;
		ans = max(ans, tmp);
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

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

using namespace std;

int main() {
    unsigned int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    if (e - a > k) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

void solve()
{
    string s;
    cin >> s;
    map<string, bool> mp;
    rep(i, 1, s.size() + 1)
    {
        string s1 = s.substr(0, i);
        string s2 = s.substr(i);
        // cerr << s1 << " " << s2 << endl;
        mp[s1 + s2] = true;
        mp[s2 + s1] = true;
        reverse(ALL(s1));

        mp[s1 + s2] = true;
        mp[s2 + s1] = true;

        reverse(ALL(s1));
        reverse(ALL(s2));

        mp[s1 + s2] = true;
        mp[s2 + s1] = true;
        reverse(ALL(s1));
        mp[s1 + s2] = true;
        mp[s2 + s1] = true;
    }
    cout << mp.size() << endl;
}

int main()
{
    int n;
    cin >> n;
    rep(i, n)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3148
//suhan lee,saitama university

#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <complex>
using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define repn(i,n) for(int i=0;i<n;i++)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
#define pb push_back 
#define pf push_front
int alphaset;
bool equation(string inp,int& i);
bool formula(string inp,int& i);
bool alphabet(string inp,int& i);
bool equation(string inp,int& i){
  bool right,left;
  left=formula(inp,i);
  i++;
  // cout<<"i:"<<i<<endl;
  right=formula(inp,i);
  //  cout<<alphaset<<endl<<left<<'='<<right<<endl;
  return right==left;
}
bool formula(string inp,int& i){
  bool left=alphabet(inp,i);
  bool right;
  while(true){
    if(inp[i]=='+'){
      right=formula(inp,++i);
      left=right||left;
    }
    else    if(inp[i]=='*'){
      right=formula(inp,++i);
      left=right&&left;
    }
    else    if(inp[i]=='-'){
      if(inp[++i]=='>'){
	right=formula(inp,++i);
	left=(!left)||right;
      }
    }
    else return left;
  }
}
bool alphabet(string inp,int& i){
  if(inp[i]=='(')
    {
      int out=formula(inp,++i);
      i++;return out;
    }
  else if(inp[i]=='-')
    return !alphabet(inp,++i);
  else if(inp[i]=='T'){i++;
    return true;}
  else if(inp[i]=='F'){i++;
    return false;}

  else{
    //   cout<<inp[i]<<i<<"  "<<alphaset<<"  "<<
    //    (alphaset & (1<<(inp[i]-'a'))>0)<<endl;
    return alphaset & (1<<(inp[i++]-'a'));
  }

}


int main(){
  while(true){
    string inp;
    int i=0;
    //  cout<<int('a')<<endl<<int('b');
    cin>>inp;
    if(inp=="#") break;
    for(alphaset=0;alphaset<(1<<11);alphaset++){
      i=0;
      if(equation(inp,i)==false){
	cout<<"NO"<<endl;
	break;
      }
    }
    if(alphaset==(1<<11)){
      cout<<"YES"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2288
#include<cstdio>
#include<algorithm>
#define r register
inline bool isd(r char x) {
	return x>='0'&&x<='9';
}
template<class temp>
inline temp F() {
	r temp x=0;
	r char ch=getchar();
	r bool bl=0;
	while(ch!='-'&&!isd(ch))
		ch=getchar();
	(ch=='-')&&(bl=1,ch=getchar());
	while(isd(ch))
		x=(x<<1)+(x<<3)+(ch^'0'),ch=getchar();
	return bl?-x:x;
}
class Graph {
	public:
		struct Edge {
			int to;
			Edge* nxt;
		};
		typedef Edge* Node;
		Node Nul,*Head;
		void Resize(r int siz) {
			Head=new Node[siz+1];
			for(r int i=0;i<=siz;++i)
				Head[i]=Nul;
		}
		void Add(r int f,r int t) {
			Node x=new Edge();
			x->to=t;
			x->nxt=Head[f],Head[f]=x;
		}
}P;
int a[200001];
int p[200001];
bool b[200001];
bool cmp(const int&x,const int&y) {
	return a[x]<a[y];
}
int main() {
	r int n=F<int>(),u,v;
	P.Resize(n);
	for(r int i=1;i<=n;++i)
		a[i]=F<int>(),p[i]=i;
	for(r int i=1;i<n;++i)
		u=F<int>(),v=F<int>(),P.Add(u,v),P.Add(v,u);
	std::sort(p+1,p+n+1,cmp);
	for(r int i=1;i<=n;++i) {
		r int x=p[i];
		for(r Graph::Node j=P.Head[x];j!=P.Nul;j=j->nxt)
			if(a[x]>a[j->to]&&!b[j->to])
				b[x]=1;
	}
	for(r int i=1;i<=n;++i)
		if(b[i])
			printf("%d ",i);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using ld = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if (s.size() == 2)
  {
    if (s[0] == s[1]) cout << "1 2" << endl;
    else cout << "-1 -1" << endl;
    return 0;
  }
  char tmp_1 = s[0], tmp_2 = s[1], tmp_3 = s[2];
  if (tmp_1 == tmp_2 || tmp_2 == tmp_3 || tmp_3 == tmp_1)
  {
    cout << "1 3" << endl;
    return 0;
  }
  REP2(i, 3, s.size())
  {
    tmp_1 = tmp_2; tmp_2 = tmp_3;
    tmp_3 = s[i];
    if (tmp_1 == tmp_2 || tmp_2 == tmp_3 || tmp_3 == tmp_1)
    {
      cout << i-1 << " " << i+1 << endl;
      return 0;
    }
  }
  cout << "-1 -1" << endl;

  return 0;
}


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

public class Program {
    public static void Main() {
        var arr = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var meu = new int[] { arr[0] + arr[1], arr[0] + arr[2], arr[1] + arr[2] };
        Console.WriteLine(meu.Min());
    }
}


Measured memory_bytes: 13396
#include <utility>
#include <stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define YES(b) std::cout<< (b ? "Yes" : "No")
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	long long int sum = 0;
	cin >> n;
	vector<int> l(n + 1), r(n + 1);
	REP(i, n) {
		cin >> l[i] >> r[i];
	}
	sort(l.begin(), l.end());
	sort(r.begin(), r.end());
	REP(i, n + 1) {
		if (l[n - i] > r[i]) {
			sum += (l[n - i] - r[i]) * 2;
		}
	}
	cout << sum;
}


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

int main(void) {
  int n;
  cin >> n;
  char s[n+1];
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') cnt++;
  }
  if (cnt * 2 > n) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin >> H >> W;

  int dist[10][10];//i->jへの直接の辺の長さ(辺が無い場合はINFを入れる)

  for(int i = 0;i < 10;i++)
    for(int j = 0;j < 10;j++)
      cin >> dist[i][j];

  //Floyd-Warshall法(任意の二点間の最短距離が求まる.),O(V^3)
  for(int k = 0;k < 10;k++){
    for(int i = 0;i < 10;i++){
      for(int j = 0;j < 10;j++){
        dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
      }
    }
  }

  int ans = 0;
  for(int i = 0;i < H * W;i++){
    int A;
    cin >> A;
    if(A >= 0)ans += dist[A][1];
  }

  cout << ans << endl;

}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

typedef long long ll;
typedef pair<ll,ll> p;

// 要素に対応する値は自分の根。根は要素数の-1倍したものを代入する。
// 根ならそのグループの要素数(負)が、子であれば親の番号が入る。初期値-1。
vector<int> uni(2000000, -1);

// 頂点aの所属するグループを調べる。
int root(int a)
{
  // uni[a]が負の値なら親はa自身
  if (uni[a] < 0) return a;
  // 正の値であれば、親ルートを調べ戻り値で根に直接つなぐ。
  else {
    uni[a] = root(uni[a]);
    return uni[a];
    // return uni[a] = root(uni[a]);
  }
}

// 頂点aとbをつなぐ、もともと同じグループの場合falseを返す。
bool connect(int a, int b)
{
  a = root(a);
  b = root(b);
  if (a == b) return false;

  // aを大きなグループにしたいので、逆であれば入れ替える。
  if (uni[a] > uni[b])
  {
    int hoge = a;
    a = b;
    b = hoge;
  }

  //aとbを結合し、bをaの親とする。
  uni[a] += uni[b];
  uni[b] = a;
  return true;
}

//  頂点a, bが同じグループか
bool isConnect(int a, int b)
{
  return root(a) == root(b);
}

// 頂点aを含むグループの頂点数を調べる
int size(int a)
{
  return -uni[root(a)];
}

int main()
{
  #define int long long
  int n, m;
  cin >> n >> m;
  vector<p> v;
  for (int i = 0; i < m; i++)
  {
    int hoge,huga;
    cin >> hoge >> huga;
    // cin >> v[i].first >> huga;
    if(huga == 1)
    {
      int tmp = hoge;
      hoge = huga;
      huga = tmp;
    }
    if(hoge == 1 || huga == n) v.push_back(make_pair(hoge, huga));
  }

  for(auto a : v)
  {
    if(a.first == 1) connect(1, a.second);
    if(a.second == n) connect(a.first, a.second);
  }

  if(isConnect(1, n)) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  // for(auto a : v)
  // {
  //   if(a.first == 1)
  //   {
  //     for(auto i : v)
  //     {
  //       // cout << a.second << " : " << i.first << endl;
  //       if(a.second == i.first && i.second == n)
  //       {
  //         cout << "POSSIBLE" << endl;
  //         return 0;
  //       }
  //     }
  //   }
  // }
  // cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 13936
import java.util.*;

public class Main {
	static final long MOD = 1000000007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		
		long[][] comb = new long[N+1][N+1];
		for(int i=0; i<N+1; i++)
			for(int j=0; j<=i; j++)
				comb[i][j] = (j==0 || j==i) ? 1 : (comb[i-1][j] + comb[i-1][j-1])%MOD;
		
		long[] fac = new long[N+1];
		fac[0] = fac[1] = 1;
		for(int i=2; i<=N; i++)
			fac[i] = (fac[i-1]*i)%MOD;
		
		long[][] dp = new long[2][N+1];
		int sw = 0;
		dp[sw][0] = 1;
		for(int i=A; i<=B; i++) {
			Arrays.fill(dp[sw^1], 0);
			
			for(int j=0; j<=N; j++) {
				dp[sw^1][j] = (dp[sw^1][j] + dp[sw][j])%MOD;
				if(j<=N-C*i) {
					long sel = 1;
					for(int k=1; k<=D; k++) {
						if(j+i*k <= N) {
							sel = (sel * comb[N-(j+(k-1)*i)][i])%MOD;
							if(C<=k) {
								dp[sw^1][j+i*k] = (dp[sw^1][j+i*k] + ((dp[sw][j]*sel)%MOD)*rev(fac[k]))%MOD;
							}
						} else {
							break;
						}
					}
				}
			}
			sw ^= 1;
		}
		
		System.out.println(dp[sw][N]);
		sc.close();
	}
	
	static long rev(long a) {
		return pow(a, MOD-2);
	}
	
	static long pow(long a, long b) {
		long ans = 1;
		while(b>0) {
			if((b&1)!=0)
				ans = (ans * a)%MOD;
			b>>=1;
			a = (a*a)%MOD;
		}
		return ans;
	}
}


Measured memory_bytes: 18624
//

fun main() {
    agc034b()
}

fun agc034b() {
    val s = readLine()!!
    var i = 0
    var a = 0L
    var count = 0L
    while (i < s.length) {
        while (i < s.length && s[i] == 'A') {
            a++
            i++
        }
        if (i >= s.length) break
        if (i < s.length - 1 && s[i] == 'B' && s[i + 1] == 'C') {
            count += a
            i++
        } else {
            a = 0L
        }
        i++
    }
    println(count)
}

Measured memory_bytes: 38800
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N; cin>>N;
	long A[N];
	rep(i,0,N) cin>>A[i];
	long ans = 0; long t = 0;
	for(int i = N-1; i >= 0; i--){
		if(A[i] > t){ ans += A[i]; t = A[i]; }
        else if(A[i] < t){ cout<<-1<<endl; return 0; }
        t--;
	}cout<<(A[0] ? -1 : ans)<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define maxn 500010
using namespace std;
char s[maxn];
int a[maxn], dp[maxn];
int main() {
    int n;
    scanf("%d%s", &n, s+1);
    for (int i = 1; i <= n; ++i) {
        if (s[i] == '0') a[i] = i;
        else a[i] = a[i-1];
    }
    for (int i = 1; i <= n; ++i) {
        dp[i] = dp[i-1];
        if (s[i] == '1') {
            if (s[i-1] == '0' && s[i-2] == '1') {
                dp[i] = max(dp[i], dp[a[i-2]]+ (i-2)-a[i-2]);
                dp[i] = max(dp[i], dp[a[i-2]+1] + (i-2) - (a[i-2]+1));
            }
            else if (a[i]>1 && s[a[i]-1] == '1') dp[i] = max(dp[i], dp[a[i]-2] + i - a[i]);
        }
    }
    printf("%d\n", dp[n]);
    return 0;
}//110111111

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

int main() {
  int N, T, c, t;
  cin >> N >> T;
  int ans=10000;
  
  for (int i; i<N; i++){
    cin >> c >> t;
    if (t<=T){
      ans=min(ans,c);
    }
  }
  if (ans!=10000){
    cout << ans << endl;
  }
  else {
    cout << "TLE" << endl;
  }
}

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

void Constraints(int H,int W)
{
  if(!(1<=H&&H<=300&&1<=W&&W<=300))
  {
    printf("条件を満たす入力をしてください。\n");
    exit(0);
  }
}

void PrintCheckSquare(int H,int W)
{
  for(int i=0;i<H;i++)
  {
      for(int j=0;j<W;j++)
      {
        if(i%2==0){
          if(j%2==0){printf("#");}
          if(j%2==1){printf(".");}
        }
        if(i%2==1){
          if(j%2==0){printf(".");}
          if(j%2==1){printf("#");}
        }
      }
      printf("\n");
  }
  printf("\n");
}

int main(void)
{
  int H=1;
  int W=1;
  while(H!=0&&W!=0)
  {
    scanf("%d %d",&H,&W);
    if(H!=0&&W!=0)
    {
      Constraints(H,W);
      PrintCheckSquare(H,W);
    }
  }
  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int N,W;
int main() {
	ll n;
	cin >> n;
	int a[n];
	rep(i,n) cin >> a[i];
	int flag=0;
	rep(i,n){
		if(i+1 != a[i]){
			flag++;
		}
	}
	if(!flag || flag==2) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256