akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	string l = "qwertasdfgzxcvb";
	string r = "yuiophjklnm";
	vector<int> a(256);
	for (int i = 0; i < l.length(); i++)
		a[l[i]] = -1;
	for (int i = 0; i < r.length(); i++)
		a[r[i]] = 1;
	for (;;) {
		string s; cin >> s;
		if (s == "#") break;
		int x = 0, cnt = 0;
		for (int i = 0; i < s.length(); i++) {
			char c = s[i];
			if (a[c] != x) {
				x = a[c];
				cnt++;
			}
		}
		cout << cnt - 1 << endl;
	}
}

Measured memory_bytes: 1196
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			
			String s = sc.next();
			String ans = "yes";
			for (int i = 0; i < s.length(); i++) {
				for (int j = i + 1; j < s.length(); j++) {
					if (s.charAt(i) == s.charAt(j)) {
						ans = "no";
					}
				}
				
			}
			System.out.println(ans);
		}
	}


Measured memory_bytes: 21972
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define printx(x) printf("%lld\n",x);
#define printxy(x,y) cout << x << y <<endl;
#define printxyz(x,y,z) cout << x << y << z <<endl;
#define deba(a) cout << #a << a << endl;
#define debab(a,b) cout << #a << a << #b << b << endl;
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("/home/kushagra/Desktop/Kushagra/input.txt", "r", stdin);
	freopen("/home/kushagra/Desktop/Kushagra/output.txt", "w", stdout);
#endif
	ll n;
	cin >> n;
	ll a[n];
	rep(i, 0, n)
	cin >> a[i];
	sort(a, a + n);
	ll ans = a[n - 1];
	ll j = n - 2;
	ll k = 2;
	while (k < n)
	{
		ans += a[j];
		k++;
		if (k < n)
		{
			ans += a[j];
		}
		j--;
		k++;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
//  int N,A,B,C,D;
  __int64_t X;
  __int64_t Y;
  cin >> X >> Y;
  int flag = 1;
  __int64_t pre = X;
  __int64_t post;
  int count = 0;

//  std::cout << X << std::endl;

//  std::cout << Y << std::endl;
  while(flag){
  count ++;
  post = pre*2;
//  std::cout << post << std::endl;
  if(post > Y){
  flag = 0;
  }
  pre = post;
  }
std::cout << count << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);
ll dx[8]={0,0,-1,1,-1,1,-1,1};
ll dy[8]={1,-1,0,0,1,1,-1,-1};
vector<vector<ll> > c(10,vector<ll>(10,0));

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    vector<ll> A(N+1);
    vector<ll> ans(N+1);
    rep1(i,N) cin>>A[i];
    
    //   A[1]  A[2]  .....   A[N]
    //山     2      3       N
    
    //山1
    ll sum=0;
    rep1(i,N) sum+=A[i];
    
    ll tmp=sum/2;
    for(ll i=2;i<=N;i+=2) tmp-=A[i];
    ans[1]=tmp*2;
    FOR(i,2,N+1){
        ans[i]=A[i-1]*2-ans[i-1];
    }
    rep1(i,N){
        cout<<ans[i]<<" ";
    }
}


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

int main()
{
	int a,b;
	cin>>a>>b;
	if(a+b>16)
	{
		cout<<":("<<endl;
		return 0; 
	}
	if(b*2>16||a*2>16)
	{
		cout<<":("<<endl;
		return 0; 
	}
	cout<<"Yay!"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[]){
        int a,b,c,d;
        while(scanf("%d %d",&a,&b)!=EOF){
                c = a+b;
                d = 0;
                while(c){
                        d++;
                        c /= 10; 
                }   
                printf("%d\n", d); 
        }   
        return 0;
}

Measured memory_bytes: 0
n = int(input())
s = input()
L = ""
R = ""
C = ""
tmp = 0
ans = []
for i in range(1, len(s)):
    L = s[:i]
    R = s[i:]
    C = len(set(L) & set(R))
    ans.append(C)
    L = ""
    R = ""
print(max(ans))

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

int main() {
  ll N, K;
  cin >> N >> K;

  vector<vector<int>> next(60, vector<int>(N));
  for (int v = 0; v < N; ++v) cin >> next[0][v], --next[0][v];
  for (int d = 0; d + 1 < 60; ++d) {
    for (int v = 0; v < N; ++v) {
      next[d + 1][v] = next[d][next[d][v]];
    }
  }
  int v = 0;
  for (int d = 0; d < 60; ++d) {
    if (K & (1LL << d)) v = next[d][v];
  }
  cout << v + 1 << endl;
}

Measured memory_bytes: 51024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)

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

    vector<pair<int,int>> wars;
    rep(i,0,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        wars.push_back(make_pair(b,a));
    }
    sort(wars.begin(),wars.end());

    int max_x=-1;
    int broken_bridge=0;
    for(auto war:wars){
        if(war.second>max_x){
            max_x=war.first-1;
            broken_bridge++;
        }        
    }

    cout<<broken_bridge<<endl;
}

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

