akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

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

    int n;cin>>n;
    vector<int>a(n+1);
    rep(i,n+1) cin>>a[i];

    if(n==0){
        if(a[0]==1){
            cout<<1<<endl;
        }else{
            cout<<-1<<endl;
        }
        return 0;
    }

    if(a[0]){
        if(n==0){
            cout<<1<<endl;
        }else{
            cout<<-1<<endl;
        }
        return 0;
    }

    

    vector<ll> lim(n+1);
    lim[n]=a[n];
    for(int i=n-1;i>=0;i--){
        lim[i]=lim[i+1]+a[i];
    }

    ll node=1;
    ll ans=1;
    for(int i=1;i<=n;i++){
        node=min(2*node,lim[i]);
        ans+=node;
        node-=a[i];
        if(node<0){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  for(int i=1;i<10;i++){
    if(N%i==0&&N/i<10){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		int X = Integer.parseInt(in.readLine());
		int A = Integer.parseInt(in.readLine());
		int B = Integer.parseInt(in.readLine());
		int result = (X - A) % B;
		System.out.println(result);
	}

	void calc() {
	}

	void showResult() {
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pib = pair<int,bool>;
using ll = long long;
using ld = long double;
#define all(x) (x).begin(),(x).end()
#ifdef fread_unlocked
#define fread fread_unlocked
#define fwrite fwrite_unlocked
#endif
#define mp make_pair
#define lc ind<<1
#define rc ind<<1|1
const int MN = 1e3+5, MOD = 1e9+7, BASE = 31, MASK = (1 << 10) - 1;
int main () {
	int a,b,c,d,e;
	scanf ("%d %d %d %d %d",&a,&b,&c,&d,&e);
	if (a == 0) printf ("1\n");
	else if (b == 0) printf ("2\n");
	else if (c == 0) printf ("3\n");
	else if (d == 0) printf ("4\n");
	else printf ("5\n");
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>


int main(){
    long X;
    std::cin >> X;
    if(X>=30){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3616
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = a - 1;
		if(b >= a){
			c = c + 1;
		}
		System.out.println(c);
		
	
	}
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i =(b)-1;i>=(a);--i)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
typedef vector<int> vi;
const int mod = 1e9 + 7;
const int maxn = 2e6 + 10;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	long double a,b;
	cin >> a >> b;
	a = a * b;
	cout << ll(a); 
	return 0;
}


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

int main() {
  
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N), y(M);
  
  for(int i=0; i<N; i++){ cin >> x.at(i); }
  sort(x.begin(), x.end());
  for(int i=0; i<M; i++){ cin >> y.at(i); }
  sort(y.begin(), y.end());

  if( max(x.at(N-1),X) < min(y.at(0),Y) ){ cout << "No War" << endl; }
  else{ cout << "War" << endl; }

}


Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())
dx=tx-sx
dy=ty-sy
ans=""
ans+="R"*dx+"U"*dy
ans+="R"+"D"*(dy+1)+"L"*(dx+1)+"U"
ans+="U"*dy+"R"*dx
ans+="U"+"L"*(dx+1)+"D"*(dy+1)+"R"
print(ans)

Measured memory_bytes: 3064
def inpl(): return list(map(int, input().split()))
N,K = inpl()
co, ce = [],[]#
odd,even,heven = 0,0,0
for i in range(1, N+1):
    if i % K == 0:
        if i%2==0:
            even+=1
            #print(i,'even')#
            ce.append(i)#
        else:
            odd+=1
            #print(i,'odd')#
            co.append(i)
    elif 2 * i % K == 0:
        heven += 1
if K%2 == 1:
    print((even+odd+heven)**3)
else:
    print(even**3+odd**3+heven**3)

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

int main(){
    string a;
    cin >> a;
    rep(i, a.size()) {
        if (a[i] == '7'){
            cout << "Yes" << endl;
            exit(0);
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, h;
    cin >> n >> h;
    vector<int> a(n);
    priority_queue<int> b;
    int ans = 0;
    
    rep(i, n) {
        int tb;
        cin >> a[i] >> tb;
        b.push(tb);
    }
    
    sort(all(a), greater<int>());
    
    while(h > 0) {
        if ((sz(b) > 0) && (b.top() > a[0])) {
            h -= b.top();
            b.pop();
        }
        else {
            h -= a[0];
        }
        
        ans++;
    }
    
    cout << ans << endl;
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> a(3*N+1, 0);
    for(int i = 1;i <= 3*N;i++) cin >> a[i];
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    LL ans = 0;
    for(int i = 0;i < N;i++)   ans += a[i*2+1];
    cout << ans << endl;
}

Measured memory_bytes: 1408
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.ArrayDeque


data class Job(val name: String, val time: Int)

fun main(args: Array<String>) {
    val expr = BufferedReader(InputStreamReader(System.`in`))
            .readText()
            .trim()
            .split(regex = """\s+""".toRegex())

    val timeSliceLength = expr[1].toInt()
    val jobsQueue = ArrayDeque<Job>()

    for (i in 2 until expr.size step 2) {
        jobsQueue.addLast(Job(name = expr[i], time = expr[i+1].toInt()))
    }

    var currentTime = 0

    while (jobsQueue.isNotEmpty()) {
        val thisJob = jobsQueue.removeFirst()
        if (thisJob.time > timeSliceLength) {
            jobsQueue.addLast(thisJob.copy(time = thisJob.time - timeSliceLength))
            currentTime += timeSliceLength
        } else {
            currentTime += thisJob.time
            println(thisJob.name + " " + currentTime)
        }
    }
}


Measured memory_bytes: 60256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

long c[10][10];
long cc[10];

int main(int argc, char* argv[])
{
    long h, w;
    scanf("%ld%ld", &h, &w);

    long i,j;
    for(i=0; i<10; i++) {
        for(j=0; j<10; j++) {
            scanf("%ld", &c[i][j]);
        }
    }

    long flag[10]={0};
    
    for(i=0;i<10;i++) {
        cc[i]=MOD;
    }
    flag[1]=1;
    long curr=1; cc[1]=0;
    while(1) {
        for(i=0; i<10; i++) {
            if(flag[i]==0) {
                long tmp = c[i][curr] + cc[curr];
                if(cc[i]>tmp) {
                    cc[i]=tmp;
                }
            }
        }
        long min=MOD;
        long imin=-1;
        for(i=0; i<10; i++) {
            if(flag[i]==0) {
                if(min>cc[i]) {
                    min=cc[i];
                    imin=i;
                }
            }
        }
        if(imin<0) break;
        curr=imin;
        flag[curr]=1;
    }

    ll sum=0;
    for(i=0; i<h; i++) {
        for(j=0; j<w; j++) {
            long  a;
            scanf("%ld", &a);
            if(a>=0) {
                sum+=cc[a];
            }
        }
    }
    printf("%lld\n", sum);
 
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long n;
long long a[200005];
long long s[200005];
long long now;
long long ans[200005];
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;++i)
	   scanf("%lld",&a[i]),a[i+n]=a[i],now+=a[i];
	int j=0;
	int k=0;
	while(j<n-1)
	{
		j+=2;
		++k;
		s[k]=s[k-1]+a[j];
	} 
	long long dx=s[k]*2;
	//cout<<now<<" "<<dx<<endl;
    for(int i=1;i<=n;i+=2)
    {
    	ans[i]=now-dx;
    	dx+=(a[i]-a[i+1])*2;
    	//cout<<dx<<endl;
	}
	for(int i=1;i<=n;++i)
	{
		if(!(i%2)) ans[i]=a[i-1]*2-ans[i-1];
		printf("%lld ",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 6504
#include <bits/stdc++.h>
#define PI 3.14159265359
typedef long long int ll;
using namespace std;


int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    ll d = c - a - b;
    if(4 * a * b < d * d && d > 0) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}

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

int main(){
    long long n,a,b;
    cin >> n >> a >> b;

    long long ans =0;
    if((b-a)%2==1){
        long long num1 = a+(b-a-1)/2;
        long long num2 = n-b+1+(b-a-1)/2;
        ans = min(num1,num2);
    }else{
        ans =(b-a)/2;
    }

    cout << ans << endl;
}



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

int main(){

    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    
    if(a >= k){
        cout << k << endl;
    }else if (b >= k-a){
        cout << a << endl;
    }else{
        cout << a - (k - a - b) << endl;
    }
   
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int n, K;
    scanf("%d%d", &n, &K);
    int cnt[n];
    memset(cnt, 0, sizeof(cnt));
    rep(_, K){
        int d;
        scanf("%d", &d);
        rep(i, d){
            int a;
            scanf("%d", &a);
            ++cnt[a-1];
        }
    }
    int ans = 0;
    rep(i, n) ans += (cnt[i] == 0);
    printf("%d\n", ans);
}

Measured memory_bytes: 3824
k,n = map(int,input().split())
a = list(map(int,input().split()))
aa = a + a

for j in range(n,2*n):
    aa[j] = aa[j] + k

dis = k

for i in range((2*n)-1):
    tonari = aa[i+1]-aa[i]
    dis = min(dis,k-tonari)

print(dis)

Measured memory_bytes: 32064
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();

    if(b <= a){
      System.out.println("delicious");
    }else if(a < b && b <= (a+x)){
      System.out.println("safe");
    }else{
      System.out.println("dangerous");
    }
  }
}

Measured memory_bytes: 22736
const lines=readlines()
const N=parse(Int,shift!(lines))
const T=zeros(Int,N,N)
const id=ones(Int,N)
function main()
	A=Array{Int}[]
	for i=1:N
		push!(A,map(x->parse(Int,x),split(shift!(lines))))
		j=0
		for u=A[i]
			j+=1
			T[i,u]=j
		end
	end
	P=Pair{Int,Int}[]
	for i=1:N
		if i<A[i][1]&&T[A[i][1],i]==1
			push!(P,i=>A[i][1])
		end
	end
	day=1
	while !isempty(P)
		day+=1
		Q=Pair{Int,Int}[]
		for (u,v)=P
			id[u]+=1
			if id[u]<N
				if T[A[u][id[u]],u]==id[A[u][id[u]]]
					push!(Q,u=>A[u][id[u]])
				end
			end
			id[v]+=1
			if id[v]<N
				if T[A[v][id[v]],v]==id[A[v][id[v]]]
					push!(Q,v=>A[v][id[v]])
				end
			end
		end
		P=Q
	end
	for i=1:N
		if id[i]<N
			day=0
			break
		end
	end
	println(day-1)
end
main()


Measured memory_bytes: 171900
# a-bが最小となる、a*b=nを満たすa,b(a>=b)を見つける作業。
# 素因数分解してすべての組み合わせで2数を作って...と考えたけどあきらかにダルい
# ダルいので全探索。1から順に割って、割り切れた数をbとする
# 10^12とデカイが、a*b=n(a>=b)と考えた時、a*a>=nだし、せいぜいaは平方根までの探索でいい
n = int(input())
ans = 10 ** 13

for v in range(1, int(n ** 0.5) + 1):
    a = v
    if n % a != 0:
        continue
    b = n // a
    ans = min(ans, a - 1 + b - 1)

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int par[240000];
int find(int x){
	if(x==par[x]) return x;
	return par[x]=find(par[x]);
}
bool same(int x,int y){
	return find(x)==find(y);
}
void unite(int x,int y){
	par[find(x)]=find(y);
}
int main(){
	int N,W,H;
	cin>>N>>W>>H;
	rep(i,N+W+H) par[i]=i;
	rep(i,N){
		int x,y;
		cin>>x>>y;
		x--,y--;
		unite(i,N+x);
		unite(i,N+W+y);
	}
	set<int> st;
	rep(i,N) st.insert(find(i));
	int x=st.size();
	if(x==1){
		cout<<N-1<<endl;
		return 0;
	}
	int a=0;
	rep(i,N){
		if(same(i,N)||same(i,N+W-1)||same(i,N+W)||same(i,N+W+H-1)) a=1;
	}
	cout<<N-1-a+x<<endl;
}

Measured memory_bytes: 3348
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
  int d,MAX = -1;
  int data[1001]={0};
  while(cin >> d){
    data[d]++;
    MAX = max( MAX , data[d] );
  }
  for(int i=0;i<100;i++){
    if(MAX == data[i])cout << i << endl;
  }
}

Measured memory_bytes: 1164
n = int(input())
P = [[0, 0, 0]]
f = True
for i in range(n):
    t, x, y = map(int, input().split())
    s = abs(x - P[i][1]) + abs(y-P[i][2])
    if s > t-P[i][0] or (t-P[i][0] - s)%2 == 1:
        f = False
    P.append([t, x, y])
if f: print("Yes")
else: print("No")

Measured memory_bytes: 19532
N = int(input())
a = list(map(int, input().split()))
from collections import deque
a = deque(a)
ans = 0
now = 1
while a:
  x = a.popleft()
  if x == now:
    now += 1
  else:
    ans += 1
if ans == N:
  ans = -1
print(ans)

  

Measured memory_bytes: 32376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    int ac = 'z' - 'a' + 1;
    int sl = s.length();
    vector<int> lc(ac, 0), rc(ac, sl);
    int ans = INT_MAX;
    
    rep(i, ac) {
        int tlc = 0, trc = sl;
        
        rep(ii, sl) {
            if ((s[ii] - 'a') == i) {
                lc[i] = max(lc[i], tlc);
                tlc = 0;
                trc = sl - ii - 1;
            }
            else {
                tlc++;
            }
        }
        
        rc[i] = trc;
    }
    
    rep(i, ac) {
        ans = min(ans, max(lc[i], rc[i]));
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<queue>
#include<vector>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdint>
#include<iostream>
#include<algorithm>
using namespace std;
int fa[100001];
inline int find(int x)
{
	if(fa[x]!=x)
		fa[x]=find(fa[x]);
	return fa[x];
}
bool v[100001];
struct num
{
	int x,p;
	bool operator <(num y) const
	{
		return x<y.x;
	}
}a[100001];
priority_queue<long long,vector<long long>,greater<long long> > Q;
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int i;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i].x);
		a[i].p=i-1;
	}
	for(i=1;i<=n;i++)
		fa[i]=i;
	for(i=1;i<=m;i++)
	{
		int s,t;
		scanf("%d%d",&s,&t);
		int fx=find(s),fy=find(t);
		if(fx!=fy)
			fa[fx]=fy;
	}
	sort(a+1,a+1+n);
	long long ans=0;
	int sum=0;
	for(i=1;i<=n;i++)
	{
		int fx=find(a[i].p);
		if(!v[fx])
		{
			sum++;
			v[fx]=true;
			ans+=a[i].x;
		}
		else
			Q.push(a[i].x);
	}
	int xx=0;
	while(!Q.empty()&&xx<sum-2)
	{
		xx++;
		ans+=Q.top();
		Q.pop(); 
	}
	if(sum==1)
		printf("0\n");
	else if(xx<sum-2)
		printf("Impossible\n");
	else
		printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2680
