akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(void)
{
  int n,a[101],i,min=1000,max=0,ans=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&a[i]);
      if(min > a[i])
	{
	  min = a[i];
	}
      if(max < a[i])
	{
	  max = a[i];
	}
    }
  ans = max - min;
  printf("%d\n",ans);
  return 0;
}
		 


Measured memory_bytes: 128
N=list(input())
a=[]
b=[]
#print(N)
#print(len(N))
for k in range(len(N)):
    if k%2>0:
        b.append(N[k])
    else:
        a.append(N[k])
if   a.count('L')==0 and b.count('R')==0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
Si = []
N = input()
for i in range(int(N)):
	Si.append(input())

C0 = Si.count('AC')
C1 = Si.count('WA')
C2 = Si.count('TLE')
C3 = Si.count('RE')

print('AC x', int(C0))
print('WA x', int(C1))
print('TLE x', int(C2))
print('RE x', int(C3))

Measured memory_bytes: 16284
from collections import Counter

def nCk(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

n = int(input())
a = list(map(int, input().split()))
b = Counter(a)
c = {}
d = {}
for k, v in b.items():
    c[k] = nCk(v, 2) if v > 1 else 0
    d[k] = nCk(v-1, 2) if v > 2 else 0
total = sum(c.values())
for i in range(n):
    ans = total - c[a[i]] + d[a[i]]
    print(ans)

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

int main() {

long double r,p;

cin >> r;

p=3.141592653589793;

cout << fixed << setprecision(15) << p*r*r << " " << fixed << setprecision(15) << 2*p*r << endl;

}


Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  long long int sum=0;
  while(m-- ){
    int x;cin>>x;
  	sum+=x;
  }
  if((n-sum)>=0)
    cout<<n-sum;
  else
    cout<<-1;
  return 0;
}

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    int a,b,c; cin >> a >> b >> c;
    if(a == b) cout << c << endl;
    else if(b == c) cout << a << endl;
    else cout << b << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int[] abc = in.nextIntArray(3);
            Arrays.sort(abc);
            out.println(abc[2] * 10 + abc[0] + abc[1]);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

    }
}



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

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

long long GCD(long long a, long long b) {
	if (a < b)
		swap(a, b);
	if (b == 0) return a;
	else return GCD(b, a % b);
}
bool sosuu_check(int num) {
	int i;
	for (i = 2; i <= sqrt(num); ++i) {
		if (num%i == 0)
			return false;
	}
	return (num < 2) ? false : true;
}
int main() {
	int N, x, cmin = 1001, xt, yt, ht, y, h, i , j;
	cin >> N;
	pair<pair<int, int>, int> t;
	vector<pair<pair<int, int>, int>> vec;
	cin >> xt >> yt >> ht;
	--N;
	if (ht > 0) {
		REP(x, 101) {
			REP(y, 101) {
				h = ht + abs(x - xt) + abs(y - yt);
				if (h >= 1)
					vec.PB(make_pair(make_pair(x, y), h));
			}
		}
	}
	else {
		REP(x, 101) {
			REP(y, 101) {
				h = abs(x - xt) + abs(y - yt);
				vec.PB(make_pair(make_pair(x, y), h));
			}
		}
	}
	if (ht == 0) {
		while (true) {
			cin >> xt >> yt >> ht;
			--N;
			if (ht > 0) {
				REP(j, (int)vec.size()) {
					h = abs(vec[j].first.first - xt) + abs(vec[j].first.second - yt) + ht;
					if (h <= vec[j].second) {
						vec[j].second = h;
					}
					else {
						vec[j].second = 1000000001;
					}
					vec[j].second = max(vec[j].second, h);

				}
				break;
			}
			else {
				REP(j, (int)vec.size()) {
					h = abs(vec[j].first.first - xt) + abs(vec[j].first.second - yt);
					vec[j].second = max(vec[j].second, h);
				}
			}
		}
	}
	while(N>=0){
		cin >> xt >> yt >> ht;
		--N;
		REP(j, (int)vec.size()) {
			if (vec[j].second != 1000000001) {
				if (ht > 0) {
					if (ht + abs(xt - vec[j].first.first) + abs(yt - vec[j].first.second) != vec[j].second) {
						vec[j].second = 1000000001;
					}
				}
				else {
					if(vec[j].second - abs(xt - vec[j].first.first) - abs(yt - vec[j].first.second)>0)
						vec[j].second = 1000000001;
				}
			}
		}
	}
	REP(i, (int)vec.size())
		if (vec[i].second != 1000000001)
			cout << vec[i].first.first << " " << vec[i].first.second << " " << vec[i].second << endl;
}