int check(double x, int N){
  if(floor(x*1.08) == N){
    return x; 
  }
  else{
  return 0;
  }
}
int main(void){
  int N;
  cin >> N;
  
  double x = N / 1.08;
  
  double x1 = floor(x);
  double x2 = floor(x) - 1;
  double x3 = floor(x) + 1;
  
  if(check(x1, N)){
    cout << check(x1, N) << endl;
  }
  else if(check(x2, N)){
    cout << check(x2, N) << endl;
  }
  else if(check(x3, N)){
    cout << check(x3, N) << endl;
  }
  else{
  cout << ":(";
  }
  
  
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

var s string
var ans []byte

func dfs(i, sum int) bool {
	if i == 4 {
		if sum == 7 {
			return true
		}
		return false
	}
	a, _ := strconv.Atoi(string(s[i]))
	if dfs(i+1, sum+a) {
		ans = append([]byte{'0' + byte(a)}, ans...)
		ans = append([]byte{'+'}, ans...)
		return true
	}
	if dfs(i+1, sum-a) {
		ans = append([]byte{'0' + byte(a)}, ans...)
		ans = append([]byte{'-'}, ans...)
		return true
	}
	return false
}

func main() {
	fmt.Scan(&s)
	ans = make([]byte, 0)
	a, _ := strconv.Atoi(string(s[0]))
	dfs(1, a)
	ans = append([]byte{'0' + byte(a)}, ans...)
	fmt.Println(string(ans) + "=7")
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] l = new long[n+1];
        l[0] = 2;
        l[1] = 1;
        for (int i = 2; i <= n; i++) {
            l[i] = l[i-1]+l[i-2];
        }

        System.out.println(l[n]);
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
int digits(int n)
{
    int sum=0;
    int temp=n;
    while(temp>0)
    {
        sum++;
        temp=temp/10;
    }
    return sum;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        int d=digits(i);
        if((d%2)!=0)
        {
            sum++;
        }
    }
    cout<<sum;
}

Measured memory_bytes: 256
/*


*/
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
#include<cmath>
#define ll long long
#define M 100010
#define mmp make_pair
using namespace std;
int read() {
	int nm = 0, f = 1;
	char c = getchar();
	for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
	for(; isdigit(c); c = getchar()) nm = nm * 10 + c - '0';
	return nm * f;
}
int n;
char s[M];
int tot[M];
const int mod = 1000000007;
int main() {
	int ans = 1;
	n = read();
	scanf("%s", s + 1);
	for(int i = 1; i <= n; i++)
	{
		tot[s[i] - 'a']++;
	}
	for(int i = 0; i <= 26; i++) ans = 1ll * ans * (tot[i] + 1) % mod;
	ans = (ans + mod - 1) % mod;
	cout << ans << "\n";
	



	return 0;
}




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

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    int N;
    long long P;
    cin >> N >> P;
    auto fac = prime_factorize(P);
    long long res = 1;
    for (auto p : fac) {
        for (int j = 0; j < p.second/N; ++j) res *= p.first;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<queue>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define ll long long
using namespace std;
int n,a[2005],tot,du[2005],h[2005],to[4000005],nex[4000005];
bool bhz[2005][2005],pd[2005];
int gcd(int a,int b)
{
    return b?gcd(b,a%b):a;
}
struct node{
    int fr,id;
}st;
bool operator <(node a,node b)
{
    return a.fr<b.fr;
}
priority_queue<node> q;
void add(int a,int b)
{
    du[b]++;
    to[++tot]=b;
    nex[tot]=h[a];
    h[a]=tot;
}
void dfs(int x)
{
    pd[x]=1;
    for(int i=1;i<=n;i++)
        if(bhz[x][i]&&!pd[i])
        {
            add(x,i);
            dfs(i);
        }
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<=n-1;i++)
    for(int j=i+1;j<=n;j++)
    if(gcd(a[i],a[j])>1) bhz[i][j]=bhz[j][i]=1;
    for(int i=1;i<=n;i++) if(!pd[i]) dfs(i);
    for(int i=1;i<=n;i++) 
        if(!du[i])
        { 
            st.fr=a[i];
            st.id=i;
            q.push(st); 
        }
    for(int i=1;i<=n;i++)
    {
        st=q.top();
        q.pop();
        int now=st.id;
        cout<<a[now]<<" ";
        int t=h[now];
        while (t){
            du[to[t]]--;
            if (!du[to[t]]){
                st.fr=a[to[t]];
                st.id=to[t];
                q.push(st);
            }
            t=nex[t];
        }
    }
    return 0;
}

Measured memory_bytes: 6656
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var n, x int
	fmt.Fscan(read, &n, &x)

	cnt := 1
	pos := 0
	for i := 0; i < n; i++ {
		var l int
		fmt.Fscan(read, &l)
		pos += l
		if pos <= x {
			cnt++
		}
	}

	fmt.Fprintln(write, cnt)
}


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