//
// Created by rajshah9914 on 30/03/20.
//

#include <bits/stdc++.h>
using namespace std;
long long a[100000];
long long dp[3001][3001];
long long play(long long l,long long r)
{
    if(l>r)
        return 0;
    if(l==r)
        return a[l];
    if(dp[l][r]!=-1)
        return dp[l][r];
    long long ans=a[l]-play(l+1,r);
    ans=max(ans,a[r]-play(l,r-1));
    return dp[l][r]=ans;

}

long long solve()
{
    long long n;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(long long i=0;i<n;i++)
        cin>>a[i];
    cout<<play(0,n-1);
}
int main()
{
    solve();
}



Measured memory_bytes: 70784
#ABC178-c
import sys,math,collections,itertools
input = sys.stdin.readline
m=10**9+7
N=int(input())
#すべての数列の数
nAll=pow(10,N,m)
nwo0 = pow(9,N,m)
nwo9 = nwo0
nwo09 = pow(8,N,m)
ans = nAll-nwo0-nwo9+nwo09
while ans<0:
    ans +=m
print(ans)


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

int main() {
    int n, q;
    cin >> n >> q;
    queue<int> que[n];
    while (q--) {
        int t;
        cin >> t;
        if (t == 0) {
            int a, b;
            cin >> a >> b;
            que[a].push(b);
        } else if (t == 1) {
            int a;
            cin >> a;
            if (que[a].size()) {
                cout << que[a].front() << endl;
            }
        } else {
            int a;
            cin >> a;
            if (que[a].size()) {
                que[a].pop();
            }
        }
    }
}


