akhauriyash/Code-Regression huggingface dataset:
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<llint>&ar,llint in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<llint>&ar,llint in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int n,x,sai=mod;cin>>n>>x;
	for(int i=0;i<n;i++){
		int m;cin>>m;x-=m;
		mineq(sai,m);
	}
	cout<<n+x/sai<<endl;
	return 0;
}

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

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		float x1, y1, x2, y2, x3, y3;
		scanf("%f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3);
		float a = (x2 - x3)*(x2 - x3) + (y2 - y3)*(y2 - y3);
		float b = (x1 - x3)*(x1 - x3) + (y1 - y3)*(y1 - y3);
		float c = (x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2);
		float s = ((x2-x1)*(y3-y1) - (x3-x1)*(y2-y1)) / 2;
		float x = (a*(b + c - a)*x1 + b*(c + a - b)*x2 + c*(a + b - c)*x3) / (16*s*s);
		float y = (a*(b + c - a)*y1 + b*(c + a - b)*y2 + c*(a + b - c)*y3) / (16*s*s);
		float r = sqrt((x-x1)*(x-x1) + (y-y1)*(y-y1));
		printf("%.3f %.3f %.3f\n", x, y, r);
	}
	return 0;
}


Measured memory_bytes: 2652
from collections import OrderedDict
n = int(input())
s_list = list()
for i in range(n):
    s_list.append(input())

dictionary_list = list()
    
for s in s_list:
    dictionary = dict()
    for w in s:
        if w in dictionary:
            dictionary[w] += 1
        else:
            dictionary[w] = 1
    dictionary_list.append(dictionary)

first = dictionary_list[0]
pop_list = list()

for key,value in first.items():
    for dictionary in dictionary_list[1:]:
        if key in dictionary:
            first[key] = min(first[key],dictionary[key])
        else:
            pop_list.append(key)

for p in pop_list:
    if p in first:
        first.pop(p)
          
first = OrderedDict(sorted(first.items(),key=lambda x: x[0]))
t = ""
for k,v in first.items():
    t += k*v
print(t)

Measured memory_bytes: 3444
package main

import "fmt"

const inf = 1 << 60

func diff(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func chmin(a *int, b int) {
	if *a > b {
		*a = b
	}
}

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}

	r := 0
	for i := 0; i < n; i++ {
		r += as[i]
	}

	l := 0
	minDiff := inf
	for i := 0; i < n-1; i++ {
		l += as[i]
		r -= as[i]
		chmin(&minDiff, diff(l, r))
	}
	fmt.Println(minDiff)
}


Measured memory_bytes: 6784
#include <iostream>
#include <complex>
#include <cstdio>
#include <cmath>
#define x real()
#define y imag()
using namespace std;
typedef complex <double> point;

double dot(point a,point b){
  return a.x*b.x+a.y*b.y;
}

double cross(point a,point b){
  return a.x*b.y-a.y*b.x;
}

int ccw(point a,point b,point c){
  point d = b-a;
  point e = c-a;
  if(cross(d,e)>0) return 1;//"COUNTER_CLOCKWISE"
  if(cross(d,e)<0) return -1;//"CLOCKWISE"
  if(dot(d,e)<0) return 2;//"ONLINE_BACK"
  if(abs(d) < abs(e)) return -2;//"ONLINE_FRONT"
  return 0;//"ON_SEGMENT"
}

point projection(point a,point b,point c){
  point d = b - a;
  return a+d*(dot(c-a,d)/(abs(d)*abs(d)));
}

point reflection(point a,point b,point c){
  return 2.0*projection(a,b,c)-c;
}

bool intersection(point a,point b,point c,point d){
  return (ccw(a,b,c)*ccw(a,b,d)<=0&&ccw(c,d,a)*ccw(c,d,b)<=0);
}

