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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

void dfs(ll i, vvl &adj, vl &col) {
	for (ll j: adj[i]) if (col[j] == -1) {
		col[j] = 1-col[i];
		dfs(j, adj, col);
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vvl adj(n);
	FOR(i,1,n) {
		ll a, b;
		cin >> a >> b;
		a--, b--;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	vl col(n,-1);
	col[0] = 0;
	dfs(0, adj, col);
	
	vl cnt(2);
	vvl comps(2);
	FOR(i,0,n) {
		cnt[col[i]]++;
		comps[col[i]].pb(i);
	}
	
	vl rem(3);
	rem[0] = n/3, rem[1] = (n+2)/3, rem[2] = (n+1)/3;

	vl res(n);
	auto draw = [&](ll i, ll c) {
		rem[c]--;
		res[i] = 3*(rem[c] + !c) + c;
	};

	auto draw_any = [&](ll i) {
		FOR(c,0,3) if (rem[c]) {
			draw(i,c); return;
		}
		assert(0);
	};

	if (cnt[0] <= rem[0]) {
		for (ll i: comps[0]) draw(i,0);
		for (ll i: comps[1]) draw_any(i);
	} else if (cnt[1] <= rem[0]) {
		for (ll i: comps[1]) draw(i,0);
		for (ll i: comps[0]) draw_any(i);
	} else {
		assert(cnt[0] >= rem[1] && cnt[1] >= rem[2]);
		for (ll i: comps[0]) draw(i, rem[1] ? 1 : 0);
		for (ll i: comps[1]) draw(i, rem[2] ? 2 : 0);
	}
	
	FOR(i,0,n) cout << res[i] << " \n"[i+1==n];
}



Measured memory_bytes: 22892
#include<iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  int A[N];
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(A[i]%2==0 && (A[i]%3!=0 && A[i]%5!=0)){
      cout<<"DENIED";
      return 0;
    }
  }
  cout<<"APPROVED";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repr(i, a, b) for (int i = a; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define sz(a) (a).size()
#define pb(a) push_back(a)
#define eb(...) emplace_back(__VA_ARGS__)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
using namespace std;
using pii = pair<int, int>;
constexpr int MOD = 1000000007;
constexpr double INF = 1e18;
constexpr double EPS = 1e-10;

struct P {
  int x, y, r;
  P() {}
  P(int x, int y, int r) : x(x), y(y), r(r) {}
};

struct edge {
  int t;
  double c;
  edge() {}
  edge(int t, double c) : t(t), c(c) {}
};

double len(P a, P b) {
  return hypot(a.x-b.x, a.y-b.y) - a.r - b.r;
}

int N;
vector<P> ps;
vector<edge> g[1010];
double dis[1010];

void dijkstra(int s) {
  fill(dis, dis+1010, INF);
  dis[s] = 0;
  using PP = pair<double, int>;
  priority_queue<PP, vector<PP>, greater<PP>> que;
  que.emplace(0, s);
  while (!que.empty()) {
    double dd;
    int cv;
    tie(dd, cv) = que.top(); que.pop();
    if (dd < dis[cv]) continue;
    for (edge e : g[cv]) {
      int nv = e.t;
      if (dis[nv] > dis[cv] + e.c) {
        dis[nv] = dis[cv] + e.c;
        que.emplace(dis[nv], nv);
      }
    }
  }
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int x, y;
  cin >> x >> y;
  ps.eb(x, y, 0);
  cin >> x >> y;
  ps.eb(x, y, 0);
  cin >> N;
  rep(i, 0, N) {
    int x, y, r;
    cin >> x >> y >> r;
    ps.eb(x, y, r);
  }
  rep(i, 0, sz(ps)) {
    rep(j, 0, sz(ps)) {
      if (i == j) continue;
      double l = len(ps[i], ps[j]);
      if (l < EPS) l = 0;
      g[i].eb(j, l);
      g[j].eb(i, l);
    }
  }
  dijkstra(0);
  cout << dis[1] << endl;

  return 0;
}

Measured memory_bytes: 39024
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
#define ll long long
int dp[100100];
int cnt = 0;
map<string,int> ma;
signed main() {
  int n;
  cin >> n;
  vector<int> a(n-1);
  rep(i,n-1) {
    cin >> a[i];
  }
  int ans = a[0]+a[n-2];
  rep(i,n-2) {
    ans += min(a[i],a[i+1]);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3632
N, M = map(int, input().split())

l = []

for i in range(M):
    l.append(list(map(lambda x: int(x) - 1, input().split())))

lis = [[] for i in range(N)]

for i in range(M):
    lis[l[i][0]].append(l[i][1])
    lis[l[i][1]].append(l[i][0])


# 隣接行列
# list = [[0 for c in range(M)] for r in range(N)]
#
# for i in range(M):
#     tmp_n, tmp_m = map(int, input().split())
#     list[tmp_n - 1][tmp_m - 1] = 1
#
#
# def dot(index1, index2):
#     results = [[0 for c in range(M)] for r in range(N)]
#     for (i, j) in zip(index1, zip(*index2)):
#         print(i,j)
#     return results



# 再起関数
# def travel(now, nextnodes, visited):
#     ends.append(visited)
#     visited.append(now + 1)
#     for node in nextnodes:
#         if node in visited:
#             continue
#         travel(node - 1, lis[node - 1], visited[:])
#
#
# travel(0, lis[0], [])

que = [[0, lis[0], []]]
ends = []

while que:
    now, nextnodes, visited = que.pop()
    ends.append(visited)
    visited.append(now)
    for node in nextnodes:
        if node in visited:
            continue
        que.append([node, lis[node], visited[:]])

print(len(list(filter(lambda ii: len(ii) is N, ends))))


Measured memory_bytes: 5236
// Try AtCoder
// author: Leonardone @ NEETSDKASU

use std::io::{stdin, stdout, Write};

fn main() {
    fn get() -> String {
    	let mut line = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    macro_rules! get {
    	() => (get().parse::<i64>().unwrap());
        ($t:ty) => (get().parse::<$t>().unwrap());
    }
    let flush = || stdout().flush().unwrap();

    let n = get!();

    println!("0");
    flush();

	let c0 = get().as_bytes()[0];
    
    if c0 == b'V' {
    	return;
    }
    if n <= 20 {
    	for i in 1..n {
        	println!("{}", i);
            flush();
        	let c = get().as_bytes()[0];
			if c == b'V' {
            	return;
            }
		}
        return;
    }
    
    let mut lp = 0;
    let mut rp = n;
    for _ in 0..19 {
    	let p = (lp + rp) / 2;
    	println!("{}", p);
        flush();
        let c = get().as_bytes()[0];
        if c == b'V' {
        	return;
        }
        if c == c0 {
        	if p % 2 == 0 {
            	lp = p + 1;
            } else {
            	rp = p;
            }
        } else {
        	if p % 2 == 0 {
            	rp = p;
            } else {
            	lp = p + 1;
            }
        }
    }    
}

Measured memory_bytes: 4948
#include <stdio.h>
#include <stdlib.h>
#define STAY 1
#define NOTSTAY -1

int row[8],col[8],unlef[15],unrig[15],Q[8][8];

void firststage();
void queen(int);
void printer();

int main(){
  int k,i,d = 0,r,c;
  firststage();

  scanf("%d",&k);
  for(i = 0;i < k;i++){
    scanf("%d%d",&r,&c);
    Q[r][c] = 1;
  }

  queen(d);
  
  return 0;
}

void firststage(){
  int i,j;
  for(i = 0;i < 8;i++){
    row[i] = NOTSTAY;
    col[i] = NOTSTAY;
    for(j = 0;j < 8;j++){// 入力の配列初期化 本来ここには必要ない
      Q[i][j] = 0;
    }
  }
  for(i = 0;i < 15;i++){
    unlef[i] = NOTSTAY;
    unrig[i] = NOTSTAY;
  }
}

void queen(int d){
  int j;
  if(d == 8){
    printer();
    return;
  }

  for(j = 0;j < 8;j++){
    if((col[j] == STAY) || (unlef[d + j] == STAY) || (unrig[d - j + 8 - 1] == STAY)) continue;
    row[d] = j;
    col[j] = unlef[d + j] = unrig[d - j + 8 - 1] = STAY;
    queen(d + 1);
    row[d] = col[j] = unlef[d + j] = unrig[d - j + 8 - 1] = NOTSTAY;
  }
  
}

void printer(){
  int i,j;
  for(i = 0;i < 8;i++){
    for(j = 0;j < 8;j++){
      if(Q[i][j] != 0){
	if(row[i] != j) return;
      }
    }
  }
  for(i = 0;i < 8;i++){
    for(j = 0;j < 8;j++){
      if(row[i] == j) printf("Q");
      else printf(".");
      
    }
    printf("\n");
  }
  
}



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

int main(){
  int N, Y;

  cin >> N >> Y;

  for(int i=0; i<=N; i++){
    for(int j=0; i+j<=N; j++){
      if(10000*i + 5000*j + 1000*(N-i-j) == Y){
        cout << i << ' ' << j << ' ' << N-i-j << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;

  return 0;
}


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

int main()
{
	string s[500];
	int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0;
	cin >> a;
	cin >> b;
	for ( c = 0; c < a; c++)
	{
		cin >> s[c];
	}
	for ( c = 0; c < a; c++)
	{
		for ( d = 0; d < b; d++)
		{
			e = 0;
			if (s[c][d] == '#')
			{


				if (c - 1 >= 0)
				{
					if (s[c - 1][d] == '#')
					{
						e = 1;
					}
				}
				if (c + 1 < a)
				{
					if (s[c + 1][d] == '#')
					{
						e = 1;
					}
				}
				if (d - 1 >= 0)
				{
					if (s[c][d - 1] == '#')
					{
						e = 1;
					}
				}
				if (d + 1 < b)
				{
					if (s[c][d + 1] == '#')
					{
						e = 1;
					}
				}
				if (e == 0)
				{
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}


	cout << "Yes" << endl;

	return 0;
}

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

int main()
{
    int N;
    double ans;
    priority_queue< int, vector<int>, greater<int> > q;
    
    cin >> N;
    for(int i=0; i<N; i++){
        int v;
        cin >> v;
        q.push(v);
    }
    
    ans = q.top();
    q.pop();
    
    while (!q.empty()) {
        ans = (ans + q.top())/2;
        q.pop();
    }
    
    cout.precision(10);
    cout << fixed << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
fn main() {
    let mut s = read::<String>().chars().collect::<Vec<char>>();
    let mut t = read::<String>().chars().collect::<Vec<char>>();
    s.sort();
    t.sort_by_key(|&c| -1 * (c as i32));
    let len = std::cmp::min(s.len(), t.len());

    for i in 0..len {
        if s[i] < t[i] {
            yn(true);
            return;
        } else if s[i] == t[i] {
            continue;
        } else {
            yn(false);
            return;
        }
    }
    yn(s.len() < t.len());
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
while True:
    n = int(input())
    if n == 0:
        break
    z = sorted([tuple(map(int, input().split())) for _ in range(n)],  key=lambda x: x[1])
    cnt = total = 0
    for a, b in z:
        total += a
        if total > b:
            cnt = 1
            break
    print("No" if cnt else "Yes")

Measured memory_bytes: 7836
n = int(input())

ls = list(map(int, input().split()))
 
count = 0

for i in range(1,n-1):
    if ls[i-1] < ls[i] and ls[i+1] > ls[i]:
        count+=1
    elif ls[i-1] > ls[i] and ls[i+1] < ls[i]:
            count += 1

print(str(count))

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    int a,b=0,j=0,i,s,e,o;
    scanf("%d",&e);
    for(i=0;i<e;i++)
    {
        scanf("%d",&a);
        //s=0;
        if(a%2==0)
           {

            j++;
            //s=0;

                if(a%3==0 || a%5==0) b++;

                }
    }

    if(j==b)
        printf("APPROVED\n");
    else
        printf("DENIED\n");
    return 0;
}



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

typedef long long ll;

int main(void)
{
	int i, j;
	int n;
	int seq[101];
	ll dp[101][21];

	scanf("%d", &n);

	for (i = 1; i <= n; i++){
		scanf("%d", &seq[i]);
	}

	memset(dp, 0, sizeof(dp));
	
	dp[1][seq[1]] = 1;

	for (i = 2; i <= n; i++){
		for (j = 0; j <= 20; j++){
			if (j + seq[i] <= 20){
				dp[i][j + seq[i]] += dp[i - 1][j];
			}
			if (j - seq[i] >= 0){
				dp[i][j - seq[i]] += dp[i - 1][j];
			}
		}
	}

	printf("%lld\n", dp[n - 1][seq[n]]);

	return (0);
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>

using namespace std;

int main(){
    string S, T;
    cin >> S >> T;

    bool flag = true;
    for(int i=0; i<S.size(); ++i){
        if(S[i] != T[i]) flag = false;
    }


    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int A, B, C, X, Y;
long long ans;

int main() {
	cin >> A >> B >> C >> X >> Y;
	C *= 2;
	if (C < A + B) {
		ans += min(X, Y) * C;
		int mn = min(X, Y);
		X -= mn;
		Y -= mn;
	}
	ans += X * min(C, A) + Y * min(C, B);
	cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<math.h>
using namespace std;
double x[110];
double y[110];
double z[110];
double ijk[110][110][110];
int v[110][110][110];
double len[110];
inline double con(double a,double b,double c){
	return min(a,b)<=c&&c<=max(a,b);
}
double eps=1e-9;
inline double ABS(int a){return max(a,-a);}
int ht[110];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<110;i++)ht[i]=0;
		for(int i=0;i<a;i++){
			scanf("%lf%lf",x+i,y+i);
		//	y[i]+=min(i,a-1-i)*(1e-10);
		}
		for(int i=0;i<a-1;i++){
			if(ABS(y[i]-y[i+1])<eps)ht[i]=1;
		}
		for(int i=0;i<a-1;i++)len[i]=sqrt((x[i+1]-x[i])*(x[i+1]-x[i])+(y[i+1]-y[i])*(y[i+1]-y[i]));
		for(int i=0;i<a;i++)z[i]=y[i];
		std::sort(z,z+a);
		for(int i=0;i<a;i++)for(int j=0;j<a;j++)for(int k=0;k<a;k++){
			ijk[i][j][k]=999999999;
			v[i][j][k]=0;
		}
		priority_queue<pair<pair<double,int>,pair<int,int> > >Q;
		Q.push(make_pair(make_pair(0,0),make_pair(0,a-2)));
		ijk[0][0][a-2]=0;
		while(Q.size()){
			double cost=-Q.top().first.first;
			int h=Q.top().first.second;
			int l=Q.top().second.first;
			int r=Q.top().second.second;
			double now=z[h];
			Q.pop();
			if(v[h][l][r])continue;
			v[h][l][r]=1;
			if(h<a-1){
				double U=z[h+1];
				if(con(y[l],y[l+1],U)&&con(y[r],y[r+1],U)&&!v[h+1][l][r]&&ijk[h+1][l][r]>cost+len[l]*(U-now)/ABS(y[l+1]-y[l])+len[r]*(U-now)/ABS(y[r+1]-y[r])){
					ijk[h+1][l][r]=cost+len[l]*(U-now)/ABS(y[l+1]-y[l])+len[r]*(U-now)/ABS(y[r+1]-y[r]);
					Q.push(make_pair(make_pair(-ijk[h+1][l][r],h+1),make_pair(l,r)));
				}
			}
			if(h){
				double D=z[h-1];
				if(con(y[l],y[l+1],D)&&con(y[r],y[r+1],D)&&!v[h-1][l][r]&&ijk[h-1][l][r]>cost+len[l]*(now-D)/ABS(y[l+1]-y[l])+len[r]*(now-D)/ABS(y[r+1]-y[r])){
					ijk[h-1][l][r]=cost+len[l]*(now-D)/ABS(y[l+1]-y[l])+len[r]*(now-D)/ABS(y[r+1]-y[r]);
					Q.push(make_pair(make_pair(-ijk[h-1][l][r],h-1),make_pair(l,r)));
				}
			}
			if(l&&ABS(y[l]-now)<eps){
				double hos=0;
				if(ht[l-1])hos+=len[l-1];
				if(!v[h][l-1][r]&&ijk[h][l-1][r]>cost+hos){
					ijk[h][l-1][r]=cost+hos;
					Q.push(make_pair(make_pair(-cost-hos,h),make_pair(l-1,r)));
				}
			}
			if(l<a-2&&ABS(y[l+1]-now)<eps){
				double hos=0;
				if(ht[l])hos+=len[l];
				if(!v[h][l+1][r]&&ijk[h][l+1][r]>cost+hos){
					ijk[h][l+1][r]=cost+hos;
					Q.push(make_pair(make_pair(-cost-hos,h),make_pair(l+1,r)));
				}
			}
			if(r&&ABS(y[r]-now)<eps){
				double hos=0;
				if(ht[r])hos+=len[r];
				if(!v[h][l][r-1]&&ijk[h][l][r-1]>cost+hos){
					ijk[h][l][r-1]=cost+hos;
					Q.push(make_pair(make_pair(-cost-hos,h),make_pair(l,r-1)));
				}
			}
			if(r<a-2&&ABS(y[r+1]-now)<eps){
				double hos=0;
				if(ht[r+1])hos+=len[r+1];
				if(!v[h][l][r+1]&&ijk[h][l][r+1]>cost+hos){
					ijk[h][l][r+1]=cost+hos;
					Q.push(make_pair(make_pair(-cost-hos,h),make_pair(l,r+1)));
				}
			}
		}
		double ret=999999999;
		for(int i=0;i<a;i++)for(int j=0;j<a;j++){
			double hos=0;
			if(ht[j])hos+=len[j];
			ret=min(ret,hos+ijk[i][j][j]);
		}
		printf("%.12f\n",ret);
	}
}

Measured memory_bytes: 15740
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(int)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef long double ld;
typedef int ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const int SIZE=10001;
const int INF=1LL<<30;
const LL p=7+1e9;
const LL SEGSIZE=1<<11;
LL H,W,T,Q;
LL segtree[SEGSIZE<<1][SEGSIZE<<1];
LL nsegtree[SEGSIZE<<1][SEGSIZE<<1];
LL query2(LL seg[SEGSIZE<<1][SEGSIZE<<1],int h,int w,int h2,int w2,int s,int e,int nowh,int now){
	//cout << nowh << " " << now <<" " << s << " " << e << endl;
	if(w<=s && e<=w2) return seg[nowh][now];
	else if(e<w or w2<s) return 0;
	else{
		int ans=0;
		ans+=query2(seg,h,w,h2,w2,s,(s+e)/2,nowh,now*2);
		ans+=query2(seg,h,w,h2,w2,(s+e)/2+1,e,nowh,now*2+1);
		return ans;
	}
}
LL query(LL seg[SEGSIZE<<1][SEGSIZE<<1],int h,int w,int h2,int w2,int s,int e,int now){
	if(h<=s && e<=h2) {
		//cout << h << " " <<h2 << " " <<s <<" " << e << endl;
		return query2(seg,h,w,h2,w2,0,SEGSIZE-1,now,1);
	}
	else if(e<h or h2<s) return 0;
	else{
		int ans=0;
		ans+=query(seg,h,w,h2,w2,s,(s+e)/2,now*2);
		ans+=query(seg,h,w,h2,w2,(s+e)/2+1,e,now*2+1);
		return ans;
	}
}
LL sum(LL seg[SEGSIZE<<1][SEGSIZE<<1],int h,int w,int h2,int w2){
	return query(seg,h,w,h2,w2,0,SEGSIZE-1,1);
}
void update(LL seg[SEGSIZE<<1][SEGSIZE<<1],int h,int w,bool isW){
	if(w==0) return;
	if(isW){
		seg[h][w]=seg[h][w*2]+seg[h][w*2+1];
		update(seg,h,w/2,true);
	}
//	cout << seg[h][w] << endl;
}
void segadd(LL seg[SEGSIZE<<1][SEGSIZE<<1],int h,int w,int val){
	//cout << "START" << endl;
	int c=SEGSIZE+h;
	while(c>=1){
		seg[c][SEGSIZE+w]+=val;
		update(seg,c,(SEGSIZE+w)/2,true);
		c/=2;
	}
}
int main(){
	cin.tie(0);
	cin >> H >> W >> T >> Q;
	queue<ppr> qu;
	REP(i,Q){
		int h,w,t,c;
		cin >> t >> c;
		while(!qu.empty()){
			int now=qu.front().first;
			if(now>t) break;
			h=qu.front().second.first;
			w=qu.front().second.second;
			qu.pop();
			segadd(nsegtree,h,w,-1);
			segadd(segtree,h,w,1);
		}
	//	cout << qu.size() << endl;
		cin >> h >> w;
		if(c==0){
			qu.push(ppr(t+T,pr(h,w)));
			segadd(nsegtree,h,w,1);	
		//	cout << sum(nsegtree,h,w,h,w) << endl;
		}else if(c==1){
			if(sum(segtree,h,w,h,w)==1){
				segadd(segtree,h,w,-1);
				//cout << sum(segtree,h,w,h,w) << endl;
			}
		}else{
			int h2,w2;
			cin >> h2 >> w2;
			cout << sum(segtree,h,w,h2,w2) << " " <<sum(nsegtree,h,w,h2,w2) << endl;
		}
	}
	REP(i,SEGSIZE<<1){
		REP(j,SEGSIZE<<1){
		//	if(nsegtree[i][j])
		//	cout <<i << " "<< j<<" "<< nsegtree[i][j]<< endl;
		}
	}
	return 0;
}

Measured memory_bytes: 259392
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, na, nb, nc;
int sa, sc;
int pa[N], pc[N];
char ch[N];
int count (int x) {
    int cnt = 0;
    while (x) x -= x & (-x), ++cnt;
    return cnt;
}
int work (int x) {
    int ans = 0;
    while (x) x %= count (x), ++ans;
    return ans;
}
signed main() {
    scanf ("%d %s", &n, ch + 1);
    for (int i = 1; i <= n; ++i)
        ch[i] -= '0', nb += ch[i];
    na = nb - 1, nc = nb + 1;
    pa[n] = pc[n] = 1;
    for (int i = n; i >= 1; --i) {
        if (na > 0) {
            sa = (sa + pa[i] * ch[i]) % na;
            pa[i - 1] = pa[i] * 2 % na;
        } if (nc > 0) {
            sc = (sc + pc[i] * ch[i]) % nc;
            pc[i - 1] = pc[i] * 2 % nc;
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (ch[i] == 0) {
            int tmp = (sc + pc[i]) % nc;
            printf ("%d\n", work (tmp) + 1);
        } else {
            if (!na) { puts ("0"); continue; }
            int tmp = ((sa - pa[i]) % na + na) % na;
            printf ("%d\n", work (tmp) + 1);
        }
    }
    return 0;
}


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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  string s;
  cin >> s;
  if(s[a] == '-'){
    bool ok = true;
    for(int i=0; i<s.length(); i++){
      if(i == a) continue;
      if(s[i] < '0' || s[i] > '9'){
        ok = false;
        break;
      }
    }
    if(ok){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>                                                 
#include<string.h>                                                
                                                                  
int main(void){                                                   
   char N[200000];                                                
   scanf("%s",N);                                                 
   int len = strlen(N);                                           
   int sum = 0;                                                   
                                                                  
   for(int i = 0; i < len; i++){                                  
      int num = N[i] - '0';                                       
      sum += num;                                                 
   }                                                              
   if(sum % 9 == 0){                                              
      printf("Yes");                                              
   }else{                                                         
      printf("No");                                               
   }                                                              
   return 0;                                                      
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define  f first
#define s second
#define ll long long int
#define vll vector<long long int>
#define vi  vector<int>
#define vpi vector<pair<int,int>>
#define prec fixed<<setprecision(10)
#define set(x) __builtin_popcount(x)
#define ffs(x) __builtin_ffs(x)
#define clz(x) __builtin_clz(x)
#define inf 1000000007
#define linf 1000000000000000007
#define a(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

int main(){
    fast
    int win = 1;
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int k = a/d + (a%d!=0);
    int l = c/b + (c%b!=0);
    if(k<l)cout << "No";
    else cout << "Yes";

}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
using namespace std;
string str,tmp;
int n,i,j;
string change(string);
bool check(string);
int main(){
	cin>>n;
	cin.ignore();
	while(n--){
		getline(cin,str);
		tmp=str;
		for(i=0;i<=1000;i++){
			for(j=0;j<=1000;j++){
				//cout<<i<<" "<<j<<endl;
				str=tmp;
				str=change(str);
				if(check(str)){
					cout<<str<<endl;
					i=j=9999;
				}
			}
		}
	}
}
string change(string st){
	for(int I=0;I<(int)st.size();I++){
		if('a'<=st[I]&&st[I]<='z'){
			st[I]= ((st[I]-'a')*i+j)%26 + 'a';
		}
	}
	return st;
}
bool check(string st){
	//cout<<st<<endl;
	for(int I=0;I<(int)st.size()-3;I++){
		if(st.substr(I,4)=="this")return true;
		if(st.substr(I,4)=="that")return true;
	}
	return false;
}

Measured memory_bytes: 1220
n = gets.to_i
a = gets.chomp.split.map(&:to_i)
a.unshift(0)
hs = Hash.new(0)
hs[0] += 1

1.step(n) do |i|
  a[i] += a[i - 1]
  hs[a[i]] += 1
end

res = 0
hs.each do |_, v|
  res += v * (v - 1) / 2
end
puts res

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

int main() {
  
  int N; string S; cin >> N >> S; int ans = 0;
  
  string alp = "abcdefghijklmnopqrstuvwxyz";
  
  for (int i = 1; i < N; i++) {
    
    int tmp = 0;
    string left = S.substr(0, i);
    string right = S.substr(i, N - i);
    
    for (int j = 0; j < alp.size(); j++) {
      
      bool leftFlag = false;
      bool rightFlag = false;
      
      for (int k = 0; k < left.size(); k++) {
        if (left.at(k) == alp.at(j)) leftFlag = true;
      }
      
      for (int k = 0; k < right.size(); k++) {
        if (right.at(k) == alp.at(j)) rightFlag = true;
      }
      
      if (leftFlag && rightFlag) tmp++;
      
    }
    
    ans = max(ans, tmp);
    
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,
        a:[i64;n],
    }
    // small -> big の間で繰り返す！
    let mut pairs = vec![];

    let mut small = 9999;
    let mut big = 0;
    for &x in a.iter() {
        if big > x {
            // 入れ替わり
            pairs.push((small, big));
            small = 9999;
            big = 0;
            // small = min(small,x);
            // big = max(
            // continue;
        }
        small = min(small, x);
        big = max(big, x);
    }
    if small != 9999 && big != 0 {
        pairs.push((small, big));
    }
    let mut ans = 1000;
    for &(s, b) in pairs.iter() {
        let count = ans / s;
        ans -= s * count;
        ans += b * count;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2172
#include <iostream>

using namespace std;

int main()
{
  int N;
  cin >> N;
  int odd = 0;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    if (A % 2) odd++;
  }
  if (odd % 2) cout << "NO" << endl;
  else cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

void card(int A[],int size, char a);

int main() {
	
	int ncards, num;
	int S[13], H[13], C[13], D[13];
	char a;
	
	while( cin >> ncards) {
		
		for(int i=0;i<13;i++){
			S[i] = 0;
			H[i] = 0;
			C[i] = 0;
			D[i] = 0;
		}
		
		for(int i=0;i<ncards;i++) {
			
			cin >> a >> num;
			
			switch(a) {
				
				case 'S': S[num-1]++; 
				break;
				case 'H': H[num-1]++; 
				break;
				
				case 'C': C[num-1]++; 
				break;
				case 'D': D[num-1]++; 
				break;
				default : break;
				
			}
			
		}
		card(S, 13, 'S');
		card(H, 13, 'H');
		card(C, 13, 'C');
		card(D, 13, 'D');
		
	}
	
	return 0;
}

void card(int A[],int size, char a) {
	
	for(int i=0;i<size;i++) {
		
		if( A[i] == 0)
		cout << a << " " << i+1 << "\n";
		
	}
	
}


Measured memory_bytes: 3068
n = gets.chomp.to_i
array = gets.chomp.split.map(&:to_i)
if n == 2
  ans = array.max
else
  start_gcd_array = [array[0]]
  end_gcd_array   = [array[n - 1]]
  (n - 1).times do |i|
    start_gcd_array << start_gcd_array[i].gcd(array[i + 1])
  end
  (n - 1).times do |i|
    end_gcd_array << end_gcd_array[i].gcd(array[n - 2 - i])
  end
  may_ans = []
  (n - 2).times do |i|
    may_ans << start_gcd_array[i].gcd(end_gcd_array[n - 3 - i])
  end
  may_ans << start_gcd_array[n - 2]
  may_ans << end_gcd_array[n - 2]
  ans = may_ans.max
end
puts ans

Measured memory_bytes: 12044
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

var (
	SENTINEL = 2000000000
	cnt      = 0
)

func main() {
	fmt.Println(answer(os.Stdin))
}

func answer(r io.Reader) string {
	n := 0

	sc := bufio.NewScanner(r)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ = strconv.Atoi(sc.Text())
	A := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		A[i], _ = strconv.Atoi(sc.Text())
	}

	mergeSort(A, n, 0, n)

	result := strings.TrimRight(fmt.Sprintf("%+v", A)[1:], "]") + "\n"
	return result + strconv.Itoa(cnt)
}

func merge(A []int, n, left, mid, right int) {
	n1 := mid - left
	n2 := right - mid
	L, R := make([]int, n1+1), make([]int, n2+1)
	for i := 0; i < n1; i++ {
		L[i] = A[left+i]
	}
	for i := 0; i < n2; i++ {
		R[i] = A[mid+i]
	}
	L[n1], R[n2] = SENTINEL, SENTINEL

	i, j := 0, 0
	for k := left; k < right; k++ {
		cnt++
		if L[i] <= R[j] {
			A[k] = L[i]
			i++
			continue
		}
		A[k] = R[j]
		j++
	}
}

func mergeSort(A []int, n, left, right int) {
	if left+1 < right {
		mid := (left + right) / 2
		mergeSort(A, n, left, mid)
		mergeSort(A, n, mid, right)
		merge(A, n, left, mid, right)
	}
}



Measured memory_bytes: 37804
#include <stdio.h>
#include <algorithm>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
int main(){
  int n,i,j;
  scanf("%d",&n);
  float v[n];
  for(i=0;i<n;i++){
    scanf("%f",&v[i]);
  }
  std::sort(v, v + SIZE_OF_ARRAY(v));
  for(i=0;i<n-1;i++){
    v[i+1]=(v[i]+v[i+1])/2;
  }
  printf("%f",v[n-1]);
}

Measured memory_bytes: 128
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,w,z;
    char ca,cb,cc;
    cin>>str;
    rep(i,3){
        if(str[i]=='1') cout<<9;
        else cout<<1;
    }
    

    return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int main()
{
	string n;
	cin >> n;
	
	int res = 0;
	for(int i = 0;i < n.size();i ++)
		res += n[i] - '0';
	
	if(res % 9) puts("No");
	else puts("Yes");
	
	return 0;
}

Measured memory_bytes: 3452
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) long long((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
typedef pair<ll, ll> P;
typedef map<string, ll> M;
typedef unordered_map<ll, ll> HM;
typedef set<ll> S;
typedef multiset<ll> MS;
typedef queue<ll> Q;
ll mod = 1e9 + 7;

int main(){
    ll n; cin>>n;
    map<ll, ll> a;
    for(ll i=0; i<n; i++){
        ll tmp; cin>>tmp;
        a[tmp]++;
    }
    bool flag = true;
    if(n&1){
        if(a[0] == 1){
            for(ll i=2; i<n; i+=2)
                if(a[i] != 2){
                    flag = false;
                    break;
                }
        }
        else
            flag = false;
    }
    else{
        for(ll i=1; i<n; i+=2)
            if(a[i] != 2){
                flag = false;
                break;
            }
    }
    if(flag){
        ll ans = 1;
        for(ll i=0; i<n/2; i++){
            ans *= 2;
            ans %= mod;
        }
        OUT(ans);
    }
    else
        OUT(0);
}


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

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

#define fr first
#define sc second

template <int N = 100010>
struct UF{
	int par[N],r[N];
	ll sum[N];
	priority_queue<P> *que[N];
	UF(){
		for(int i = 0 ; i < N ; i ++){
			par[i] = i;
			r[i] = 0;
			sum[i] = 0;
			que[i] = new priority_queue<P>;
		}
	}
	void init(){
		for(int i = 0 ; i < N ; i ++){
			par[i] = i;
			r[i] = 0;
			sum[i] = 0;
			if(que[i] != nullptr)delete que[i];
			que[i] = new priority_queue<P>;
		}
	}
	int find(int x){
		if(par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	bool same(int x,int y){
		return find(x) == find(y);
	}
	void unit_(int x,int y){
		par[x] = y;
		sum[y] += sum[x];
		if(que[x]->size() < que[y]->size()){
			while(!que[x]->empty()){
				P p = que[x]->top(); que[x]->pop();
				que[y]->push(p);
			}
			delete que[x];
			que[x] = nullptr;
		}
		else {
			while(!que[y]->empty()){
				P p = que[y]->top(); que[y]->pop();
				que[x]->push(p);
			}
			delete que[y];
			que[y] = que[x];
			que[x] = nullptr;
		}
		if(r[x] == r[y])r[y] ++;
	}
	void unit(int x,int y){
		if(same(x,y))return;
		x = find(x);
		y = find(y);
		if(r[x] < r[y]){
			unit_(x,y);
		}
		else {
			unit_(y,x);
		}
	}
	void run(int v,int w){
		while(1){
			v = find(v);
			if(que[v]->empty())break;
			P p = que[v]->top();
			if(find(p.sc) == v)que[v]->pop();
			else if(p.fr+sum[v]+w >= 0){
				que[v]->pop();
				unit(v,p.sc);
			}
			else break;
		}
	}
};

UF<100010> uf;

int main(){
	static int n,m;
	static int a[100010],b[100010];
	static int u[100010],v[100010];
	scanf("%d%d",&n,&m);
	for(int i = 0 ; i < n ; i ++){
		scanf("%d%d",&a[i],&b[i]);
	}
	for(int i = 0 ; i < m ; i ++){
		scanf("%d%d",&u[i],&v[i]);
		u[i] --;
		v[i] --;
	}
	
	if(n == 1){
		cout << max( a[0] , b[0] ) << endl;
		return 0;
	}
	
	ll l = 0, r = 1000000000;
	while(l<r){
		int mi = (l+r)/2;
		uf.init();
		for(int i = 0 ; i < m ; i ++){
			uf.que[u[i]]->push(P(b[v[i]]-a[v[i]],v[i]));
			uf.que[v[i]]->push(P(b[u[i]]-a[u[i]],u[i]));
		}
		for(int i = 0 ; i < n ; i ++){
			uf.sum[i] = b[i];
		}
		for(int i = 0 ; i < n ; i ++){
			if(a[i] <= b[i]+mi)uf.run(i,mi);
		}
		int root = uf.find(0);
		bool ok = true;
		for(int i = 0 ; i < n ; i ++){
			ok &= uf.find(i) == root;
		}
		if(ok)r = mi;
		else l = mi+1;
	}
	for(int i = 0 ; i < n ; i ++){
		l += b[i];
	}
	cout << l << endl;
}



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

#define ll long long

using namespace std;

const int N = (int)3e3 + 7;
const ll inf = (ll)1e18 + 7;

ll dp[2][N][N];
ll a[N];
int n;

ll calc(int tp, int l, int r) {
	if (l > r) return 0;
	ll &res = dp[tp][l][r];
	if (res != -1) return res;
	res = 0;
	if (tp == 0) {
		res = -inf;
		res = max(res, calc(tp ^ 1, l + 1, r) + a[l]);
		res = max(res, calc(tp ^ 1, l, r - 1) + a[r]);
	} else {
		res = inf;
		res = min(res, calc(tp ^ 1, l + 1, r) - a[l]);
		res = min(res, calc(tp ^ 1, l ,r - 1) - a[r]);
	}
	return res;
}

main() {
	memset(dp, -1, sizeof dp);
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
	}
	cout << calc(0, 1, n);
}


Measured memory_bytes: 141696
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot

#############
# Main Code #
#############

N, Y = getNM()

n10k = Y // 10000
ans = []
for i in range(n10k + 1):
    left5 = Y - (i * 10000)
    n5k = left5 // 5000
    for j in range(n5k + 1):
        left1 = left5 - (j * 5000)
        l = left1 // 1000
        if i + j + l == N:
            ans = [i, j, l]
if len(ans) == 0:
    print(-1, -1, -1)
else:
    print(*ans)

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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);	
	int A, B; cin >> A >> B;
	string s; cin >> s;
	bool ans = true;
	for (int i = 0; i < s.length(); ++i){
		if (i == A && s[i] != '-'){
				ans = false;	
		}else if (i != A){
			if (!(s[i] - '0' >= 0 && s[i] - '0' <= 9)){
				ans = false;
			}
		}
	}	
	cout << (ans ? "Yes" : "No") << "\n";
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>

using namespace std;

int main(){

    string S,T,U;
    int A,B;


    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if(U == S){
        A -= 1;
        cout << A <<" " << B;
    }else{
        B -= 1;
        cout << A <<" " << B;
    }




    return 0;
}

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

int main() {
  string a, b;
  cin >> a >> b;
  string tasu = a + b;
  int number = stoi(tasu);
  float s = sqrt(number);
  int si = s;
  if (si < s) {
  	cout << "No" << endl;
  } else {
  	cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3600
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    ll tx, ty;
    cin >> tx >> ty;
    for (int i = 1; i < n; ++i) {
        ll x, y, k;
        cin >> x >> y;
        k = max((tx + x - 1) / x, (ty + y - 1) / y);
        if (k > 0) {
            tx = x * k;
            ty = y * k;
        }
    }

    cout << tx + ty << endl;
}

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

using namespace std;

const int N = 100000;
const int M = 11;

double dp[N][M], data[N+1], ans[N], sum;
int n;

main(){
  data[0] = 1.0;
  for(int i=1;i<=M;i++) data[i] = data[i-1] * 0.5;
  fill(dp[0], dp[N], 0.0);
  dp[0][0] = 1.0;
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      if(dp[i][j] > 0.0){
        sum += dp[i][j] * data[j];
        dp[i+1][0] += dp[i][j] * (1.0 - data[j]);
        dp[i+1][j+1] += dp[i][j] * data[j];
      }
    }
    ans[i] = sum;
  }
  while(cin >> n && n) printf("%.3f\n", ans[n-1]);
}

Measured memory_bytes: 10572
#include <stdio.h>
#include <math.h>
#include <ctype.h>

#define min(a,b) (((a)<(b))?(a):(b))

int main(void)
{
    int N;
    scanf("%d",&N);
    int cnt = 0;
    for(int i=0;i<N;i++)
    {
        int p;
        scanf("%d",&p);
        cnt += p != (i+1);
    }
    puts((cnt==0 || cnt==2)?"YES":"NO");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

int main() {
    // input
    string s;
    cin >> s;
    // solve
    reverse(ALL(s));
    int n = s.size();
    vector<string> t = {"dream", "dreamer", "erase", "eraser"};
    rep(i, 4) {
        reverse(ALL(t[i]));
    }
    bool flag = true;
    int i = 0;
    while (i < n and flag) {
        if (s[i] == 'm') {
            rep(j, 5) {
                if (i+j >= n or s[i+j] != t[0][j]) {
                    flag = false;
                    break;
                }
            }
            i += 5;
        } else if (s[i] == 'e') {
            rep(j, 5) {
                if (i+j >= n or s[i+j] != t[2][j]) {
                    flag = false;
                    break;
                }
            }
            i += 5;
        } else if (i+2 < n and s[i] == 'r' and s[i+1] == 'e') {
            if (s[i+2] == 's') {
                rep(j, 6) {
                    if (i+j >= n or s[i+j] != t[3][j]) {
                        flag = false;
                        break;
                    }
                }
                i += 6;
            } else if (s[i+2] == 'm') {
                rep(j, 7) {
                    if (i+j >= n or s[i+j] != t[1][j]) {
                        flag = false;
                        break;
                    }
                }
                i += 7;
            } else {
                flag = false;
                break;
            }
        } else {
            flag = false;
            break;
        }
    }
    // output
    if (flag) printf("YES\n");
    else printf("NO\n");
}

Measured memory_bytes: 3760
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

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

  int n, x, t; cin >> n >> x >> t;
  cout << (n + x - 1) / x * t << endl; 

  return 0;
}


Measured memory_bytes: 3556
#include <iostream>
#include <string>

using namespace std;

int main(){
  string s;
  while(getline(cin,s)){
    for(int i=0;i<26;i++){
      string ans;
      for(string::iterator it=s.begin();it!=s.end();it++){      
	if(*it==' '||*it=='.'){
	  ans.push_back(*it);
	  continue;
	}
	ans.push_back((char)(((int)*it-0x61+i)%26+0x61));
      }
      if(ans.find("the")!=string::npos||ans.find("this")!=string::npos||ans.find("that")!=string::npos){
	cout<<ans<<endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1184
N = int(input())
v = list(map(int,input().split()))

odd = [v[i] for i in range(N) if i%2 == 1]
even = [v[i] for i in range(N) if i%2 == 0]

oddmemo = [0 for i in range(100001)]
evenmemo = [0 for i in range(100001)]
for i in odd:
  oddmemo[i] = oddmemo[i] + 1
for i in even:
  evenmemo[i] = evenmemo[i] + 1
  
oddres = [(oddmemo[i],i) for i in range(100001)]
evenres = [(evenmemo[i],i) for i in range(100001)]
oddres.sort()
evenres.sort()
if oddres[-1][1] == evenres[-1][1]:
	print(min(N-oddres[-1][0]-evenres[-2][0],N-oddres[-2][0]-evenres[-1][0]))
else:
	print(N-oddres[-1][0]-evenres[-1][0])


Measured memory_bytes: 31008
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		String b = sc.next();
		
		long ans = 0;
		ans += a * Long.valueOf(b.substring(0, 1)) * 100;
		ans += a * Long.valueOf(b.substring(2, 3)) * 10;
		ans += a * Long.valueOf(b.substring(3, 4));
		ans /= 100;
		
		System.out.println(ans);
		
		sc.close();
	}
}



Measured memory_bytes: 27052
#include <bits/stdc++.h>
 
#define scd second
#define fst first
#define pb push_back
#define mkp make_pair
#define all(x) x.begin(), x.end()
#define VT(T) vector<T>
 
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vint> vvint;
typedef vector<vlong> vvlong;
typedef list<int> lint;
typedef list<ll> llong;
typedef list<pii> lpii;
typedef list<pll> lpll;
typedef list<lint> llint;
typedef list<llong> lllong;
 
ll const LINF=numeric_limits<long long int>::max();
int const INF=numeric_limits<int>::max();
 
ll gcd(ll a, ll b){
	return b ? gcd(b,a%b) : a;
}
 
ll pow_mod(ll a, ll e, ll m){
	ll res=1;
	while(e){
		if(e&1) res=res*a%m;
		a=a*a%m;
		e>>=1;
	}
	return res;
}
 
ll inv_mod(ll b, ll m){
	b%=m;
	ll x=0, y=1, r, q, a=m;
	while(b){
		q=a/b;
		r=a%b;
		a=b;
		b=r;
		r=x;
		x=y;
		y=r-q*y;
	}
	x+=m;
	return x%m;
}

void solve(int id, int n, vpii test[], vint &unkind, int &ans){
	if(id>=n){
		int f=true;
		for(int i=0; i<n; i++){
			if(unkind[i]==0){
				for(auto y : test[i]){
					if(y.second==unkind[y.first]){
						f=false;
						break;
					}
				}
			}
			if(!f) break;
		}
		if(f) ans=max(ans,n-accumulate(all(unkind),0));
	} else {
		unkind[id]=0;
		solve(id+1,n,test,unkind,ans);
		unkind[id]=1;
		solve(id+1,n,test,unkind,ans);
	}
}

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

	int n;
	cin>>n;
	vpii test[n];
	vint unkind(n,1);
	for(int i=0; i<n; i++){
		int ai;
		cin>>ai;
		for(int j=0; j<ai; j++){
			int xij, yij;
			cin>>xij>>yij;
			test[i].pb({xij-1,yij});			
		}
	}

	int ans=0;
	solve(0,n,test,unkind,ans);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;

const long long INF = 1LL << 60;

//各桁の和を出力
long long Sum(long long n) {
long long m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}

const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


#define comuse Comuse()
//nCk(comuseを使え)
long long combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
//pCk(comuseを使え)
long long perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}

//最小公倍数(aとbの)
long long lcm(long long a,long long b){
  long long n;
  n=a/__gcd(a,b)*b;
  return n;
}

//auto A = div(n)
vector<long long> div(long long n){
  vector<long long> ret;
  for(long long i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  sort(ret.begin(),ret.end());
  return ret;
}

//(aのn乗をmodで割ったあまり)
long long modpow(long long a,long long n,long long mod){
  long long ans=1;
  while(n>0){
    if(n&1){
      ans=ans*a%mod;
    }

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  solve();
}

///////////////////////////////////////////////////////////

int N;
int cnt = 1;
void solve(){
  cin >> N;
  vector<int> brick(N);
  for(int i = 0; i < N; i++){
    cin >> brick.at(i);
  }
  for(int i = 0; i < N; i++){
    if(brick.at(i) == cnt){
      cnt++;
    }
  }
  if(cnt == 1){
    cout << -1 <<endl;
  }
  else{
    cout << N - cnt + 1 <<endl;
  }
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		StringTokenizer st = new StringTokenizer(str, " ");
		String x = st.nextToken();
		String y = st.nextToken();
		int a = Integer.parseInt(x);
		int b = Integer.parseInt(y);

		int c = a*b;
		int d = 2*a + 2*b;
		System.out.print(c);
		System.out.print(" ");
		System.out.println(d);
	}
}

Measured memory_bytes: 24092
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int N;
  cin >> N;
  bool jad = false;
  bool swi = true;
  
  vector<int> a(N);
  
  for(int i = 0 ; i < N ; i++){
    
    cin >> a.at(i);
    
  }
  
  for(int i = 0; i < N ; i++){
    
    int num = a.at(i);
    
    if(num == i+1){
      
      if(i == N -1){
        jad = true;
        break;
      }
      continue;
    }
    
    if(num != i+1){
      
      if(a.at(num-1) == i+1 ){
        
        if(swi){
          
          swi = false;
          a.at(num-1) = num;
          a.at(i) = i+1;
          
        }
        else{
          break;
        }
      }
      else{
          break;
      }
    }
  }
  
  if(jad){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 384