akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
bool isk(ll a,ll b,ll k,ll x,ll y){
    if(a==b){
        return false;
    }
    ll dist = abs(b-a);
    dist = min(dist,abs(x-a)+1+abs(y-b));
    dist = min(dist,abs(y-a)+1+abs(x-b));
    if(dist==k){
        return true;
    }else{
        return false;
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,x,y;
    cin >> n >> x >> y;
    vvll dis(n+1);
    for(ll i=1;i<=n;i++){
        dis[i].pb(i);
    }    
    for(ll i=1;i<=n-1;i++){
        ll cnt = 0;
        for(ll j=1;j<=n;++j){
            vll v;
            while(!dis[j].empty()){
                ll now = dis[j].back();
                dis[j].pop_back();
                ll n1;
                if(now==1){
                    n1=0;
                }else{
                    n1=now-1;
                }
                if(n1!=0&&isk(j,n1,i,x,y)){
                    v.pb(n1);
                }
                if(now==n){
                    n1=0;
                }else{
                    n1=now+1;
                }
                if(n1!=0&&isk(j,n1,i,x,y)){
                    v.pb(n1);
                }
                if(now!=x){
                    n1=0;
                }else{
                    n1=y;
                }
                if(n1!=0&&isk(j,n1,i,x,y)){
                    v.pb(n1);
                }
                if(now!=y){
                    n1=0;
                }else{
                    n1=x;
                }
                if(n1!=0&&isk(j,n1,i,x,y)){
                    v.pb(n1);
                }
            }
            sort(ALL(v));
            v.erase(unique(v.begin(),v.end()),v.end());
            while(!v.empty()){
                dis[j].pb(v.back());
                v.pop_back();
                cnt++;
            }
        }
        cout << cnt/2 << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x;
  cin >> x;
  if(x >= 400 && x < 600){
    cout << "8" <<endl;
  }
    else if(x >= 600 && x < 800){
      cout << "7" << endl;
    }
  else if(x >= 800 && x < 1000){
      cout << "6" << endl;
    }
  else if(x >= 1000 && x < 1200){
      cout << "5" << endl;
    }
  else if(x >= 1200 && x < 1400){
      cout << "4" << endl;
    }
  else if(x >= 1400 && x < 1600){
      cout << "3" << endl;
    }
  else if(x >= 1600 && x < 1800){
      cout << "2" << endl;
    }
  else if(x >= 1800 && x < 2000){
      cout << "1" << endl;
    }
  else{
    cout << "invalid";
  }
  return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		Stack<Integer> stack = new Stack<Integer>();

		while (in.hasNext()) {
			String cur = in.next();
			
			if (cur.equals("*") || cur.equals("+") || cur.contentEquals("-")) {
				int x = stack.pop();
				int y = stack.pop();
				int z;

				if (cur.equals("*")) {
					z = y * x;
				} else if (cur.contentEquals("+")) {
					z = y + x;
				} else {
					z = y - x;
				}

				stack.push(z);
			} else {
				stack.push(Integer.parseInt(cur));
			}
		}
		
		System.out.println(stack.peek());
	}
}


Measured memory_bytes: 26108
// C - Sequence
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))

int main(){
	int N; cin>>N;
	vector<ll> A(N);

	ll csum = 0;
	ll a = 0;
	up(i,0,N,1){
		cin>>A[i];
		csum += A[i];
		if(i%2==0 && csum<=0){//even +
			a += abs(csum) + 1;
			csum = 1;
		}
		if(i%2==1 && csum>=0){//odd -
			a += abs(csum) + 1;
			csum = -1;
		}
	}

	csum = 0;
	ll b = 0;
	up(i,0,N,1){
		csum += A[i];
		if(i%2==1 && csum<=0){//odd +
			b += abs(csum) + 1;
			csum = 1;
		}
		if(i%2==0 && csum>=0){//even -
			b += abs(csum) + 1;
			csum = -1;
		}
	}

	cout<< (a<b?a:b) <<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	string S;
	cin >> S;

	int ans = 0;
	for(int i=0; i<(S.length()+1)/2; i++) {
		int x = S.length()-1-i;
		// cout << "[deb: a b ]" << i << " " << x << endl;
		if(S[i] != S[x]) ans++;
		
	}
	cout << ans;
	// cout << "[deb: val ]" << val <<endl;
	return 0;
}



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

