akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

struct Edge {
	ll to, cost;
	Edge() {}
	Edge(ll a, ll b) {
		to = a, cost = b;
	}
};

ll n, m;
vector<Edge> G[100000];
P Limit[100000];
bool isused[100000];

void dfs(int pos, int pre) {
	isused[pos] = true;
	P x = Limit[pos];
	for (int i = 0; i < G[pos].size(); i++) {
		if (G[pos][i].to == pre)continue;
		if (isused[G[pos][i].to])continue;
		Limit[G[pos][i].to] = P(-x.first, G[pos][i].cost - x.second);
		dfs(G[pos][i].to, pos);
	}

}

int main() {
	cin >> n >> m;
	ll u, v, s;
	for (int i = 0; i < m; i++) {
		cin >> u >> v >> s;
		u--, v--;
		G[u].push_back(Edge(v, s));
		G[v].push_back(Edge(u, s));
	}

	Limit[0] = P(1, 0);

	dfs(0, -1);

	ll mans = 1, Mans = 1e15;
	for (int i = 0; i < n; i++) {
		if (Limit[i].first > 0)mans = max(mans, 1 - Limit[i].second);
		else Mans = min(Mans, Limit[i].second - 1);
	}

	ll onlyans = -1;

	for (int i = 0; i < n; i++) {
		for(int j = 0; j < G[i].size(); j++) {
			int u = G[i][j].to;
			if (Limit[i].first + Limit[u].first == 0) {
				//辺の両端の二つの頂点が互いにx+a, -x+bの形をしてるとき
				if (Limit[i].second + Limit[u].second - G[i][j].cost != 0) {
					//それで符合しなかったとき
					cout << 0 << endl;
					return 0;
				}
			}
			else {

				P tmp = P(Limit[i].first + Limit[u].first, 
					Limit[i].second + Limit[u].second - G[i][j].cost);
				if (tmp.first > 0) {
					//両端の頂点がいずれもx+a, x+b型の時、
					//-x+a, -x+bの型と同様に処理できるように-1を辺のコストとの差のところにかける
					tmp.second *= -1;
				}

				if (tmp.second <= 0 || tmp.second % 2 != 0) {
					//x+a, x+bの時に、一つの解をもちうる可能性があるけど、
					//2で割り切れなかったり、解が1以上を満たさないときは無理
					
					cout << 0 << endl;
					return 0;
				}

				if (onlyans == -1) {
					onlyans = tmp.second / 2;
				}
				else {
					if (onlyans * 2 != tmp.second) {
						cout << 0 << endl;
						return 0;
					}
				}
			}
		}
	}

	if (onlyans != -1 && mans <= onlyans && Mans >= onlyans)cout << 1 << endl;
	else if (mans > Mans) {
		cout << 0 << endl;
	}
	else {
		cout << Mans - mans + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 17280
#include <bits/stdc++.h>
using namespace std;
int main(void){
    char b;
    cin >> b;
    if(b == 'A') cout << 'T' << endl;
    else if(b == 'T') cout << 'A' << endl;
    else if(b == 'G') cout << 'C' << endl;
    else if(b == 'C') cout << 'G' << endl;
}


Measured memory_bytes: 256
a, b, k = map(int, input().split())

s = set()
for i in range(a, a + k):
    if i <= b:
        s.add(i)

for i in range(b + 1 - k, b + 1):
    if i >= a:
        s.add(i)

e = list(s)
e.sort()
for i in e:
    print(i)

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (ll i=(ll)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const ll INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(ll x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { ll d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll modpow(ll x, ll p) { ll result = 1, now = 1, pm = x; while (now<=p) { if (p&now) { result = result * pm % MOD; } now*=2; pm = pm*pm % MOD; } return result; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

vector<vector<ll>> adj;

void c_dis(vector<int> &d, int n=0, int p=-1) {
  if (p==-1) d[n] = 0;
  for (auto x: adj[n]) {
    if (x==p) continue;
    d[x] = d[n]+1;
    c_dis(d,x,n);
  }
}

void dfs(vector<ll> &dis, ll n=0, ll p=-1) {
  for (auto x: adj[n]) {
    if (x==p||dis[x]!=-1) continue;
    dis[x] = dis[n]+1;
    dfs(dis,x,n);
  }
}

ll calc_d() {
  int N = adj.size();
  vector<int> d_0(N,-1); c_dis(d_0,0,-1);
  int d0_pos = 0; rep(i,N) if (d_0[d0_pos]<d_0[i]) d0_pos = i;
  vector<int> d_1(N,-1); c_dis(d_1,d0_pos,-1);
  int d1_pos = 0; rep(i,N) if (d_1[d1_pos]<d_1[i]) d1_pos = i;
  return d_1[d1_pos];
}


int main() {
  ll N; cin >> N;
  adj.resize(N);
  rep(i,N-1) {
    ll a, b; cin >> a >> b; a--; b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  ll d = calc_d();
  string result = d%3!=1 ? "First" : "Second";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 28340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, ll> Pil;

int N;
ll K;
const int MAX_N = 2.0e5 + 10;
int A[MAX_N];

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) cin >> A[i];

    bool visited[N];
    memset(visited, false, sizeof(visited));
    int next = 1;
    int start;
    for (int i = 0; i < N; i++) {
        if(visited[next - 1]) {
            start = next;
            break;
        }
        else {
            visited[next - 1] = true;
            next = A[next - 1];
        }
    }

    vector<int> vec;

    next = 1;
    ll to_start = 0;
    for (int i = 0; i < N; i++) {
        if (next == start) break;
        else {
            vec.push_back(next);
            next = A[next - 1];
            to_start++;
        }
    }

    vec.push_back(start);
    next = A[start - 1];
    ll loop = 1;
    for (int i = 0; i < N; i++) {
        if (next == start) break;
        else {
            vec.push_back(next);
            next = A[next - 1];
            loop++;
        }
    }

    
    if (K <= to_start) cout << vec[K] << endl;
    else cout << vec[to_start + (K - to_start) % loop] << endl;

    return 0;
}

Measured memory_bytes: 5296
using System;
class Program
{
    static void Main(string[] args)
    {
        int a = int.Parse(Console.ReadLine());
       string s =Console.ReadLine();

        if (a < 3200)
        {
            Console.WriteLine("red");
        }
        else
        {
            Console.WriteLine(s);
        }
    }
}

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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int x=0;
  for(int i=0;i<K;i++){
    x += vec.at(i);
  }
  cout << x << endl;
}

Measured memory_bytes: 3600
import java.util.*;

public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
		HashSet<String> S = new HashSet<String>();
        for(int i=0; i<N; i++) {
        	S.add(sc.next());
        }
        System.out.println(S.size());
    }
}

Measured memory_bytes: 76888
#include <cstdio>
using namespace std;
int main(){
  int N;
  scanf("%d",&N);
  N%=28;
  for(int i=0;i<=N;i+=7){
    if((N-i)%4==0){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	int n,d,x;
	std::cin >> n >> d >> x;
	int a;
	for (size_t i = 0; i < n; i++) {
		std::cin >> a;
		x = x + (d-1)/a + 1;
	}
	std::cout << x << '\n';
	return 0;
}


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

int main() {
  long long L, R;
  cin >> L >> R;
  int ModL = L % 2019;
  int ModR = R % 2019;
  int Min = 2020;
  if ( R - L >= 2018 ){
      cout << 0 << endl;
  }
  else if ( ModL > ModR ){
      cout << 0 << endl;
  }
  // ModL - ModRの範囲で探索
  else {
    for ( int i = ModL; i <= ModR - 1; i++ ){
        for ( int j = i + 1; j <= ModR; j++ ){
            if ( Min > ( i * j  % 2019 ) )
                Min = ( i * j ) % 2019;
        }
    }
    cout << Min << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define FORl(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORDl(i, a, b) for (ll i = (a); i >= (b); i--)
using namespace std;
int main () {
  int n, m;
  scanf("%d %d", &n, &m);
  FOR(i, 1, m) {
    int t;
    scanf("%d", &t);
    n -= t;
  }
  printf("%d\n", max(n, -1));
  return 0;
}

Measured memory_bytes: 3824
import itertools
N, M, Q = map(int, input().split())

a = []
b = []
c = []
d = []

for _ in range(Q):
    ai, bi, ci, di = map(int, input().split())
    a.append(ai)
    b.append(bi)
    c.append(ci)
    d.append(di)


ans = 0

nums = range(1, M+1)


for A in itertools.combinations_with_replacement(nums, N):
    s = 0

    # print(A[0])
    for i in range(Q):
        ai = a[i]-1
        bi = b[i]-1
        ci = c[i]
        di = d[i]
        if A[bi]-A[ai] == ci:

            s += di

    ans = max(ans, s)

print(ans)


Measured memory_bytes: 73608
package main

import "fmt"

func main() {
	var x int
	fmt.Scan(&x)
	fmt.Println(Lcm(x, 360) / x)
}

// Gcd returns greatest common divisor
func Gcd(x, y int) int {
	mod := x % y
	if mod > 0 {
		return Gcd(y, mod)
	} else {
		return y
	}
}

// Lcm returns least common multiple
func Lcm(x, y int) int {
	return x * y / Gcd(x, y)
}


Measured memory_bytes: 1768
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main(){
    string s; cin >> s;

    int cnt = 0;
    if(s[0]=='R'&&s[1]=='R'&&s[2]=='R'){
        out(3);
        return 0;
    }else if(s[0]=='R'&&s[1]=='R'){
        out(2);
        return 0;
    }else if(s[1]=='R'&&s[2]=='R'){
        out(2);
        return 0;
    }else if(s[0]=='S'&&s[1]=='S'&&s[2]=='S'){
        out(0);
        return 0;
    }else{
        out(1);
        return 0;
    }

}

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


int main() {
  long long N,K;
  cin >> N;
  K = N/2;
  vector<long long> A(N);
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  long long ans = 0;
  long long term = 0;
  vector<vector<long long>> dp(K,vector<long long> (3,0));
  if (N % 2 == 0) {
    for (int i=0; i<N; i+=2) {
      term += A[i];
    }
    ans = term;
    for (int i=N-1; i>=0; i-=2) {
      term += A[i];
      term -= A[i-1];
      ans = max(term,ans);
    }
  }
  else {
    dp[0][0] = A[0];
    dp[0][1] = max(A[0],A[1]);
    dp[0][2] = max(dp[0][1],A[2]);
    for (int i=1; i<K; i++) {
      dp[i][0] = dp[i-1][0] + A[i*2];
      dp[i][1] = max(dp[i][0],dp[i-1][1] + A[i*2+1]);
      dp[i][2] = max(dp[i][1],dp[i-1][2] + A[i*2+2]);
    }
    ans = dp[K-1][2];
  }
  cout << ans << endl;

}

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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

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

    li r;

    cin>>r;

    cout<<fixed<<setprecision(6);

    cout<<2.0*3.141592653589*(ld)r;

    return 0;
}

Measured memory_bytes: 3804
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a, a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ld x, ld y, ld a, ld b){ return sqrt((x-a)*(x-a) + (y-b)*(y-b)); }
void debug(ll* a, ll n) { for ( ll k = 0; k < n; k++ ){ cerr << a[k] << " ";} cout << "\n"; }
#define PI 3.14159265358979323846
#define FF first
#define SS second

int main(){
	FASTIO;
	ll n; cin >> n;
	ll a[n]; parseArray(a, n);
	ll ans = 0, mx = a[0];
	for ( int k = 0; k < n; k++ ){
		ans += max(mx - a[k], 0ll);
		mx = max(mx, a[k]);
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i,a,b)                for(ll i=a;i<b;i++)
#define re(i,b)                for(ll i=0;i<b;i++)
#define repr(i,n)                for(ll i=n-1;i>=0;i--)
#define ll long long
#define ld long double
#define llu long long unsigned
#define vll std::vector<ll>
#define mll std::map<ll, ll>
#define pll std::pair<ll, ll>
#define mpll std::map<pair<ll,ll>, ll>
#define sll std::set<ll>
#define fi first
#define se second
#define msll std::multiset<ll>
#define all(c) c.begin(), c.end()
#define allr(c) c.rbegin(), c.rend()
#define srt(x) sort(all(x))
#define rsrt(x) sort(allr(x))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define s(yy) ll yy;cin>>yy
#define mod 1000000007
#define maxlong 9223372036854775808


/*
###################################################### 
#                                                    #
#                     @author                        #
#                  Parth Lathiya                     #
#      https://www.cse.iitb.ac.in/~parthiitb/        #
#                                                    #
###################################################### 
*/

// vll primes;
// vll primefac[10000001];

// void sieve(ll n)
// {
// 	rep(i,2,n+1)
// 	{
// 		if(primefac[i].empty())
// 		{	
// 			primes.pb(i);
// 			for(ll j=i;j<=n;j+=i)
// 				primefac[j].pb(i);
// 		}
// 	}
// }

bool bt(ll a,ll b,ll c)
{
	return c>=a && c<=b;
}
int main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	#ifdef PARTH_LATHIYA_HOME

		freopen("C_in.txt","r",stdin);
	
		ll ttt,bkkk;
		cin>>ttt;
		bkkk=ttt;
		while(ttt--) {
			cout<<"Testcase - "<<bkkk-ttt<<"\n";
	#endif

//--------------------------------------------------------------------------------------


	s(n);
	ll a[n];
	re(i,n)
		cin>>a[i];
	ll rg[9];
	re(i,9)
		rg[i]=0;
	re(i,n)
	{
		if(bt(1,399,a[i]))
			rg[0]++;
		else if(bt(400,799,a[i]))
			rg[1]++;
		else if(bt(800,1199,a[i]))
			rg[2]++;
		else if(bt(1200,1599,a[i]))
			rg[3]++;
		else if(bt(1600,1999,a[i]))
			rg[4]++;
		else if(bt(2000,2399,a[i]))
			rg[5]++;
		else if(bt(2400,2799,a[i]))
			rg[6]++;
		else if(bt(2800,3199,a[i]))
			rg[7]++;
		else if(bt(3200,10000000000000000,a[i]))
			rg[8]++;
	}
	ll cnt=0,mi,ma;
	re(i,8)
		if(rg[i])
			cnt++;
	if(rg[8] && !cnt){
		mi=1;ma=rg[8];
	}
	else{
		mi=cnt;ma=mi+rg[8];
	}
	cout<<mi<<" "<<ma;

//--------------------------------------------------------------------------------------
	
	#ifdef PARTH_LATHIYA_HOME
		cout<<"\n"; }
	#endif

	return 0;
}

Measured memory_bytes: 256
#input
import numpy as np
A = np.full((3, 3), 0)

A[0, 0], A[0, 1], A[0, 2] = map(int, input().split())
A[1, 0], A[1, 1], A[1, 2] = map(int, input().split())
A[2, 0], A[2, 1], A[2, 2] = map(int, input().split())
N = int(input())
B = [0] * N
for j in range(N):
    B[j] = int(input())

#output
if A[0, 0] in B and A[0, 1] in B and A[0, 2] in B:
    print("Yes")
elif A[1, 0] in B and A[1, 1] in B and A[1, 2] in B:
    print("Yes")
elif A[2, 0] in B and A[2, 1] in B and A[2, 2] in B:
    print("Yes")
elif A[0, 0] in B and A[1, 0] in B and A[2, 0] in B:
    print("Yes")
elif A[0, 1] in B and A[1, 1] in B and A[2, 1] in B:
    print("Yes")
elif A[0, 2] in B and A[1, 2] in B and A[2, 2] in B:
    print("Yes")
elif A[0, 0] in B and A[1, 1] in B and A[2, 2] in B:
    print("Yes")
elif A[0, 2] in B and A[1, 1] in B and A[2, 0] in B:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 12020
# Written by Shagoto

n = int(input())
arr = list(map(int, input().split(" ")))
start = 0
end = 3
count = 0

while(end <= n):
    temp = arr[start:end]
    high = max(temp)
    low = min(temp)
    if(temp[1] != high and temp[1] != low):
        count += 1
    start += 1
    end += 1

print(count)

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

namespace aizu1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            DoublyList mylist = new DoublyList(n);

            for(int i=0;i<n;i++)
            {
                mylist.Parse(Console.ReadLine());
            }

            mylist.PrintAll();
        }
    }

    public struct DoublyList
    {
        LinkedList<int> list;
        private int n;

        public DoublyList(int n)
        {
            list = new LinkedList<int>();
            this.n = n;
        }
        public void insert(int x)
        {
            list.AddFirst(x);
        }

        public void delete(int x)
        {
            var index = list.Find(x);
            if(index!=null)list.Remove(index);
        }

        public void deleteFirst()
        {
            list.RemoveFirst();
        }

        public void deleteLast()
        {
            list.RemoveLast();
        }

        public void Parse(string command)
        {
            if (command.Contains("insert")) insert(int.Parse(command.Split(' ')[1]));
            else if (command.Contains("deleteFirst")) deleteFirst();
            else if (command.Contains("deleteLast")) deleteLast();
            else delete(int.Parse(command.Split(' ')[1]));
        }

        public void PrintAll()
        {
            if (n == 0) Console.Write("");
            Console.WriteLine(string.Join(" ", Array.ConvertAll(list.ToArray(),(i)=>i.ToString())));
        }
    }
}

Measured memory_bytes: 80976
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int f[maxn],siz[maxn],n,m;
int find(int x)
{
	if(x==f[x]) return x;
	else return find(f[x]);
}
int main()
{
	int i,j;
	cin>>n>>m;
	for(i=1;i<=n;i++) f[i]=i,siz[i]=1;
	for(i=1;i<=m;i++)
	{
		int x,y,z;cin>>x>>y>>z;
		int fx=find(x),fy=find(y);
		if(fx==fy) continue;
		if(siz[fx]>siz[fy]) swap(fx,fy);
		f[fx]=fy;
		siz[fy]+=siz[fx];
		n--;
	}
	cout<<n<<endl;
}

Measured memory_bytes: 1024
/*Made by Shivam Solanki*/
#include<bits/stdc++.h> 
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
typedef queue<int> qii;
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define repllr(i,k,n) for (ll i = n; i >= k; --i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;

void solve(){
    string s;
    cin>>s;
    deque<char>ans;
    rep(i,0,s.size()){
        ans.pb(s[i]);
    }
    int q;
    cin>>q;
    int m=0;
    while(q--){
        int t;
        cin>>t;
        if(t==1){
            m++;
        }
        if(t==2){
            int f;
            char c;
            cin>>f>>c;
            if(f==1){
                if(m&1){
                    ans.push_back(c);
                }
                else{
                    ans.push_front(c);
                }
            }
            else{
                if(m&1){
                    ans.push_front(c);
                }
                else{
                    ans.push_back(c);
                }
            }
        }
    }
    if(m&1){
        while(!ans.empty()){
            cout<<ans.back();
            ans.pop_back();
        }
    }
    else{
        while(!ans.empty()){
            cout<<ans.front();
            ans.pop_front();
        }
    }
} 
 
  
int main(){
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 976
#include <iostream>
using namespace std;
int main() {
int n;
int a[113];
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
for(int x = -100; x <= 100; x++){
int current_cost = 0;
for(int i=0;i<n;i++) {
current_cost += (x - a[i]) * (x - a[i]);
}
a[112] = min(a[112],current_cost+4000000-2147483647);
}
cout << a[112] - 4000000 + 2147483647 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

//FILE * in = freopen("input.txt", "r", stdin);

int n;
int key[100];
char temp[1000];

char getChar(char c, int key){
	int code = 0;
	if('A' <= c && c <= 'Z') {
		code = c - 'A';
	}
	else if('a' <= c && c <= 'z'){
		code = c - 'a' + 26;
	}

	code -= key;
	if(code < 0) code += 52;

	if(code < 26) {
		return code + 'A';
	}
	return code + 'a' - 26;
}

void process(){
	int kp = 0;
	for(int i = 0; temp[i] ; i++){
		temp[i] = getChar(temp[i], key[kp++]);
		kp %= n;
	}
}

int main() {
	while(true){
		scanf("%d", &n);
		if(n == 0) break;
		for(int i = 0; i < n; i++) {
			scanf("%d", &key[i]);
		}
		gets(temp);
		gets(temp);
		process();
		printf("%s\n", temp);
	}
	return 0;
}

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

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; ++i) cin >> h[i];
	int ans = 0, l = 0, r = 0;
	while (r < n) {
		int tmp = 0;
		while (r + 1 < n && h[r] >= h[r + 1]) tmp++, r++;
		ans = max(ans, tmp);
		if (l == r) r++;
		else l = r;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String N = br.readLine();
	System.out.println(N.contains("7") ? "Yes" : "No");
    }
}

Measured memory_bytes: 32580
while True :
    n, m = map(int, input().split())
    if n == 0 and m == 0 :
        break
    
    guest = []
    for i in range(n) :
        guest.append(i+1)
    potate = n - 1
    
    while True :
        potate += m
        while potate >= n :
            potate -= n
        n -= 1
        del guest[potate]
        potate -= 1
        
        if n == 1 :
            break
    print(*guest)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int N, M;
void func()
{
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}
int main()
{
    func();
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
double s(ll x) {
    double ans = 0;
    while(x > 0) {
        ans += x % 10;
        x /= 10;
    }
    return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<ll> snuke;
    set<pair<double, ll>> candidate_snuke;
    candidate_snuke.insert({1 / s(1), 1});
    while(snuke.empty() or snuke.back() < 1'000'000'000'000'000) {
        ll cur = candidate_snuke.begin()->second;
        candidate_snuke.erase(candidate_snuke.begin());
        if(snuke.empty() or cur >= snuke.back()) {
            snuke.push_back(cur);
            for(ll d = 1; d <= 1'000'000'000'000'000; d *= 10) {
                candidate_snuke.insert({(cur + d) / s(cur + d), cur + d});
            }
        }
    }
    int k;
    cin >> k;
    for(int i = 0; i < k; i++) {
        cout << snuke[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include<cmath>
#include<queue>
#include<ctime>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7fffffff
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
} 
int n;
ll a[200005],b[200005],x,ls[200005],rs[200005];
ll lsum,rsum; 
int main()
{
	int i,j;
	n=read();
	for(i=1;i<=n;i++) b[i]=a[i]=read()-i;
	sort(a+1,a+n+1);
	x=n/2;
	for(i=1;i<=n;i++) 
		lsum+=abs(a[x]-a[i]);
	x++;
	for(i=1;i<=n;i++) 
		rsum+=abs(a[x]-a[i]);
	lsum=min(lsum,rsum);
	x-=2;rsum=0;
	for(i=1;i<=n;i++) 
		rsum+=abs(a[x]-a[i]);
	printf("%lld",min(lsum,rsum));
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Poll
            int N = int.Parse(Console.ReadLine());

            var words = new Dictionary<string, int>();

            for (int i = 0; i < N; i++)
            {
                var s = Console.ReadLine();

                if (words.ContainsKey(s))
                {
                    words[s]++;
                }
                else
                {
                    words.Add(s, 1);
                }
            }

            int max = words.Max(x => x.Value);

            //var ans = words.Where(x => x.Value == max)
            //               .ToDictionary(x => x.Key, x => x.Value).Keys.ToList();

            var ans = new List<string>();

            foreach (var w in words)
            {
                if (w.Value == max)
                {
                    ans.Add(w.Key);
                }
            }

            ans.Sort(StringComparer.Ordinal);

            foreach (var a in ans)
            {
                Console.WriteLine(a);
            }
        }
    }
}


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

A.sort()
ans = 0

if A[0] == 0:
    print(ans)
    exit()

for i in A:
    if ans != 0:
        ans = ans * i
    else:
        ans = i
    if ans > 1000000000000000000:
        print("-1")
        exit()

print(ans)

Measured memory_bytes: 84860
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int k = std.nextInt();
        int x = std.nextInt();
        boolean ans = 500 * k >= x;
        if (ans) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

int main ()
{
    int n;cin>>n;
    int cnt = 0;
    for(int i = 1; i<=n; i++)
    {
        if(i%2)cnt++;
    }
    double x  = double(n);
    double ans = double(cnt)/x;
    printf("%0.10f\n", ans);
    return 0;
}


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

void Main() {
	int N;
	cin >> N;
	priority_queue<int> mochi;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		mochi.push(a);
	}
	
	int dansu = 0;
	int prev = 200;
	while (!mochi.empty()) {
		int now = mochi.top();
		if (now < prev) {
			prev = now;
			dansu++;
		}
		mochi.pop();
	}

	cout << dansu << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	Main();
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int date[11]={48.00,51.00,54.00,57.00,60.00,64.00,
				  69.00,75.00,81.00,91.00};
	int i,j;
	double n;
	while(scanf("%lf",&n)!=EOF) {
		if(n<=date[0]) printf("light fly\n");
		else if(n>date[0] && n<=date[1]) printf("fly\n");
		else if(n>date[1] && n<=date[2]) printf("bantam\n");
		else if(n>date[2] && n<=date[3]) printf("feather\n");
		else if(n>date[3] && n<=date[4]) printf("light\n");
		else if(n>date[4] && n<=date[5]) printf("light welter\n");
		else if(n>date[5] && n<=date[6]) printf("welter\n");
		else if(n>date[6] && n<=date[7]) printf("light middle\n");
		else if(n>date[7] && n<=date[8]) printf("middle\n");
		else if(n>date[8] && n<=date[9]) printf("light heavy\n");
		else if(n>date[9]) printf("heavy\n");
	}
	return 0;
}

Measured memory_bytes: 1036
#include <iostream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))
using namespace std;


int main(void)
{
	int N; cin >> N;
	map<string, int> s;
	map<string, int>::iterator it;
	rep(i, 0, N) {
		string S; cin >> S;
		s[S]++;
	}
	int max = 0;
	for (it = s.begin(); it != s.end(); it++) {
		if (max < it->second)max = it->second;
	}
	for (it = s.begin(); it != s.end(); it++) {
		if (max == it->second)cout << it->first << endl;
	}

	return 0;
}


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

#define int long long
#define N 100005

vector<int> adj[N];
bool vis[N];
int dp[N];

int dfs(int s)
{
    if(vis[s]){
        return dp[s];
    }
    vis[s]=1;
    for(auto u : adj[s])
    {
        dp[s] =max(dp[s],1 + dfs(u));
    }
    return dp[s];
}

int32_t main()
{
    int n,m;
    cin >> n >> m;
    int a,b;
    for(int i=0;i<=n;++i) {
        vis[i]=0;
        dp[i]=0;
    }
    for(int i=0;i<m;++i)
    {
        cin >> a >> b;
        adj[a].push_back(b);
    }
    for(int i=1;i<=n;++i)
    {
        if(!vis[i]) dfs(i);
    }
    int ans =0;
    for(int i=1;i<=n;++i){
        ans = max(ans,dp[i]);
    }
    cout << ans << endl;

}

Measured memory_bytes: 11904
#変換表の数を入力し０なら処理を終わる
while True:
    a = int(input())
    if a == 0:break

    #空の辞書とリストを作成する
    di = {}
    line = []
    
    #変換表を入力し、辞書に入れ、キーをリストに入れる
    for _ in range(a):
        s1,s2 = input().split()
        di[s1] = s2
        line.append(s1)
        
    #文字を入力し変換表に含まれているなら変換し入っていなかったらそのまま出力する
    for _ in range(int(input())):
        l = input().rstrip()
        if l in line:print(di[l],end="")
        else:print(l,end="")
    print()


Measured memory_bytes: 5616
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = sum(B)

for i in range(N-1):
  if A[i]+1 == A[i+1]:
    ans += C[A[i]-1]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;

    vector<int> V(N), C(N);
    for (int i = 0; i < N; i++){
        cin >> V[i];
    }
    for (int i = 0; i < N; i++){
        cin >> C[i];
    }
    
    vector<int> v(N);
    for (int i = 0; i < N; i++){
        v[i] = V[i] - C[i];
    }

    sort(v.rbegin(), v.rend());
    int ans = 0;
    int i = 0;
    while (v[i] > 0){
        ans += v[i];
        i++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#encoding:utf-8 No.0073 2014.10.16
while true
  x = gets.chomp.to_f
  h = gets.chomp.to_f

  if x == 0.0 && h == 0.0
    break
  end
  
  y = Math.sqrt(h**2 + (x/2)**2)  #yは側面の三角形の高さ
  s = x**2 + 2*x*y

  printf("%.6f\n",s)
end

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

using namespace std;

template<typename Weight>
class Dinic {
public:
    Dinic(const int n) : n(n), g(n), INF(numeric_limits<Weight>::max()) {}

    void add_edge(const int src, const int dst, const Weight cap) {
        g[src].emplace_back(Edge(src, dst, cap, g[dst].size()));
        g[dst].emplace_back(Edge(dst, src, 0, g[src].size() - 1));
    }

    // O(|E||V|^2)
    Weight MaximumFlow(const int s, const int t) {
        Weight flow = 0;

        while(true) {
            vector<int> level(n, -1), iter(n);
            Bfs(s, level);
            if(level[t] == -1) break;
            for (Weight f = 0; (f = Dfs(s, t, INF, level, iter)) > 0; )
                flow += f;
        }

        return flow;
    }

private:
    struct Edge {
        int src, dst, rev;
        Weight weight;
        Edge(int f, int t, Weight cap, int rev = 0) :
            src(f), dst(t), rev(rev), weight(cap) {}
    };

    int n;
    vector<vector<Edge>> g;
    const Weight INF;

    void Bfs(const int s, vector<int> &level){
        queue<int> que;
        for (level[s] = 0, que.push(s); !que.empty(); ) {
            const int v = que.front(); que.pop();
            for (auto &e : g[v])
                if(0 < e.weight && level[e.dst] == -1){
                    level[e.dst] = level[v] + 1;
                    que.push(e.dst);
                }
        }
    }

    Weight Dfs(int v, int t, Weight flow, vector<int> &level, vector<int> &iter) {
        if(v == t) return flow;
        for ( ; iter[v] < (int)g[v].size(); ++iter[v]) {
            Edge &e = g[v][iter[v]];

            if(0 < e.weight && level[v] < level[e.dst]){
                Weight d = Dfs(e.dst, t, min(flow, e.weight), level, iter);
                if(0 < d){
                    e.weight -= d;
                    g[e.dst][e.rev].weight += d;
                    return d;
                }
            }
        }
        return 0;
    }
};

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

    int n, m, u, v, c;

    cin >> n >> m;
    Dinic<int> flow(n);
    for (int i = 0; i < m; ++i) {
        cin >> u >> v >> c;
        flow.add_edge(u, v, c);
    }

    cout << flow.MaximumFlow(0, n - 1) << endl;

    return 0;
}



Measured memory_bytes: 3208
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;


int w,h;
char ba[10][60];
typedef pair<int,int> pii;
typedef pair<double, int> pdi;

int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};

bool visited[10][60];

bool f;

pdi rec(pii p) {          // Ôèl@first: dSÌ x ÀW, second: d³
  char c = ba[p.first][p.second];

  int ll = INF, rr = 0;

  int weight = 0;
  double gx = 0;

  int nowweight = 0;
  double nowgx = 0;

  queue<pii> Q;
  Q.push(p);

//  cout << p.first << " " << p.second << endl;
    
  while(!Q.empty()) {
    int x = Q.front().first;
    int y = Q.front().second;
    Q.pop();
    if (visited[x][y]) continue;
    visited[x][y] = 1;

//    printf("x=%d,y=%d\n",x,y);
    nowgx += 0.5+x;
    nowweight++;
    
    if (y==h-1 || y<h-1 && ba[x][y+1] != '.' && ba[x][y+1] != c) {
      ll = min(ll, x);
      rr = max(rr, x+1);
    }
    if (y>0 && ba[x][y-1] != '.' && ba[x][y-1] != c && !visited[x][y-1]) {
      pdi ppp = rec(pii(x,y-1));
      weight += ppp.second;
      gx += ppp.first * ppp.second;
    }
    
    REP(k,4) {
      int xx = x+dx[k];
      int yy = y+dy[k];

      if (xx<0||xx>=w||yy<0||yy>=h) continue;
      if (ba[xx][yy]!=c || visited[xx][yy]) continue;
      Q.push(pii(xx,yy));
    }
  }
  gx += nowgx;
  weight += nowweight;
//  cout << gx << endl;
  gx = gx / weight;             // ¡ÌubNÈãÌubN½¿ÌdS
//  printf("%c : ll=%d, rr=%d, gx=%f, weight=%d\n", c, ll, rr, gx,weight);
  if (gx <= ll || gx >= rr) {
    f = 1;
  }
  return pdi(gx, weight);
}

int main() {
  while(cin>>w>>h,w||h) {
    REP(i,h) {
      REP(j,w)
        cin >> ba[j][i];
    }
    int xx = 0;
    REP(i, w) {
      if (ba[i][h-1] != '.') {
        xx = i;
        break;
      }
    }
    memset(visited,0,sizeof(visited));
    f = 0;
    rec(pii(xx, h-1));
    if (f) {
      cout << "UNSTABLE" << endl;      
    } else
      cout << "STABLE" << endl;
  }
}

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

int main() {
	int n, m, c;
	cin >> n >> m >> c;
	vector<int> b(m);
	vector<vector<int>> a;
	for (int i = 0; i < m; ++i) {
		cin >> b[i];
	}
	for (int j = 0; j < n; ++j) {
		vector<int> tmp;
		for (int k = 0; k < m; ++k) {
			int ele;
			cin >> ele;
			tmp.push_back(ele);
		}
		a.push_back(tmp);
	}
	int out = 0;
	for (int l = 0; l < n; ++l) {
		int tmp = c;
		for (int o = 0; o < m; ++o) {
			tmp += a[l][o] * b[o];
		}
		if (tmp > 0) ++out;
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var a = one[0];
  var b = one[1];
  var c = one[2];
  var d = one[3];
  if(Math.abs(a - c) <= d || (Math.abs(a - b) <= d && Math.abs(c - b) <= d )){
     myout("Yes");
  }else{
     myout("No");
  }
}

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int dist = abs(A - B) - 1;
    if (dist % 2 != 0) cout << "Alice" << endl;
    else cout << "Borys" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define dl double
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL)
#define cases ll t; cin>>t; while(t--)
#define rep1(qq,pp) for(ll i=qq;i<pp;i++)
#define rep2(qqq,ppp) for(ll i=qqq;i>=ppp;i--)
#define nl "\n"
#define Y cout<<"Yes\n"
#define N cout<<"No\n"
//cout<<fixed<<setprecision(13);

int main(){
	faster;

	int ans,mn=INT_MAX;
	string s,s1,x;

    cin>>s>>x;
    
    rep1(0,s.length()-x.length()+1){
        ans=x.length();
        s1=s.substr(i,x.length());
        for(int j=0;j<x.length();j++){
            if(s1[j]==x[j]) ans--;
        }
        
        mn=min(mn,ans);
    }
    
    cout<<mn<<nl;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (1) {
    c -= b;
    if (c <= 0) {
      cout << "Yes"
           << "\n";
      return 0;
    }
    a -= d;
    if (a <= 0) {
      cout << "No"
           << "\n";
      return 0;
    }
  }
  return 0;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

lli cnt[200100];

void func(long long N, std::vector<long long> A){

    REP(i,0,N){
        cnt[A[i]] = cnt[A[i]-1]+1;
    }

    lli ans = 0;
    REP(i,0,N){
        chmax(ans,cnt[A[i]]);
    }

    cout<<N-ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    func(N, std::move(A));
    return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int K, N;
int A[400100];

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

  std::cin >> K >> N;

  for(int i=0;i<N;++i){
      std::cin >> A[i];
      A[i+N] = A[i] + K;
  }

  int res = 1001001001;

  for(int i=0;i<N;++i){
      res = std::min(res, A[i+N-1] - A[i]);
  }

  for(int i=N;i<2*N;++i){
      res = std::min(res, A[i] - A[i-N+1]);
  }

  std::cout << res << std::endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;

int main() {

	int n;
	cin >> n;

	switch (n % 10)
	{
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		cout << "hon" << endl;
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		cout << "pon" << endl;
		break;
	case 3:
		cout << "bon" << endl;
		break;
	}

	return 0;
}

Measured memory_bytes: 3636
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    H=[int(_) for _ in input().split()]
    cunt_p=0
    while sum(H):
        in_p=False
        for i in range(n):
            if H[i]>0:
                H[i]-=1
                if in_p==False:
                    cunt_p+=1
                    in_p=True
            elif H[i]==0 and in_p:
                in_p=False
    print(cunt_p)

if __name__=='__main__':
    main()

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	string s;
	cin>>s;
	if(s.size()%2==1){
		cout<<"No"<<endl;
		return 0;
	}
	REP(i,s.size()){
		if(i%2==0){
			if(s[i]!='h'){
				cout<<"No"<<endl;
				return 0;
			}
		}else{
			if(s[i]!='i'){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(long long i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(long long i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using Int = long long;
using ll = long long;
using P = pair<Int,Int>;
using vi = vector<Int>;
using vvi = vector<vi>;
using vp = vector<P>;
using vvp = vector<vp>;

const Int INF = (1<<30)-10;


void solve(long long A, long long B){
  rep(i, int(2e4)){
    bool chk = (ll(double(i) * 0.08) == A) && (ll(double(i) * 0.1) == B);
    if(chk){
      cout << i << endl;
      return;
    }
  }
  cout << -1 << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  solve(A, B);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<cstring>
using namespace std;
typedef long long ll;
stack<char>a;
int main()
{
    int cnt=0;
    int i;
    char s[100005];
    scanf("%s",s);
    int len=strlen(s);
    for(i=0; i<=len-1; i++)
    {
        if(a.empty()||a.top()==s[i])
            a.push(s[i]);
        else
        {
            a.pop();
            cnt+=2;
        }
    }
    printf("%d",cnt);
    return 0;
}


Measured memory_bytes: 384