Measured memory_bytes: 4276
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int N; cin >> N;
  map<string, int> cnt;
  rep(i,N){
    string s; cin >> s;
    cnt[s]++;
  }
  cout << "AC x " << cnt["AC"] << endl;
  cout << "WA x " << cnt["WA"] << endl;
  cout << "TLE x " << cnt["TLE"] << endl;
  cout << "RE x " << cnt["RE"] << endl;

    

  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
	int n;
	std::cin >> n;

	int l, i = 0, a[30];
	while (std::cin >> l) {
		a[i] = l;
		i++;
		if (i >= n) {
			break;
		}
	}

	int t;
	int max = 0;
	int total= 0;
	for (t = 0; t < n; t++) {
		if(a[t]>=max){
			total += 1;
			max = a[t];
		}
	}

	cout << total;

 
	

	return 0;
}

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

using namespace std;

const double PI = 3.14159265358979;

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

    double a,b,h,m,hours,minutes,ans;
    cin>>a>>b>>h>>m;

    hours=30.0*h+(m/2.0);
    minutes=6.0*m;
    double angle=abs(hours-minutes)*PI/180.0;

    ans=(a*a)+(b*b)-(2*a*b*cos(angle));

    cout<<fixed<<setprecision(12)<<sqrt(ans)<<"\n";

    return 0;
}

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