Measured memory_bytes: 512
# coding: utf-8
# Your code here!
N=int(input())
S=list(map(int,list(input())))

#print(S)

def search(lis,num):
    for index,item in enumerate(lis):
        if item==num:
            return True,index
  
    return False,-1

l=[[[0 for i in range(10)] for i in range(10)] for i in range(10)]
ans=0
for i in range(10):
    judge1,temp1=search(S,i)
    #print(temp1)
    if judge1:
        #print(i)
        for j in range(10):
            judge2,temp2=search(S[temp1+1:],j)
            if judge2:
                #print(j)
                for k in range(10):
                    #print(k)
                    if search(S[temp1+temp2+2:],k)[0]:
                        #print(i,j,k)
                        #print(temp1,temp1+temp2)
                        l[i][j][k]=1
                    else:
                        continue
            else:
                continue
    else:
        continue
ans=0
for item in l:
    for item2 in item:
        ans+=sum(item2)

#print(l)
print(ans)



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

int main()
{
  int w,h,n;
  cin >> w >> h >> n;
  vector<int> x(n);
  vector<int> y(n);
  vector<int> a(n);

  for(int i=0; i < n; i++)
    cin >> x[i] >> y[i] >> a[i];

  int x0 = 0;
  int y0 = 0;

  for(int i=0; i < n; i++){
    if(a[i] == 1){
      if(x[i] > x0)
        x0 = x[i];
    }else if(a[i] == 2){
      if(x[i] < w)
        w = x[i];
    }else if(a[i] == 3){
      if(y[i] > y0)
        y0 = y[i];
    }else if(a[i] == 4){
      if(y[i] < h)  
        h = y[i];
    }
  }

  int sum;
  if(w > x0 && h > y0)
    sum = (w-x0) * (h-y0);
  else
    sum = 0;

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 384
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {

		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();

		int a[] = new int[n];
		for (int i = 0; i < q; i++) {
			a[sc.nextInt() - 1]++;
		}
		for (int x : a) {
			System.out.println(k + x - q <= 0 ? "No" : "Yes");
		}
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
            return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
            }
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
            }
        }

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
        }

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 41484
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <math.h>
using namespace std;

int main()
{
	int s;
	cin >> s;
	int h = s / 3600;
	s %= 3600;
	int m = s / 60;
	s %= 60;
	cout << h << ":" << m << ":" << s << endl;

	return 0;
}



Measured memory_bytes: 3100
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 基本はdouble
//map<キー,値> p は辞書。p[キー] = 値
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}


int main() {
	double a, b, h; cin >> a >> b >> h;
	cout << (a + b) * h / 2.0 << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

        int n = sc.nextInt();
        HashSet<Integer> S = new HashSet<>();
        for(int i = 0;i < n;i++){
            S.add(sc.nextInt());
        }
        
        int q = sc.nextInt();
        int count = 0;
        for(int i = 0;i < q;i++){
            if(S.contains(sc.nextInt()))    count++;
        }

        System.out.println(count);
    }
}


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

#define hey(x) cerr << #x << " : " << x << "\n";
#define int long long int
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pair<int, int> >
#define vvpi vector<vector<pair<int, int> > >
#define all(v) (v).begin(), (v).end()   
#define rall(v) (v).rbegin(), (v).rend()
#define pii pair<int, int>
#define pb push_back
#define SZ(x) (int)(x).size()
#define inf 1e12
#define F first
#define S second
#define fill(v, val) memset((v), val, sizeof(v))
#define PI 3.1415926535897932384626
#define out cout << fixed << setprecision(12)
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define hey2(x, y) cerr << #x << " : " << x << "," << #y << " : " << y << '\n';