int main(){
    unsigned long N;
    cin >> N;
    vector<unsigned long> A(N), r(N), l(N), ans(N);
    for(auto& i : A)cin >> i;
    partial_sum(A.cbegin(), A.cend() - 1, r.begin() + 1, __gcd<unsigned long>);
    partial_sum(A.crbegin(), A.crend() - 1, l.rbegin() + 1, __gcd<unsigned long>);
    transform(r.cbegin(), r.cend(), l.cbegin(), ans.begin(), __gcd<unsigned long>);
    cout << *max_element(ans.cbegin(), ans.cend()) << endl;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

int main() {
    string s;
    int K;
    cin >> s >> K;
    int l = s.size();
    vector<vector<long long>> dp;
    dp.assign(l, vector<long long>(4));
    int count = 0;
    rep(i, 0, l) {
        int t = s[i] - '0';
        // cout << "ddd:" << t << "  count" << count << endl;
        if(i == 0) {
            dp[i][0] = 1;
            dp[i][1] = t;
            count++;

            continue;
        }
        int tb = s[i - 1] - '0';
        dp[i][0] = dp[i - 1][0];
        dp[i][1] = dp[i - 1][1] + dp[i - 1][0] * 9;
        dp[i][2] = dp[i - 1][2] + dp[i - 1][1] * 9;
        if(count == 1) {
            dp[i][2] -= 9 - t;
        }
        dp[i][3] = dp[i - 1][3] + dp[i - 1][2] * 9;
        if(count == 2) {
            dp[i][3] -= 9 - t;
        }
        if(t != 0) {
            count++;
        }
    }
    cout << dp[l - 1][K] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>
#include<type_traits>
using namespace std;


int main() {	
	long long int N;
	
	cin >> N;
	int NN = N;
	int n = 0;
	while (NN) {
		n+=NN%10;
		NN=NN / 10;
	}
	
	if (N%n == 0) {
		cout <<"Yes"<< endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}




Measured memory_bytes: 256
import java.util.*

fun main(args:Array<String>){
    val s = readLine()!!
    val a = Integer.parseInt(s.substring(0, 2))
    val b = Integer.parseInt(s.substring(2,4))
    println(
    if((a == 0 && b == 0) || (a > 12 && b > 12)){
        "NA"
    }
    else if(a == 0){
        if(b > 12) "NA"
        else "YYMM"
    }
    else if(b == 0){
        if(a > 12) "NA"
        else "MMYY"
    }
    else if(a <= 12 && b <= 12){
        "AMBIGUOUS"
    }
    else if(a > 12){
        "YYMM"
    }
    else if(b > 12){
        "MMYY"
    }
    else{
        "NA"
    })
}


Measured memory_bytes: 31868
#include <iostream>
#include <string.h>
using namespace std;

int main() {
    string s;
    cin >> s;
    int c[3];
    for(int i=0;i<3;i++) c[i] = 0;
    for(int i=0;i<3;i++){
        c[s[i]-'a']++;
    }
    if(c[0]==1 && c[1]==1 && c[2]==1) cout <<"Yes"<<"\n";
    else cout <<"No" <<"\n";
    return 0;
}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int ans = 0 ;
int main()
{
	int n ;
	cin >> n ;
	string s;
	cin >> s;
	rep(i,1000){
		string search = "000";
		if( i < 10){
			search = "00"+to_string(i);
		} else if ( i < 100){
			search = "0" + to_string(i);
		} else {
			search = to_string(i);
		}
		int index =  0 ; 
		rep(j,s.size()){
			if(s[j] ==  search[index]){
				index ++ ;
			}
		}
		if(index >= 3 ){
			ans ++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 200005
using namespace std;
struct edge{
	int k,next;
}e[N<<2];
int n,X,Y,home[N],home1[N],cnt=-1,dep[N],fa[N][25];
bool vis[N];
void add(int *home,int x,int y){
	cnt++;
	e[cnt].k=y;
	e[cnt].next=home[x];
	home[x]=cnt;
}
void dfs(int k,int F){
	dep[k]=dep[F]+1;fa[k][0]=F;
	for(int i=1;i<=20;i++) fa[k][i]=fa[fa[k][i-1]][i-1];
	for(int i=home1[k];~i;i=e[i].next){
		if(e[i].k!=F){
			dfs(e[i].k,k);
		}
	}
}
int q[N][2];
bool used[N];
int get(int x,int y){
	if(dep[x]<dep[y]) swap(x,y);
	for(int i=20;i>=0;i--){
		if(dep[fa[x][i]]>dep[y]) x=fa[x][i];
	}
	return x;
}
int bfs(){
	q[0][0]=X;q[0][1]=Y;used[X]=1;
	int tou=0,wei=1,ans=0;
	for(int i=0;;i++){
		if(tou==wei) return ans;
		int g=tou;tou=wei;
		for(int p=g;p<tou;p++){
			int k=q[p][0];
			if(vis[k]) return -1;
			for(int j=home[k];~j;j=e[j].next){
				if(dep[e[j].k]<dep[q[p][1]]) continue;
				q[wei][0]=e[j].k;
				q[wei][1]=get(e[j].k,q[p][1]);
				if(q[wei][0]!=q[wei][1]&&!used[q[wei][0]]) used[q[wei][0]]=1,wei++;
			}
			ans=max(ans,i+i+2*(dep[q[p][0]]-dep[q[p][1]]));
		}
	}
}
int main(){
	memset(home,-1,sizeof(home));
	memset(home1,-1,sizeof(home1));
	scanf("%d%d%d",&n,&X,&Y);
	for(int i=1,x,y;i<n;i++){
		scanf("%d%d",&x,&y);
		add(home,x,y);add(home,y,x);
	}
	for(int i=1,x,y;i<n;i++){
		scanf("%d%d",&x,&y);
		add(home1,x,y);add(home1,y,x);
	}
	dfs(Y,0);
	for(int i=1;i<=n;i++){
		for(int p=home[i];~p;p=e[p].next){
			int x=e[p].k,y=i;
			if(dep[x]<dep[y]) swap(x,y);
			if(fa[x][0]!=y&&fa[x][0]!=fa[y][0]&&fa[x][1]!=y) vis[x]=vis[y]=1; 
		}
	}
	printf("%d",bfs());
	return 0;
}

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

int main(){
  double w,h,x,y;cin >> w >> h >> x >> y;
  double ans;
  ans = w*h/2.0;
  int a;
  if (w == x*2 && h == y*2) a = 1;
  else a = 0;

  cout << fixed;
  cout << setprecision(5) << ans << endl;
  cout << a << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int asc(const void*a,const void *b){
    return *(char*)a-*(char*)b;
}
int main(void){
    char s[4];
    scanf("%s",s);
    qsort(s,3,sizeof(char),asc);
    if(s[0]==s[2]) printf("No");
    else printf("Yes");
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "No";
            if (sS[0].Contains("7")) { sOut = "Yes"; }

            // 出力
            System.Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 25820
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const ll N=2e5+5;
vector<ll>ans;
int main()
{
    map<string,ll>mp;
    ll n,maxi=0,ans=0;
    cin>>n;
    string s[n];
    for(ll i=0;i<n;i++){
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
        mp[s[i]]++;
    }
    for(auto i:mp){
        ans+=(i.second*(i.second-1))/2;
    }
    cout<<ans;
   return 0;
}


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

int main() {
	string s;
	cin >>s;
	for (int i=0 ; i<s.size() ; i++) {
		if (s[i] == '?') s[i] = 'D';
	}
	cout <<s<<endl;
	return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
int k,n,x[200000];
int ans=1000000000;
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>x[i];
    for(int i=0;i<n-k+1;i++){
        int a=x[i];
        int b=x[i+k-1];
        int dis=min(abs(0-a)+(b-a),abs(0-b)+(b-a));
        ans=min(ans,dis);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    int n;
    cin >> n;
    vector<int> x(n), y(n), h(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i] >> h[i];
    }
    for (int i = 0; i < 101; i++)
    {
        for (int j = 0; j < 101; j++)
        {
            int tmp = -1;
            for (int k = 0; k < n; k++)
            {
                if (h[k] > 0)
                {
                    int hoge = h[k] + abs(i - x[k]) + abs(j - y[k]);
                    if (tmp == -1)
                        tmp = hoge;
                    else
                    {
                        if (tmp != hoge)
                        {
                            tmp = -2;
                            break;
                        }
                    }
                }
            }
            for (int k = 0; k < n; k++)
            {
                if (h[k] == 0)
                {
                    int dist = h[k] + abs(i - x[k]) + abs(j - y[k]);
                    if (tmp > dist)
                    {
                        tmp = -2;
                        break;
                    }
                }
            }
            if (tmp == -2)
                continue;
            cout << i << " " << j << " " << tmp << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x,y,i,i2,ic,map[100][100];
    char l;
    cin>>y>>x;
    for(i=0;i<y;i++)for(i2=0;i2<x;i2++)map[i2][i]=-2;
    for(i=0;i<y;i++){
        for(i2=0;i2<x;i2++){
            cin>>l;
            switch(l){
                case 'c':
                for(ic=0;ic<x-i2;ic++)map[i2+ic][i]=ic;
                case '.':
                if(map[i2][i]==-2)map[i2][i]=-1;
            }
        }
    }
    for(i=0;i<y;i++){
        for(i2=0;i2<x;i2++){
            cout<<map[i2][i];
            if(i2!=x-1)cout<<' ';
        }
        cout<<endl;
    }
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  VI h(n);
  int ans = 0;
  rep(i, n) {
    cin >> h[i];
    if(h[i] >= k) ans++;
  }
  out(ans);
  return 0;
}


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

using namespace std;
const int N = 2e5 + 3;
vector<int> adj[N];
int sum[N];
void go(int u, int p, int c = 0) {
	for (auto v: adj[u])
		if (v != p)
			go(v, u, c + sum[u]);
	sum[u] += c;
}
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
#endif
	int n, q;
	scanf("%d %d", &n, &q);
	for (int i = 1; i < n; ++i) {
		int u, v;
		scanf("%d %d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	while (q--) {
		int p, x;
		scanf("%d %d", &p, &x);
		sum[p] += x;
	}
	go(1, 1);
	for (int i = 1; i <= n; ++i)
		printf("%d%c", sum[i], " \n"[i == n]);
	return 0;
}


Measured memory_bytes: 26624
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        //        int n = sc.nextInt();
        String s = sc.next();

        int a = s.indexOf("A");
        int z = s.lastIndexOf("Z");

        String str = s.substring(a, z + 1);

        //        boolean ans = false;

        //        for (int i = 0; i < n; i++) {
        //
        //        }

        //        if (1200 <= n)
        //            ans = true;

        sc.close();

        System.out.println(str.length());
        //        System.out.println(ans ? "Yes" : "No");

    }
}

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

void loop(int h, int w) {
	vector<vector<string>> s(h, vector<string>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> s.at(i).at(j);
			if (s.at(i).at(j) == "snuke") {
				cout << char('A' + j) << i + 1 << endl;
				return;
			}
		}
	}
}

int main()
{
	int h, w;
	cin >> h >> w;

	loop(h, w);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);


		int n = Integer.parseInt(scanner.nextLine());

		String[] temp = scanner.nextLine().split(" ");
		int[] list = new int[n];

		for(int i = 0; i < n; i ++) {

			list[i] = Integer.parseInt(temp[i]);

		}

		int ans = 0;

		for(int i = 0; i < n; i ++) {
			for(int j = i + 1; j < n; j++) {

				ans += list[i] * list[j];

			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22612
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::{min, max};

struct Scanner<R: Read> {
    reader: R,
    buffer: String,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader, buffer: String::new() }
    }

    // fn line(&mut self) -> String {
    //     self.buffer = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
    //         .skip_while(|&c| c == '\n' || c == '\r')
    //         .take_while(|&c| !(c == '\n' || c == '\r'))
    //         .collect::<String>();
    //     self.buffer.clone()
    // }

    fn read_buffer(&mut self) {
        self.buffer = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        self.read_buffer();
        if self.buffer.is_empty() {
            None
        } else {
            self.buffer.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(std::io::stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.read()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item=U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(104_857_600)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}

fn solve() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n = sc.read();
    let mut list: LinkedList<u32> = LinkedList::new();

    for _ in 0..n {
        let com: String = sc.read();
        match com.as_str() {
            "insert" => {
                let x = sc.read();
                list.push_front(x);
            },
            "delete" => {
                let x: u32 = sc.read();
                let pos = list.iter().position(|&e| e == x).unwrap_or(list.len());
                let mut tail = list.split_off(pos);
                tail.pop_front();
                list.append(&mut tail);
            },
            "deleteFirst" => {
                list.pop_front();
            },
            "deleteLast" => {
                list.pop_back();
            },
            _ => panic!(),
        }
    }

    println!("{}", list.iter().join(" "));
}



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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long[] a = sc.LongArray();

        a = a.OrderBy(num => num).ToArray();

        long sum = a[0];

        long answer = 1;
        for (int i = 1; i < n; i++)
        {
            long num = a[i];

            if (sum * 2 < num)
            {
                answer = 1;
            }
            else
            {
                answer++;
            }

            sum += num;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
const ll mod = 1000000007;

int main() {
    int n,m,u,v,s,t;
    cin >> n >> m;
    vector<int> E[n];
    rep(i,m) {
        cin >> u >> v;
        E[u-1].push_back(v-1);
    }
    cin >> s >> t;
    s--;
    t--;
    int dist[n][3];
    rep(i,n) rep(j,3) dist[i][j] = -1;

    queue<pair<int, int>> que;
    que.push({s,0});
    dist[s][0] = 0;
    while (!que.empty()) {
        pair<int, int> q = que.front();
        int f = q.first;
        int d = q.second;
        que.pop();
        for(int to : E[f]) {
            if(dist[to][(d+1)%3] == -1) {
                dist[to][(d+1)%3] = dist[f][d] + 1;
                que.push({to,(d+1)%3});
            }
        }
    }
    if (dist[t][0] == -1) {
        cout << -1 << endl;
    } else {
        cout << dist[t][0] / 3 << endl;
    }
    return 0;
}


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

template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}

__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    int w, h;
    cin >> w >> h;

    auto a = make_vec<int>({2, max(w, h)});
    rep(i, w) cin >> a[0][i];
    rep(i, h) cin >> a[1][i];

    vector<tuple<int, int, int>> ord;
    rep(i, w) ord.emplace_back(a[0][i], 0, i);
    rep(i, h) ord.emplace_back(a[1][i], 1, i);

    sort(ord.begin(), ord.end());

    ll ans = 0;
    int row = 0, col = 0;
    rep(i, w + h) {
        auto [cost, j, _] = ord[i];
        if (j == 0) {
            ans += 1LL * cost * (h + 1 - row);
            col++;
        } else {
            ans += 1LL * cost * (w + 1 - col);
            row++;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 7212
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
using namespace std;
 
int main() {
	int a,b,c,ans=0;
	cin >> a;
	string s[100],t[100];
	rep(i, a)cin >> s[i];
	cin >> b;
	rep(j, b)cin >> t[j];
	rep(i, a) {
		int x = 0;
		rep(j, a) {
			if (s[i] == s[j])x++;
		}
		rep(j, b) {
			if (s[i] == t[j])x--;
		}
		ans = max(ans, x);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = []

for a in range(n):
    s.append(input())

t = []
m = int(input())

for a in range(m):
    t.append(input())

kind = list(set(s))
kind_length = len(kind)

counter = dict()
for a in range(kind_length):
    counter[kind[a]] = 0

for a in range(n):
    counter[s[a]] += 1

for a in range(m):
    if t[a] not in counter:
        continue
    counter[t[a]] -= 1

print(max(max(counter.values()), 0))


Measured memory_bytes: 9180
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // write your code here
        //dream dreamer erase eraser
        int H;
        int W;
        String[] sList;
        try (Scanner sc = new Scanner(System.in)) {
            H = sc.nextInt();
            W = sc.nextInt();
            sList = new String[H];
            for (int i = 0; i < H; i++) {
                sList[i] = sc.next();
            }
        }
        long dp[][] = new long[H + 2][W + 2];

        for (int i = 1; i <= H; i++) {
            char[] c = sList[i - 1].toCharArray();
            for (int j = 1; j <= W; j++) {
                if (c[j - 1] == '#') {
                    //爆弾
                    addSurroundMass(dp, i, j);
                }
            }
        }

        for (int i = 1; i <= H; i++) {
            char[] c = sList[i - 1].toCharArray();
            for (int j = 1; j <= W; j++) {
                if (c[j - 1] == '#') {
                    System.out.print("#");
                } else {
                    //空きマス
                    System.out.print(dp[i][j]);
                }
            }
            System.out.println("");
        }
        return;
    }

    private static void addSurroundMass(long[][] dp, int i, int j) {
        dp[i - 1][j] += 1;
        dp[i - 1][j - 1] += 1;
        dp[i][j - 1] += 1;
        dp[i + 1][j - 1] += 1;
        dp[i + 1][j] += 1;
        dp[i + 1][j + 1] += 1;
        dp[i][j + 1] += 1;
        dp[i - 1][j + 1] += 1;
    }
}


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

int hs[100005];
int costos[100005];
int n,k,rta,minimo;

int calc(int a){
    if(costos[a]!=-1){
        return costos[a];
    }
    minimo = calc(a-1)+abs(hs[a]-hs[a-1]);
    for(int i=2; i<=k && i<=a; i++){
        minimo = min(minimo, calc(a-i)+abs(hs[a]-hs[a-i]) );
    }
    return costos[a] = minimo;
}
int main(){

   scanf("%d %d", &n, &k);
   for(int i=0; i<n; i++){
       scanf("%d", &hs[i]);
   }
   fill(begin(costos),end(costos),-1);
   costos[0] = 0;
   rta = calc(n-1);
   printf("%d\n",rta);
   return 0; 
}

Measured memory_bytes: 5760
N=gets.chomp.to_i
a_array=gets.chomp.split(" ").map(&:to_i).sort
b_array=gets.chomp.split(" ").map(&:to_i).sort
c_array=gets.chomp.split(" ").map(&:to_i).sort
ret=0
a=0
c=0
b_array.each do |b|
    while a != N && a_array[a] < b do
        a+=1
    end
    while c != N && c_array[c] <= b do
        c+=1
    end
    ret+=a*(N-c)
end
puts ret


Measured memory_bytes: 30504
[X, N] = list(map(int, input().split()))
P = list(map(int, input().split()))
answer = 0
c = 0
N_min = X
N_max = X
while c == 0:
    if N_min not in P:
        answer = N_min
        c += 1
    elif N_max not in P:
        answer = N_max
        c += 1
    N_min = N_min - 1
    N_max = N_max + 1
print(answer)

Measured memory_bytes: 61736
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n,k;
    cin >> n >> k;
    ll cur = 1;
    rp(i,n){
      if(cur < k) cur *=2;
      else cur +=k;
    }
    cout<<cur << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll, ll>
#define SZ(x) ((int)(x).size())
ll mod = 1e9 + 7;
//const double pi = acos(-1.0);
/*
ll kmp(string x)
{
    ll n= x.length();
    //cout<<x<<endl;
    vector<ll> lcp(x.length(), 0);
    for(ll i=1;i<n;i++)
    {
        ll j=lcp[i-1];
        while(j>0 && x[j]!=x[i])
            j=lcp[j-1];
        if(x[i]==x[j])
            j++;
        lcp[i]=j;
    }
    return lcp[n-1];
}

int N = 1000002;
int ar[100002];
void sieve()
{
    for(int i=1;i<=N;i++)
        ar[i] = 1;
    ar[0] = 0;
    for(int i=2;i*i<=N;i++)
    {
        if(ar[i] && i*i<=N)
        {
            for(int j = i*i; j<=N;j+=i)
                ar[j] = 0;
        }
    }
}

ll modex(ll a,ll b){
    if(b<=0){
        return 1;
    }
    if(b%2==0)
    {
        ll x = modex(a, b/2);
        return ((x*x)%mod);
    }
    else
        return ((a%mod * modex(a, b-1))%mod);
}

ll c[1010][1010];

ll combina(ll i, ll j){
        for (int i=0;i<=1005;i++)
        for (int j=0;j<=i;j++)
        {
            if (j==i||j==0)
                c[i][j]=1;
            else
            c[i][j]=c[i-1][j-1]+c[i-1][j];
            c[i][j]%=mod;
        }
        return c[i][j];
}
void find_fac(int x){
    vector<ll> di;
    for(ll i = 2; i*i <= x; i++)
    {
        if(x%i==0){
            di.push_back(i);
            while(x%i==0)
                x/=i;
        }
    }
    if(x > 1)
        di.push_back(x);
}
*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout.precision(12);
    ll n;
    cin>>n;
    vector<vector<ll> > gr;
    gr.resize(n+1);
    ll c = 0;
    for(ll i=0;i<(n-1);i++){
        ll x, y;
        cin>>x>>y;
        gr[x].push_back(y);
        ll mi = min(x, y);
        ll ma = max(x, y);
        c += (mi*(n-ma+1));
    }
    ll an = 0;
    for(ll i=1;i<=n;i++){
        an += i*(n-i+1);
    }
    an -= c;
    cout<<an<<endl;
    return 0;
}


Measured memory_bytes: 12632
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**6)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
#show_flg=True

n,k=LI()
a=LI()
b=[k-1]
for i in range(n):
    b.append((b[-1]+a[i])%k)
b=[(b[i]-i)%k for i in range(n+1)]
ans=0
dc=defaultdict(int)
show(a)
show(b)
for i in range(n+1):
    if i>=k:
        dc[b[i-k]]-=1
    ans+=dc[b[i]]
    #if dc[b[i]]>0:show(i,a[i],dc[b[i]],ans)
    #show(i,b[i],dc)
    dc[b[i]]+=1

print(ans)


Measured memory_bytes: 111836
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    enum blocks{
        A = 18, B = 48, C = 6, D = 30, E = 20, F = 34, G = 16
    };
    string surface, input;
    while(cin >> surface){
        rep(i,7){
            cin >> input;
            surface+= input;
        }
        int first = -1, location = 0;
        rep(i,65){
            if(surface[i] == '1' && first == -1){
                first = i;
            }else if(surface[i] == '1'){
                location+= i - first;
            }
        }
        if(A == location) cout << 'A' << endl;
        else if(B == location) cout << 'B' << endl;
        else if(C == location) cout << 'C' << endl;
        else if(D == location) cout << 'D' << endl;
        else if(E == location) cout << 'E' << endl;
        else if(F == location) cout << 'F' << endl;
        else if(G == location) cout << 'G' << endl;
    }
}

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

int main() {
    string s,t;
    cin >> s >> t;
    int a,b;
    cin >> a >> b;
    string u;
    cin >> u;
    if (u == s) a--;
    else b--;
    cout << a << " " << b << endl;
}


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

#define ll long long

using namespace std;
const int MX = 200'000 + 5; // check bounds!

int n;
string s;
int main() {
    cin >> n >> s;
    if (n % 2) {
        cout << "No";
    } else {
        bool ok = s.substr(0, n / 2) == s.substr(n / 2);
        cout << (ok ? "Yes" : "No");
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#include<vector>
#include<cstdlib>
#include<fstream>

using namespace std;

int main(){
  int h,w;
  cin>>h>>w;
  char c[h][w];

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>c[i][j];
    }
  }
  int cnt=0;
  for(int i=0;i<h;){
    for(int j=0;j<w;j++){
      cout<<c[i][j];
    }
    cnt++;
    if(cnt==2){i++;cnt=0;}
    cout<<endl;
  }



return 0;}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
  var r = input;

  var result = Math.pow(r, 2) * 3;
  
 	console.log(result);
 }
 //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
 Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
//using
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;

//関数マクロ
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl

//定数マクロ
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>

//定数
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);

//テンプレート関数
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; }
//intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); } //c++17からある
//intl lcm(intl a,intl b){ return a / gcd(a, b) * b; } //c++17からある

//自作テンプレート関数
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}//Yes,Noの出力を楽にするよう
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}//上の関数のYes,Noを任意の文字列でできるようにしたもの
intl kai(intl k){ intl a = 1; for(int i = 2; i <= k; i++){ a *= i; } return a; }//k!を求める関数,O(N)
intl digit10(intl a){ intl b = 0; do{ a /= 10; b++; }while(a); return b; }//aを10進数で表したときの桁数を求める関数,桁数回の演算だからだいたいO(logN)くらい?



//--------------入力受け取る場所----------------------------------------------------
intl h,w,k;
char c[6][6];

void input_var(){
    cin >> h >> w >> k;
    rep(i,h)rep(j,w)cin >> c[i][j];
}
//-------------------------------------------------------------------------------

signed main(){
    cout << fixed << setprecision(10);
    m0(c);
    input_var();
    //rep(i,h)rep(j,w)cout << c[i][j];
    intl ans = 0;
    for(intl i = 0; i < (1 << h); i++){
        for(intl j = 0; j < (1 << w); j++){
            intl cnt = 0;
            rep(l,h){
                if(!(i & (1 << l)))continue;
                rep(m,w){
                    if(!(j & (1 << m)))continue;
                    cnt += (c[l][m] == '#');
                }
            }
            //debug(cnt);
            if(cnt == k)ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
#define LL long long
#define INF 0x3f3f3f3f

const int MAXN = 1e5 + 5;
const LL MOD = 1e9 + 7;

int f[105][6][3];
int p[105][11];

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
#endif

    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < 5; j++)
            for(int k = 0; k < 2; k++)
                scanf("%d", &f[i][j][k]);
    int aaa;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j <= 10; j++)
            scanf("%d", &p[i][j]);
    }
    int ans = -INF;
    for(int ll = 1; ll < 1024; ll++)
    {
        int sw[10];
        int kk = ll;
        int ansn = 0;
        for(int j = 0; j < 10; j++)
        {
            sw[j] = kk % 2;
            kk = kk / 2;
        }
        for(int i = 0; i < n; i++)
        {
            int sum = 0;
            int cnt = 0;
            for(int j = 0; j < 5; j++)
            {
                for(int k = 0; k < 2; k++)
                {
                    sum += f[i][j][k]*sw[cnt++];
                }
            }
            ansn += p[i][sum];
        }
        ans = max(ans, ansn);
    }

    cout << ans << endl;
    return 0;
}

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

int main(){
	int a, b, k, i;
	cin >> a >> b >> k;
	vector<int>vec;

	if (b-a < k) k=b-a+1;

	for (int i=0; i<k; i++){
		vec.push_back(a+i);
	}
	for (int i=k; i>0; i--){
		vec.push_back(b-i+1);
	}
	sort(vec.begin(), vec.end());
	vec.erase(unique(vec.begin(), vec.end()), vec.end());
	for (vector<int>::iterator i=begin(vec); i!=end(vec); ++i){
		cout << *i << endl;
	}
	return 0;
}	


Measured memory_bytes: 256
#include<stdio.h>
main(){
  int i,n,x;
  scanf("%d",&n);
  for(i=3;i<=n;i++){
    x=i;
    if(x%3==0) printf(" %d",i);
    else if(x%10==3) printf(" %d",i);
    else {
      while(x>10){
        x/=10;
        if(x%10==3){
          printf(" %d",i);
          break;
        }
      }
      continue;
    }
  }
  printf("\n");
  return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
  ll A; cin >> A;
  ll B; cin >> B;
  ll C; cin >> C;
  if ((A <= C && C <= B) || (B <= C && C <= A)) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
  return 0;
}


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

int main(void) {

    int N, A, B; cin >> N >> A >> B;
    int a = 0, b = 0;
    string S; cin >> S;

    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'a') {
            if (a+b < A+B) {
                cout << "Yes" << endl;
                a++;
            } else {
                cout << "No" << endl;
            }
        } else if (S[i] == 'b') {
            if (a+b < A+B && b < B) {
                cout << "Yes" << endl;
                b++;
            } else {
                cout << "No" << endl;
            }
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int cnt=0;
    int x,min=1000000000;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(x<=min)
        {
            cnt++;
            min=x;
        }
    }
    cout<<cnt<<endl;



    return 0;
}


Measured memory_bytes: 256
import math
n = int(input())

# 1以外のNの約数
divisors = []
for i in range(1, int(math.sqrt(n)) + 1):
    if n % i == 0:
        divisors.append(i)
        if i ** 2 != n:
            divisors.append(n // i)
divisors.sort()

candidates = set()
for k in divisors[1:]:
    tmp = n
    while True:
        if tmp % k != 0:
            break
        tmp = tmp // k
    if (tmp - 1) % k == 0:
        candidates.add(k)

# N-1の約数
divisors = []
for i in range(1, int(math.sqrt(n-1)) + 1):
    if (n-1) % i == 0:
        divisors.append(i)
        if i ** 2 != n-1:
            divisors.append((n-1) // i)

for k in divisors[1:]:
    candidates.add(k)

print(len(candidates))


Measured memory_bytes: 40300
from math import sqrt


def distance(a, b):
    return sqrt(a ** 2 + b ** 2)


n, d = list(map(int, input().split()))
res = 0
for _ in range(n):
    l = list(map(int, input().split()))
    if d >= distance(l[0],l[1]):
        res += 1
print(res)


Measured memory_bytes: 9164
h, w = map(int, input().split())
s = [['#']*(w+2) for _ in [0]*(h+2)]
for i in range(h):
    s[i+1][1:-1] = input()
for i in range(1, h+1):
    for j in range(1, w+1):
        if s[i][j]=='#':
            if s[i-1][j]+s[i+1][j]+s[i][j-1]+s[i][j+1]=='....':
                print('No')
                break
    else: continue
    break
else:
    print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int d[510][510]={};

int main(){
	int n,m;
	while(1){
		cin>>n>>m;
		if(n+m==0) break;
		rep(i,0,510){
			rep(j,0,510){
				d[i][j]=0;
			}
		}
		rep(i,0,m){
			int a,b;
			cin>>a>>b;
			a--;
			b--;
			d[a][b]++;
			d[b][a]++;
		}
		int f[510]={0},ans=0;
		rep(i,1,n){
			if(d[0][i]){
				if(f[i]==0){
					f[i]++;
					ans++;
				}
				rep(j,1,n){
					if(d[i][j] && f[j]==0){
						f[j]++;
						ans++;
					}
				}
			}
		}
		o(ans);
	}
}

Measured memory_bytes: 2172
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
 
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
 
 
int main()
{
    long long int n,p;
    scanf("%lld %lld\n",&n,&p);
    if(n==1){
        printf("%lld\n",p);
        return 0;
    }
    else if(n>=40){
        printf("1\n");
        return 0;
    }
    long long int max=0;
    for(int i=1;pow(i,n)<=p;i++){
        long long int div=pow(i,n);
        if(p%div==0)max=i;
    }
    printf("%lld\n",max);
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
priority_queue <ll> P;
priority_queue <ll,vector <ll>,greater <ll> > Q;
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n;
    ll A=0,B=0,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++) {
	int l=gi(),r=gi();
	B+=r-l;
	P.push(r-A),Q.push(r-B);
	while(P.top()+A>Q.top()+B) {
	    ll x=P.top()+A,y=Q.top()+B;
	    P.pop(),Q.pop(),ans+=x-y;
	    P.push(y-A),Q.push(x-B);
	}
	A-=r-l;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 2036