using namespace std;

typedef long long int64;

int main()
{
  int N;
  cin >> N;
  int64 lcm = 1;
  for(int i = 0; i < N; i++) {
    int64 t;
    cin >> t;
    lcm = t / __gcd(t, lcm) * lcm;
  }
  cout << lcm << endl;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

ll tansaku(map<ll,ll>& mp, ll n, ll a, ll b, ll c, ll d)
{
    if(n == 0) return mp[0] = 0;
    if(n == 1) return mp[1] = d;
    if(mp.count(n)) return mp[n]; 
    ll i,j;
    ll ans = 1e18;
    double ansd;
    double dn = n;
    double dd = d;
    ansd = dn*dd;
    if(ansd < 2e18){
        ll tmp = n*d;
        ans = min(ans, tmp);
    }
    for(i = 0;i < 3;++i){
        ll p = 1;
        ll cost = 0;
        if(i == 0) p = 2, cost = a;
        else if(i == 1) p = 3, cost = b;
        else if(i == 2) p = 5, cost = c;
        if(n%p == 0){
            ll tmp = tansaku(mp,n/p,a,b,c,d) + cost;
            ans = min(ans, tmp);
        }else{
            ll tc = n + (p - n%p);
            ll tf = n - n%p;
            ll tmp = tansaku(mp,tc/p,a,b,c,d) + (tc - n)*d + cost;
            ans = min(ans,tmp);
            tmp = tansaku(mp,tf/p,a,b,c,d) + (n - tf)*d + cost;
            ans = min(ans,tmp);
        }
    }
    return mp[n] = ans;
}

ll solve()
{
    ll n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    if(n == 1) return d;
    map<ll,ll> mp;
    tansaku(mp, n, a, b, c, d);
    return mp[n];
}

int main()
{
    ll i,j;
    ll t;
    cin >> t;
    for(i = 0;i < t;++i){
        ll ans = solve();
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 4456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}


int V[55];
int main() {
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> V[i];
    }
    int ans = 0;
    for (int i = 0; i <= min(k, n); i++) {
        for (int j = 0; i + j <= min(k, n); j++) {
            vector<int> v;
            for (int x = 1; x <= i; x++) v.push_back(V[x]);
            for (int x = 0; x < j; x++) v.push_back(V[n - x]);
            sort(v.rbegin(), v.rend());
            int k2 = k - i - j;
            while (k2 > 0 && !v.empty() && v.back() < 0) {
                v.pop_back();
                k2--;
            }
            int sum = 0;
            for (int x : v) sum += x;
            ans = max(ans, sum);
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
a = 0
b = 0
n = 0
k = 0
c = 0
list = []
i = str(input())+" "
for n in range(4):
 i += str(input())+" "
k = int(input())
list = i.split()
for n in range(0,4):
 a = int(list[n])
 b = int(list[n+1])
 if b - a <= k:
  c += 1
a = int(list[0])
b = int(list[4])
if b - a > k:
 c = 0
if c == 4:
 print("Yay!")
else:
 print(":(")

Measured memory_bytes: 3064
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>
#include <map>   
#include <stdio.h>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ull unsigned long long
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	cout << max(A + B, max(A + A - 1, B + B - 1)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> a(n),b(n),e(n);
    for(int i=0;i<n;i++) cin>>a[i];
    b[0]=a[0],e[n-1]=a[n-1];
    for(int i=1;i<n;i++)
        b[i]=max(b[i-1],a[i]);
    for(int i=n-2;i>=0;i--)
        e[i]=max(e[i+1],a[i]);
    printf("%d\n",e[1]);
    for(int i=1;i<n-1;i++)
        printf("%d\n",max(b[i-1],e[i+1]));
    printf("%d\n",b[n-2]);
    return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

using mint = modint998244353;

struct S{
    ll num;
    mint psum;
};
S e(){ return S{0, 0}; }
S op(S x, S y){ return S{x.num + y.num, x.psum + y.psum}; }

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

    vector<ll> p(n);
    REP(i, n){
        cin >> p.at(i);
        p.at(i)--;
    }

    const mint q = mint(k - 1) / mint(k);
    const mint qinv = q.inv();

    // cerr << "q=" << q.val() << ", qinv=" << qinv.val() << endl;

    segtree<S, op, e> st(n);

    mint ans = 0;

    REP(i, n){
        const ll pi = p.at(i);
        const ll fi = max(i - k + 1, 0LL);

        const auto sd = st.prod(0, pi);
        mint tmp1 = q.pow(fi) * sd.psum / 2;

        const auto su = st.prod(pi + 1, n);
        mint tmp2 = su.num - q.pow(fi) * su.psum / 2;

        mint tmp = tmp1 + tmp2;

        // cerr << "i=" << i << ", tmp=" << tmp.val() << ", tmp1=" << tmp1.val() << ", tmp2=" << tmp2.val() << endl;
        ans += tmp;

        st.set(pi, S{1, qinv.pow(fi)});
    }

    cout << ans.val() << endl;

    return 0;
}


Measured memory_bytes: 16044
//      https://youtu.be/X_hMZYDMps4

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

typedef long long ll;
typedef long double ld;
typedef long long unsigned llu;
typedef pair<long long, long long> pll;
const long long inf = 2000000000000000000LL;    // 2e18
#define pi                  acos(-1.0)
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define nl                  "\n"
#define ff                  first
#define ss                  second
#define pb                  push_back
#define pf                  push_front
#define all(x)              x.begin(),x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"

int main()
{
    fast;
    ll t,i,j,k,l,m,n,o,p,q,temp,ans=0,flag=0,mod=1000000007,odd=0,even=0;
    cin>>n;
    ll v[n+1],a[n+2],b[n+2];
    for(i=1;i<=n;i++){
        cin>>v[i];
        a[i]=0;
        b[i]=0;
    }
    for(i=n,temp=n;i>0;i--,temp--){
        b[1]+=temp;
        b[v[i]+1]-=temp;
        a[1]-=(temp);
        a[v[i]]+=(temp);
    }
    //cout<<a[1]<<" "<<b[1]<<nl;
    for(i=2;i<=n;i++){
        //cout<<a[i]<<" "<<b[i]<<nl;
        a[i]+=a[i-1];
        b[i]+=b[i-1];
    }
    for(i=1;i<=n;i++) cout<<a[i]+((n*n)+10)<<" ";
    cout<<nl;
    for(i=1;i<=n;i++) cout<<b[i]<<" ";
}


Measured memory_bytes: 4120
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
using P = pair<int,int>;
int main() {
   int n;cin>>n;
   vector<int>up,down;
   rep(i,n){
      int x,y;cin>>x>>y;
      up.push_back(x+y);
      down.push_back(x-y);
   }
   sort(up.begin(),up.end());
   sort(down.begin(),down.end());
   int ans=0;
   ans=max(abs(up[0]-up[n-1]),abs(down[0]-down[n-1]));
   cout<<ans<<endl;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	int a,b,c;
	cin >> a >> b >> c;
	if(((a*100)+(b*10)+c)%4==0) cout << "YES" << endl;
	else cout << "NO" << endl;

	
//////////////////////////////////////////////
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
 
#define file ""
 
#define all(x) x.begin(), x.end()
 
#define sc second
#define fr first
 
#define pb push_back
#define mp make_pair
 
#define pss pair<line*, line*>
 
using namespace std;
using namespace __gnu_cxx;
 
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
                                 
const ll inf = 1e18;
const int MOD = 1e9 + 7;
 
const int dx[] = {-1, +1, -2, +2, -2, +2, -1, +1};
const int dy[] = {-2, -2, -1, -1, +1, +1, +2, +2};
 
int const N = 3e5 + 5;
int const M = 1e8	;

int main() {                 
#ifdef Mask                                                         
  freopen(".in", 	"r", stdin);
  freopen(".out", "w", stdout);  
#endif
	ios_base :: sync_with_stdio(false);               
  cin.tie(nullptr);
  srand(time(nullptr));	
  char a;
  cin >> a;
  if (a >= 'a' && a <= 'z') 	cout << "a", exit(0);
  cout << "A ";
	return 0;
 
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)


signed main() {
  INIT;
  VAR(int,a,b,k);

	int cnt=0;
	RFOR(i,1,101){
		if(a%i==0 && b%i==0) ++cnt;
		if(cnt==k){
			OUT(i)BR;
			return 0;
		}
	}
	
  return 0;
}


Measured memory_bytes: 256
N = int(input())
l = map(str, range(1, N+1))
summary = [[0 for _ in range(9)] for _ in range(9)]

for i in l:
    if i[-1] != "0":
        summary[int(i[0])-1][int(i[-1])-1] += 1

c = 0
for i in range(9):
    for j in range(9):
        c += summary[i][j] * summary[j][i]

print(c)

Measured memory_bytes: 3064
#include <stdio.h>

#define MAX_WEIGHT 512

void cal_weight(int, int);

int main(void) 
{
	int weight;

	while (scanf("%d", &weight) != EOF) {
		cal_weight(weight, MAX_WEIGHT);
		printf("\n");
	}

	return 0;
}

void cal_weight(int rest_weight, int weight) 
{
	if (rest_weight >= weight) {
		rest_weight -= weight;
		if (rest_weight != 0) {
			cal_weight(rest_weight, weight / 2);
		}

		if (rest_weight == 0) {
			printf("%d", weight);				
		} else {
			printf(" %d", weight);
		}
	} else {
		cal_weight(rest_weight, weight / 2);
	}
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll solve(ll W, ll H) {
    ll mi = min(W, H);
    for (ll i = 1; i < W; i++) {
        ll wi = W - i;
        ll C1 = i * H;
        ll C2 = wi*(H/2);
        ll C3 = wi*((H/2) + (H%2 == 1));
        ll sma = max({C1,C2,C3});
        ll smi = min({C1,C2,C3});
        mi = min(mi, sma - smi);
    }
    return mi;
}
int main() {
    ll H, W; cin >> H >> W;
    if (H % 3 == 0 || W % 3 == 0) {
        cout << 0 << endl;
        return 0;
    }

    cout << min(solve(W, H), solve(H, W)) << endl;
}


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

using namespace std;
#define pi 3.14159265

int main()
{
	long long ans = 0, i = 0, j = 0, k = 0, l = 0;
	long long a, b, c, d, N, q, h, s;
	cin >> q >> h >> s >> d >> N;

	a = q * 8; b = h * 4; c = s * 2;
	long long mini[4];
	mini[0] = min(a, b);
	mini[1] = min(c, mini[0]);
	mini[2] = min(d, mini[1]);
	mini[3] = min(mini[0], mini[1]);

	ans += N / 2 * mini[2];
	N %= 2;
	ans += N * mini[3] / 2;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll a[200001];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll ans=ll(1e18);
	int n; cin>>n;
	ll sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	ll cur=0;
	for(int i=0;i<n-1;i++)
	{
		cur+=a[i];
		ans=min(ans,abs(cur-(sum-cur)));
	}	
	cout<<ans<<'\n';
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>
#include <stdio.h>

class UnionFind {
public:
  std::vector<int> data;
  UnionFind(int size) { data.assign(size, -1); }
  int find(int x) {
    if (data[x] < 0) {
      return x;
    } else {
      data[x] = find(data[x]);
      return data[x];
    }
  }
  void unite(int x, int y) {
    int xpar = find(x);
    int ypar = find(y);
    if (xpar != ypar) {
      if (data[xpar] > data[ypar])
        std::swap(xpar, ypar);
      data[xpar] += data[ypar];
      data[ypar] = xpar;
    }
  }
  int size(int x) { return -1 * data[find(x)]; }
};

int main() {
  int N, Q;
  scanf("%d %d", &N, &Q);
  UnionFind uf(N);
  while(Q--) {
    int t, x, y;
    scanf("%d %d %d", &t, &x, &y);
    if(t == 0) uf.unite(x, y);
    else printf("%d\n", uf.find(x) == uf.find(y));
  }
}

// int main() {
//   int n, m;
//   std::cin >> n >> m;
//   std::vector<std::pair<int, int>> bridges(m);
//   for (int i = 0; i < m; i++)
//     std::cin >> bridges[i].first >> bridges[i].second;

//   UnionFind uf(n);
//   long long int ans = n * (n - 1) / 2;
//   std::vector<long long int> answers(m);
//   answers[m - 1] = ans;

//   for (int i = m-1; i > 0; i--) {
//     int a = bridges[i].first;
//     int b = bridges[i].second;
//     if (uf.find(a) != uf.find(b)) {
//       int size1 = uf.size(a);
//       int size2 = uf.size(b);
//       ans -= (long long int)size1 * size2;
//       uf.unite(a, b);
//     }
//     answers[i-1] = ans;
//   }
//   for (auto a : answers)
//     std::cout << a << std::endl;
// }


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

int main(){
	//recieve data
	int n;
	cin >> n;
	vector<int> takoyaki(n);
	for(int i=0;i<n;i++){
		cin >> takoyaki.at(i);
	}
	//keisan
	int sum1;
	for(int i=0;i<n-1;i++){
		for(int m=i+1;m<n;m++){
			sum1 += takoyaki.at(i)*takoyaki.at(m);

		}
	}
	cout << sum1 <<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,m;
  while(cin >> m >> n && n) {
    double a[m][m];
    rep(i,m)rep(j,m) R a[i][j];
    double d[n][m];
    mem(d);
    rep(i,m) d[0][i]=1;
    REP(i,1,n) {
      rep(j,m) {
        rep(k,m) d[i][k]=max(d[i][k],d[i-1][j]*a[j][k]);
      }
    }
    double ans=0;
    rep(i,m) ans=max(ans,d[n-1][i]);
    printf("%.2f\n",ans);
  }
}

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


Measured memory_bytes: 1364
//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 2147483647
#define MOD 1000000007
#define MAX 200005
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<ii> vii;
typedef priority_queue<int,vector<int>,greater<int> > PQ;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

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

    int x, y;

    cin>>x>>y;

    int Min = 2 * x, Max = 4 * x;

    if(y >= Min && y <= Max && (y % 2) == 0) {
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k,i;
  cin >> n >> k;
  vector<int> h(n);
  for(i=0;i<n;i++)cin >> h[i];
  sort(h.begin(),h.end());
  for(i=0;i<n;i++)if(h[i]>=k)break;
  cout << n-i << endl;
  return 0; 
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = long long;
using P = pair<int,int>;


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

    int ans = 0;
    int right = 0;

    rep(left, N){
        while(H[right] >= H[right+1] && right + 1 < N) right++;
        ans = max(ans, right-left);
        if(right == left) right++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main(){
    string s;
    cin>>s;
    int tmp=0;
    for(int i=0;i<s.size();++i){
        if(s[i]=='o') tmp++;
    }
    cout<<700+tmp*100;
    return 0;
}

Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
X = [input() for _ in range(N)]


def solve(x):
    d = {"A": 0, "B": 1, "C": 2}
    ans = []
    for i in range(N):
        u, v = X[i]
        if x[d[u]] == x[d[v]] == 0:
            return

        if x[d[u]] < x[d[v]]:
            x[d[u]] += 1
            x[d[v]] -= 1
            ans.append(u)
        elif x[d[u]] > x[d[v]]:
            x[d[u]] -= 1
            x[d[v]] += 1
            ans.append(v)
        elif i < N - 1 and X[i] != X[i + 1]:
            # x[d[u]] == x[d[v]] >= 1
            if u in X[i + 1]:
                x[d[u]] += 1
                x[d[v]] -= 1
                ans.append(u)
            else:
                x[d[u]] -= 1
                x[d[v]] += 1
                ans.append(v)
        else:
            x[d[u]] += 1
            x[d[v]] -= 1
            ans.append(u)

        if x[d[u]] < 0 or x[d[v]] < 0:
            return

    return ans

ans = solve([A, B, C])
if ans:
    print("Yes")
    print(*ans, sep="\n")
else:
    print("No")


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

using namespace std;
using ll = long long;

int main() {
    int s,w;
    cin >> s >> w;
    string ans;
    if(s > w) {
        ans = "safe";
    } else {
        ans = "unsafe";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
import bisect
 
N = int(input())
L = map(int, input().split())
L = sorted(L)
 
count = 0
for i in range(N):
  for j in range(i+1, N):
    index = bisect.bisect_left(L, L[i]+L[j])
    count += index - 1 - j

print(count)

Measured memory_bytes: 3188
#include<stdio.h>

int sumOfNumber() {
	char number[1001];
	int i = 0 , length = 0;
	int sum = 0;

	while((number[i] = getchar()) != '\n') {
		sum += number[i] - '0';
		i++;
	}

	if (sum == 0) return 0;
	printf("%d\n" , sum);
	return 1;
}

int main () {
	while(sumOfNumber());
	return 0;
}

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


int main() {
  int N,T,A;
  double C = 10000;
  int ans;

  cin >> N >> T >> A;
  for(int i=1;i<=N;++i){
    int h; cin >> h;
    if(C > abs(A-(T-0.006*h))){
      C = abs(A-(T-0.006*h));
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
import sys
def side(p1,p2):
  global D
  y1,x1=p1
  y2,x2=p2
  dy=y2-y1
  dx=x2-x1
  for p3 in D[::-1]:
    y3,x3=p3
    if p1==p3 or p2==p3:pass
    elif (x3-x1)*dy-dx*(y3-y1)<0:return 0
  else:return 1

while 1:
  n=input()
  if n==0:break
  D=sorted([list(input()) for i in range(n)])
  p=p1=D[0]
  D1=D[:]
  while True:
    for p2 in D1:
      if p1!=p2 and side(p1,p2):break
    p1=p2
    D1.remove(p2)
    if p2==p:break
  print len(D1)

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

#define int long long

#define Vanya Unstoppable

using namespace std;

const int N = 5007;

int a[N], b[N];

bool us[N];

int solve(int n, int x, int k) {
    for (int i = 0; i < n; ++i) {
        us[i] = false;
    }
    
    vector<int> v;
    while (true) {
        int new_x = a[x];
        if (!us[new_x]) {
            v.push_back(b[new_x]);
            us[new_x] = true;
        } else {
            break;
        }
        x = new_x;
    }
    
    int sum = 0, m = (int)v.size();
    for (int to : v) {
        sum += to;
    }
    
    int ans = -1e18, p = k / m;
    if (sum >= 0 && p > 0) {
        sum = sum * (p - 1);
        k -= (p - 1) * m;
        for (int i = 0; i < k; ++i) {
            sum += v[i % m];
            ans = max(ans, sum);
        }
    } else {
        sum = 0;
        for (int i = 0; i < min(k, m); ++i) {
            sum += v[i];
            ans = max(ans, sum);
        }
    }
    
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    
    int n, k;
    cin >> n >> k;
    
    for (int i = 0; i < n; ++i) {
        cin >> a[i]; --a[i];
    }
    
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    
    int ans = -1e18;
    for (int i = 0; i < n; ++i) {
        ans = max(ans, solve(n, i, k));
    }
    
    cout << ans;
}


Measured memory_bytes: 3748
use std::f64;
// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

fn main() {
    let (A, B, H, M) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let mut iter = s.split_whitespace().map(|i| i.parse::<i32>().unwrap());
        (
            iter.next().unwrap() as f64,
            iter.next().unwrap() as f64,
            iter.next().unwrap() as f64,
            iter.next().unwrap() as f64,
        )
    };
    let hm = H * 60.0 + M;
    let seta = (hm / (12.0 * 60.0) - M / 60.0).abs() * 2.0 * f64::consts::PI;
    let sqr: f64 = A * A + B * B - 2.0 * A * B * seta.cos();

    println!("{}", sqr.sqrt());
}

Measured memory_bytes: 2932
#include<bits/stdc++.h>
#define dbg(x) cout<<#x<<'='<<(x)<<endl;
#define pb push_back
#define fo(i,n) for(int i=0;i<n;i++)
#define fab(i,a,b) for(int i=a;i<=b;i++)
#define dsort(arr,n) sort(arr, arr + n, greater<int>())
#define vsortd(a) sort(a.begin(), a.end(), greater<double>())
#define vsort(a) sort(a.begin(), a.end())
#define ll long long int
#define loop(i,b,a) for(int i=a;i>=b;i--)
#define test int tc;cin>>tc;while(tc--)
#define dbg2(x,y) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define minheap priority_queue <int, vector<int>, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ff first
#define ss second
#define mpr make_pair
const int mod=1e9+7;
using namespace std;
bool sortcol( const vector<int>& v1,const vector<int>& v2 ) {return v1[1] < v2[1];}



void solve()
{
    char c;cin>>c;
    if(c-'A'<=26)
        cout<<'A'<<endl;
    else
        cout<<'a'<<endl;
}

int main()
{
    fastio
  //  test
        solve();
}


Measured memory_bytes: 3636
# -*- coding: utf-8 -*-

tmp = input()

r = {}
for s in tmp:
    if s in r.keys():
        r[s] += 1
    else:
        r[s] = 1

if len(r.keys()) == 2 and r[list(r.keys())[0]] == 2:
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 2940
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int a[50]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  scanf("%d\n",&k);
  k--;
  printf("%d\n",a[k]);
  return 0;
}

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

int top,S[1000];

void push(int x){
	S[++top]=x;
}

int pop(){
	top--;
	return S[top+1];
}

int main(){
	int a,b;
	char s[100];
	top=0;
	while(scanf("%s",s)!=EOF){
		if(s[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}else if(s[0]=='-'){
			b=pop();
			a=pop();
			push(a-b);
		}else if(s[0]=='*'){
			a=pop();
			b=pop();
			push(a*b);
		}else{
			push(atoi(s));
		}
	}
	
	printf("%d\n",pop());
	
	return 0;
}

Measured memory_bytes: 548
x, y = map(int, input().split(" "))

g1 = [2]
g2 = [1,3,5,7,8,10,12]
g3 = [4,6,9,11]

if (x in g1 and y in g1):
    print("Yes")
elif (x in g2 and y in g2):
    print("Yes")
elif (x in g3 and y in g3):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060