int main(){
  point a,b,c,d;
  int q;
  cin >> q;
  for(int i=0;i<q;i++) {
    cin >>a.x>>a.y>>b.x>>b.y>>c.x>>c.y>>d.x>>d.y;
    cout << intersection(a,b,c,d)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1244
n=int(input())-1
m=n;i=0;lst=[]
while m>=0:
    i+=1;k=m;m-=26**i
    k
while k>0:
    lst.append(k%26)
    k//=26
for j in range(i-len(lst)):
    lst.append(0)
print(''.join([chr(b+97) for b in lst][::-1]))

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

int tort()
{
  int trip, train, taxi;
  int traincost = 0;
  cin >> trip >> train >> taxi;
  traincost = trip * train;
  
  if(traincost <= taxi)
  {
    return traincost;
  }
  else
  return taxi;
}
int main()
{
  cout << tort() << endl;
}


Measured memory_bytes: 3640
using System;

public class hello
{
    public static void Main()
    {
        var dp = new int[11, 340];
        var used = new bool[10];
        calc(0, 0,used,dp);
        string txt;
        for (; (txt = Console.ReadLine()) != null;)
        {
            string[] line = txt.Trim().Split(' ');
            var n = int.Parse(line[0]);
            var s = int.Parse(line[1]);
            Console.WriteLine(s > 330? 0:dp[n,s]);
        }
    }
    static void calc (int c , int sum , bool[] used , int[,] dp)
    {
        if (c == 11) return;
        for (int i = 0; i < 10; i++)
        {
            if (used[i]) continue;
            used[i] = true;
            dp[c + 1, sum + i * (c + 1)]++;
            calc(c + 1, sum + i * (c + 1) , used,dp);
            used[i] = false;
        }
    }
}



Measured memory_bytes: 15960
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using ll = long long;
#define AC ios::sync_with_stdio(0),cin.tie(0);

int main()
{
    AC
    int n;
    cin>>n;
    vector<ll> v(n+1),sum(n+1);
    vector<vector<ll>> dp(n+1,vector<ll>(n+1));
    for(int i=1;i<=n;i++) cin>>v[i],sum[i]=sum[i-1]+v[i];
    for(int i=1;i<n;i++)
        for(int j=1;j+i<=n;j++)
        {
            dp[j][j+i]=1e18;
            for(int k=j;k<j+i;k++)
                dp[j][j+i]=min(dp[j][j+i],dp[j][k]+dp[k+1][j+i]);
            dp[j][j+i]+=sum[j+i]-sum[j-1];
        }
    cout<<dp[1][n]<<'\n';
}

Measured memory_bytes: 1536
n = int(input())
lst = [input() for i in range(n)]

c_ac = 0
c_wa = 0
c_tle = 0
c_re = 0
for e in lst:
  if e == 'AC':
    c_ac += 1
  elif e == 'WA':
    c_wa += 1
  elif e == 'TLE':
    c_tle += 1
  elif e == 'RE':
    c_re += 1
print('AC x {}'.format(c_ac))
print('WA x {}'.format(c_wa))
print('TLE x {}'.format(c_tle))
print('RE x {}'.format(c_re))

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

int main(){
    int n,ans,a=1;
    cin>>n;
    while(ans<n){
        ans=a*a;
        a++;
    }
    if(ans>n)
    ans=(a-2)*(a-2);
    cout<<ans<<endl;
    return 0;
}

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

int main ()
{
	long long int N, A, B;

	cin >> N >> A >> B;

	long long int timesInN = N / (A + B);
	long long int leftOver = N % (A + B);

	long long int numBlue = timesInN * A;

	if (A <= leftOver)
	{
		numBlue += A;
	}
	else
	{
		numBlue += leftOver;
	}

	cout << numBlue;

	return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str[]      = br.readLine().split(" ");
		int in[]          = parseInts(str);
		int in1[][]       = new int[in[0]][in[1]];
		String str1[]     = new String[in[1]];
		int in2[]         = new int[in[1]];
		int x;
		for(int i=0; i<in[0]; i++){
			str1 = br.readLine().split(" ");
			in1[i] = parseInts(str1);
		}
		for(int i=0; i<in[1]; i++){
			in2[i] = Integer.parseInt(br.readLine());
		}
		for(int n=0; n<in[0]; n++){
			x = 0;
			for(int m=0; m<in[1]; m++){
				x = in1[n][m] * in2[m] + x;
			}
			System.out.println(x);
		}
	}
	static int[] parseInts(String[] s){
		int[] x = new int[s.length];
		for(int i=0; i<s.length; i++){
			x[i] = Integer.parseInt(s[i]);
		}
		return x;
	}
}

Measured memory_bytes: 22668
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll mypow(ll a, ll b) {
  ll ans = 1;
  ll tmp;
  ll two;
  while(b>0) {
    two = 1;
    tmp = a;
    while(2*two<b) {
      two *= 2;
      tmp *= tmp;
      tmp %= mod;
    }
    b -= two;
    ans *= tmp;
    ans %= mod;
  }
  return ans;
}

int main() {
  ll N;
  cin>>N;
  cout<<(mypow(10, N)-mypow(9, N)*2%mod+mod+mypow(8, N))%mod<<endl;
}



Measured memory_bytes: 3632
#!/usr/bin/ruby
a=[0]*3
gets
gets.split.each{|e|a[e.to_i%3]+=1}
if a[1]==0 && a[2]==0
	p [1,a[0]].min
else
	pairs=[a[1],a[2]].min
	a[1]-=pairs
	a[2]-=pairs
	p a[0]+pairs*2+[[3,a[1]].min,[3,a[2]].min].max
end

Measured memory_bytes: 33840
a = Array.new(2).map{Array.new(4,0)}
readlines.each do |x|
  b = Array.new(2)
  b[0],b[1] = x.chomp.split(" ").map(&:to_f)
  for i in 0..1
    if b[i]>=1.1
      a[i][0]+=1
    elsif b[i]>=0.6
      a[i][1]+=1
    elsif b[i]>=0.2
      a[i][2]+=1
    else 
      a[i][3]+=1
    end
  end
end
for i in 0..3
  print(a[0][i]," ",a[1][i],"\n")
end


Measured memory_bytes: 6116
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define loop(i,a,n) for(int i = a; i < (n); i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

#define max_n 100005

vector<vi> g(max_n);
int a[max_n];
int n;
bool ans = true;
ll dfs(int now, int p){
    if(g[now].size() == 1){ //葉
        return a[now];
    }

    ll sum = 0;
    ll max_ci = 0;
    rep(i,g[now].size())if(g[now][i] != p){
        ll t = dfs(g[now][i], now);
        sum += t;
        max_ci = max(max_ci, t);
    }
    ll t = 2 * a[now] - sum;
    ll l = (sum - t) / 2;



    if(t < 0 || l < 0){
        ans = false;
    }

    if(p == -1 && t){
        ans = false;
    }

    if(2 * max_ci >= sum){
        if(l > sum - max_ci)
            ans = false;
    }else{
        if(2 * l > sum)
            ans = false;
    }
    
    return t;
}

int main(void) {
    cin>>n;
    rep(i,n) cin >> a[i];

    rep(i,n-1){
        int x,y;
        cin >> x >> y;
        x--,y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    if(n == 2){
        if(a[0] == a[1]){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
        return 0;
    }
    int root;
    rep(i,n)if(g[i].size() >= 2){
        root = i;
        break;
    }

    dfs(root, -1);

    if(ans){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;

int main(){
  string s; cin >> s;
  ll ans = 700;
  for(auto c:s){
    if(c=='o') ans+=100;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define ll long long
#define f   first
#define s   second
#define pb          push_back
#define mod         1000000007
#define hell        998244353
#define inf         1000000000000000000LL
using namespace std;
ll n,k,m,l;
//ll dp[15][1005];
void solve()
{   
cin>>n;  
string s;
cin>>s;
vector<int> v[3];
for(int i=0;i<n;i++)
{
    if(s[i]=='R') v[0].pb(i);
    else if(s[i]=='G') v[1].pb(i);
    else v[2].pb(i);
}
map<char,int> hm;
hm['R']=1;hm['G']=2;hm['B']=3;
ll ans=0;
//cout<<v[1].size()<<"\n";
//for(auto x:v[2]) cout<<x<<" ";
    //cout<<v[2].size()<<"\n";
for(int i=0;i<n;i++)
{
    for(int j=i+1;j<n;j++)
    {
        if(s[i]!=s[j])
        {
            ll x=6-hm[s[i]]-hm[s[j]];
            x--;
            auto it=upper_bound(v[x].begin(),v[x].end(),j);
            if(it==v[x].end()) continue;
            ll y=it-v[x].begin();
            ll z=0;
            auto it2=lower_bound(v[x].begin(),v[x].end(),2*j-i);
            ll z1=it2-v[x].begin();
            if(it2==v[x].end()) z=0;
            else if(v[x][z1]==(2*j-i))z=1;
            ans+=(v[x].size()-y);
            ans-=z;
            //cout<<ans<<" ";

        }
    }
}
cout<<ans;





}    
int main()
{  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //cout<<primes.size();
    ll t=1;
    //cin>>t;
    while(t--)
        solve();

}


Measured memory_bytes: 3688
#include <stdio.h>
#include <stdlib.h>

int min(int x, int y)
{
  if(x<y) return x; else return y;
}

int comp(const void *a, const void *b)
{
	return *(int*)a - *(int*)b;
}

int main()
{
	int i,j, n, k;
	int len,left,right;
	int sum;
	int val[50];
	int v[50];
	int cost[200];
	for (i = 0; i < 200; i++){
		cost[i] = 0;
	}

	scanf("%d%d", &n, &k);
	for (i = 0; i < n; i++) {
		scanf("%d", &val[i]);
	}

	for (len = 1; len <= min(n,k); len++) {
      for(left=0;left<=len;left++){
        right=len-left;
        for(i=0;i<left;i++){
          v[i]=val[i];
        }
        for(i=0;i<right;i++){
          v[left+i]=val[n-1-i];
        }
		qsort(v, len, sizeof(int), comp);
		sum = 0;
		for (i = 0; i < len; i++) {
			sum += v[i];
		}
		if (sum > cost[len]) {
			cost[len] = sum;
		}
		for (i = 0; i < len; i++) {
			sum -= v[i];
			if (sum > cost[len+i+1]) cost[len+i+1] = sum;
		}
      }
	}
	int maxval = 0;
	for (i = 0; i <= k; i++) {
 	  if (cost[i] > maxval) maxval = cost[i];
	}
	printf("%d\n", maxval);

	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
//
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
		int n=sc.nextInt();
		int m=sc.nextInt();
		int ans =-1;
		int[] digits =new int[n];
		int[] s_array=new int[m];
		int[] c_array=new int[m];
		
		for (int i=0;i<m;i++) {
			s_array[i]=sc.nextInt();
			c_array[i]=sc.nextInt();
		}
		int start =0;
		if(n==2) {
			start=10;
		}
		if(n==3) {
			start =100;
		}
		for (int i=start;i<1000;i++) {
			int i_digit =i;
			for (int j=n-1;j>=0;j--) {
				digits[j]=i_digit%10;
				i_digit /= 10;
			}

			boolean isAns=true;

			for (int k=0;k<m;k++) {
				if (digits[s_array[k]-1]!=c_array[k]) {
					isAns =false;
				}
			}
			if (isAns) {
				ans=i;
				break;
			}
		}
		//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
		System.out.println(ans);
	}
	//----------------------------------------
	//メソッド置き場

	//----------------------------------------
}

Measured memory_bytes: 23508
#include <iostream>
#include <iomanip>
#include <climits>
#include <limits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <cmath>
#include <complex>

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define INFL (int)1e9
#define INFLL (ll)1e18
#define INFD numeric_limits<double>::infinity()
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(i, vector.size()) { cout << vector[i] << " "; } cout << endl;
#define rnd(d) (ll)((double)d + (d >= 0 ? 0.5 : -0.5))
#define floorsqrt(x) ((ll)sqrt((double)x) + ((ll)sqrt((double)x) * (ll)sqrt((double)x) <= (ll)x ? 0 : -1))
#define ceilsqrt(x) ((ll)sqrt((double)x) + ((ll)x <= (ll)sqrt((double)x) * (ll)sqrt((double)x) ? 0 : 1))
#define ceildiv(a, b) ((ll)a / (ll)b + ((ll)a % (ll)b == 0 ? 0 : 1))
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)

/*******************************************************/

int main() {
  const int N = 100;
  int a, b; cin >> a >> b;
  vector<vector<char>> board(N, vector<char>(N, '#'));
  Loop(i, b - 1) {
    int base_r = i / (N / 2) * 2;
    int base_c = i % (N / 2) * 2;
    board[base_r][base_c] = '#';
    board[base_r + 1][base_c] = '.';
    board[base_r][base_c + 1] = '.';
    board[base_r + 1][base_c + 1] = '.';
  }
  if (b == 1) board[0][0] = '.';
  Loop(i, a - 1) {
    int base_r = (N - 1) - (i / (N / 2) * 2);
    int base_c = i % (N / 2) * 2;
    board[base_r][base_c] = '.';
  }
  cout << N << " " << N << endl;
  Loop(i, N) {
    Loop(j, N) {
      cout << board[i][j];
    }
    cout << endl;;
  }
}

Measured memory_bytes: 256
// Problem: C - 1D Reversi
// Contest: AtCoder - AtCoder Regular Contest 063
// URL: https://atcoder.jp/contests/arc063/tasks/arc063_a
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 1e6 + 1;

string s;

int32_t main() { cin.tie(0)->sync_with_stdio(0);
  cin >> s;
  int n = s.size();
  s = ' ' + s;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] != s[i - 1]) {
      ans++;
    }
  }
  cout << ans - 1;
}

Measured memory_bytes: 3760
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    n = int(input())
    aa = list(map(int, input().split()))
    bb = list(map(int, input().split()))

    turn = sum(bb)-sum(aa)
    for a, b in zip(aa, bb):
        turn -= max([0,b-a+1])//2
    if turn < 0:
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 4596
#include<cstdio>
#include<algorithm>

using namespace std;

const int N = 2005;
int n, k, q, a[N], ans = 1e9+5, t[N], b[N], c[N];

void cal(int mn){
    int l = 1, r = 1;
    b[0] = 0;
    while(l <= n){
        c[0] = 0;
        while(a[l] < mn && l <= n)  l++;
        r = l;
        while(a[r] >= mn && r <= n) r++;
        for(int i = l; i < r && i <= n; i++)
            c[++c[0]] = a[i];
        if(c[0] >= k){
            sort(c+1, c+c[0]+1);
            for(int i = 1; i <= c[0] - k + 1; i++)
                b[++b[0]] = c[i];
        }
        l = r;
    }
    sort(b+1, b+b[0]+1);
    if(b[0] >= q)   ans = min(ans, b[q] - b[1]);
}

int main(){
    scanf("%d%d%d", &n, &k, &q);
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
        t[i] = a[i];
    }
    sort(t+1, t+n+1);
    for(int i = 1; i <= n; i++)
        cal(t[i]);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+7;

int main()
{   
    ios_base::sync_with_stdio(0);
    cin.tie(0); 
    ll n,a[N];
    ll c=1e18;
    cin>>n;
    for(int i=0;i<n;i++){ 
        cin>>a[i];
        if(a[i]==0){ 
            cout<<0;
            return 0;
        }
    }
    for(int i=0;i<n;i++){ 
        if(a[i]>c){ 
            cout<<-1;
            return 0;
        }
        c=c/a[i];
    }
    ll ans=1;
    for(int i=0;i<n;i++){ 
        ans=ans*a[i];
    }
    cout<<ans<<'\n';
}
    

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

int main()
{
    int N,M,X;
    cin>>N>>M>>X;
    int pre = 0;
    int lat = 0;
    for (int i = 1; i <= M; i++)
    {
        int A;
        cin>>A;
        if (A < X)
            pre++;
        else
            lat++;
    }
    cout<<min(pre, lat)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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(){
    string s;
    cin >> s;
    ll ans = 0;
    for (ll i = 0; i < s.size() - 1; i++)
        if (s[i] != s[i + 1]) ans++;
    cout << ans << endl;
}

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

using namespace std;

int main() {
    
    int X;
    cin >> X;
    
    int ans=1;
    
    for(int b=1;b<=1000;b++){
        for(int p=2;p<=10;p++){
            if((pow(b,p)<=X)&&(pow(b,p)>=ans)){
                ans = pow(b,p);
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 640
# N is Amount of song
N = input()
# Song_List has song title and song time.
# Song_List[title,time]
Song_List = []
for i in range (int(N)):
    Song_List.append(list(input().split()))
# X is song title when Niwango-kun started sleeping.
X = input()
ans = 0
for i in range(int(N)):
    if Song_List[i][0] == X:
        if i < int(N):
            for i in range(i,int(N)-1):
                ans +=int(Song_List[i+1][1])
        else:
            continue
    else:
        continue
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
using namespace std;

int main(void)
{
    int num1, num2;
    stack<int> s;
    char inputTmp[7];
    char newLineCheck;

    while ("Main loop") {
        scanf("%s%c", inputTmp, &newLineCheck);
        switch (inputTmp[0]) {
        case '+':
            num1 = s.top(); s.pop();
            num2 = s.top(); s.pop();
            s.push(num2 + num1);
            break;
        case '-':
          num1 = s.top(); s.pop();
          num2 = s.top(); s.pop();
            s.push(num2 - num1);
            break;
        case '*':
          num1 = s.top(); s.pop();
          num2 = s.top(); s.pop();
            s.push(num2 * num1);
            break;
        case '/':
          num1 = s.top(); s.pop();
          num2 = s.top(); s.pop();
            s.push(num2 / num1);
            break;
        default:
            s.push(atoi(inputTmp));
            break;
        }
        if (newLineCheck == '\n') break;
    }
    cout << s.top() << endl;

    return 0;
}

Measured memory_bytes: 1204
while True:
    data = raw_input().split();
    #print data[0] , data[1], data[2]
    a = int(data[0])
    b = int(data[2])
    
    if data[1] == '?' :
        break
    elif data[1] == '+':
        print a + b
    elif data[1] == '-':
       print a - b
    elif data[1] == '*':
       print a * b
    elif data[1] == '/':
       print a / b
       
    

Measured memory_bytes: 6364
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# rstrip().decode('utf-8')
# INF=float("inf")
MOD=10**9+7
# sys.setrecursionlimit(2147483647)
# import math
#import numpy as np
# import operator
# import bisect
# from heapq import heapify,heappop,heappush
#from math import gcd
# from fractions import gcd
# from collections import deque
# from collections import defaultdict
# from collections import Counter
# from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# map(int,input().split())

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod



def main():
	N,K=map(int,input().split())
	
	for i in range(1,K+1):
		if i<=N-K+1:
			print(comb(N-K+1,i,MOD)*comb(K-1,i-1,MOD)%MOD)
		else:
			print(0)
	





if __name__ == '__main__':
	main()


Measured memory_bytes: 51948
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 


void solve(){
   int n;
   cin >> n;
   vector<int> v;
   for(int i = 0; i < n; i++){
   	 int x;
   	 cin >> x;
   	 v.push_back(x);
   }
   vector<int> b(n);
   b = v;
   sort(all(b));
   int cnt = 0;
   for(int i = 0; i < n; i++){
     if (v[i] != b[i]) cnt++;
   }
   bool ok = (cnt == 0 || cnt == 2);
   if (ok) cout << "YES" << endl;
   else cout << "NO" << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+2;
const int mod=1e9+7;
void add(int &x,int y){
	x+=y;
	if(x>=mod){
		x-=mod;
	}
}
void sub(int &x,int y){
	x-=y;
	if(x<0){
		x+=mod;
	}
}
int mul(int x,int y){
	return (1ll*x*y)%mod;
}
int dp[N][2][3][3];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	int n,i,j,k,l;
	cin>>s;
	n=s.size(); s=' '+s;
	dp[0][1][0][0]=1;
	for(i=1;i<=n;i++){
		if(s[i]=='0'||s[i]=='?'){
			for(j=0;j<2;j++){
				for(k=0;k<3;k++){
					for(l=0;l<3;l++){
						add(dp[i][j][k%2+1][l],dp[i-1][j][k][l]);
					}
				}
			}
		}
		if(s[i]=='1'||s[i]=='?'){
			for(j=0;j<2;j++){
				for(k=0;k<3;k++){
					for(l=0;l<3;l++){
						if(k==0){
							if(l==0&&j==1){
								add(dp[i][(j+1)%2][0][l+1],dp[i-1][j][k][l]);
							}
							else{
								if(l==1&&j==0){
									add(dp[i][(j+1)%2][0][l+1],dp[i-1][j][k][l]);
								}
								else{
									add(dp[i][(j+1)%2][0][l],dp[i-1][j][k][l]);		
								}
							}
						}
						else{
							if(k==2){
								add(dp[i][(j+1)%2][0][l],dp[i-1][j][k][l]);
							}
							else{
								add(dp[i][j][0][l],dp[i-1][j][k][l]);
							}
						}
					}
				}
			}
		}
//		for(j=0;j<2;j++){
//			for(k=0;k<3;k++){
//				for(l=0;l<3;l++){
//					cout<<i<<' '<<j<<' '<<k<<' '<<l<<' '<<dp[i][j][k][l]<<endl;
//				}
//			}
//		}
	}
	i=n+1;
	for(j=0;j<2;j++){
		for(k=0;k<3;k++){
			for(l=0;l<3;l++){
				if(k==0){
					if(l==0&&j==1){
						add(dp[i][(j+1)%2][0][l+1],dp[i-1][j][k][l]);
					}
					else{
						if(l==1&&j==0){
							add(dp[i][(j+1)%2][0][l+1],dp[i-1][j][k][l]);
						}
						else{
							add(dp[i][(j+1)%2][0][l],dp[i-1][j][k][l]);
						}
					}
				}
				else{
					add(dp[i][(j+1)%2][0][l],dp[i-1][j][k][l]);
				}
			}
		}
	}
	for(i=0;i<2;i++){
		for(j=0;j<3;j++){
			if(i==0&&j==0){
				continue;
			}
			add(dp[n+1][0][0][2],dp[n+1][i][j][2]);
		}
	}
	cout<<dp[n+1][0][0][2];
}

Measured memory_bytes: 24800
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        pw.println(N * 800 - (N / 15) * 200)
    }
}


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

#define rep(X,N) for(int X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

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

    cout << a * b << endl;

    return 0;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<utility>
using namespace std;
int n,a;
int main()
{
    cin>>n>>a;
    int curr=n/500;
    if (n%500==0){cout<<"Yes"<<endl;return 0;}
    if (n%500>a){cout<<"No"<<endl;return 0;}
    cout<<"Yes"<<endl;




return 0;
}


Measured memory_bytes: 768
#pragma GCC optimize("Ofast")

//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

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() {
  // 高速化
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);


    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    bool win = false;
    while(true){
        c-= b;
        if(c<=0){
            win = true;
            break;
        }
        a -= d;
        if(a<=0){
            win = false;
            break;
        }
    }
    if(win){
        cout << "Yes" << "\n"; 
    }
    else
    {
          cout << "No" << "\n"; 
   
    }
    

    return 0;



}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;
int main(){
    int n,r,p,c;
    while(true){
        cin >> n >> r;
        if(n==0 && r==0){
            break;
        }
        vector<int> a(n);
        for (int i=0;i<n;i++){
            a[i]=n-i;
        }
        for(int i=0;i<r;i++){
            cin >> p >> c;
            rotate(a.begin(),a.begin()+p-1,a.begin()+p+c-1);
            for (int i=0;i<n;i++){
            }
        }
        cout << a[0] << endl;
    }
}

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int h,w;
	int K;
	char s[10][1000];
	cin>>h>>w>>K;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>s[i][j];
		}
	}
	int ans=1e9+7;
	for(int i=0;i<(1<<(h-1));i++){
		int cnt=0;
		vector<int> hoge;
		hoge.push_back(0);
		for(int j=0;j<h;j++){
			if(i&(1<<j)){
				hoge.push_back(j+1);
				cnt++;
			}
		}
		hoge.push_back(h);
		int sum[10][1000]={};
		for(int j=1;j<hoge.size();j++){
			for(int k=hoge[j-1];k<hoge[j];k++){
				for(int l=0;l<w;l++){
					sum[j-1][l]+=(s[k][l]=='1'?1:0);
				}
			}
		}
		bool ok=true;
		for(int j=0;j<hoge.size()-1;j++){
			for(int k=0;k<w;k++){
				if(sum[j][k]>K){
					ok=false;
				}
			}
		}
		if(!ok){
			continue;
		}
		for(int j=1;j<w;j++){
			bool f=true;
			for(int k=0;k<hoge.size()-1;k++){
				if(sum[k][j]+sum[k][j-1]>K){
					f=false;
				}
			}
			if(f){
				for(int k=0;k<hoge.size()-1;k++){
					sum[k][j]+=sum[k][j-1];
				}
			}else{
				cnt++;
			}
		}
		ans=min(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define REPEAT(i, N) for (int i = 0; i < (N); i++)

int main() {
  int R;
  
  cin >> R;
  
  cout << (double) R * 2 * 3.14159265358979 << endl;
  
  return 0;
}

Measured memory_bytes: 3776
#include <iostream>
#include <vector>
#include <iomanip>
#include <ios>
#include <algorithm>
using namespace std;
int main(void){
  string s;
  cin >> s;
  
  int n = s.length();
  int ans = 0;
  
  for(int i=0;i<n;i++){
    if(s[i] == 'o')
      ans++;
  }
  
  if(ans + (15 - n) >= 8)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main()
{
    int n,r;
    cin >> n >> r;
    if(n<10){
        r+=100*(10-n);
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 764
//28
#include<iostream>
#include<string>

using namespace std;

int main(){
  for(string s[2],b;cin>>s[0]>>s[1]>>b,s[0]!="-";){
    int si[2]={0,1};
    char c=s[1][0];
    string r;
    for(int bi=0;bi<b.size();){
      int l=b[bi]!=c;
      if(l){
	r+=c;
      }else{
	bi++;
      }
      c=s[l][si[l]++];
    }
    r+=c+s[1].substr(si[1]);
    cout<<r<<endl;
  }
  return 0;
}

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

#define int long long
#define MOD ((int)1e9+7)
#define INF (int)1e18

#define MAX 30

int w, d;
int h[MAX], hd[MAX];

int solve(){
  int ans = 0;
  int used[MAX] = {};
  
  for(int i = 0; i < w; i++){
    for(int j = 0; j < d; j++){
      if(used[j])continue;
      if(h[i] == hd[j]){
	used[j] = true;
	ans -= hd[j];
	break;
      }
    }
  }
  
  for(int i = 0; i < w; i++){
    ans += h[i];
  }
   for(int i = 0; i < d; i++){
    ans += hd[i];
  }
  return ans;
}

signed  main(){

  
  while(true){
    
    cin>>w>>d;

    if(!w&&!d) break;
    
    for(int i = 0; i < w; i++){
      cin>>h[i];
    }
    for(int i = 0; i < d; i++){
      cin>>hd[i];
    }
    cout<<solve()<<endl;
  }

  return 0;
}



Measured memory_bytes: 3084
/*
    NEVER GIVE UP!
    THE EXPERT IN ANYTHING WAS ONCE A BEGINNER
*/
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;

void solve()
{
    ll n,m,x,y,mi,c=0;
    cin >> n >> m;
    vll a(n+5);
    vector<vll> g(n+5);

    f(i,1,n)
    {
        cin >> a[i] ;
    }

    f(i,1,m)
    {
        cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
    }

    f(i,1,n)
    {
        mi=i;

        fa(it,g[i])
        {
            if(a[mi] <= a[it])
                mi=it;
        }

        if(i==mi)
        {
            c++;
            // cout << i << " ";
        }

    }

    cout << c << endl;
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 9800
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

fill table (c : cs) = do
  point <- VUM.read table c
  VUM.write table c (point + 1)
  when (cs /= []) $ fill table cs

fillVector table (a : as) n = do
  point <- VUM.read table a
  if point == 0 || point == 1
    then do
      if point == 1
        then do
          VUM.write table a 2
        else do
          let diva = n `div` a
          let cs = map (\x -> x * a) [1 .. diva]
          fill table cs
      when (as /= []) $ fillVector table as n
    else do
      when (as /= []) $ fillVector table as n

seek table (a : as) xs = do
  point <- VUM.read table a
  let xs' = if point == 1 then a : xs else xs
  if as == []
    then return xs'
    else seek table as xs'

main = do
  n <- getInt
  as <- getIntList
  let as' = sort as
  let m = last as'
  table <- VUM.replicate (m + 1) 0 :: IO (VUM.IOVector Int)
  fillVector table as' m
  rs <- seek table as' []
  print $ length rs


Measured memory_bytes: 39076
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<vector>
#define MAX 2000000002
#define NIL NULL
using namespace std;
struct node{
    int data=0;
    node *parent=NIL,*left=NIL,*right=NIL;
};

vector<int> PreOrder,InOrder;
node *root=NIL;

void getPre(node *root){
    if(root==NIL) return;
    PreOrder.push_back(root->data);
    getPre(root->left);
    getPre(root->right);
}
void getIn(node *root){
    if(root==NIL) return;
    getIn(root->left);
    InOrder.push_back(root->data);
    getIn(root->right);
}
node *findNode(int num){
    node *temp=root;
    while(temp && temp->data!=num){
        if(temp->data>num)
            temp=temp->left;
        else temp=temp->right;
    }
    return temp;
}
//void insertToTree(node *root,node *z){
void insertToTree(node *z){
    node *x,*y;
    y=NIL;
    x=root;
    while(x!=NIL){
        y=x;
        if(z->data<x->data){
            x=x->left;
        }else{
            x=x->right;
        }
    }
    z->parent=y;
    if(y==NIL){
        root=z;
    }else if(z->data<y->data){
        y->left=z;
    }else{
        y->right=z;
    }

}
void show(vector<int> B){
    for(int i=0;i<B.size();i++){
        cout<<' '<<B[i];
    }
    cout<<endl;
}

int main(){
    int n,i;
    string str;
    int num;
    node *z=NIL;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>str;
        if(str=="insert"){
            cin>>num;
            z=(node *)malloc(sizeof(node));
            z->data=num;
            z->left=NIL;
            z->right=NIL;
            z->parent=NIL;
            //insertToTree(root,z);
            insertToTree(z);
        }else if(str=="find"){
            cin>>num;
            if(findNode(num))
                cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        }else if(str=="print"){
            getIn(root);
            show(InOrder);
            InOrder.clear();
            getPre(root);
            show(PreOrder);
            PreOrder.clear();
            //root=NULL;
        }
    }
}



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

using namespace std;

struct UnionFind{
    vector<int> p;
    UnionFind(int n){
        p.resize(n, -1);
    }

    int find(int x){
        if(p[x] == -1)return x;
        else return find(p[x]);
    }
    
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y)return;
        p[x] = y;
    }
    
};

int main(){
    int n, q, com , x, y;
    cin >> n >> q;
    UnionFind uf(n);
    for(int i = 0;i < q;i++){
        cin >> com >> x >> y;
        if(com == 0){
            uf.unite(x, y);
        }
        if(com == 1){
            if(uf.find(x) == uf.find(y)){
                cout << 1 << endl;
            }else{
                cout << 0 << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3160
H, W, A, B = map(int, input().split())

if A > W/2 or B > H/2:
    print('No')
    exit()

for i in range(H):
    if i < B:
        print('0'*(W-A)+'1'*A)
    else:
        print('1'*(W-A)+'0'*A)


Measured memory_bytes: 39792
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#define  go return 0
#define pb push_back
#include<utility>
#include <algorithm>
#include<iterator>
typedef long long ll;
typedef double db;
#define lp1(i, n)  for(int i=0; i<(int)(n); ++i)
#define lp2(i, n)  for(int i=0; i<(int)(n-1); ++i)
#define lp3(j, n)  for(int j=1; j<=(int)(n); ++j)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
typedef vector<int> vi;
const int N=1e5+5;
int arr[N];

int main(){

ll r,x,d;
cin>>r>>d>>x;
for(int i=0 ; i<10 ; i++)
{
    x=r*x-d;
    cout<<x<<endl;
}

go;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll cnt=0;
    while(1){
        cnt++;
        ll a;cin>>a;
        if(a==0)break;
        if(cnt!=1)cout<<endl;
        vector<ll>c(4);
        rep(i,4)cin>>c[i];
        vector<ll>b(4);
        ll mi=inf;
        ll sum=c[0]+c[1]+c[2]+c[3];
        rep(i,c[0]+1){
            rep(j,c[1]+1){
                rep(k,c[2]+1){
                    rep(l,c[3]+1){
                        if(10*i+50*j+100*k+500*l>=a){
                            ll sum1=sum-(i+j+k+l);
                            ll sum2=0;
                            ll change=10*i+50*j+100*k+500*l-a;
                            sum2+=change/500;
                            change%=500;
                            sum2+=change/100;
                            change%=100;
                            sum2+=change/50;
                            change%=50;
                            sum2+=change/10;
                            sum1+=sum2;
                            if(mi>sum1){
                                b[0]=i;
                                b[1]=j;
                                b[2]=k;
                                b[3]=l;
                                mi=sum1;
                            }
                        }
                    }
                }
            }
        }
        if(b[0])cout<<10<<' '<<b[0]<<endl;
        if(b[1])cout<<50<<' '<<b[1]<<endl;
        if(b[2])cout<<100<<' '<<b[2]<<endl;
        if(b[3])cout<<500<<' '<<b[3]<<endl;
    }
}


Measured memory_bytes: 3052
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long N;
    long long total=0,val;
    cin >> N;
    vector<int> A(100001,0);
    for (int i = 0; i<N; ++i) {
        cin >> val;
        ++A[val];
        total+=val;
    }
    long long Q,B,C,amount;
    cin >> Q;
    for (int i = 0; i<Q; ++i) {
        cin >> B >> C;
        amount = A[B];
        A[B] = 0;
        total -=amount*B;
        A[C] += amount;
        total += amount*C;
        cout << total << '\n';
    }
}

Measured memory_bytes: 3612
#include <iostream>
#include <cmath>

using namespace std;

void dump(int w, int s)
{
    cout << (s+w) << ' ' << s << '\n';
}

int main(){
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    int w_max = 0;
    int s_max = 0;
    double k_max = 0;

    for(int w = 0; w <= f; w += 100 * a)
    {
        for(int w2 = w; w2 <= f; w2 += 100 * b)
        {
            const int limit = min(100*(f-w2), e*w2);
            for(int s = 0; 100*s <= limit; s += c)
            {
                for(int s2 = s; 100*s2 <= limit; s2 += d)
                {
                    const double k = (double)s2 / (s2+w2);
                    if(k_max < k)
                    {
                        w_max = w2; s_max = s2; k_max = k;
                    }
                }
            }
        }
    }
    if(w_max == 0) w_max = 100*a;
    dump(w_max, s_max);
    
    return 0;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    string n;
    cin >> n;
    int x = stoi(n);
    int a = x/1000;
    int b = x/100-a*10;
    int c = x/10-a*100-b*10;
    int d = x-a*1000-b*100-c*10;
    if(a+b+c+d == 7){cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;}
    else if(a-b+c+d == 7){cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;}
    else if(a-b-c+d == 7){cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;}
    else if(a-b-c-d == 7){cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;}
    else if(a+b+c-d == 7){cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;}
    else if(a+b-c-d == 7){cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;}
    else if(a+b-c+d == 7){cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;}
    else if(a-b+c-d == 7){cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;}
    return 0;
}

Measured memory_bytes: 256