akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <queue>
using namespace std;

int N;
priority_queue<double> Q;

int main(void) {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		double v;
		cin >> v;
		Q.push(-v);
	}
	for (int i = 1; i <= N - 1; ++i) {
		double v1 = Q.top(); Q.pop();
		double v2 = Q.top(); Q.pop();
		Q.push((v1 + v2) / 2.0);
	}
	double ans = -Q.top();

	cout << fixed << setprecision(7) << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#define io ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
const int maxn=1e6+10;
ll a[maxn],pre[maxn];//,sum[maxn];
const int mod=1e9+7;
void solve(){
    int n;cin>>n;
    int a,b,last=0;
    int ans=0,ok=0;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        if(a==b){last=1;ans++;if(ans==3)ok=1;}
        else {last=0;ans=0;}
    }
    if(ok)cout<<"Yes\n";
    else cout<<"No\n";
}
int main(){
    io;
    //int T;cin>>T;
    //while(T--)
        solve();
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define  pb push_back
#define sort1(v) sort(v.begin(),v.end())
#include <sstream>
//cout<<fixed<<setprecision(n)<<number - for n digits after decimal
long long int max(ll a,ll b)
{
    if(a>b)
        return a;
    else
        return b;
}
void print(vector<int>arr)
{
    for(int i=0;i<(int)arr.size();i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
}
// A modular inverse based solution to
// compute nCr % p
long long int power(long long int x,
						ll y,ll p)
{
	long long int res = 1; // Initialize result

	x = x % p; // Update x if it is more than or
	// equal to p

	while (y > 0) {
		// If y is odd, multiply x with result
		if (y & 1)
			res = (res * x) % p;

		// y must be even now
		y = y >> 1; // y = y/2
		x = (x * x) % p;
	}
	return res;
}

// Returns n^(-1) mod p
long long int modInverse(long long int n,long long int p)
{
	return power(n, p - 2, p);
}

// Returns nCr % p using Fermat's little
// theorem.
long long int ncr(ll n,
								ll r, ll p)
{
	if(r>n)
        return 0;
	if (r == 0)
		return 1;

	// Fill factorial array so that we
	// can find all factorial of r, n
	// and n-r
	long long int fac[n + 1];
	fac[0] = 1;
	for (long long int i = 1; i <= n; i++)
		fac[i] = (fac[i - 1] * i) % p;

	return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p;
}

void upd(int a[],int l,int r,int num)
{
    for(int i=l;i<=r;i++)
        a[i]+=num;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    ll x[n],y[n],add[n],subs[n];
    for(int i=0;i<n;i++)
    {
        cin>>x[i]>>y[i];
        add[i]=x[i]+y[i];
        subs[i]=x[i]-y[i];
        //cout<<add[i]<<" "<<subs[i]<<"\n";
    }
    sort(add,add+n);
    sort(subs,subs+n);
    ll ans=max(add[n-1]-add[0],subs[n-1]-subs[0]);
    cout<<ans<<"\n";


}








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

N, M = map(int, input().split())
abM = [list(map(int, input().split())) for i in range(M)]

transit = []
transit2 = []
for i in range(M):
    if abM[i][0] == 1:
        transit.append(abM[i][1])
    if abM[i][1] == N:
        transit2.append(abM[i][0])

# setで共通要素の集合を取ってみる
if len(set(transit) & set(transit2)) != 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 61028
#include <bits/stdc++.h>
#define ll unsigned long long

using namespace std;

int main() {
    ll n,k;
    cin >>n>>k;
    vector<char> s;
    for(ll i=0;i<n;i++) {
        char tmp;
        cin >> tmp;
        s.push_back(tmp);
    }
    s[k-1] = tolower(s[k-1]);
    for(ll i=0;i<n;i++) {
        cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64, i64> P;
#define rep(i, s, e) for (int i = (s); i <= (e); i++)

int a, b;

int ans[101][101];

string word = " .#";

int main() {
  cin >> a >> b;
  for (int i = 0; i < 49; i++) {
    for (int j = 0; j < 100; j++) {
      ans[i][j] = 1;
    }
  }
  for (int i = 49; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      ans[i][j] = 2;
    }
  }
  b--;
  a--;
  {
    int cou = 1;
    while (b > 0) {
      for(int j = 1;j < 100 && b > 0;j+=2){
        ans[cou][j] = 2;
        b--;
      }
      cou += 2;
    }
  }
  {
    int cou = 98;
    while (a > 0) {
      for(int j = 1;j < 100 && a > 0;j+=2){
        ans[cou][j] = 1;
        a--;
      }
      cou -= 2;
    }
  }

  cout << 100 << " " << 100 << endl;

  for(int i = 0;i < 100;i++){
    for(int j = 0;j < 100;j++){
      cout << word[ans[i][j]];
    }
    cout << endl;
  }
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }




signed main() {

	string S, T;
	cin >> S >> T;
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		if (S[i] == T[i]) ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def main():
    import sys
    input = sys.stdin.readline
    ans = "No"
    A = [list(map(int,input().split())) for i in range(3)]
    N = int(input())
    B = [int(input()) for i in range(N)]
    for b in B:
        for i in range(3):
            for j in range(3):
                if A[i][j] == b:
                    A[i][j] = False
    for a in A:
        if not any(a):
            ans = "Yes"
    for a_c in zip(*A):
        if not any(a_c):
            ans = "Yes"
    if A[0][0] == False and A[1][1] == False and A[2][2] == False:
        ans = "Yes"
    if A[0][2] == False and A[1][1] == False and A[2][0] == False:
        ans = "Yes"

    print(ans)

if __name__ == "__main__":
    main()


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

using namespace std;

int main(){
    int n, k, c = 0;
    cin >> n >> k;
    int arr[n];
    for (int i = 0; i < n; i++){
        cin >> arr[i];
    }
    sort(arr, arr+n);
    for (int i = 0; i < k ;i++){
        c += arr[i];
    }
    cout << c;
    return 0;
}




Measured memory_bytes: 3652
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
int d[300];

int main(){
	while(cin>>n){
		rep(i,n){
			cin>>d[i];
		}
		int p = 0;
		unsigned long long int dp[100][22]={0};//dp[i][j]
		dp[0][d[0]] = 1;
		for(int i = 1;i < n-1;i++){
			for(int j = 0;j <=20;j++){
				if(dp[i-1][j]>0){
					if(j+d[i] <=20){
						dp[i][j+d[i]] +=dp[i-1][j];
					}
					if(j-d[i]>=0)
						dp[i][j-d[i]] +=dp[i-1][j];
				}
			}
		}
		int sum = 0;
		for(int i = 0;i <=100000;i++){
			sum +=1;
		}
		cout <<dp[n-2][d[n-1]]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a*b%2==0)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

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

class Main {
    static int[] days = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

    static boolean isLeap(int y) {
        return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));
    }

    static int yTod(int y) {
        if (isLeap(y))
            return 366;
        else
            return 365;
    }

    static int myTod(int m, int y) {
        if (m == 2 && isLeap(y))
            return 29;
        else
            return days[m];
    }

    static int dmyTod(int d, int m, int y) {
        int res = 0;
        int month = 0;
        while (++month < m) {
            res += myTod(month, y);
        }
        res += d;
        return res;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;

        int y1, m1, d1, y2, m2, d2;
        while ((line = br.readLine()) != null) {
            String[] input = line.split(" ");
            y1 = Integer.parseInt(input[0]);
            m1 = Integer.parseInt(input[1]);
            d1 = Integer.parseInt(input[2]);
            y2 = Integer.parseInt(input[3]);
            m2 = Integer.parseInt(input[4]);
            d2 = Integer.parseInt(input[5]);
            if (y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) {
                break;
            }

            long sum = 0;
            if (y1 < y2) {
                sum += yTod(y1) - dmyTod(d1, m1, y1) + 1;
                y1++;
                m1 = 1;
                d1 = 1;
            }

            while (y1 < y2) {
                sum += yTod(y1++);
            }

            sum += dmyTod(d2, m2, y2) - dmyTod(d1, m1, y1);

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


Measured memory_bytes: 24484
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  string s;
  while(cin >> s){
    for(int i=0;i<s.size();i++){
      if(s[i]!='@')cout << s[i];
      else{
        n=s[i+1]-'0';
        for(int j=0;j<n;j++){
          cout << s[i+2];
        }
        i+=2;
      }
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3220
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

template <typename M>
struct SegmentTree
{
	const int n;
	const M I;
	const std::function<M(M,M)> f;
	std::vector<M> data;
	SegmentTree(int n, M I, std::function<M(M,M)> f) : n(n), data(2*n,I), I(I), f(f) {}
	void set(int i, const M& v) {
		data[n+i]=v;
	}
	void build() {
		for(int i=n-1;i>0;i--) {
			data[i]=f(data[i<<1],data[i<<1|1]);
		}
	}
	void update(int i, const M& v) {
		set(i,v);
		i+=n;
		for(i>>=1;i>0;i>>=1) {
			data[i]=f(data[i<<1],data[i<<1|1]);
		}
	}
	M get(int i) {
		return data[n+i];
	}
	M query(int l, int r) {
		M L=I, R=I;
		l+=n; r+=n;
		while(r>l) {
			if(l&1) L=f(L,data[l++]);
			if(r&1) R=f(data[--r],R);
			l>>=1; r>>=1;
		}
		return f(L,R);
	}
};


signed main() {
	int n,k,q;
	std::cin >> n >> k >> q;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	const int INF=1e14;
	int min=INF;
	rep(ii,n) {
		int x=a[ii];
		std::vector<std::pair<int,int> > b;
		for(int i=0;i<n;) {
			while(i<n && a[i]<x) i++;
			int start=i;
			while(i<n && a[i]>=x) i++;
			if(i>start) b.emplace_back(start,i);
		}
		std::vector<int> take;
		for(auto p:b) {
			int l=p.first,r=p.second;
			if(r-l<k) continue;
			std::vector<int> xx;
			for(int i=l;i<r;i++) xx.emplace_back(a[i]);
			std::sort(all(xx));
			rep(i,r-l-k+1) take.emplace_back(xx[i]);
		}
		std::sort(all(take));
		if(take.size()<q) continue;
		min=std::min(min,take[q-1]-x);
	}
	print(min);
	return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int D[101000], D2[101000], n;
vector<int>E[101000];
void DFS(int a, int pp, int d) {
	D[a] = d;
	int i;
	for (i = 0; i < E[a].size(); i++) {
		if (E[a][i] != pp)DFS(E[a][i], a, d + 1);
	}
}
int main() {
	int i, a, b;
	scanf("%d", &n);
	for (i = 1; i < n; i++) {
		scanf("%d%d", &a, &b);
		E[a].push_back(b);
		E[b].push_back(a);
	}
	DFS(n, 0, 0);
	for (i = 1; i <= n; i++)D2[i] = D[i];
	DFS(1, 0, 0);
	int r1 = 0, r2 = 0;
	for (i = 1; i <= n; i++) {
		if (D[i] <= D2[i])r1++;
		else r2++;
	}
	if (r1 > r2)printf("Fennec\n");
	else printf("Snuke\n");
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define eF(i,u) for(int i=h[u];i;i=nxt[i])
#define Mod 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll,int> pli;

int n,m,S,T;
ll Ans;
int U[200001],V[200001],D[200001];
int h[100001],nxt[400001],to[400001],w[400001],tot;
void ins(int x,int y,int z){nxt[++tot]=h[x];to[tot]=y;w[tot]=z;h[x]=tot;}

ll d1[100001],d2[100001],g1[100001],g2[100001];bool v1[100001],v2[100001];
priority_queue<pli,vector<pli>,greater<pli> > pq;

void Dij(ll*d,ll*g,bool*v,int s){
    d[s]=0ll;
    pq.push(pli(0ll,s));
    g[s]=1;
    while(!pq.empty()){
        pli P=pq.top(); pq.pop();
        int u=P.second; ll du=P.first;
        if(v[u]||d[u]<du) continue;
        v[u]=1;
        eF(i,u){
            if(d[to[i]]==du+w[i])
                g[to[i]]=(g[to[i]]+g[u])%Mod;
            if(d[to[i]]>du+w[i])
                g[to[i]]=g[u],
                d[to[i]]=du+w[i], pq.push(pli(d[to[i]],to[i]));
        }
    }
}

int main(){
    int x,y,z;
    scanf("%d%d",&n,&m);
    scanf("%d%d",&S,&T);
    F(i,1,m) scanf("%d%d%d",&x,&y,&z), ins(x,y,z), ins(y,x,z), U[i]=x, V[i]=y, D[i]=z;
    memset(d1,0x3f,sizeof d1);
    Dij(d1,g1,v1,S);
    memset(d2,0x3f,sizeof d2);
    Dij(d2,g2,v2,T);
    ll Dist=d1[T];
    Ans=g1[T]*g1[T]%Mod;
    F(i,1,n){
        if(d1[i]+d2[i]==Dist&&d1[i]==d2[i])
            Ans=(Ans-g1[i]*g1[i]%Mod*g2[i]%Mod*g2[i]%Mod)%Mod;
    }
    int u,v,d;
    F(i,1,m){
        u=U[i], v=V[i], d=D[i];
        if(d1[u]+d+d2[v]==Dist && d1[u]+d>d2[v] && d2[v]+d>d1[u]){
            Ans=(Ans-g1[u]*g2[v]%Mod*g1[u]%Mod*g2[v]%Mod)%Mod;
        }
        u=V[i], v=U[i], d=D[i];
        if(d1[u]+d+d2[v]==Dist && d1[u]+d>d2[v] && d2[v]+d>d1[u]){
            Ans=(Ans-g1[u]*g2[v]%Mod*g1[u]%Mod*g2[v]%Mod)%Mod;
        }
    }
    printf("%lld",(Ans%Mod+Mod)%Mod);
    return 0;
}

Measured memory_bytes: 12656
n=int(input())
a=sorted(list(map(int,input().split())))[::-1]
mod=10**9+7
ans=1
j=a[0]
for i in range(1,n):
  if i%2:
    if a[i]!=j:
      print(0)
      break
    else:ans=2*ans%mod
  else:j=a[i]
else:print(ans%mod)

Measured memory_bytes: 20448
#include<bits/stdc++.h>
using namespace std;
int main(){
	string st;
	cin>>st;
	int s=0,ans=atoi(st.c_str());
	for(int i=0;i<st.length();i++){
		s+=(int(st[i])-48); 
	}
	if(ans%s==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
// C - Factors of Factorial
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define irp(i,n) for(int i=(n);i>=0;i--)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define dw(i,s,e,d) for(int i=(s);i>(e);i-=(d))
// #define in(x) cin>>(x)
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define vecmax(v) (*max_element(v.begin(),v.end()))
void bye(auto x, int code=0){cout<<(x)<<endl;exit(code);}
// int in(){int x;cin>>x;return x;}
int in(){int x;scanf("%d",&x);return x;}
// template<class T> T in(){T x;cin>>x;return x;}

void vprn(vector<int> &v){ for(int i=0;i<v.size();i++) cout<<v[i]<<(i<v.size()-1?",\t":"\n"); }
void vvprn(vector<vector<int>> &vv){ for(auto v:vv) vprn(v); }

// template<class T> void vprn(T &v, string s, string m, string e)
// {cout<<s;for(int i=0;i<v.size();i++)cout<<v[i]<<m;cout<<e;}
// template<class T> void vvprn(T &vv, string s, string m, string e)
// {for(auto v:vv) vprn(v,s,m,e);}

map<int, int> prime_count;

int div_count(int n, int d){
	while(n%d==0){
		prime_count[d]++;
		n /= d;
	}
	return n;
}

void prime_create(int n){
	n = div_count(n,2);
	int d=3;
	while(n!=1){
		n = div_count(n,d);
		d += 2;
	}
}

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

	dw(i,n,1,1){
		prime_create(i);
	}

	// ote(prime_count.size());
	// for(auto e:prime_count){
	// 	cout<<e.first<<","<<e.second<<"\n";
	// }

	ll ans = 1;
	for(auto e:prime_count){
		ans = ans * (e.second+1) % MOD;
	}
	ote(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC

const int N = 20007;
vector <int> ans;

const int K = 10;

void solve(int n) {
    vector <int> p;
    int pref = max(2ll, n - K); 
    int cur = 0;
    for (int i = 0; i < pref; ++i) {
        p.app(ans[i]);    
        cur += ans[i];
        cur %= 6;
    }

    if (n == 3) {
        cout << "2 5 63" << endl;
        exit(0);
        return;
    }   

    int r = n - pref;
    for (int mask = 0; mask < (1 << (2 * K)); ++mask) {
        if (bp(mask) == r) {
            int add = 0;
            for (int i = 0; i < (2 * K); ++i) {
                if ((mask >> i) & 1) {
                    add += ans[pref + i];
                }   
            }   
            if ((cur + add) % 6 == 0) {
                for (int i = 0; i < (2 * K); ++i) {
                    if ((mask >> i) & 1) {
                        p.app(ans[pref + i]);
                    }   
                }
                for (int e : p)
                    cout << e << ' ';
                cout << endl;
                exit(0);
            }   
        }   
    }

    cout << "GG" << endl;  
    exit(1);
    
}

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    for (int i = 1; i <= 30000; ++i) {
        if (i % 6 == 0 || i % 6 == 2 || i % 6 == 3 || i % 6 == 4) {
            ans.app(i);
        }
    }   
    
    int n;
    cin >> n;
    solve(n);
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main() {
    int N;
    long long int M;
    cin >> N >> M;
    vector<long long int> A(N);
    vector<long long int> Asum(N+1, 0);
    int Cnt[200001]={0};
    for(int n=0; n<N; n++) {
        cin >> A[n];
        Cnt[A[n]]++;
    }

    sort(A.begin(), A.end(), greater<long long int>());
    for(int n=0; n<N; n++) {
        Asum[n+1] = Asum[n]+A[n];
    }

    for(int i=199999; i>=0; i--) {
        Cnt[i] += Cnt[i+1];
    }
    // for(int i=40; i>=0; i--) {
    //     cout << i << ": " << Cnt[i] << endl;
    // }

    
    long long int l=1, r=200001;
    long long int counter=0;
    long long int ans;
    long long int X;
    map<long long int, long long int> mp;
    while(r-l>1) {
        X=(l+r)/2;
        long long int counter=0;
        ans=0;
        for(int n=0; n<N; n++) {
            counter += Cnt[(int)max(X-A[n], (long long int)0)];
            
            ans += (Asum[Cnt[(int)max(X-A[n], (long long int)0)]]+A[n]*Cnt[(int)max(X-A[n], (long long int)0)]);
        }
        
        if(counter>=M) {
            l = X;
        } else {
            r = X;
        }
        
        mp[X] = counter;
    }

    if(l==X) {
        cout << ans-abs(M-mp[l])*l << endl;
    } else if(r==X) {
        cout << ans+abs(M-mp[r])*l << endl;
    }

    return 0;
    
}

Measured memory_bytes: 2560
while true do
  num=Array.new(3)
  str=gets.chomp
  number=str.split
  num[0]=number[0].to_i
  num[1]=number[1].to_i
  num[2]=number[2].to_i
  if num[0]==-1 && num[1]==-1 && num[2]==-1 then
    break
  else
    if num[0]==-1 || num[1]==-1 then
      puts "F"
    elsif num[0]+num[1]>=80 then
      puts "A"
    elsif num[0]+num[1]>=65 then
      puts "B"
    elsif num[0]+num[1]>=50 then
      puts "C"
    elsif num[0]+num[1]>=30 then
      if num[2]>=50 then
        puts "C"
      else
        puts "D"
      end
    else
      puts "F"
    end
  end
end

Measured memory_bytes: 8672
#include <iostream>
#include <string>
using namespace std;
int main(void){

    string x,y;
    cin >> x >> y; 
    

    if(x>y) cout << ">" << endl;
    else if (x<y) cout << "<" << endl;
    else cout << "=" << endl;
           
     return 0;   
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; cin >> n;
  ll cnt = 0;
  for(ll a = 1; a < n; a++){
      for(ll b = 1; a * b < n; b++){
          cnt++;
      }
  }
  cout << cnt << ln;  
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    int n;
    cin >> n;
    vector<int> x(n);

    int n_min = 101;
    int n_max = -1;
    rep(i, n){
        int tmp;
        cin >> tmp;
        x[i] = tmp;
        n_min = min(n_min, tmp);
        n_max = max(n_max, tmp);
    }

    int d_min = 300000;
    for(int i = n_min; i <= n_max; ++i){
        int dist = 0;
        rep(j, n){
            dist += (i - x[j]) * (i - x[j]);
        }
        d_min = min(d_min, dist);
    }

    cout << d_min << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define 	pb	push_back 
#define 	ff	first 
#define 	ss	second 
using namespace std;
typedef long long ll;
inline void debug() {
	#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin); 
	freopen("output.txt", "w", stdout);
	#endif
	}
int main(){
ll a;
cin>>a;
cout<<a+a*a+a*a*a;





}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1e9
//S.size()

using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;

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

  bool jud = false;


  for(int t = 0;t < S.size();t++){
    if(S.substr(t,S.size() / 2) == T)jud = true;
  }
  cout<<(jud?"Yes":"No");

}


Measured memory_bytes: 256
a = raw_input()
b = raw_input()

l = len(a)
if a == b:
    print "Yes"
else:
    state = 0
    for i in range(l-1):
        a = a[-1]+a[0:-1]
        if a == b:
            print "Yes"
            state = 1
            break
    if state == 0:
        print "No"


Measured memory_bytes: 2568
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
tmp = []

for i in range(n):
    x = t - h[i] * 0.006
    if a >= x:
        TMP = a - x
        tmp.append(TMP)
    else:
        TMP = x - a
        tmp.append(TMP)

for i in range(n):
    if tmp[i] == min(tmp):
        print(i+1)

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

int main() {
string n;
  cin >>n;
  for(int i =0;i<3;i++){
if(n.at(i)=='1'){
  n.at(i)='9';
}
    else if(n.at(i)=='9'){
      n.at(i)='1';
    }
  }
  cout <<n <<endl;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

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

    double b = 0.0;
    rep(i, N) {
        b += 1.0 / A[i];
    }

    write(1.0 / b);
}

Measured memory_bytes: 256
n = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

cnt = 0
for i in range(n+1):
  if len(make_divisors(i)) == 8 and i%2 == 1:
    cnt = cnt + 1
print(cnt)

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9+7;
const ll INF = 1e18;
const int MAX = 1e5;

// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -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;
}

struct edge {int to, cost;}; // 辺
vector<edge> graph[MAX]; // 隣接リスト
bool visit[MAX]; // 訪問状況
int indeg[MAX]; // 頂点の入次数
vector<int> t_sort; // トポロジカルソート
int n, m; // 変数
int dp[MAX]; // 頂点vを始点としたときの最長路の長さ

void bfs() {
    queue<int> q;
    rep(i, n) {
        if (indeg[i] == 0) {
            q.push(i);
        }
    }
    while (not q.empty()) {
        int cur = q.front();
        q.pop();
        t_sort.push_back(cur);
        for (edge e : graph[cur]) {
            int adj = e.to;
            indeg[adj]--;
            if (indeg[adj] == 0) {
                q.push(adj);
                chmax(dp[adj], dp[cur] + 1);
            }
        }
    }
}

int main() {
// input
    cin >> n;
    cin >> m;
    rep(i, m) {
        int from, to;
        cin >> from;
        cin >> to;
        from--; to--;
        graph[from].push_back({to, 0});
        indeg[to]++;
    }
// solve
    bfs();
    int ans = 0;
    rep(i, n) {
        chmax(ans, dp[i]);
    }
// output
    cout << ans << "\n";
}

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

int main(){
  long long n,d;
  cin >> n >> d;
  int ans = 0;
  for(int i = 0; i < n; i++){
    long long a,b;
    cin >> a >> b;
    if(sqrt((long double)((long long)a * a + (long long)b * b)) <= d){
      ans++;
    }
  }
  cout << ans << endl;
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	int n;
	cin >> n;
	string s;
	string ans;
	cin >> s;

	stack<char> st;
	for(int i=0; i<n; i++){
		if(s[i] == '('){
			st.push(s[i]);
			ans += '(';
		}else if(s[i] == ')'){
			if(!st.empty() && st.top() == '('){
				st.pop();
				ans += ')';
			}else{
				ans += ')';
				ans = '(' + ans;
			}
		}
		//cout << ans << endl;
	}
	while(!st.empty()){
		ans += ')';
		st.pop();
	}

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String line = br.readLine();
        int num = Integer.parseInt(line);
        
        ArrayList<String> list = new ArrayList<String>();
        
        for (int i = 0; i < num; i++) {
            list.add(br.readLine());
        }
        
        for (int i = 1; i <= 13; i++) {
            if(list.contains("S " + i) == false){
                System.out.println("S " + i);
            }
        }
        
        for (int i = 1; i <= 13; i++) {
            if(list.contains("H " + i) == false){
                System.out.println("H " + i);
            }
        }
        
        for (int i = 1; i <= 13; i++) {
            if(list.contains("C " + i) == false){
                System.out.println("C " + i);
            }
        }
        
        for (int i = 1; i <= 13; i++) {
            if(list.contains("D " + i) == false){
                System.out.println("D " + i);
            }
        }
    }
}

Measured memory_bytes: 24300
package main

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

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60
const mod int = 1e9 + 7

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()

	p := make([]int, n)
	for i := 0; i < n; i++ {
		p[i] = ri()
	}

	ans := 0
	for i := 2; i < n; i++ {
		x, y, z := p[i-2], p[i-1], p[i]
		if (x >= y && y >= z) || (x <= y && y <= z) {
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cstring>



#define REP(i, n) for (long long i = 0; i < (n); i++) 
#define ll long long

using namespace std;

int main(){
    ll a,b;
    cin >> a >> b;
    string res = "Even";

    if(a % 2 == 1 && b % 2 == 1)res = "Odd";

    cout << res << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200011;
int main() {
  int n, m, a, b;
  scanf("%d%d%d%d", &n, &m, &a, &b);
  vector<vector<int>> ans(n, vector<int>(m));
  for (int i = 0; i < b; ++i) {
    for (int j = 0; j < a; ++j) {
      ans[i][j] = 1;
    }
  }
  for (int i = b; i < n; ++i) {
    for (int j = a; j < m; ++j) {
      ans[i][j] = 1;
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      printf("%d", ans[i][j]);
    }
    puts("");
  }
  return 0;
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<bool> done(N);
  vector<vector<int>> levels(N, vector<int>(N));

  bool completed = false;
  for (int next_level = 0; !completed; ++next_level) {
    completed = true;
    for (int i = 0; i < N; ++i) {
      if (!done[i]) {
        bool skip = false;
        done[i] = true;
        for (int j = i + 1; j < N; ++j) {
          if (levels[i][j] == 0) {
            if (!skip) {
              skip = true;
              levels[i][j] = next_level;
            } else {
              skip = false;
            }
            done[i] = false;
            completed = false;
          }
        }
      }
    }
  }

  for (int i = 0; i < N; ++i) {
    bool first = true;
    for (int j = i + 1; j < N; ++j) {
      if (first)
        first = false;
      else
        cout << " ";
      cout << levels[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 1536
import sys
input=sys.stdin.readline

def main():
    S = input().strip()
    for i,c in enumerate(S):
        if i%2 == 0:
            if c == "L":
                print("No")
                return
        if i%2 == 1:
            if c == "R":
                print("No")
                return
    print("Yes")

if __name__ == '__main__':
    main()


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

using namespace std;

int main()
{
    int N;
    cin >> N;

    string S,T;
    cin >> S >> T;

    string ans;
    for (int i = 0; i < N; i++) {
        ans.push_back(S[i]);
        ans.push_back(T[i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a, b, c, d, e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if (e - a > k){
        cout << ":(" << endl;
    }
    else {
        cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <cmath>

using namespace std;

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

    int k;
    if(n>=b-1){
        cout<<floor(a*(b-1)/b)<<endl;
        return 0;
    }else{
        cout<<floor(a*n/b)<<endl;
    }

    return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
string s;
int n; 
int w;
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	cin>>n>>s;
	int ans=0;
	rep(i,n)if(s[i]=='W')w++;
	rep(i,n-w){
		if(s[i]=='W')ans++;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3780
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
#define ref goto refrain
int main(){
	double x1,x2,y1,y2;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	double a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	printf("%lf\n",a);
	return 0;
}

Measured memory_bytes: 1236
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<stack>
#include<cmath>
#include<vector>
using namespace std;
int n,m;
int p[120000],y[120000];
vector<int> o[120000];
int main(){
  scanf("%d%d",&n,&m);
  for(int i=0;i<m;i++)scanf("%d%d",p+i,y+i),p[i]--;
  for(int i=0;i<m;i++)o[p[i]].push_back(y[i]);
  for(int i=0;i<n;i++)sort(o[i].begin(), o[i].end());
  for(int i=0;i<m;i++)printf("%06d%06d\n",p[i]+1,lower_bound(o[p[i]].begin(), o[p[i]].end(),y[i])-o[p[i]].begin()+1);
  return 0;
}

Measured memory_bytes: 8192
#include "bits/stdc++.h"
using namespace std;
int a[111][111];
int par[111];
int bad[111];
int n;

int bfs(int p) {
	memset(par, -1, sizeof par);
	queue <int> Q;
	Q.push(p);
	par[p] = p;

	int q = -1;

	while(!Q.empty()) {
		int x = Q.front();
		Q.pop();
		for(int i = 1; i <= n; i++) {
			if(a[x][i] != 0 && par[i] == -1) {
				par[i] = x;
				Q.push(i);
			}
		}
		if(bad[x] && p != x) {
			q = x;
			break;
		}
	}
	if(q == -1) return -1;
	bad[p] = bad[q] = false;
	while(q != p) {
		int nxt = par[q];
		a[nxt][q] *= -1;
		a[q][nxt] *= -1;
		q = nxt;
	}
	return q;
} 

int cmp[111];
void dfs(int x, int comp) {
	cmp[x] = comp;
	for(int i = 1; i <= n; i++) {
		if(a[x][i] != 1 && cmp[i] == 0) {
			dfs(i, comp);
		}
	}
}

void connector() {
	int comp = 0;
	vector <int> v;
	for(int i = 1; i <= n; i++) {
		if(cmp[i] == 0) {
			dfs(i, ++comp);
			v.push_back(i);
		}
	}
	if(v.size() == 1) return ;
	if(v.size() > 2) {
		for(int i = 0; i < v.size(); i++) {
			int p = v[i];
			int q = v[(i + 1) % v.size()];
			a[p][q] = a[q][p] = -1;
		}
		return ;
	}
	for(int i = 1; i <= n; i++) {
		for(int j = i + 1; j <= n; j++) {
			if(cmp[i] == cmp[j] && a[i][j] == -1) {
				a[i][j] = a[j][i] = 1;
				int piv = v[0];
				if(cmp[piv] == cmp[i]) piv = v[1];
				a[piv][i] = a[i][piv] = -1;
				a[piv][j] = a[j][piv] = -1;
				return ;
			}
		}
	}
	vector <int> p, q;
	for(int i = 1; i <= n; i++) {
		if(cmp[i] == cmp[v[0]]) {
			p.push_back(i);
		} else q.push_back(i);
	}

	if(p.size() > q.size()) swap(p, q);
	vector <int> alternating;
	while(true) {
		if(alternating.size() & 1) {
			if(p.empty()) break;
			alternating.push_back(p.back());
			p.pop_back();
		} else {
			if(q.empty()) break;
			alternating.push_back(q.back());
			q.pop_back();
		}
	}
	if(alternating.size() < 4) {
		puts("-1");
		exit(0);
	}
	alternating.resize(4);
	for(int i = 0; i < 4; i++) {
		int p = alternating[i];
		int q = alternating[(i + 1) % 4];
		a[p][q] = a[q][p] = -1;
	}
	return ;
}

int main(int argc, char const *argv[])
{
	int m;
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			if(i != j) a[i][j] = 1;
		}
	}
	for(int i = 1; i <= m; i++) {
		int p, q;
		scanf("%d %d", &p, &q);
		a[p][q] = a[q][p] = 0;
		bad[p] ^= 1;
		bad[q] ^= 1;
	}
	for(int i = 1; i <= n; i++) {
		if(bad[i]) {
			int q = bfs(i);
			if(q == -1) {
				puts("-1");
				exit(0);
			}
		}
	}
	connector();
	int cnt = 0;
	for(int i = 1; i <= n; i++) {
		for(int j = i + 1; j <= n; j++) {
			cnt += (a[i][j] == -1);
		}
	}
	printf("%d\n", cnt);
	for(int i = 1; i <= n; i++) {
		for(int j = i + 1; j <= n; j++) {
			if(a[i][j] == -1) {
				printf("%d %d\n", i, j);
			}
		}
	}
	return 0;
}


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

using namespace std;

template<typename T>
struct node {
    T value;
    node<T>* left;
    node<T>* right;
    
    node(T v) : value(v), left(NULL), right(NULL) {}
    ~node() {
        if(left!=NULL) delete left;
        if(right!=NULL) delete right;
    }
    
    template<class Func>
    void preorder(Func f) {
        f(value);
        if(left!=NULL) left->preorder(f);
        if(right!=NULL) right->preorder(f);
    }
    
    template<class Func>
    void inorder(Func f) {
        if(left!=NULL) left->inorder(f);
        f(value);
        if(right!=NULL) right->inorder(f);
    }
};

template<typename T>
struct BST {
    node<T>* root;
    
    BST() : root(NULL) {}
    ~BST() {
        if(root!=NULL) delete root;
    }
    
    void insert(T v) {
        node<T>** insertp = &(root);
        node<T>* cur = root;
        while(cur != NULL) {
            if(v < cur->value) {
                insertp = &(cur->left);
                cur = cur->left;
            } else {
                insertp = &(cur->right);
                cur = cur -> right;
            }
        }
        *insertp = new node<T>(v);
    }
    
    template<class Func>
    void inorder(Func f) {
        if(root!=NULL) root->inorder(f);
    }
    
    template<class Func>
    void preorder(Func f) {
        if(root!=NULL) root->preorder(f);
    }
};

int main() {
    int n;
    cin >> n;
    BST<int>* bst = new BST<int>();
    for(int i=0; i<n; i++) {
        string cmd;
        cin >> cmd;
        if(cmd=="insert") {
            int v;
            cin >> v;
            bst->insert(v);
        } else if(cmd=="print") {
            bst->inorder([](int v){cout << " " << v;});
            cout << endl;
            bst->preorder([](int v){cout << " " << v;});
            cout << endl;
        }
    }
    delete bst;
}


Measured memory_bytes: 18692
n,a,b,c,d=map(int,input().split())
s=input()
for i in range(a,d-1):
	if s[i]==s[i+1]=="#":
		print("No")
		exit()
three=0
s="#"+s+"#"
for i in range(b,d+1):
	if s[i]==s[i+1]==s[i-1]==".":
		three=True
if c<d:
	print("Yes")
elif three==True:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,a,b,c,d,i,j,k,sum;
    cin>>a>>b>>c>>d;
    while(1)
    {
        c=c-b;
        if(c<=0)
        {
            cout<<"Yes";
            break;
        }
        a=a-d;
        if(a<=0)
        {
            cout<<"No";
            break;
        }
    }

}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	ll n,a,b;
	cin >> n >> a >> b;
	ll cnt = n/(a+b);
	ll left = n % (a+b);
	cout << (cnt * a + min(a,left)) << '\n';
}


Measured memory_bytes: 256
n, m = map(int, input().split())

A = []
B = []
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        A.append(b)
    if b == n:
        B.append(a)

if len(set(A) & set(B)) >= 1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

int main() {
  int N, K;
  cin >> N >> K;
  long long ans = K;
  for (int i = 1; i <= N - 1; i++) {
    ans *= (K - 1);
  }
  cout << ans << endl;
  return 0;
}

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

namespace AtCoder02
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            string a = input[1] + input[0];
            Console.WriteLine(a);
        }
    }
}


Measured memory_bytes: 11092
N = int(input())
strings = []
for i in range(N):
    strings.append(input())
ans = 0
acount = 0
bcount = 0
abcount = 0
for i in range(N):
    for j in range(len(strings[i])-1):
        if strings[i][j:j+2] == "AB":
            ans += 1
    if strings[i][0] == "B" and strings[i][-1] == "A":
        abcount += 1
    elif strings[i][0] == "B":
        bcount += 1
    elif strings[i][-1] == "A":
        acount += 1

if abcount > 0:
    ans += abcount-1
    if acount > 0:
        ans += 1
        acount -= 1
    if bcount > 0:
        ans += 1
        bcount -= 1
    ans += min(acount, bcount)
else:
    ans += min(acount, bcount)
print(ans)


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

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;

    if (x - r >= 0 && x + r <= W  && y - r >= 0 && y + r <= H) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3124
// Knapsack 1
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define times(t) int t; cin >> t; while(t--)
#define mod 1000000007
#define pb push_back
#define mp make_pair

void solve() {
	int n, W; cin >> n >> W;
	ll dp[n+1][W+1];
	int wev[n][2];
	for(int i=0; i<n; i++) {
		cin >> wev[i][0] >> wev[i][1];
	}
	memset(dp, -1, sizeof(dp));
	for(int i=0; i<=n; i++) dp[i][0] = 0;
	for(int i=0; i<=W; i++) dp[0][i] = 0;
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=W; j++) {
			if(wev[i-1][0] <= j) {
				dp[i][j] = max(dp[i-1][j], dp[i-1][j-wev[i-1][0]] + wev[i-1][1]);
			}
			else {
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	// for(int i=0; i<=n; i++) {
	// 	for(int j=0; j<=W; j++) {
	// 		cout << dp[i][j] << ' ';
	// 	}
	// 	cout << endl;
	// }
	cout << dp[n][W] << endl;
	return;
}

int main() {
	IOS;
	// #ifndef ONLINE_JUDGE
	// freopen("C:/Gen code/CompProg/input.txt", "r", stdin);
	// freopen("C:/Gen code/CompProg/output.txt", "w", stdout);
	// #endif
	solve();
	return 0;
}

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

char tolower(char c) {
  return (c + 0x20);
}

int main() {
    int N,K;
    string S;
    cin >> N >> K >> S;
    S[K-1] = tolower(S[K-1]);
    cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    unsigned long long r,c;
    while(cin>>r>>c){
        if(r==1||c==1)cout<<"1\n";
        else if((r*c)%2==0)cout<<(r*c)/2<<endl;
        else
            cout<<((r*c)+1)/2<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    string s;
    cin >> s;
    int count = 0,ans = 0;
    for(int i = 0;i < s.size();i++)
    {
        if(s[i] == 'A' || s[i] == 'G' || s[i] == 'C' || s[i] == 'T')
        {
            count++;
        }
        else
        {
            if(ans < count){ans = count;}
            count = 0;
        }
    }
    if(ans < count){ans = count;}
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int a, b;
  	cin >> a >> b;
  	if(a>b) rep(i,a) cout << b;
    else rep(i,b) cout << a;  
	return;
}

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

Measured memory_bytes: 256
/*
sonu_verma1
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(a) push_back(a)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
	int a[]={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<<a[k-1]<<endl;


	return 0;
}

Measured memory_bytes: 256