akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>=10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int k,int mod){
	int res=1,bas=x;
	while(k){
		if(k&1) res=1ll*res*bas%mod;
		bas=1ll*bas*bas%mod,k>>=1;
	}
	return res;
}
const int N = 2e3+5;
int n,x,y,ans[N];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(x),read(y);
	for(ri i=1;i<n;++i)
		for(ri j=i+1;j<=n;++j){
			if(j<=x) ++ans[j-i];
			else if(i>=y) ++ans[j-i];
			else if(i<=x&&j>=x&&j<=y) ++ans[min(j-i,x-i+1+y-j)];
			else if(i>=x&&i<=y&&j>=y) ++ans[min(j-i,j-y+1+i-x)];
			else if(i<=x&&j>=y) ++ans[x-i+1+j-y];
			else ++ans[min(j-i,i-x+y-j+1)];
		}
	for(ri i=1;i<n;++i) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0:
        break
    Num_lis = list(map(int,input().split()))
    New_lis = []
    num = 0
    while True:
        for i in range(n):
            New_lis.append(Num_lis.count(Num_lis[i]))
        if Num_lis == New_lis:
            break
        num += 1
        Num_lis = New_lis
        New_lis = []
    print(num)
    ans = str(Num_lis[0])
    for j in range(1,n):
        ans = ans + " " + str(Num_lis[j])
    print(ans)

Measured memory_bytes: 7576
#include "bits/stdc++.h"
using namespace std;

const int MXN = 3005;
int dp[MXN][MXN];
int par[MXN][MXN];

int n, m;
string s, t;

int solve(int a, int b) {
	// a from string s and b from string t to consider
	
	if (dp[a][b] != -1) return dp[a][b];
	
	if (a == n || b == m) {
		// lcs of empty and anything is empty
		par[a][b] = 0;
		return dp[a][b] = 0;
	}
	if (s[a] == t[b]) {
		// if char a and b are same
		par[a][b] = 3;
		return dp[a][b] = 1 + solve(a+1, b+1);
	}
	// if they're not, then skip either a or b
	int best = 0;
	int skipb = solve(a, b+1);
	if (skipb > best) {
		par[a][b] = 1;
		best = skipb;
	}
	int skipa = solve(a+1, b);
	if (skipa > best) {
		par[a][b] = 2;
		best = skipa;
	}
	return dp[a][b] = best;
	
}

void retrav(int a, int b) {
	if (par[a][b] == 0) return;
	if (par[a][b] == 1) {
		retrav(a, b+1);
	}
	if (par[a][b] == 2) {
		retrav(a+1, b);
	}
	if (par[a][b] == 3) {
		cout << s[a];
		retrav(a+1, b+1);
	}
}

int main() {
	for (int i=0; i<MXN; i++) for (int j=0; j<MXN; j++) dp[i][j] = -1;
	cin >> s >> t;
	n = s.size();
	m = t.size();
	solve(0, 0);
	retrav(0, 0);
	
}