int main(void){
	int n, k;
	string s;
	cin >> n >> k >> s;
	vector<int> a;
	int sum = 0;
	for(int i = 0; i < n; ++i){
		if(s[i] == '0'){
			if(sum>=0){
				if(sum!=0) a.push_back(sum);
				sum = -1;
			}else{
				sum--;
			}
		}else{
			if(sum<=0){
				if(sum!=0) a.push_back(sum);
				sum = 1;
			}else{
				sum++;
			}
		}
	}
	if(sum!=0) a.push_back(sum);
	
	if(a.front() < 0) a.insert(a.begin(),0);
	if(a.back() < 0) a.push_back(0);
	// for(auto x : a){
	// 	cout << x << endl;
	// }
	int ans = 0;
	if(a.size() <= 2*k+1){
		for(auto x : a){
			ans += abs(x);
		}
		cout << ans << endl;
		return 0;
	}
	int tmp = 0;
	for(int i = 0; i < 2*k+1; ++i){
		tmp += abs(a[i]);
	}
	ans = tmp;
	// cout << tmp << endl;
	for(int i = 2; i < a.size()-(2*k); i+=2){
		tmp -= abs(a[i-1]) + abs(a[i-2]);
		tmp += abs(a[i+2*k-1]) + abs(a[i+2*k]);
		ans = max(tmp, ans);
		// cout << tmp << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string S;
    cin >> S;
    int size = S.size();
    vector<int> A(size);
    for (int i = 0; i < size; ++i) {
        A[i] = (S[i]-'A'+N)%26;
    }
    for (int i = 0; i < size; ++i) {
        putchar('A'+A[i]);
    }
    putchar('\n');
    return 0;
}


Measured memory_bytes: 384
s = input()

if 0 < int(s[:2]) <= 12 and 0 < int(s[2:]) <= 12:
  print("AMBIGUOUS")
elif 0 < int(s[:2]) <= 12:
  print("MMYY")
elif 0 < int(s[2:]) <= 12:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 3060
// abc137_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;



int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, M;
    cin >> N >> M;
    priority_queue<P, vector<P>, greater<P>> pq_origin;
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        pq_origin.push(P(a,b));
    }

    priority_queue<int> avaliable;
    ll ans = 0;
    REPN(i, 1, M+1){

        while (!pq_origin.empty() && pq_origin.top().first <= i){
            avaliable.push(pq_origin.top().second); pq_origin.pop();
        }

        if (!avaliable.empty()){
            ans += avaliable.top(); avaliable.pop();
        }
    }

    print(ans);


    return 0;
}


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

int main (){
  int n;
  cin >> n;
  long long a[n];
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int cnt = 0;
  if (a[0] != 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 1; i < n; i++) {
    cnt++;
    if (a[i] == cnt) {
      ans++;
    } else if (a[i] < cnt) {
      cnt = a[i];
      ans += a[i];
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=100100;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
    int N,M;
    ll ans=0;
    cin>>N>>M;
    vector<vector<int>> v(N);
    vector<int> p;
    for(int i=0;i<N;i++) p.push_back(i);
    for(int i=0;i<M;i++){
        int a,b;
        cin>>a>>b;
        v[a-1].push_back(b-1);
        v[b-1].push_back(a-1);
    }
    do{
        if(p[0]!=0) break;
        ll cnt=0;
        for(int i=0;i<N-1;i++){
            for(int j=0;j<v[p[i]].size();j++){
                if(v[p[i]][j]==p[i+1]) cnt++;
            }
        }
        if(cnt==N-1) ans++;
    }while(next_permutation(p.begin(),p.end()));
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
from decimal import Decimal as D
orth=lambda l:((D(l[2])-D(l[0]))*(D(l[6])-D(l[4]))+(D(l[3])-D(l[1]))*(D(l[7])-D(l[5])))
[print(l) for l in ["YES" if orth(j)==0 else "NO" for j in [l.split() for l in sys.stdin]]]



Measured memory_bytes: 6340
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());

		int X[] = new int[N];
		int Xcopy[] = new int[N];

		for (int i = 0; i < N; i++) {
			X[i] = Integer.parseInt(sc.next());
			Xcopy[i] = X[i];
		}

		Arrays.sort(Xcopy);

		int mSmall = Xcopy[N / 2 - 1];
		int mLarge = Xcopy[N / 2];

		for (int i = 0; i < N; i++) {
			if (X[i] <= mSmall) {
				System.out.println(mLarge);
			} else {//if (X[i] > mLarge) {
				System.out.println(mSmall);
			}
		}

	}

}

Measured memory_bytes: 91476
s = input()
a,b,c,d = [int(s[i]) for i in range(len(s))]

op1 = '+'
op2 = '+'
op3 = '+'