const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const double pi = acos(-1);

void read(vi &a) {
    for(int &i : a)
        cin >> i;
}
void print(vi &a) {
    for(int i : a)
        cerr << i << ' ';
    cerr << '\n';
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, w;
    cin >> n >> w;
    int dp[n + 1][w + 1];
    vi W(n + 1), val(n + 1);
    for(int i = 1; i <= n; ++i)
        cin >> W[i] >> val[i];
    fill(dp, -1e9);
    for(int item = 0; item <= n; ++item) {
        dp[item][0] = 0;
    }
    for(int weight = 1; weight <= w; ++weight) { 
        for(int item = 1; item <= n; ++item) {
            dp[item][weight] = dp[item - 1][weight];
            if(weight - W[item] >= 0) {
                dp[item][weight] = max(dp[item - 1][weight - W[item]] + val[item], dp[item][weight]);
            }
        }
    }
    cout << dp[n][w];
    return 0;
}


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

int main(){
    int x,y;
    cin>>x>>y;
    if(y<2*x){
        cout<<"No"<<endl;
		return 0;	
	}
    if(y>4*x){
    	cout<<"No"<<endl;
    	return 0;
	}
    if(y%2==1){
    	cout<<"No"<<endl;
    	return 0;
	}
    else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll p[200005];
int main() {
	int n;
	cin >> n;
	ll min=10000000;
	
	ll count = 0;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		
		if (min > p[i]) {
			min = p[i];
			count++;
		}
	}

	cout << count << endl;
	return 0;

}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>a(n),b(n),c(n);
	for(auto&i:a)cin>>i; for(auto&i:b)cin>>i; for(auto&i:c)cin>>i;
	sort(a.begin(),a.end()); sort(c.begin(),c.end());
	uint64_t ans=0;
	for(auto&i:b){
		auto aiter=lower_bound(a.begin(),a.end(),i);
		auto citer=upper_bound(c.begin(),c.end(),i);
		ans+=(uint64_t)(aiter-a.begin())*(c.end()-citer);
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 1408
import java.io.*;

class Main{
	public static void main(String[] args){
		try{
			BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
			String str = buf.readLine();
			String[] input = str.split(" ");
			int W = Integer.parseInt(input[0]); // 長方形の横
			int H = Integer.parseInt(input[1]); // 長方形の縦
			int x = Integer.parseInt(input[2]); // 円の中心のx座標
			int y = Integer.parseInt(input[3]); // 円の中心のy座標
			int r = Integer.parseInt(input[4]); // 円の半径

			// はみ出ているか判定フラグの定義( true=長方形の中に収まっている, false=長方形の外にはみ出ている )
			Boolean Range = true;
			// 円の上下左右の値が高い点、低い点を割り出す

			// 円の最も低いx座標が0より大きいか判定
			// 円の最も低いy座標が0より大きいか判定
			// 円の最も高いx座標がWより小さいか判定
			// 円の最も高いy座標がHより小さい判定
			if( (x-r) < 0 || (y-r) < 0 || W < (x+r) || H < (y+r) ){
				Range = false;
			}

			if(Range){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}
		}
		catch(IOException e){
			
		}
	}
}


Measured memory_bytes: 24452
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def f(b, n):
    if n < b:
        return n
    return f(b, n // b) + n % b


def main():
    N = int(input())
    S = int(input())

    if N == S:
        print(N + 1)
        return
    if N < S:
        print(-1)
        return

    ans = INF
    for b in range(2, int(sqrt(N)) + 1):
        if f(b, N) == S:
            ans = min(ans, b)

    bs = set()
    t = N - S
    for i in range(1, int(sqrt(N)) + 1):
        if t % i == 0:
            bs.add(i + 1)
            bs.add((t // i) + 1)
    
    for b in bs:
        if b == 1:
            continue
        if f(b, N) == S:
            ans = min(ans, b)

    if ans == INF:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4068
N, X = map(int, input().split())
a, p = [1], [1]

for i in range(50):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def Burger(N, X):
    if N == 0:
        return 1
    if X == 1:
        return 0
    elif 1 < X <= a[N-1]+1:
        return Burger(N-1, X-1)
    elif X == a[N-1]+2:
        return p[N-1]+1
    else:
        return p[N-1]+1+Burger(N-1, X-2-a[N-1])

print(Burger(N, X))

Measured memory_bytes: 3064
Q=int(input())

fact=[True]*(10**5+1)
fact[0]=False
fact[1]=False

num=[0]*(10**5+1)
cur=0
for i in range(len(fact)):
  if fact[i]:
    for j in range(i*2,len(fact),i):
      fact[j]=False
    if fact[(i+1)//2]:
      cur+=1
  num[i]=cur
      
for i in range(Q):
  l,r=map(int,input().split())
  print(num[r]-num[l-1])


Measured memory_bytes: 4980
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

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

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

  z = malloc(sizeof(struct 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;
  }
}

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

void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

Node treeSuccessor(Node x){
  Node y;

  if(x->right != NIL) return treeMinimum(x->right);

  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node p;
  Node y; // node to be deleted
  Node x; // child of y

  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;

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

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


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for (i=0;i<n;i++){
    scanf("%s",com);
     if (com[0]=='f'){
      scanf("%d",&x);
      Node t=treeSearch(root,x);
      if (t != NIL) printf("yes\n");
      else printf("no\n");
     }
     else if (com[0]=='i'){
       scanf("%d",&x);
       insert(x);
     } else if (com[0]=='p'){
       inorder(root);
       printf("\n");
       preorder(root);
      printf("\n");
     }
     else if (com[0]=='d'){
      scanf("%d",&x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20488
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cstdlib>
#include<cmath>
using namespace std;

#define MAX_V 100001
#define INF (1e9 + 1)
#define REP(i,n) for(long long int (i)=0;(i) < (n);(i)++)
#define REV(i,n) for(long long int (i)=(n-1);(i) > -1;(i)--)

int n,u,v,mid;
int a[MAX_V];

int main(){
  cin >> n;
  int tmp = INF;
  REP(i,n) cin >> a[i];
  sort(a,a+n);
  u = a[n-1];
  mid = u/2;
  if(u%2==0){
    REP(i,n){
      if(tmp>std::abs(mid - a[i])){
        tmp = std::abs(mid - a[i]);
        v = a[i];
      }
      else break;
    }
  }
  else{
    REP(i,n){
      if(tmp>min(std::abs(mid - a[i]),std::abs(mid - a[i] + 1))){
        tmp = min(std::abs(mid - a[i]),std::abs(mid - a[i] + 1));
        v = a[i];
      }
      else break;
    }
  }

  cout << u << " " << v << endl;




  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;
  vector<string> s(2);
  cin>>s;

  Int sts = 0;//0:左の色がなし, 1:左の色が1色, 2:左の色が2色
  Int ans = 1;
  for(Int i=0;i<N;i++){
    if(s[0][i] == s[1][i]){
      if(sts == 0) ans *= 3;
      if(sts == 1) ans *= 2;
      if(sts == 2) ans *= 1;
      sts = 1;
    }
    else{
      assert(s[0][i] == s[0][i+1]);
      assert(s[1][i] == s[1][i+1]);
      if(sts == 0) ans *= 3 * 2;
      if(sts == 1) ans *= 2;
      if(sts == 2) ans *= 3;
      sts = 2;
      i++;
    }
    ans %= mod;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<int>a(n-1);
    map<int,int>mp;
    REP(i,n-1){
        cin >> a[i];
        mp[a[i]]++;
    }


    FOR(i,1,n+1)cout << mp[i] << endl;
    return 0;
}

Measured memory_bytes: 13552
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

char str[100005];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    
    long len=strlen(str);
    if(str[0]==str[len-1]) {
        if(len%2) {
            printf("Second\n");
        }
        else {
            printf("First\n");
        }
    }
    else {
        if(len%2) {
            printf("First\n");
        }
        else {
            printf("Second\n");
        }
    }

    return 0;
}




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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const long long INF = 2e18;
const long long MOD = 1e9+7;

#define sx(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a),end(a)

int main(void) {
    int N;
    cin >> N;
    vector<int> d(N);
    REP(i, N) cin >> d[i];
    sort(ALL(d));
    if (d[N/2-1] == d[N/2]) {
        cout << 0 << endl;
    }
    else {
        cout << d[N/2] - d[N/2-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES 1
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <random>
#include <ctime>

#define MOD 1000000007

const long long INF = 10000000000000000;

using namespace std;

int main(){
	long long N,M;
	cin>>N>>M;
	if(2*N>=M){
		if(M%2==0) cout<<M/2<<endl;
		else cout<<(M-1)/2<<endl;
	}else{
		M=M-2*N;
		
		cout<<N+M/4<<endl;
	}
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  string a, b;
  cin >> a >> b;
  int a1 = a.size();
  int b1 = b.size();
  if(a1 > b1){
    cout << "GREATER" << endl;
    return 0;
  }else if(a1 < b1){
    cout << "LESS" << endl;
    return 0;
  }else{
    for(int i = 0;i < a1;i++){
      if(a[i] > b[i]){
        cout << "GREATER" << endl;
        return 0;
      }else if(a[i] < b[i]){
        cout << "LESS" << endl;
        return 0;
      }
    }
    cout << "EQUAL" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	i, err := strconv.Atoi(readString())
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func vi(n int, args ...int) []int {
	res := make([]int, n)
	if len(args) == 0 {
		return res
	}
	v := args[0]
	if v == 0 {
		return res
	}
	for i := 0; i < n; i++ {
		res[i] = v
	}
	return res
}

func vvi(n int, args ...int) [][]int {
	res := make([][]int, n)
	m := n
	if len(args) > 0 {
		m = args[0]
	}
	v := 0
	if len(args) > 1 {
		v = args[1]
	}
	for i := 0; i < n; i++ {
		res[i] = vi(m, v)
	}
	return res
}

func main() {
	defer stdout.Flush()

	// readString() string
	// readInt() int
	// readIntSlice(n int) []int
	// readLengthAndSlice() []int
	n := readInt()
	ans := 0
	for i := 0; i < n; i++ {
		for a := readInt(); a%2 == 0; a /= 2 {
			ans++
		}
	}
	println(ans)
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

int main()
{

    lint n;
    cin >> n;
    lint ans=0, tmp;

    vector<lint> h(n);
    REP(i, n) { cin >> h[i]; }

    lint c=0;

    REP(i, n-1){
        if(h[i+1] <= h[i])
        {
            c += 1;
        }else{
            ans = max(ans, c);
            c = 0;
        }
    }

    ans = max(ans, c);

    cout << ans <<"\n";

    return 0;
}

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

int n, k;

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> k;
    ll ans = n / k;
    ans = ans * ans * ans;
    ll tmp = n / k + (n % k >= k / 2);
    if(k % 2 == 0) ans += tmp * tmp * tmp;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
input = gets.chomp.split(" ").map { |n| n.to_i }
if input[1] < input[2]
	if input[0] + input[1] < input[2]
		puts input[2] - (input[0] + input[1])
	else
		puts 0
	end
else
	if input[0] + input[2] < input[1]
		puts input[1] -(input[0] + input[2])
	else
		puts 0
	end
end

Measured memory_bytes: 3836
n,m=map(int,input().split())
student=[list(map(int,input().split())) for _ in range(n)]
checkpoint=[list(map(int,input().split())) for _ in range(m)]
ans=[0]*n

for i in range(n):
    distance=10**9
    index=0
    for j in range(m):
        if abs(student[i][0]-checkpoint[j][0])+abs(student[i][1]-checkpoint[j][1])<distance:
            distance=abs(student[i][0]-checkpoint[j][0])+abs(student[i][1]-checkpoint[j][1])
            index=j
    print(index+1)

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N=in<ll>();
    vector<pair<ll,ll>> x;
    ll x_temp;
    REP(i,N){
        cin>>x_temp;
        x.push_back(make_pair(x_temp,i));
    }
    sort(x.begin(),x.end());
    ll med;ll med_;
    ll ans[N];
    med=x[N/2].first;
    med_=x[N/2-1].first;
    REP(i,N){
        if(i<N/2){
            ans[x[i].second]=med;
        }else{
            ans[x[i].second]=med_;
        }
    }
    REP(i,N){
        print(ans[i]);
    }

    return 0;
}

Measured memory_bytes: 7276
while True:
    H, W = list(map(int, input().split()))
    if H == 0 and W == 0:
        break

    for i in range(H):
        o = (i == 0) or (i % 2 == 0)
        for j in range(W):
            c = "#"
            if j == 0 or j % 2 == 0:
                if o:
                    c = "#"
                else:
                    c = "."
            else:
                if o:
                    c = "."
                else:
                    c = "#"
            print(c, end="")
        print()
    print()



Measured memory_bytes: 7000
using System;

class MainClass {
    static void Main() {
        Scanner cin=new Scanner();

        int[] A=new int[3];
        for (int i=0; i<3; ++i)
            A[i] = cin.nextInt();

        Array.Sort(A);

        Console.WriteLine((A[0]==5 && A[1]==5 && A[2]==7)? "YES":"NO");
    }
}

class Scanner {
    string[] buf;
    int i;
    char[] SplitChar=new char[] {' '};
    public Scanner() {
        buf = new string[0];
        i = 0;
    }
    public string next() {
        if (i < buf.Length) return buf[i++];

        string tmp=Console.ReadLine();
        while (tmp == "")
            tmp = Console.ReadLine();

        buf = tmp.Split(SplitChar, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return buf[i++];
    }
    public int nextInt() {
        return int.Parse(next());
    }
    public long nextLong() {
        return long.Parse(next());
    }
    public double nextDouble() {
        return double.Parse(next());
    }
}


Measured memory_bytes: 2648
#include <bits/stdc++.h>
#define int long long
#define double long double
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T> void prArr(T a,string s=" "){int i=0;for(auto t:a)cout<<i++? s:""<<t;cout<<endl;}


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

  set<int> S;
  for(int i=0;i<n;i++) {
    int a;
    cin>>a;
    S.insert(a);
  }
  
  cout<<S.size()<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define nmax 10000
#define qmax 500
int main(){
  int i,j;
  int n,q;
  int S[nmax];
  int T[qmax];
  int count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(T[i]==S[j]){
	count++;
	break;
      }
    }
  }

  printf("%d\n",count);
  
  
  return 0;
  
}



Measured memory_bytes: 2108
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
typedef long long LL;
const int IN=0x3f3f3f3f;
const int MAX=1e5+5;
int a[MAX];
int G[110][110];

int main()
{
    int h,w;
    while(scanf("%d%d",&h,&w)!=EOF)
    {
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;++i)
            scanf("%d",&a[i]);
        int cn=1;
        for(int i=1;i<=h;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=w;++j)
                {
                   if(a[cn]>0) {G[i][j]=cn;--a[cn];}
                   else if(a[cn]==0) {++cn;G[i][j]=cn;--a[cn];}
                }
            }else
            {
                for(int j=w;j>=1;--j)
                {
                    if(a[cn]>0) {G[i][j]=cn;--a[cn];}
                    else if(a[cn]==0) {++cn;G[i][j]=cn;--a[cn];}
                }
            }
        }
        for(int i=1;i<=h;++i)
        {
            for(int j=1;j<=w;++j)
            {
                if(j!=w) printf("%d ",G[i][j]);
                else printf("%d\n",G[i][j]);
            }
        }
    }
    return 0;
}

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

const long long F = (2e5) * (1e9);

int main()
{
    long long n;
	cin >> n;
	long long* a = new long long[n];
	long long* sum = new long long[n];
    sum[0] = 0;
    long long tot = 0;
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
        tot += a[i];
    }
    for(int i = 1;i < n;i++)
        sum[i] = sum[i - 1] + a[i - 1];
    long long Min = F;
    for(int i = 1;i < n;i++)
    {
        if(Min > abs(2 * sum[i] - tot))
            Min = abs(2 * sum[i] - tot);
    }
    cout << Min << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<int(n);++i)
#define MAX_V 10000
int V;

using Weight = int;

const Weight INF = 1000000000;
// const Weight eps = 1e-8;

struct Edge{
  int src, dest;
  int cap, rev;
  bool isReal;
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

int d[MAX_V];
int iter[MAX_V];

void add_edge(Graph &g, int src, int dest, int cap) {
  g[src].push_back((Edge){src, dest, cap, (int)g[dest].size(),true});
  g[dest].push_back((Edge){dest, src, 0, (int)g[src].size() - 1,false});
}

void bfs(Graph &g, int s) {
  memset(d, -1, sizeof(d));
  queue<int> que;
  d[s] = 0;
  que.push(s);
  while(!que.empty()) {
    int v = que.front(); que.pop();
    REP(i, g[v].size()) {
      Edge &e = g[v][i];
      if (e.cap > 0 && d[e.dest] < 0) {
        d[e.dest] = d[v] + 1;
        que.push(e.dest);
      }
    }
  }
}

int dfs(Graph &g, int v, int t, int f) {
  if (v == t) return f;
  for (int &i = iter[v]; i < g[v].size(); i++) {
    Edge &e = g[v][i];
    if (e.cap > 0 && d[v] < d[e.dest]) {
      int d = dfs(g, e.dest, t, min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        g[e.dest][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(Graph& g, int s, int t) {
  int flow = 0;
  for (;;) {
    bfs(g, s);
    if (d[t] < 0) return flow;
    memset(iter, 0, sizeof(iter));
    int f;
    while ((f = dfs(g, s, t, INF)) > 0) flow += f;
  }
}
int main(){
  int n,m,s,t;
  while(cin>>n>>m>>s>>t,n){
    s--,t--;
    vector<int> a(m),b(m);
    for(int i=0;i<m;i++){
      cin>>a[i]>>b[i];
      a[i]--,b[i]--;
    }
    Graph g(n);
    for(int i=0;i<m;i++){
      add_edge(g,a[i],b[i],1);
    }

    int f=max_flow(g,s,t);

    vector<int> ca,cb;

    
    function<void(int,Graph&,vector<int>&)> mydfs=[&](int v,Graph &graph,vector<int>& used){
      if(used[v]) return;
      used[v]=true;
      for(int i=0;i<graph[v].size();i++) if(graph[v][i].cap>0) mydfs(graph[v][i].dest,graph,used);
      return;
    };
    vector<int> sside(n);
    mydfs(s,g,sside);

    for(int i=0;i<n;i++){
      for(int j=0;j<g[i].size();j++){
	if(!g[i][j].isReal) continue;
	if(!sside[i] && sside[g[i][j].dest]){
	  ca.push_back(g[i][j].dest);
	  cb.push_back(i);
	}
      }
    }
    int res=0;
    for(int i=0;i<ca.size();i++){
      int aa=ca[i],bb=cb[i];
	Graph newg=g;
	add_edge(newg,aa,bb,1);
	int f2=max_flow(newg,s,t);
	if(f2>0) res++;
    }
    if(res==0){
      cout<<f<<" "<<0<<endl;
    }
    else{
      cout<<f+1<<" "<<res<<endl;
    }
    
  }
  
  return 0;
}


Measured memory_bytes: 4108
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto x : v) cerr << x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int i = 0; i < (n); ++i) cerr << a[i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
int main() {
	int x;
	scanf("%d", &x);
	for (int i = 1;; ++i) {
		int v = i * (i + 1) / 2;
		if (v >= x) {
			printf("%d\n", i);
			break;
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n, m, k;
    cin>>n>>m>>k;
    vector<ll> a(n+1);
    a[0] = 0;
    for(ll i=0;i<n;++i){
        ll x;
        cin>>x;
        a[i+1] = a[i] + x;
    }
    vector<ll> b(m+1);
    b[0] = 0;
    for(ll i=0;i<m;++i){
        ll x;
        cin>>x;
        b[i+1] = b[i] + x;
    }

    ll ans = 0;
    ll index = m;
    for(ll i=0;i<n+1;++i){
        for(ll j=index;j>=0;--j){
            if(a[i] + b[j] <= k){
                ans = max(ans, i+j);
                index = j;
                break;
            }
        }
    }
    cout<<ans<<endl;
}

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

int main()
{
  string s, n;
  cin >> n;
  cin >> s;
  int ans = 0, x = 0;
  rep(i, s.size()){
    if(s[i] == 'I') ans = max(ans, ++x);
    else ans = max(ans, --x);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int data[100];
int data2[100];
int main(){
  int n;
  cin >> n;
  REP(i, n){
    cin >> data[i];
    data2[i] = data[i];
  } 
  sort(data, data+n);
  int cnt = 0;
  REP(i, n){
    if(data[i] != data2[i]) cnt++;
  }
  if(cnt <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
steps = gets.chomp.split("").reverse
answers = []
current_step = 0
until current_step == n do
  stepped = false
  m.downto(1) do |index|
    if steps[current_step + index] == "0"
      current_step += index
      answers << index
      stepped = true
      break
    end
  end
  if stepped == false
    puts -1
    exit
  end
end
puts answers.reverse.join(" ")


Measured memory_bytes: 12284
d, g = map(int, input().split())
PC = []
for i in range(d):
    p, c = map(int, input().split())
    PC.append((p, c))

PC.reverse()

ans = 10**18
for i in range(2**d):
    temp = 0
    cnt = 0
    flag = True
    for j in range(d):
        if (i >> j) & 1:
            temp += 100*(d-j)*PC[j][0]+PC[j][1]
            cnt += PC[j][0]
    for j in range(d):
        if not ((i >> j) & 1):
            t = 100*(d-j)
            r = g-temp
            if r > 0:
                q = (r+t-1)//t
                if q < PC[j][0]:
                    temp += 100*(d-j)*q
                    cnt += q
                else:
                    flag = False
    if flag and temp >= g:
        ans = min(ans, cnt)
print(ans)


Measured memory_bytes: 73732
N, M = list(map(int,input().split()))

lists = []
for i in range(M):
    lists.append(list(map(int,input().split())))
lists.sort(key=lambda x: x[1])
ans = 0
min_b = 0
for a, b in lists:
    if min_b <= a:
        min_b = b
        ans += 1
print(ans)
    





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

int main() {
    int n;
    cin >> n;
    int d, x;
    cin >> d >> x;
    vector<int> a(n);
    for (auto& e : a) cin >> e;

    int ans = x;
    for (auto& e : a) ans += 1 + (d - 1) / e;
    
    cout << ans << endl;
}


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

ll n, l, r, c;
ll decL = 0, incR = 0;
priority_queue<ll> pql;
priority_queue<ll, vector<ll>, greater<ll>> pqr;

int main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> n >> l >> r;
	pql.push(l); pqr.push(l); c = 0;

	ll lastsz = 0, cursz = r-l+1, ans = 0;
	for(int i = 1; i < n; i++) {
		cin >> l >> r;
		lastsz = cursz; cursz = r-l+1;

		decL -= cursz - 1;
		incR += lastsz - 1;

		if(l <= pql.top() + decL) {
			ll x = pql.top() + decL;
			ans += x - l;
			pql.push(l - decL);
			pql.push(l - decL);
			pql.pop();
			pqr.push(x - incR);
		} else if(l >= pqr.top() + incR) {
			ll x = pqr.top() + incR;
			ans += l - x;
			pqr.push(l - incR);
			pqr.push(l - incR);
			pqr.pop();
			pql.push(x - decL);
		} else {
			pql.push(l - decL);
			pqr.push(l - incR);
		}
	}

	cout << ans << '\n';

	return 0;
}

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

#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	while(cin >> n){
		vector<pair<int,int> >v;
		f(n){
			int add1, add2;
			cin >> add1 >> add2;
			v.pb({add2,add1});
		}
		sort(v.begin(),v.end());
		int cur = 0;
		int f = 0;
		for(auto i:v){
			cur += i.S;
			if(cur > i.F){
				f = 1;
			}
		}
		if(!f){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
	}
}

Measured memory_bytes: 2420