Measured memory_bytes: 70784
nums = input()
while(nums != '0 0'):
    d = nums.split(' ')
    n1 = int(d[0])
    n2 = int(d[1])

    if(n1 > n2):
        print('{0} {1}'.format(n2, n1))
    else:
        print('{0} {1}'.format(n1, n2))

    nums = input()


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ;
  cin >> n;
  int ans = 111;
  
  while(ans<n){
    ans += 111;
  }
  
  cout << ans ; 


}


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

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

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

    int ans = 0;
    if(n >= 10) {
        ans = r;
    } else {
        ans = r + 100 * (10 - n);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
object Main {

  def loop(exp: Array[String]):Unit={
    if(!exp.contains("?")){
      println(exp(1) match {
        case "+" => exp(0).toInt+exp(2).toInt
        case "-" => exp(0).toInt-exp(2).toInt
        case "*" => exp(0).toInt*exp(2).toInt
        case "/" => exp(0).toInt/exp(2).toInt
      })
      loop(readLine.split(" "))
    }
  }

  def main(args: Array[String]): Unit = loop(readLine.split(" "))
}

Measured memory_bytes: 43752
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define rrep1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

vector<vector<int>> g;

int main() {
    int n, m; cin >> n >> m;
    g.resize(n);
    rep(i, m) {
        int u, v; cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
    }
    int s, t; cin >> s >> t;
    s--; t--;

    vector<vector<ll>> dist(n, vector<ll>(3, -1));
    dist[s][0] = 0;
    queue<pii> q;
    q.emplace(s, 0);
    while (!q.empty()) {
        pii now = q.front(); q.pop();
        int u = now.first;
        int parity = now.second;
        for (auto v: g[u]) {
            int np = (parity + 1) % 3;
            if (dist[v][np] == -1) {
                dist[v][np] = dist[u][parity] + 1;
                q.emplace(v, np);
            }
        }
    }

    if (dist[t][0] == -1) {
        cout << -1 << endl;
    } else {
        cout << dist[t][0] / 3 << endl;
    }
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  map<int, int> m;
  rep(i, n) {
    int a;
    cin >> a;
    m[a]++;
  }
  for(auto p : m) {
    if(p.second > 1) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES"<< endl;
  return 0;
}

Measured memory_bytes: 9600
N = int(input())
D = sorted(map(int, input().split()))
M = int(input())
T = sorted(map(int, input().split()))
i = 0
for t in T:
    while D[i] < t:
        i += 1
    if D[i] == t:
        i += 1
    else:
        print('NO')
        exit()
print('YES')


Measured memory_bytes: 35420
#include<bits/stdc++.h>
#define  ll  unsigned long long int
#define  sz  200010

using namespace std;




int main()
{

    ll n,m,i,j,k,a,b;

    cin>>n>>m;
    n--;
    m--;
    n=(n*(n+1))/2;
    m=(m*(m+1))/2;

    cout<<n+m<<endl;

    return 0;
}


Measured memory_bytes: 256
def checkContinuous(line, memo, count, w)
    1.upto(w-1) do |i|
        if line[i] === "#" && line[i-1] === "#" then
            memo[count][i] = 1
            memo[count][i-1] = 1
        end
    end
end

def main(h, w)
    s = []
    memo = Array.new(h).map{Array.new(w,0)}
    count = 0
    h.times do
        line = gets.chomp.split("")
        s << line
        checkContinuous(line, memo, count, w)
        count += 1
    end
    s = s.transpose
    memo = memo.transpose
    count = 0
    s.each do |arr|
        checkContinuous(arr, memo, count, h)
        arr.each_with_index do |item, index|
            if item === "#" && memo[count][index] === 0 then
                print "No"
                exit
            end
        end 
        count += 1
    end
    print "Yes"
end

h, w = gets.chomp.split(" ").map(&:to_i)
if w===1 then
    if h === 1 then
        gets
        puts "No"
        exit
    end
    c = []
    memo = Array.new(h, 0)
    h.times do
        c << gets.chomp.to_s
    end
    (1...h).each do |i|
        if c[i] == "#" && c[i-1] == "#" then
            memo[i] = 1
            memo[i-1] = 1
        end
    end
    c.each_with_index do |item, index|
        if item === "#" && memo[index] === 0 then
            print "No"
            exit
        end
    end
    print "Yes"
    exit
end
main(h, w)

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

class Work {
public:
	long long cost;
	long long limit;

	Work() {

	}
	Work (long long c, long long l) {
		cost = c;
		limit = l;
	}
	bool operator<(const Work &another) const{
		return limit < another.limit;
	} 
};

int N;
vector<Work> works;

int main(){
	int N;
	cin >> N;
	works = vector<Work>(N);

	for (int i = 0; i < N; i++)
	{
		cin >> works[i].cost;
		cin >> works[i].limit;
	}

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

	long long sum = 0;
	for (int i = 0; i < N; i++)
	{
		sum += works[i].cost;
		if ( sum > works[i].limit) {
			cout << "No" << endl;
	cin >> N;
			return 0;
		}
	}
	cout << "Yes" << endl;
	cin >> N;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	while(true){
		int N;
		cin >> N;
		if(N == 0)break;
		vector<int> A(N);
		for(int i = 0; i < N; i ++)cin >> A[i];
		sort(all(A));
		int ans = 10000000;
		for(int i = 0; i < N - 1; i ++){
			ans = min(ans, abs(A[i] - A[i + 1]));
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3144
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = true;

int main(){

    int W, a, b;
    cin >> W >> a >> b;

    if(a <= b && (a + W) >= b ){
        cout << 0 << endl;
    }
    else if(b <= a && (b + W) >= a  ){
        cout << 0 << endl;
    }
    else{
        cout << min( { abs(b - (a+W) ), abs(b - a ), abs(b+W - a) } ) << endl;
    }


}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define Yes "Yes"
#define No "No"
#define YESNO OUT(three(solve(),YES,NO))
#define YesNo OUT(three(solve(),Yes,No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b-1);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,zero,b)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 3e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p =   998244353;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;
ut N, M, K, L, Q, D, H, W,R;
LL vals[SIZE], answer = zero;
int A[SIZE],B[SIZE];string s[SIZE];
Vpr edges[SIZE];
LL dist[SIZE];
LL C[SIZE];
set<int> withes;
map<int,int> mpa,mpb,mpc;
LL solve(){
	cin >> N;
	VI VA,VB;
	REP(i,N){
		cin >> A[i];
		VA.pb(A[i]);
	}
	REP(i,N){
		cin >> B[i];
		VB.pb(B[i]);
	}
	sort(ALL(VA));
	sort(ALL(VB));
	REP(i,N) if(VA[i]>VB[i]) return 0;
	FOR(i,1,N) if(VA[i]<=VB[i-1]) return 1;
	REP(i,N) {
		mpa[VA[i]]=i;
		if(i) assert(VA[i]!=VA[i-1]);
	}
	REP(i,N){
		mpb[VB[i]]=i;
		if(i) assert(VB[i]!=VB[i-1]);
	}
	REP(i,N) A[i]=mpa[A[i]];
	REP(i,N) B[i]=mpb[B[i]];
	REP(i,N) mpc[A[i]]=i;
	int st=0;
	REP(i,N){
		st=mpc[B[st]];
		if(i!=N-1 and st==0) return 1;
		if(i==N-1 and st==0) return 0;
	}
	assert(0);
	return 1;
}

signed main() {
 
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	string s;
	YesNo;
 
 
	//cin >> N;
	return 0;
 
}


Measured memory_bytes: 34804
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest051-B
#  https://atcoder.jp/contests/abc051/tasks/abc051_b
from itertools import product
def  queueAnswer(maxValue,sumNumber):
	baseList = list(range(0,maxValue+1,1))
	xyPool = product(baseList,baseList)
	counter = 0
	for x,y in xyPool:
		z = sumNumber - x - y
		if ( 0 <= z ) and ( z <= maxValue):
			counter = counter + 1

	answer = counter
	return answer


if __name__ == '__main__':
	k,s = map(int,input().strip().split(' '))
	solution=queueAnswer(k,s)
	print(solution)

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
map<int, int> mp;
int main()
{
	int n, d, x;
	cin >> n >> d >> x;
	vector<int> a(n);
	int ans = x;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) {
		ans += (d + a[i] - 1) / a[i];
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    while(1){
        int N;
        cin >> N;
        if(N==0)
            break;
        int s[111];
        for (int i = 0; i < N; i++)
            cin >> s[i];
        int M=-1, m=1111, sum = 0; // M:最大値, m:最小値
        for (int i = 0; i < N;i++){
            M = max(M, s[i]);
            m = min(m, s[i]);
            sum += s[i];
        }
        int ans = (sum - M - m) / (N - 2);
        cout << ans << endl;
    }
}


Measured memory_bytes: 3040
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,a[100];
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    sort(a,a+n);
    ll ans=0;
    while(true){
        bool ok=true;
        rep(i,n){
            if(a[i]>=n){
                ok=false;
                break;
            }
        }
        if(ok) break;
        ll s=a[n-1]/n;
        a[n-1]%=n;
        ans+=s;
        rep(i,n-1){
            a[i]+=s;
        }
        sort(a,a+n);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
# Title: count Shichi-Go-San numbers under N
# Link: https://abc114.contest.atcoder.jp/tasks/abc114_c

import sys


sys.setrecursionlimit(10 ** 6)

read_single_int = lambda: int(sys.stdin.readline().strip())


def dfs(s: str, n: int, count: list):
    if int(s) > n:
        return
    if s.count('3') >= 1 and s.count('5') >= 1 and s.count('7') >= 1:
        count[0] += 1
    
    dfs(s+'3', n, count)
    dfs(s+'5', n, count)
    dfs(s+'7', n, count)


def solution(n: int):
    count = [0]
    dfs('0', n, count)
    return count[0]


def main():
    n = read_single_int()
    print(solution(n))


if __name__ == '__main__':
    main()

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

int main(){
    int k;
    string s;
    cin >> k >> s;
    if(s.size()<=k){
        cout << s << endl;
        return 0;
    }
    else{
        cout << s.substr(0,k) + "..." << endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cstdlib>
#include <string>
#include <typeinfo>
#include <cstring>
#include <iostream>
using namespace std;

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

Node *root, *NIL;

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

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 * treeSuccessor(Node *x){
    if( x -> right != NIL)return treeMinimum(x -> right);
    Node *y = x -> parent;
    while(y != NIL && x == y -> right){
        x = y;
        y = y -> parent;
    }
    return y;
}

void treeDelete(Node *z){
    Node *y;
    Node *x;
    
    if(z -> left == NIL || z -> right == NIL)y = z;
    else y = treeSuccessor(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 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;
}

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(){
    int n,i,x;
    string com;
    
    cin >> n;
    
    for(i = 0; i < n; i++){
        cin >> com;
        if(com[0] == 'f'){
        cin >> x;
        Node *t = find(root, x);
        if(t != NIL)cout << "yes" << endl;
        else cout << "no" << endl;
        }else if(com == "insert"){
        cin >> x;insert(x);
       }else if(com == "print"){
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }else if(com == "delete"){
            cin >> x;
            treeDelete(find(root, x));
        }
    
    }
    return 0;
}






Measured memory_bytes: 21824
// Shinchan Loves Coding :)))
#include<bits/stdc++.h>
#include<map>
#include<set>
#include<stack>
using namespace std;

#define night_rider ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define double long double
#define en "\n"
#define fi first
#define se second
#define MP make_pair
#define PB push_back
typedef vector<int> vi;
typedef pair<int,int> vii;
bool secdes(const pair<int,int>&a , const pair<int,int>&b){if(a.se==b.se){return a.fi>b.fi;}else{return a.se>b.se;}}//second descending !
bool sir(const pair<int,int>&a , const pair<int,int>&b){if(a.fi==b.fi){return a.se>b.se;}else{return a.first>b.first;}}//first descending !
bool bysec(const pair<int,int>&a , const pair<int,int>&b){if(a.se==b.se){return a.fi<b.fi;} else{return a.se<b.se;}}//second ascending !

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/

const int no=4e5+5;
const int modulo=1e12+7;
int a[no]={},bb[no]={},vsd[no]={},suma[no]={};
stack<int> S;
stack<int> ma;

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/

signed main()
{
    night_rider
  //  freopen("input.txt","r",stdin);
  //  freopen("output.txt","w",stdout);

    int t=1; cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        if(s=="AC") a[1]++;
        else if(s=="WA") a[2]++;
        else if(s=="TLE") a[3]++;
        else a[4]++;
    }
    cout<<"AC x "<<a[1]<<en;
    cout<<"WA x "<<a[2]<<en;
    cout<<"TLE x "<<a[3]<<en;
    cout<<"RE x "<<a[4]<<en;
}


Measured memory_bytes: 3680
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map(String::toLong)
    val aList = readLine()!!.split(" ").map(String::toLong)
    val aMax = aList.max()!!
    val d = aList.reduce(::gcd)
    println(if (k % d == 0L && k <= aMax) "POSSIBLE" else "IMPOSSIBLE")
}

fun gcd(x: Long, y: Long): Long {
    return if (x < y) gcd(y, x) else if (x % y == 0L) y else gcd(y, x % y)
}

Measured memory_bytes: 51792
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b;
    char c;
    cin >> a >> c >> b;
    if(c == '+')
    {
        cout << a + b;
    }
    else
    {
        cout << a - b;
    }

    return 0;
}

Measured memory_bytes: 256
h,w,a,b=map(int,input().split())
for i in range(h):
    if i<b:
        print("1"*a+"0"*(w-a))
    else:
        print("0"*a+"1"*(w-a))
'''
行と列のそれぞれに注目して考えると、条件を満たすものであればそれぞれを入れ替えても条件を満たす(自分の都合のいいように行列を作ることができる)
↓
また、条件を満たすものであれば0と1を入れ替えても条件を満たす(0の個数にまずは注目して考える)
↓
入れ替えていってまずは行列を最終的には下のような形にすることができる
'''

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

int main() {
  int a, b;
  cin >> a >> b;
  int ans;
  if (a >= 13) ans = b;
  else if (a <= 12 && a>= 6) ans = b / 2;
  else if (a <= 5) ans = 0;
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {

            var a = Console.ReadLine().Trim();
            var cnt = 0;
            switch (a)
            {
                case "RRR":
                    cnt = 3;
                    break;
                case "SRR":
                    cnt = 2;
                    break;
                case "RRS":
                    cnt = 2;
                    break;
                case "RSS":
                    cnt = 1;
                    break;
                case "SSR":
                    cnt = 1;
                    break;
                case "RSR":
                    cnt = 1;
                    break;
                case "SRS":
                    cnt = 1;
                    break;
                case "SSS":
                    cnt = 0;
                    break;
                default:
                    cnt = 2;
                    break;
            }

            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 25832
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define RREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const long long INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int solve(){
  ll n;
  cin >> n;
  vector<ll>A(n),B(n),C(n);
  rep(i,n)cin >> A[i];
  rep(i,n)cin >> B[i];
  rep(i,n)cin >> C[i];
  sort(all(A));
  sort(all(C));
  ll ans = 0;
  rep(i,n){
    ll a = lower_bound(all(A),B[i]) - A.begin();
    ll b = n - (upper_bound(all(C),B[i]) - C.begin());
    ans += a * b;
  }
  cout<<ans<<endl;
  return 0;
}
int main(){
  ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 2688
S = input()

S_01 = int(S[0] + S[1])
S_23 = int(S[2] + S[3])

yymm_flag = False
mmyy_flag = False

if S_01 == 0 and S_23 == 0:
    yymm_flag = False
    mmyy_flag = False
    
if S_01 <= 12 and S_01 >= 1:
    mmyy_flag = True

if S_23 <= 12 and S_23 >= 1:
    yymm_flag = True

if yymm_flag == True and mmyy_flag == True:
    print('AMBIGUOUS')
elif mmyy_flag == True and yymm_flag == False:
    print('MMYY')
elif yymm_flag == True and mmyy_flag == False:
    print('YYMM')
else:
    print('NA')

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

int main() {

  char c;
   
  cin >> c;

  if( c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' ){
      
      cout << "vowel" << endl ;

  }

  else { cout << "consonant" << endl ;
  
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

int main() {
  int n;
  scanf("%d", &n);
  char a[n + 1];
  scanf("%s", a);
  int m;
  scanf("%d", &m);
  char k = a[m - 1];
  for (int i = 0; i < n; i++) {
    printf("%c", (a[i] == k ? a[i] : '*'));
  }
  puts("");
  return 0;
}

Measured memory_bytes: 128
function Main(input) {
    var input = input.split('\n');
    var a = input.slice(1,input.length).map(n => parseInt(n));
    var Filter = a.filter((x, i, self) => self.indexOf(x) === i);
    var result = Filter.length;
    console.log(result);
    }
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 11468
using System;

namespace ABC172
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int a = int.Parse(s);
            int ans = (int)(a + Math.Pow(a, 2) + Math.Pow(a, 3));
            Console.WriteLine(ans);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 27868
#include <stdio.h>
#include <string.h>

int main()
{
	char s[101];
	int k,i,n;
	scanf("%d",&k);
	scanf("%s",s);
    n=strlen(s);
	if(n>k) 
	{
		for(i=0;i<k;i++) printf("%c",s[i]);
		printf("...");
	}
	else printf("%s",s);
	puts("");
	
	return 0;
}

Measured memory_bytes: 1732
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ACirclePond solver = new ACirclePond();
        solver.solve(1, in, out);
        out.close();
    }

    static class ACirclePond {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            double r = in.nextInt();

            //out.print("Case #"+ testNumber + ": ");
            out.println(2d * Math.PI * r);
        }

    }

    static class FastReader {
        public BufferedReader br;
        public StringTokenizer st;
        String context = null;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            if (context != null) {
                System.err.print("[" + context + "] Wait for input ...");
            }
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                }
            }
            String res = st.nextToken();
            if (context != null) {
                System.err.println("[" + context + "] ... received : " + res);
            }
            return res;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 33340
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T*)array, (T*)(array+N), val);
}
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class BGreedyTakahashi {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll a, b, k;
        in >> a >> b >> k;

        ll newa = max(a - k, 0LL);
        ll newb = max(b - max(k - a, 0LL), 0LL);
        out << newa sp newb << endl;
	}
};


int main() {
	BGreedyTakahashi solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int N;
int main() {
	cin>>N;
	long long R=1;
	for(int i=1;i<N+1;i++){
		R=(R*i)%1000000007;
	}

	cout<<R<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    ll T; cin >> T;
    vecl t(N); REP(i,N) cin >> t[i];
    ll ans = 0;
    REP(i,N-1) {
        if(t[i]+T <= t[i+1]) ans += T;
        else ans += t[i+1]-t[i];
    }
    ans += T;
    cout << ans << endl;
}

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

typedef pair<int, int> P;

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

const int INF = 1e9;
const int INFLL = 1e18;
const int MOD = 1e9 + 7;

bool isPrime[1000000];

signed main(){
    fill( isPrime, isPrime + 1000000, true );
    isPrime[0] = isPrime[1] = false;

    FOR( i, 2, 1000000 ){
        if( isPrime[i] ){
            for( int j = i * i; j < 1000000; j += i ){
                isPrime[j] = false;
            }
        }
    }

    int a, d, n, cnt = 0;
    while( cin >> a >> d >> n, a | d | n ){
        cnt = 0;
        while( 1 ){
            if( isPrime[a] ) cnt++;
            if( cnt == n ) break;
            a += d;
        }
        cout << a << endl;
    }

}



Measured memory_bytes: 3976
from itertools import starmap
(lambda *_: None)(
    *map(print,
         (lambda board, pairs: starmap(board, pairs))(
             (lambda h, w:
                 (lambda rows: ''.join(map(lambda i: rows[i%2], range(h))))(
                     (lambda row: (row[:w]+'\n', row[1:w+1]+'\n'))(
                         '#.'*(w//2+1)))),
             map(lambda t: map(int, t),
                 map(str.split, iter(input, '0 0'))))))

Measured memory_bytes: 7808
from itertools import groupby


S = input()
X, Y = map(int, input().split())


def check(A, x, starts):
    S = set(starts)
    for a in A:
        new_S = set([])
        for s in S:
            new_S.add(s + a)
            new_S.add(s - a)
        S = new_S
    # print(S)
    return x in S

groups = groupby(S)
tmp = True
A = []
B = []
starts = None
which = None
init_T = None
for i, (k, g) in enumerate(groups):
    if k == "T":
        if len(list(g)) % 2 != 0:
            tmp = not tmp
    else:
        if starts is None:
            t = len(list(g))
            if S[0] == "T":
                starts = [t, -t]
            else:
                starts = [t]
            which = tmp
        else:
            if tmp:
                A.append(len(list(g)))
            else:
                B.append(len(list(g)))
# print(starts, which, A, B)

if starts is None:
    if X == 0 and Y == 0:
        print("Yes")
    else:
        print("No")
    exit()

if which:
    if check(A, X, starts) and check(B, Y, [0]):
        print("Yes")
    else:
        print("No")
else:
    if check(A, X, [0]) and check(B, Y, starts):
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3620
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
  public class Program
  {
    public static void Main(string[] args)
    {
      new Program().Solve(new ConsoleInput(Console.In, ' '));
    }

    public void Solve(ConsoleInput cin)
    {
      var a = cin.ReadInt;
      var b = cin.ReadInt;
      var c = cin.ReadInt;
      
      if ((a-c)*(b-c)>0) {
        WriteLine("No");
      } else {
        WriteLine("Yes");
      }
    }
  }

  public class ConsoleInput
  {
    private readonly System.IO.TextReader _stream;
    private char _separator = ' ';
    private Queue<string> inputStream;
    public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
    {
      this._separator = separator;
      this._stream = stream;
      inputStream = new Queue<string>();
    }
    public string Read
    {
      get
      {
        if (inputStream.Count != 0) return inputStream.Dequeue();
        string[] tmp = _stream.ReadLine().Split(_separator);
        for (int i = 0; i < tmp.Length; ++i)
          inputStream.Enqueue(tmp[i]);
        return inputStream.Dequeue();
      }
    }
    public string ReadLine { get { return _stream.ReadLine(); } }
    public int ReadInt { get { return int.Parse(Read); } }
    public long ReadLong { get { return long.Parse(Read); } }
    public double ReadDouble { get { return double.Parse(Read); } }
    public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
    public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
    public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
  }
}

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

int main() {
  int N, A, s = 0;
  cin >> N;

  for(int i = 0; i < N; i++){
    cin >> A;
    int cnt = 0;
    while(1){
      if(A % 2){
        break;
      }else{
        A /= 2;
        cnt++;
      }
    }
    if(s > cnt || i == 0)
      s = cnt;
  }
  cout << s << endl;
  
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
constexpr auto MAX = 10E9+1;
using namespace std;
using ll = long long;
using VI = vector<int>;

int main()
{   
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    for (int i = 0; i < k; i++) {
        if (c <= a) {
            c *= 2;
        }
        else if (c <= b) {
            c *= 2;
        }
        else if (b <= a) {
            b *= 2;
        }
    }

    if (a < b && b < c) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 3628
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
    --y;
  }

  return sum;
}

/*考えを書くスペース
  AtCoder Grand Contest 019-A

  動的計画法で解く
  ・dp[i][j]-残りがjリットルになるまでの最小の金額
  i - 番号？
  j - 残りのリットル数
  ・dp[j]-残りがjリットルになるまでの最小の金額
  j - 残りの金額

  メモ化再帰か動的計画法
  ->メモ化再帰で解いてみる
  ->まず全探索を書いてみる
*/
//main.cpp----------------------------


void solve();
ll dfs(ll);

ll n, q, h, s, d;

int main() {
  cin >> q >> h >> s >> d >> n;

  solve();

  return 0;
}

void solve() {

  h = min(h, q*2);
  s = min(s, h*2);

  if(2*s<=d) {
    cout << n*s << endl;
  }else {
    cout << (n/2)*d + (n%2)*s << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define INF (1<<29)

typedef pair<int, int> pii;

int d[3000][3000]; // ???i, j????????¢
int minCost[3000]; // ???i????????§???????????°??¢???????????§??????????????¢
bool shop[3000]; // ???i????????§???????????°??¢??????????????????
vector<pii> g[3000]; // to, cost
int n, m, k;

int main() {
	cin >> n >> m >> k;
	
	fill(d[0], d[n], INF);
	fill(minCost, minCost + n, INF);
	
	REP(i, m) {
		int a, b, l;
		scanf("%d %d %d", &a, &b, &l);
		a--; b--;
		g[a].push_back(pii(b, l));
		g[b].push_back(pii(a, l));
		d[a][b] = d[b][a] = l;
	}
	
	REP(i, k) {
		int pos;
		scanf("%d", &pos);
		pos--;
		shop[pos] = true;
		
	}
	
	REP(i, n) {
		priority_queue<pii, vector<pii>, greater<pii> > pq; // cost, pos
		pq.push(pii(0, i));
		
		vector<int> dist(n, INF);
		dist[i] = 0;
		while (!pq.empty()) {
			pii now = pq.top(); pq.pop();
			
			int ncost = now.first;
			int npos = now.second;
			
			if (dist[npos] < ncost) continue;
			
			if (shop[npos]) {
				minCost[i] = dist[npos];
				break;
			}
			
			REP(j, g[npos].size()) {
				int to = g[npos][j].first;
				int cost = ncost + g[npos][j].second;
				if (dist[to] > cost) {
					dist[to] = cost;
					pq.push(pii(cost, to));
				}
			}
		}
	}
	
	int ans = 0;
	REP(i, n) FOR(j, i + 1, n) {
		if (d[i][j] == INF) continue;
		ans = max(ans, (minCost[i] + minCost[j] + d[i][j] + 1) / 2);
	}
	cout << ans << endl;
	
	return 0;
}

//1:20

Measured memory_bytes: 41172
#include<stdio.h>
int main(void){
int i,j,H,W;
while(1){
scanf("%d %d",&H ,&W);
if (H == 0 && W == 0)break;
for(i=0;i < H;i++){
for(j=0;j < W;j++){
if ((i+j)%2 == 0){
printf("#");
}else{
printf(".");
}
}
printf("\n");
}
printf("\n");
}
return 0;
}

Measured memory_bytes: 572
import sys
a =[0] * 5
for i in range(5):
    a[i] = int(input())
k =int(input())
for i in range(4):
    for j in range(i+1,5):
        if a[j] -a[i] > k:
            print(':(')
            sys.exit()
print('Yay!')




Measured memory_bytes: 3060
package main

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

func main() {
	defer writer.Flush()
	H, W, A, B := ReadInt(), ReadInt(), ReadInt(), ReadInt()
	for y := 0; y < H; y++ {
		for x := 0; x < W; x++ {
			if (x < A && y < H-B) || (x >= A && y >= H-B) {
				Printf("0")
			} else {
				Printf("1")
			}
		}
		Println()
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}

var writer = bufio.NewWriter(os.Stdout)

func Printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }
func Println(a ...interface{})               { fmt.Fprintln(writer, a...) }


Measured memory_bytes: 1892
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
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; }
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,q; cin>>n>>q;
    string s; cin>>s;

    vector<ll> t(n+1,0);
    rep1(i,n-1){
        if(s[i-1] == 'A' && s[i] == 'C' ) t[i]++;
        t[i+1] = t[i]; 
    }

    rep(i,q){
        int l,r;cin>>l>>r;
        cout<<t[r-1] -t[l-1]<<endl;
    }
}

Measured memory_bytes: 4216
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int a[10001];
	cin>>n;
	
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	cout<<a[0]<<" ";
	sort(a,a+n,greater<int>());
	cout<<a[0]<<" ";
	long long sum=0;
	for(int i=0;i<n;i++){
		sum+=a[i];
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int A, B;
	
	cin>>A>>B;
	
	for(int i = 0, con = 1; ; i++, con += A-1){
		if(con >= B){
			cout<<i<<endl;
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a-1;i>=(ll)b;i--)
#define Fi first
#define Se second
typedef pair<ll, ll> pll;
const ll MAX = 100;
const char ENDL = '\n';
ll N, M, sub = 0;
string S, T, Ans;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	cin >> S >> T;
	Ans = S;
	bool unres = true;
	repr(i, S.size(), 0) {
		bool flag = true;
		if ((S[i] == T[0])||(S[i]=='?')) {
			rep1(j,T.size()){
				if ((S[i + j] == T[j]) || (S[i + j] == '?'))
					continue;
				else {
					flag = false;
					break;
				}
			}
			if (flag == true) {
				rep(k, T.size())
					Ans[i + k] = T[k];
				unres = false;
				break;
			}
		}
	}
	if (unres == false) {
		rep(i, S.size()) {
			if (Ans[i] == '?')
				Ans[i] = 'a';
		}
		cout << Ans << ENDL;
	}
	else
		cout << "UNRESTORABLE" << ENDL;

	return 0;
}

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

# n<= 10**9なので、高速化する
# 約数列挙でroot N に抑えるか？
def prime_divide(n):
    res = []
    i = 2
    while True:
        if n % i == 0:
            res.append(i)
            n //= i
        else:
            i += 1
            if i > n ** (0.5):
                break
    if n != 1:
        res.append(n)
    return res


print(n, end="")
print(":", *prime_divide(n))



Measured memory_bytes: 5648