if a+b+c-d==7:
    op3 = '-'
elif a+b-c+d==7:
    op2 = '-'
elif a-b+c+d==7:
    op1 = '-'
elif a+b-c-d==7:
    op3 = '-'
    op2 = '-'
elif a-b+c-d==7:
    op3 = '-'
    op1 = '-'
elif a-b-c+d==7:
    op1 = '-'
    op2 = '-'
elif a-b-c-d==7:
    op3 = '-'
    op2 = '-'
    op1 = '-'

print(a,op1,b,op2,c,op3,d,"=7",sep='')

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int main(){
	
	string str;
	cin >> str;
	
	int id1 = 0;
	int id2 = str.size() - 1;
	
	int ans = 0;
	for(int i = 0; i <= str.size(); i++){
		//cout << str[id1] << " " << str[id2] << endl;
		if(id1 >= id2){
			break;
		}
		if(str[id1] == str[id2]){
			id1++;
			id2--;
		}else if(str[id1] == 'x'){
			id1++;
			ans++;
		}else if(str[id2] == 'x'){
			id2--;
			ans++;
		}else{
			ans = -1;
			break;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 512
from functools import reduce

n = int(input())
d = [int(i) for i in input().split()]


def lcm(x, y):
    a, b = x, y
    while y != 0:
        x, y = y, x % y
    return (a * b) // x


lc = reduce(lcm, d)

ans = 0
for i in d:
    ans += lc // i

print(ans % (10 ** 9 + 7))


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

Measured memory_bytes: 256
/**
 *      ABC 112 C
 *      author  : kyomukyomupurin
 *      created : 2018-10-06 21:07:54
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    int x[N] = {}; int y[N] = {}; int h[N] = {};
    for (auto i = 0; i < N; ++i) {
        cin >> x[i] >> y[i] >> h[i];
    }

    int maxH = *max_element(h, h + N);

    for (auto i = 0; i <= 100; ++i) {
        for (auto j = 0; j <= 100; ++j) {
            for (auto k = maxH; k <= maxH + 200 ; ++k) {
                for (auto l = 0; l < N; ++l) {
                    if (max(k - abs(x[l] - i) - abs(y[l] - j), 0) != h[l]){
                        break;
                    }
                    if (l == N - 1){
                        cout << i << " " << j << " " << k << '\n'; return 0;
                    }
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; i>0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define FORR(i, m, n) for(int i=m; i>=n; i--)
#define INF 1999999999
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

#ifdef INPUT
stringstream input(R"(
1 9 7 4
)");
#define cin input
#endif

int main()
{
    vector <int> n(4);
    for (int i=0; i<4; i++)
        cin >> n[i];
    sort(n.begin(), n.end());

    string s;
    for (int i=0; i<4; i++)
        s += to_string(n[i]);

    if (s == "1479")
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1e9
#define EPS 10e-8

int main(){
  char S[107];cin >>  S;
  char C[107];
  ll t=0;
  rep(i,strlen(S)){
    if(t==0 && S[i]=='B'){
      continue;
    }
    else if(S[i]=='B'){
      t--;
    }
    else if(S[i]=='1'){
      C[t]='1';
      t++;
    }
    else if(S[i]=='0'){
      C[t]='0';
      t++;
    }
  }
  rep(i,t){
    cout << C[i];
  }
  cout <<endl;
}

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


class Program {

	const long mod = 1000000007;
	//public static int[] max;

	static void Main(string[] args) {

		char[] cs = new char[] { ' ', ',' };
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//int n = vals[0];
		//string res="";

		//int y = vals[0];
		//int x = vals[1];

		
		int[] fig =new int[27];

		//int res = vals[0] + vals[1];

		for (int i = 0; i < str.Length; i++) {
			//int b = str[i];
			fig[(char)str[i]-'a']++;
		}

		int flg = 0;
		for (int i = 0; i < fig.Length; i++) {
			if (fig[i] > 1) { flg = 1; break; }
		}

		if (flg == 1) { Console.WriteLine("no");  } else { Console.WriteLine("yes"); }


		return;
	}



	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryl(string[] str) {
		long[] nums = new long[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}



	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
		return re;
	}

}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define f first
#define se second
#define pb push_back
#define ld long double
 
using namespace std;
 
 
const int N = 2e5 + 123;
const int MAXN = 1e5 + 12;
const int inf = 1e9 + 7;
const ll mod = 1e9 + 7;


int n, m, col[N], p[N];
vector <int> g[N], b;
unordered_set <int> st;
bool is = 0;


void getcycle(int u) {
    b.pb(u);
    st.insert(u);
    if (b.size() != 0 && p[u] == b[0])
        return;
    getcycle(p[u]);
}


void dfs(int u, int p1) {
    col[u] = 1;
    p[u] = p1;
    for (int i = 0; i < g[u].size(); i++) {
        if (is)
            return;
        if (col[g[u][i]] == 1) {
            p[g[u][i]] = u;
            getcycle(g[u][i]);
            is = 1;
            return;
        }
        if (is)
            return;
        if (col[g[u][i]] == 0)
            dfs(g[u][i], u);
    }
    col[u] = 2;
}

 
int main() {
    cin >> n >> m;
    st.clear();
    int u, v;
    for (int i = 1; i <= m; i++) {
        cin >> u >> v;
        g[u].pb(v);
    }
    for (int i = 1; i <= n; i++) {
        if (col[i] == 0)
            dfs(i, -1);
        if (is)
            break;
    }
    if (b.size() == 0)
        return cout << -1, 0;
    vector <int> c;
    reverse(b.begin(), b.end());
    bool iss;
    int L, R;
    while (true) {
        iss = 1;
        bool tob = 0;
        for (int i = 0; i < b.size(); i++) {
            if (tob)
                break;
            tob = 0;
            for (int j = 0; j < g[b[i]].size(); j++) {
                if (st.find(g[b[i]][j]) == st.end())
                    continue;
                if (g[b[i]][j] == b[(i + 1) % b.size()])
                    continue;
                iss = 0;
                R = i;
                for (int k = 0; k < b.size(); k++)
                    if (b[k] == g[b[i]][j]) {
                        L = k;
                        break;
                    }
                tob = 1;
                break;
            }
        }
        if (iss) {
            cout << b.size() << endl;
            for (int i = 0; i < b.size(); i++)
                cout << b[i] << endl;
            break;
        }
        c.clear();
        st.clear();
        if (L < R) {
            for (int i = L; i <= R; i++) {
                c.pb(b[i]);
                st.insert(b[i]);
            }
            b.clear();
            b = c;
        } else {
            for (int i = L; i < b.size(); i++) {
                c.pb(b[i]);
                st.insert(b[i]);
            }
            for (int i = 0; i <= R; i++) {
                c.pb(b[i]);
                st.insert(b[i]);
            }
            b.clear();
            b = c;
        }
    }
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

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

    rep(i, h){
        rep(j, w){
            if(j < a){
                if(i < h-b)cout << 1;
                else cout << 0;
            }
            else {
                if(i < h-b)cout << 0;
                else cout << 1;
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include <stdio.h>
        int main(){
        int x;
        scanf("%d",&x);
        int a,b,c,d;
        a=x/1000;
        b=(x%1000)/100;
        c=((x%1000)%100)/10;
        d=((x%1000)%100)%10;
         
        if(a==b&&b==c) puts("Yes");
        else
        if(b==c&&c==d) puts("Yes");
        else puts("No");
         
        return 0;
        }

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

using namespace std;

const int INF = 2e9 + 5;

int a,b;

int main(){
	scanf("%d%d", &a, &b);
	int res = INF;
	if(b - a >= 0)
	res = min(res, abs(b - a));
	a *= -1;
	if(b - a >= 0)
	res = min(res, abs(b - a) + 1);
	b *= -1;
	if(b - a >= 0)
	res = min(res, abs(b - a) + 2);
	a *= -1;
	if(b - a >= 0)
	res = min(res, abs(b - a) + 1);
	printf("%d\n", res);
}


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

#define faster      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi          acos(-1.0)
#define nl          '\n'

///Library
#define mem(a,b)    memset(a,b,sizeof(a))
#define all(a)      a.begin(),a.end()
#define Sort(x)     sort(x.begin(),x.end())
#define Reverse(x)  reverse(x.begin(),x.end())
#define SortA(ar,s) sort(ar,ar+s)
#define SortD(ar,s) sort(ar,ar+s,greater<int>())
#define gcd(a,b)    __gcd(a,b)
#define lcm(a,b)    (a*(b/gcd(a,b)))
#define sq(x)       (x)*(x)

#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min(b,min(c,d)))
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max(b,max(c,d)))
#define ABS(x)             ((x)<0?-(x):(x))
#define pb                 push_back
#define mod                1000000007
#define end                printf("\n")
#define yes                printf("Yes\n")
#define no                 printf("No\n")

///data type
typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    string s;
    cin>>s;
    ll sum=0,x;
    for(int i=0; i<s.size(); i++)
    {
        x=s[i]-'0';
        sum+=x;
    }
    //cout<<sum<<nl;
    if(sum%9==0)
        yes;
    else no;
    return 0;
}


Measured memory_bytes: 3748
short len[3], used[3], s[3][100], d, i;

void rec(t){
        if(used[t]++>=len[t]) putchar('A'+t);
        else rec(s[t][used[t]-1]);
}

int main(){
        for(i=0; i<3; i++){
                while((d=getchar())!='\n'){
                        s[i][len[i]++] = d-'a';
                }
        }
        rec(0);
        return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	vector<int>v={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;
	cin>>k;
	cout<<v.at(k-1)<<"\n"s;
}

Measured memory_bytes: 256
#n = int(input()) #入力
#a, b = (int(x) for x in input().split())

#a = [int(x) for x in input().split()]
#a = list(map(int, input().split()))
#a = [list(map(int,input().split(" "))) for i in range(N)]   #2次元


#a.sort() # C++ の sort(a.begin(), a.end());
#a.append(3) # C++ の a.push_back(3);


#exit(0) # return 0 的な。終了できる。
## 整数の切り捨て除算は // (ダブルスラッシュ)

import math
import copy
#math.gcd(a, b) で、gcd 計算できる。
#math.pi は円周率。

INF = 10**18 #べき乗 C++ の pow(10, 18) or 1e18;
pi = math.pi

MOD = 1000000007
#MOD = 1000000009
#MOD = 998244353




#繰り返し2乗法
#N^aの、Mで割った余りを求める。
def my_pow(N, a, M):
    if(a == 0):
        return 1
    else:
        if(a % 2 == 0):
            tempo = my_pow(N, a/2, M)
            return (tempo * tempo) % M
        else:
            tempo = my_pow(N, a - 1, M)
            return (tempo * N) % M




#N_C_a を M で割った余り
def my_combination(N, a, M):
    res = 1

    for i in range(0, a):
        res *= N - i
        res %= M

    for i in range(0, a):
        res *= my_pow(i + 1, M - 2, M)
        res %= M

    return res




#N_C_i を M で割った余りを、v[i] に代入する。
def my_combination_table(N, M, v):
    if(len(v) < N + 1):
        l = N + 1 - len(v)
        tempo = [1] * l
        v.extend(tempo)

    for i in range(1, N + 1):
        v[i] = v[i - 1] * (N - (i - 1))
        v[i] %= M

        v[i] *= my_pow(i, M - 2, M)
        v[i] %= M

    return




#math.factorial で階乗は計算できる。
#math.gcd で gcd は計算できる。


N, D = (int(x) for x in input().split())
X = []
Y = []

for i in range(0, N):
    p, q = (int(x) for x in input().split())
    X.append(p)
    Y.append(q)

res = 0

for i in range(0, N):
    if(X[i] * X[i] + Y[i] *Y[i] <= D * D):
        res += 1


print(res)




Measured memory_bytes: 25296
import java.util.Scanner;
import java.lang.Math;
import java.util.ArrayList;
import java.util.List;
//List<Integer> list = new ArrayList<>();

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		//int k = stdIn.nextInt();
		double[] x = new double[n];
		String[] u = new String[n];
		for (int i = 0; i < n; i++) {
			x[i] = stdIn.nextDouble();
			u[i] = stdIn.next();
		}
		double sum = 0.0;
		for (int i = 0; i < n; i++) {
			if (u[i].equals("JPY"))
				sum = sum + x[i];
			else
				sum = sum + x[i] * 380000;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 23124
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;

int par[110000]; //親
int ran[110000]; //木の深さ
int diff_weight[110000]; //親ノードとの値の差分

// n要素を初期化
void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    ran[i]=0;
  }
}

//木の根を求める
int find(int x){
  if(par[x]==x){
    return x;
  }else{
    //経路圧縮の際に重みも更新
    int r=find(par[x]);
    diff_weight[x]+=diff_weight[par[x]];
    return par[x]=r;
  }
}

int weight(int x){
  find(x); //経路圧縮
  return diff_weight[x];
}


//xとyの属する集合を併合
void unite(int x,int y,int w){
  w+=weight(x); w-=weight(y);
  x=find(x);
  y=find(y);
  if(x==y) return;

  if(ran[x]<ran[y]) swap(x,y),w=w*(-1);

  if(ran[x]==ran[y]) ran[x]++;
  par[y]=x;

  diff_weight[y]=w;

}

//xとyが同じ集合に属するか否か
bool same(int x,int y){
  return find(x)==find(y);
}


int diff(int x,int y){
  return weight(y)-weight(x);
}

int main(){
  bool flag=true;
  int N,M,l,r,d;
  cin>>N>>M;
  init(N+1);
  for(int i=0;i<M;i++){
    cin>>l>>r>>d;
    if(same(l,r) && diff(l,r)!=d){
      flag=false;
      //cout<<l<<" "<<r<<" "<<diff(l,r)<<endl;
    } 
    else unite(l,r,d);
  }

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







Measured memory_bytes: 1408
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

U = 2*10**5
MOD = 10**9+7
 
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
 
for i in range(1,U+1):
    fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U], MOD-2, MOD)
 
for i in range(U,0,-1):
    fact_inv[i-1] = (fact_inv[i]*i)%MOD

n = int(input())
T = [[] for _ in range(n)]
for _ in range(n-1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  T[a].append(b)
  T[b].append(a)
size = [0]*n
par = [-1]*n
dp1 = [-1]*n
dp2 = [-1]*n
def dfs1(p, v):
  if dp1[v] != -1:
    return dp1[v]
  temp = 1
  s = 1
  for nv in T[v]:
    if nv == p:
      continue
    temp *= dfs1(v, nv)
    temp *= fact_inv[size[nv]]
    temp %= MOD
    par[nv] = v
    s += size[nv]
  size[v] = s
  temp *= fact[s-1]
  temp %= MOD
  dp1[v] = temp
  return temp
dfs1(-1, 0)
def dfs2(v):
  if v == 0:
    return dp1[0]
  if dp2[v] != -1:
    return dp2[v]
  temp = dfs2(par[v])
  temp *= fact[n-size[v]-1]
  temp *= fact[size[v]]
  temp %= MOD
  temp *= fact_inv[size[v]-1]
  temp *= fact_inv[n-size[v]]
  temp %= MOD
  dp2[v] = temp
  return temp
for i in range(n):
  print(dfs2(i))

Measured memory_bytes: 79192
#include "stdio.h"

int main()
{
	//文字変数を作る
	char A=' ', B=' ';

	//標準入力
	scanf("%c %c",&A,&B);

	//AとBが一致するとき、Topcodeerは正直者である
	if (A == B)
		printf("H");
	else
		printf("D");

    return 0;
}



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

typedef long long int llint;

int main()
{
  llint ans = 0;
  string str;
  int n;
  llint m, a, r, c, h;
  m = a = r = c = h = 0;
  
  cin>> n;

  for(int i = 0; i < n; i++){
    cin>> str;
    if(str[0] == 'M') m++;
    if(str[0] == 'A') a++;
    if(str[0] == 'R') r++;
    if(str[0] == 'C') c++;
    if(str[0] == 'H') h++;
  }

  ans += m * a * r;
  ans += m * a * c;
  ans += m * a * h;
  ans += m * r * c;
  ans += m * r * h;
  ans += m * c * h;
  ans += a * r * c;
  ans += a * r * h;
  ans += a * c * h;  
  ans += r * c * h;  
  
  cout<< ans <<endl;

  return 0;
}


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

struct Node{
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL){
    y = x;
    if( z->key < x->key){
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  } else {
    if (z->key < y->key){
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

bool isExist(int k, Node *x){
  if (x == NIL) return false;
  if(x->key == k) return true;
  else if(k < x->key) isExist(k, x->left);
  else isExist(k, x->right);
}

Node * find(Node *u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

Node * getMinimum(Node *x){
  while( x->left != NIL){
    x = x->left;
  }
  return x;
}

Node * getSuccessor(Node *x){
  if (x->right != NIL) return getMinimum(x->right);
  Node *y = x->parent;
  while (y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void deleteTree(Node *z){
  Node *y;
  Node *x;
  if(z->left == NIL || z->right == NIL) y = z;
  else y = getSuccessor(z);

  if(y->left != NIL) x = y->left;
  else x = y->right;

  if(x != NIL) x->parent = y->parent;
  if(y->parent == NIL) root = x;
  else if (y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;

  if(y != z) z->key = y->key;
  free(y);
}


void inorder(Node *u){
  if (u == NIL) return;
  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);
}

void preorder(Node *u){
  if (u == NIL) return;
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);
}



int main() {
    ios::sync_with_stdio(false);

    int n, x;
    string com;
    cin >> n;
    for(int i=0; i<n; i++){
      cin >> com;
      if(com == "insert"){
        cin >> x;
        insert(x);
      } else if (com == "find") {
        cin >> x;
        isExist(x, root) ? cout << "yes\n" : cout << "no\n";
      } else if(com == "delete") {
        cin >> x;
        deleteTree(find(root, x));
      } else if (com == "print"){
        inorder(root);
        cout << "\n";
        preorder(root);
        cout << "\n";
      }
    }
    return 0;
}

Measured memory_bytes: 19976
N = int(input())
C_0 = 0
C_1 = 0
C_2 = 0
C_3 = 0
for _ in range(N):
    S = input()
    if S == 'AC':
        C_0 += 1
    elif S == 'WA':
        C_1 += 1
    elif S == 'TLE':
        C_2 += 1
    else:
        C_3 += 1
print('AC x {}'.format(C_0))
print('WA x {}'.format(C_1))
print('TLE x {}'.format(C_2))
print('RE x {}'.format(C_3))


Measured memory_bytes: 8924
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define FOR(i,a,b) for (int i = (a) ; i <= (b); ++i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい



void Main(){
	ll N, m;
	string ans = "";
	cin >> N;

	while(N > 0){
		string p;
		N--;
		m = N%26;
		p = 'a' + m;
		ans = p + ans;
		N /= 26;
	}


	cout << ans << endl;


}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=c && c<=b){
		cout<<"Yes"<<endl;	
	}else{
		cout<<"No"<<endl;
	}
	
	// your code goes here
	return 0;
}

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

using namespace std;
typedef long long ll;
#define F first
#define S second

const int N = (1<<18);

ll n, c;
vector<pair<ll, ll>> iv;
vector<ll> d[2];

ll st[2][2*N];

ll res = 0;

void muuta(int t, int k, ll x) {
	k += N;
	st[t][k] = x;
	for (k /= 2; k >= 1; k /= 2) {
		st[t][k] = max(st[t][2*k], st[t][2*k+1]);
	}
}

ll rmq(int t, int a, int b) {
	a += N; b += N;
	ll cres = -1000000000000000005;
	while (a <= b) {
		if (a%2 == 1) cres = max(cres, st[t][a++]);
		if (b%2 == 0) cres = max(cres, st[t][b--]);
		a /= 2; b /= 2;
	}
	return cres;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> c;
	for (int i = 1; i <= n; ++i) {
		ll cx, cv;
		cin >> cx >> cv;
		iv.push_back({cx, cv});
	}
	ll cde = 0;
	ll cp = 0;
	for (int i = 0; i < n; ++i) {
		ll cdi = iv[i].F-cp;
		cde += (iv[i].S-cdi);
		cp = iv[i].F;
		muuta(0, i, cde);
		res = max(res, cde);
		d[0].push_back(cde);
	}
	cde = 0;
	cp = 0;
	for (int i = n-1; i >= 0; --i) {
		ll cdi = c-iv[i].F-cp;
		cde += (iv[i].S-cdi);
		cp = c-iv[i].F;
		muuta(1, n-1-i, cde);
		res = max(res, cde);
		d[1].push_back(cde);
	}

	for (int i = 0; i < n-1; ++i) {
		ll nde = d[0][i];
		nde -= iv[i].F;
		nde += (rmq(1, 0, (n-1)-(i+1)));
		res = max(res, nde);
	}
	for (int i = 0; i < n-1; ++i) {
		ll nde = d[1][i];
		nde -= c-iv[n-i-1].F;
		nde += (rmq(0, 0, (n-1)-(i+1)));
		res = max(res, nde);
	}
	cout << res << "\n";
	return 0;
}

Measured memory_bytes: 11376
N = int(input())
a = list(map(int, input().split()))
ma = a.index(max(a))+1
mi = a.index(min(a))+1
print(2*N-1)

if (abs(max(a)) >= abs(min(a))):
    for i in range(1, N+1):
        print(str(ma) + " " + str(i))
    for i in range(1, N):
        print(str(i) + " " + str(i+1))
else:
    for i in range(1, N+1):
        print(str(mi) + " " + str(i))
    for i in reversed(range(2, N+1)):
        print(str(i) + " " + str(i-1))

Measured memory_bytes: 3064
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    a,b = map(int,input().strip().split())
    # 100*a//8 <= x < 100*(a+1)//8
    # range(100*a//8,100*(a+1)//8)
    x=100*a//8
    while True:
        if 100*b <= 10*x < 100*(b+1) and 100*a <= 8*x < 100*(a+1):
            print(x)
            return
        if 10*x > 100*(b+1) and 8*x > 100*(a+1):
            print(-1)
            return
        x+=1
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 62828
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
	int n;
	int a,c;
	
	cin >> n;

	for (int i = 1;; ++i) {
		if (n <= i*(i + 1) / 2) {
			a = i;
			break;
		}
	}

	c = a*(a + 1) / 2 - n;
	for (int i = 1; i <= a; ++i) {
		if (i !=c) {
			cout << i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int D;
    scanf("%d",&D);
    if(D==25)
    printf("Christmas");
    else if(D==24)
    printf("Christmas Eve");
    else if(D==23)
    printf("Christmas Eve Eve");
    else if(D==22)
    printf("Christmas Eve Eve Eve");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int f[12][12];
int main()
{
	int n,d,cnt1=0;
	cin>>n>>d;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=d;j++)
			cin>>f[i][j];
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++)
		{
			double cnt=0;
			for(int k=1;k<=d;k++)
				cnt+=abs(f[i][k]-f[j][k])*abs(f[i][k]-f[j][k]);
			if(sqrt(cnt)==int(sqrt(cnt)))
				cnt1++;
		}
	cout<<cnt1<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int n; ll a[401];

//累積和

ll b[404];
void init(){
    b[0]=a[0];
    rep(i, 1, n) b[i]=b[i-1]+a[i];
}

ll get(int l, int r){
    ll res = b[r];
    if(l) res-=b[l-1];
    return res;
}

//

ll memo[404][404];
int vis[404][404];
ll dp(int l, int r){
    if(l==r) return 0;
    if(vis[l][r]) return memo[l][r];
    vis[l][r]=1;
    
    ll res=LLINF;
    rep(c, l, r)chmin(res, dp(l,c)+dp(c+1,r)+get(l,r));
    return memo[l][r]=res;
}   

int main(){
    cin>>n;
    rep(i,0,n)cin>>a[i];
    init();
    cout<<dp(0,n-1)<<endl;
}

Measured memory_bytes: 2176