akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

bool isbo(char c) {
    return c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o';
}

int solve(const vector<string> v) {
    int n = v.size();
    rep2(k, 1, 50 + 1) {
        set<string> st;
        rep(i, n) {
            st.insert(v[i].substr(0, min<int>(v[i].size(), k)));
        }
        if (st.size() == n) {
            return k;
        }
    }
    return -1;
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n;
    while (cin >> n, n) {
        vector<string> v(n);
        rep(i, n) {
            string s;
            cin >> s;
            v[i] += s[0];
            rep(j, s.size() - 1) {
                if (isbo(s[j])) {
                    v[i] += s[j + 1];
                }
            }
        }
        
        cout << solve(v) << endl;
    }
}

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<cmath>
using namespace std;
typedef vector<int> vi;
set<string> cands;
int dy[]={-1,-1,-1,0,0,1,1,1};
int dx[]={-1,0,1,-1,1,-1,0,1};
int maxlength=0,h,w;
string ans="";
vector<int> pri;
bool arr[10005];
void func()
{
  for(int i=0;i<=10000;i++)
    {
      arr[i]=true;
    }
  for(int i=2;i<=sqrt(10000);i++)
    {
      if(arr[i])
	{
	  for(int j=2*i;j<=10000;j++)
	    {
	      if(j%i==0)arr[j]=false;
	    }
	}
    }
  for(int i=2;i<10000;i++)
    {
      if(arr[i]) pri.push_back(i);
    }
}

int main()
{
  func();
  while(1) 
    {
      int m,a,b;
      cin >> m >> a >> b;
      if(!m) break;
      int ans=0;
      int height=0,width=0;
      for(int i=0;i<pri.size();i++)
	{
	  for(int j=0;j<pri.size();j++)
	    {
	      if(pri[i]*pri[j]<=m && (double)pri[j]/pri[i]>=(double)a/b && (double)pri[j]/pri[i]<=1)
		{
		  if(pri[i]*pri[j]>ans)
		    {
		      ans=pri[i]*pri[j];
		      height=pri[i];
		      width=pri[j];
		    }
		}
	    }
	}
      
      cout << width << ' ' << height << endl;
    }
  return 0;
}



Measured memory_bytes: 3120
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        try {
            int building, floor, room, value;
            String line;
            House house = new House();
            int n = Integer.parseInt(br.readLine());
            for (int i = 0; i < n; i++) {
                line = br.readLine();
                st = new StringTokenizer(line);
                building = Integer.parseInt(st.nextToken());
                floor = Integer.parseInt(st.nextToken());
                room = Integer.parseInt(st.nextToken());
                value = Integer.parseInt(st.nextToken());
                house.addInhabitant(building,floor,room,value);
            }
            house.showInhabitant();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

class House {
    private int[][][] inhabitant;

    House() {
        inhabitant = new int[4][3][10];
    }

    void addInhabitant(int building, int floor, int room, int value) {
        inhabitant[building - 1][floor - 1][room - 1] += value;
    }

    void showInhabitant(){
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 3; j++) {
                StringBuilder sb = new StringBuilder();
                for (int k = 0; k < 10; k++) {
                    sb.append(" ").append(inhabitant[i][j][k]);
                }
                System.out.println(sb.toString());
            }
            if(i<3) {
                System.out.println("####################");
            }
        }
    }
}

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

int main() {
  ll a,b,c,x;
  cin >> a >> b >> c >> x;
  ll ans = 0;
  
  rep(i,a+1){
    rep(j,b+1){
      rep(k,c+1){
        if(500*i + 100*j + 50*k == x)
          ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
n = int(input())
b = list(map(int, input().split()))
i = n - 1
ans = []
while i > -1 and n != 0:
    if b[i] == i + 1:
        ans.append(b.pop(i))
        n -= 1
        i = n - 1
    else:
        i -= 1
if n == 0:
    ans.reverse()
    print(*ans, sep='\n')
else:
    print(-1)

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if((a * b) % 2 == 0) {
			System.out.println("Even");
		}else 
			System.out.println("Odd");
	}
}
 

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

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

    int64_t prev = 2, cur = 1;
    for (auto i : irange(0, n - 1)) {
        auto next = prev + cur;
        prev = cur;
        cur = next;
    }

    cout << cur << endl;

    return 0;
}

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

using namespace std;

#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)
typedef pair<int, int> P;
#define F first
#define S second
#define INF 0x3f3f3f3f
#define MP make_pair
#define PB push_back
#define LL long long
#define MAXN 200005

double arr[MAXN];

int main()
{
	int n, k;
	while(~scanf("%d %d\n",&n,&k))
	{
		memset(arr, 0.0, sizeof(arr));
		double tmp;
		arr[0] = 0;
		for (int i = 1; i <= n; i++)
		{
			cin >> tmp;
			arr[i] = arr[i-1] + (1.0+tmp)/2.0;
		}
		double ans = INT_MIN;
		for(int i = 0; i+k-1 <= n; i++)
		{
			ans = max(ans, arr[i+k] - arr[i]);
		}
		printf("%.12f\n",ans);
	}
	return 0;
}

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

int main() {
  ll int n;
  cin >> n;
  ll int r=0, g=0, b=0;
  string s;
  cin >> s;
  
  for(auto c : s) {
    if(c == 'R') ++r;
    else if(c == 'G') ++g;
    else ++b;
  }
  
  ll int all = r*g*b;
//  cout << "all:" << all << endl; 
//  cout << r.size() << " " << g.size() << " " << b.size() << endl;
  
  ll int minus = 0;
  for(ll int i = 0; i < n; ++i) {
    for(ll int j = i+1; j < n; ++j) {
      ll int k = (2 * j) - i;
      if(k >= n || k <= j) continue;
      if(s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) ++minus;
//      cout << i << j << k << endl;
    }
  }
  
  ll int ans = all - minus;
  cout << ans << endl;
  
  return 0;
      
  
  return 0;
}


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

using namespace std;

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

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

void solve(int casi){
//	cout << "Case #" << casi << ": ";
	cin >> n >> m;
	int p = 0, q = 0;
	for (int i = 1; i <= n; i++){
		int x;
		cin >> x;
		if (x & 1) q++;
		else p++;
	}
	ll ans = 1 - m, now = 1;
	for (int i = 1; i <= q; i++){
		now = now * (q + 1 - i) / i;
		if (i % 2 == m)
			ans += now;
	}
	for (int i = 1; i <= p; i++)
		ans *= 2;
	cout << ans << endl;
}

void printans(){

}


int main(){
	std::ios::sync_with_stdio(false);
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}



Measured memory_bytes: 256
/**
 * Tree - Binary Trees
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

public class Main {

	static final int NIL = -1;

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

		int n = parseInt(br.readLine());
		Node[] T = new Node[n];

		StringTokenizer st;
		for (int i = 0; i < n; i++) {
			st = new StringTokenizer(br.readLine());
			int id = parseInt(st.nextToken());
			T[id] = new Node();
			T[id].node = id;
			T[id].left = parseInt(st.nextToken());
			T[id].right = parseInt(st.nextToken());
		}
		// set parent
		for (int i = 0; i < n; i++) {
			if (T[i].left != NIL) T[T[i].left].parent = i;
			if (T[i].right != NIL) T[T[i].right].parent = i;
		}
		// set depth
		int root = 0;
		while (T[root].parent != NIL) root++;
		Deque<Node> stack;

		stack = new ArrayDeque<Node>();
		stack.push(T[root]);
		while (!stack.isEmpty()) {
			Node u = stack.pop();
			if (u.left != NIL) {
				T[u.left].depth = u.depth + 1;
				stack.push(T[u.left]);
			}
			if (u.right != NIL) {
				T[u.right].depth = u.depth + 1;
				stack.push(T[u.right]);
			}
		}
		// set height
		stack = new ArrayDeque<Node>();
		stack.push(T[root]);
		while (!stack.isEmpty()) {
			Node u = stack.pop();
			if (u.height == -1) {
				u.height = 0;
				stack.push(u);
				if (u.left != NIL) stack.push(T[u.left]);
				if (u.right != NIL) stack.push(T[u.right]);
			} else {
				u.height = Math.max(
						u.left != NIL ? T[u.left].height + 1 : 0,
						u.right != NIL ? T[u.right].height + 1 : 0
				);
			}
		}
		// set sibling
		for (int i = 0; i < n; i++) {
			if (T[i].left != NIL && T[i].right != NIL) {
				T[T[i].left].sibling = T[i].right;
				T[T[i].right].sibling = T[i].left;
			}
		}
		// set degree
		for (int i = 0; i < n; i++) {
			if (T[i].left != NIL) T[i].degree++;
			if (T[i].right != NIL) T[i].degree++;
		}
		// set type
		for (int i = 0; i < n; i++) {
			if (T[i].parent == NIL) {
				T[i].type = "root";
			} else if (T[i].left != NIL || T[i].right != NIL) {
				T[i].type = "internal node";
			} else {
				T[i].type = "leaf";
			}
		}
		// print
		for (int i = 0; i < n; i++) {
			System.out.print(T[i].toString());
		}
	} //end main
}

class Node {
	int node;
	int parent = -1;
	int left = -1;
	int right = -1;
	//
	int degree = 0;
	int sibling = -1;
	int depth = 0;
	int height = -1;
	String type;

	public String toString() {
		return String.format(
				"node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n",
				node,
				parent,
				sibling,
				degree,
				depth,
				height,
				type);
	}
}

Measured memory_bytes: 17080
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
    int n, w; cin >> n >> w;
    vector<int> ws(n), vs(n);
    long long w_sum=0;
    int v_sum=0;
    for(int i=0; i<n; ++i){
        cin >> ws[i] >> vs[i];
        w_sum+=ws[i];
        v_sum+=vs[i];
    }
    long long w_inf=w_sum+1;
    vector<long long> dp(v_sum+1, w_inf);
    dp[0]=0;
    for(int i=0; i<n; ++i){
        for(int v=v_sum; v>=vs[i]; --v){
            if(dp[v-vs[i]]==w_inf) continue;
            dp[v]=min(dp[v], dp[v-vs[i]]+ws[i]);
        }
    }
    for(int v=v_sum; v>=0; --v){
        if(dp[v]<=w){
            cout << v << endl;
            break;
        }
    }
    return 0;
}


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

int main(){
  int n, p;
  cin >> n >> p;
  vector<long long> s(n);
  for(int i=0;i<n;i++){
    char x;
    cin >> x;
    s[i] = x - '0';
  }
  vector<long long> x(p);
  x[0]+=1;
  long long amount=0, ans=0;
  //pで割ったあまりが同じものをカウント
  if(p==2){
    for(int i=0;i<n;i++){
      if(s[i]%2==0){
        ans += i+1;
      }
    }
  }else if(p==5){
    for(int i=0;i<n;i++){
      if(s[i]%5==0){
        ans += i+1;
      }
    }
  }else{
    int y=1;
    for(int i=0;i<n;i++){
      if(i!=0) y=y*10;
      y = y%p;
      amount += y*s[n-i-1];
      //cout << amount << endl;
      amount=amount%p;
      x[amount] += 1;
    }
    for(int i=0;i<p;i++){
      if(x[i]>1) ans += x[i]*(x[i]-1)/2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1920
r, c = map(int, input().split())
data = [[0]*(c+1) for j in range(r+1)]

r_sum = 0
for i in range(r):
    imf = list(map(int, input().split()))
    for j in range(c):
        data[i][j] = imf[j]
        r_sum += imf[j]
    data[i][c] = r_sum
    r_sum = 0

c_sum = 0
for i in range(c+1):
    for j in range(r):
        c_sum += data[j][i]
    data[r][i] = c_sum
    c_sum = 0
    
for i in range(r+1):
    print("%d" %data[i][0], end="")
    for j in range(1, c+1):
        print(" %d" %data[i][j], end="")
    print()


Measured memory_bytes: 6204
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}
int cnt=0;


int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		ll n,m;
		cin>>n>>m;
		char a[n][m];
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++)
			cin>>a[i][j];
		}
		ll b[n][m];
		if(a[0][0]=='#')
		{
			b[0][0]=1;
		}
		else
		{
			b[0][0]=0;
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(i==0&&j==0)
				continue;
				if(i==0){
					if(a[i][j]=='.')
					b[i][j]=b[i][j-1];
					else{
						if(a[i][j-1]=='#')
						b[i][j]=b[i][j-1];
						else
						b[i][j]=b[i][j-1]+1;
					}
				}
				else if(j==0){
					if(a[i][j]=='.')
					b[i][j]=b[i-1][j];
					else{
						if(a[i-1][j]=='#')
						b[i][j]=b[i-1][j];
						else
						b[i][j]=b[i-1][j]+1;
					}
					
				}
				else{
					if(a[i][j]=='.'){
						b[i][j]=min(b[i-1][j],b[i][j-1]);
					}
					else{
						if(a[i-1][j]=='#')
						b[i][j]=b[i-1][j];
						else
						b[i][j]=b[i-1][j]+1;
						if(a[i][j-1]=='#')
						b[i][j]=min(b[i][j],b[i][j-1]);
						else
						b[i][j]=min(b[i][j],b[i][j-1]+1);
					}
				}
			}
		}
		cout<<b[n-1][m-1];
	}
	return 0;
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

const ll MOD = 1000000009ll;

int n,k;
int a[5252];
ll dp[5252];
ll bef[5252];

int main(){
  scanf("%d%d",&n,&k);
  REP(i,n)scanf("%d",a+i);
  // first dp
  dp[0] = 1;
  REP(i,n)FORR(j,0,k+1){
    if(j-a[i]>=0){
      dp[j] += dp[j-a[i]];
      dp[j] %= MOD;
    }
  }
  int ans = n;
  // modosu
  REP(i,n){
    int yo = a[i];
    REP(j,k+1){
      bef[j] = dp[j];
      if(j-yo>=0){
        bef[j] -= bef[j-yo];
        bef[j] += MOD;
        bef[j] %= MOD;
      }
      // printf("%d ",bef[j]);
    }
    // puts("");
    bool ok = false;
    FOR(j,max(0,k-yo),k){
      if(bef[j]>0)ok=true;
    }
    if(ok)ans--;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
		string[] str =Console.ReadLine().Split(' ');
      int N=int.Parse(str[0]);
      int M=int.Parse(str[1]);
      int i=0;
     while(N>0){
        N=N-M;
       i=i+1;
        

    }
      Console.WriteLine(i);
    
  }

}
}

Measured memory_bytes: 11092
#include <iostream>
using namespace std;
int main()
{
	int W, H , x , y , r;
	cin >> W >> H >> x >> y >> r;
	//横からはみ出る時
	if (x - r < 0 || W < x + r)
		cout << "No" << endl ;
	//縦からはみ出る時
	else if (y - r < 0 || H < y + r )
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	
}


Measured memory_bytes: 3112
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let input = read_vec::<usize>();
    let (n, k) = (input[0], input[1]);


    let mut ret = 0f64;

    for i in 1..n+1 {
        let mut temp = 1f64 / n as f64;
        let mut now = i;

        while now < k {
            now *= 2;
            temp /= 2f64;
        }
        ret += temp;
    }

    println!("{}", ret);
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i) // ROF(i,n,0)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで降順
#define SUM(a) accumulate(all(a),int(0))
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>T add(const T &a, const T &b){return (a+b)%mod;}

signed main(){
  int n; cin >> n;
  cout << 3*n*n << endl;
}


Measured memory_bytes: 384
#include <complex>
#include <vector>
#include <tuple>
#include <algorithm>
#include <random>

std::pair<std::complex<double>, double> min_circle (std::vector<std::complex<double>> points, int seed = 2020) {
    using point = std::complex<double>;
    using circle = std::pair<point, double>;
    const double eps = 1e-10; int n = int(points.size());
    if (n == 1) { return {points[0], 0}; };
    auto inner = [&] (const point &a, const circle &c) -> bool { 
        return std::norm(a - c.first) <= c.second + eps;
    };
    auto make_circle_2 = [&](const point &a, const point &b) -> circle {
        point c = (a + b) / 2.0; double r = std::norm(a - c);
        return {c, r};
    };
    auto make_circle_3 = [&](const point &a, const point &b, const point &c) -> circle {
        double A = std::norm(b - c), B = std::norm(c - a), C = std::norm(a - b);
        double S = std::norm((a - c) * std::conj(b - c) - std::conj(a - c) * (b - c));
        point p = (A * (B + C - A) * a + B * (C + A - B) * b + C * (A + B - C) * c) / S;
        double r = std::norm(p - a);
        return {p, r};
    };
    
    // MinDisk
    std::shuffle (points.begin(), points.end(), std::mt19937(seed));
    circle d = make_circle_2(points[0], points[1]);
    for (int i = 2; i < n; i++) {
        if (not inner(points[i], d)) {
            // MinDiskWithPoints
            d = make_circle_2(points[0], points[i]);
            for (int j = 1; j < i; j++) {
                if (not inner(points[j], d)) {
                    // MinDiskWith2Points
                    d = make_circle_2(points[i], points[j]);
                    for (int k = 0; k < j; k++) {
                        if (not inner(points[k], d)) {
                            d = make_circle_3(points[k], points[j], points[i]);
                        }
                    }
                }
            }
        }
    }
    return d;
}


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

int main() {
    int n;
    cin >> n;
    vector<complex<double>> points;
    for (int i = 0; i < n; i++) {
        double x, y;
        cin >> x >> y;
        points.emplace_back(x, y);
    }
    
    double ans = min_circle(points).second;
    
    cout << fixed << setprecision(20) << sqrt(ans) << '\n';
    
    return 0;
}

Measured memory_bytes: 3812
#include<cstdio>
#include<algorithm>
using namespace std;
const double INF = 10000.0;

int n, m, p, a, b, t[8], x[450], y[450], z[450];
int d[30][30];

double dp[1<<8][30];

int main() {
  while (1) {
    scanf("%d%d%d%d%d", &n, &m, &p, &a, &b);
    a--; b--;
    if (n == 0) break;
    for (int i = 0; i < m; i++) for (int j = 0; j < m; j++) d[i][j] = -1;
    for (int i = 0; i < n; i++) scanf("%d", &t[i]);
    for (int i = 0; i < p; i++) {
      scanf("%d%d%d", &x[i], &y[i], &z[i]);
      x[i]--; y[i]--;
      d[x[i]][y[i]] = z[i];
      d[y[i]][x[i]] = z[i];
    }
    for (int i = 0; i < 1 << n; i++) for (int j = 0; j < m; j++) dp[i][j] = INF;
    dp[(1 << n) - 1][a] = 0;
    double ans = INF;
    for (int i = (1 << n) - 1; i >= 0; i--) {
      ans = min(ans, dp[i][b]);
      for (int j = 0; j < m; j++) {
        for (int k = 0; k < n; k++) {
          if (((i >> k) & 1) == 0) continue;
          for (int r = 0; r < m; r++) {
            if (d[j][r] < 0) continue;
            dp[i & ~(1 << k)][r] = min(dp[i & ~(1 << k)][r], dp[i][j] + (double)d[j][r] / t[k]);
          }
        }
      }
    }
    if (ans != INF) printf("%f\n", ans);
    else printf("Impossible\n");
  }
}



Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int K, N;
    cin >> K >> N;

    if (K % 2 == 0) {
        cout << K / 2;
        for (int i = 1; i < N; i++)
            cout << " " << K;
        cout << endl;
        return 0;
    }

    if (K == 1) {
        for (int i = 0; i < (N - 1) / 2 + 1; i++) {
            if (i) cout << " ";
            cout << 1;
        }
        cout << endl;
        return 0;
    }

    vi res(N, (K + 1) / 2);
    for (int i = 0; i < N / 2; i++) {
        if (res.back() == 1) {
            res.pop_back();
        }
        else {
            res.back()--;
            while (sz(res) < N) res.push_back(K);
        }
    }

    for (int v : res) cout << v << " ";
    cout << endl;

    return 0;
}



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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    string S;
    std::cin >> S;
    map<string, int> map;
    map.emplace("SUN", 7);
    map.emplace("MON", 6);
    map.emplace("TUE", 5);
    map.emplace("WED", 4);
    map.emplace("THU", 3);
    map.emplace("FRI", 2);
    map.emplace("SAT", 1);
    std::cout << map[S] << std::endl;

    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)

m1 = s.count('B')
m2 = s[n-m1::].count('B')

c = 0
for i in range(n):
    if s[i] == 'B':
        c += n-i-1
for i in range(m1):
    c -= i

print(c)

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

int main(void) {
  int a, b;
  cin >> a >> b;

  if (a>b) {
    cout << "a > b" << endl;
  } else if (a == b) {
    cout << "a == b" << endl;
  } else {
    cout << "a < b" << endl;
  }

  return 0;
}


Measured memory_bytes: 3084
n = int(input())
s = input()

rinds, ginds, binds = [], [], set()

for i in range(n):
    if s[i] == 'R': rinds.append(i)
    elif s[i] == 'G': ginds.append(i)
    else: binds.add(i)

rlen, glen, blen = len(rinds), len(ginds), len(binds)


ans = 0

for i in rinds:
    for j in ginds:
        dist = abs(i-j)
        i_ = min(i, j)
        j_ = max(i, j)
        ans += blen
        # i' < j' < k
        if j_ + dist in binds:
            ans -= 1
        if dist%2==0 and i_ + dist//2 in binds:
            ans -= 1
        if i_ - dist in binds:
            ans -= 1

        # if binsearch_same(binds, blen, dist, j_):
        #     ans -= 1
        # # i'< k < j' 
        # if dist%2==0 and binsearch_same(binds, blen, dist//2, i_):
        #     ans -= 1
        # # # k < i' < j'
        # if binsearch_same(binds, blen, -dist, i_):
        #     ans -= 1

print(ans)















# n = input()
# print('Yes' if '7' in n else 'No')

# n = int(input())
# ans = 0
# for i in range(1, n+1):
#     if i%3 == 0 or i%5==0:
#         pass
#     else:
#         ans += i
# print(ans)


# k = int(input())
# def gcd(a, b):
#     if b == 0:
#         return a
#     return gcd(b, a%b)

# ans = 0
# for a in range(1, k+1):
#     for b in range(1, k+1):
#         for c in range(1, k+1):
#             ans += gcd(gcd(a, b), c)
# print(ans)

Measured memory_bytes: 68972
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>
#include <set>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;


const long long MAX_N = 1 << 17;
const long long MOD = 1000000007;

long long dat[2 * MAX_N - 1];

ll fact(ll n) {
	if (n == 1) return 1;
	return n * fact(n - 1);
}

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

/*
//C
int main(void) {
	ll n, k, s;
	cin >> n >> k >> s;
	
	 if (n == k) {
		rep(i, 0, n) {
			if (i < n - 1) cout << s << " ";
			else cout << s << endl;
		}
	 }
	 else if (s == 1) {
		 rep(i, 0, n) {
			 if (i < k) {
				 if (i < n - 1) cout << s << " ";
			 }
			 else {
				 if (i < n - 1) {
					 if (i < n - 1) cout << s+1 << " ";
				 }
				 else cout << s + 1 << endl;
			 }
		 }
	 }
	else {
		ll a, b;
		a = s / 2;
		b = s % 2 == 0 ? a : a + 1;
		swap(a, b);
		rep(i, 0, n) {
			if (i <= k) {
				if(i < n -1)
					cout << (i % 2 == 0 ? a : b) << " ";
				else
					cout << (i % 2 == 0 ? a : b) << endl;
			}
			else if (i < n - 1) {
				if (s < 1e9) cout << s + 1 << " ";
				else cout << s - 1 << " ";
			}
			//i == n-1
			else {
				if (s < 1e9) cout << s + 1 << endl;
				else cout << s - 1 << endl;
			}
		}
	}
}
*/


//B
int main(void) {
	ll n;
	cin >> n;
	vector<pair<ll,ll>> fuck = vector<pair<ll,ll>>(n);
	rep(i, 0, n) {
		ll x, l;
		cin >> x >> l;
		fuck[i] = make_pair(x + l, l);
	}
	sort(fuck.begin(), fuck.end());
	ll x = fuck[0].first;
	ll ans = 1;
	rep(i, 1, n) {
		if (x <= fuck[i].first - fuck[i].second * 2) {
			ans++;
			x = fuck[i].first;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1920
#include<iostream>
#include<string>
#include<string.h>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<cstdlib>
#include<vector>
#include<set>
#include<deque>
#include<queue>
#include<math.h>
#include<chrono>
#include<list>
#include<random>
#include<bitset>
#include<assert.h>
#include<ctime>
#include<cstdio>
#include <unordered_map>
using namespace std;
ifstream fi("test.txt");
ofstream fo("out.txt");
#define fast_input() {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); }
#define ll long long
#define For(i,n) for (int(i) = 0; (i)<(n); (i)++)
#define For1(i,n) for (int(i) = 1; (i) <= (n); (i)++)
#define Forlr(i,l,r) for (int(i) = (l); (i) <= (r); (i)++)
#define Forrl(i,r,l) for (int(i) = (r); (i) >= (l); (i)--)
#define all(a) a.begin(), a.end() 
#define pb push_back
#define pp pop_back
#define mp make_pair
#define PI 3.14159265
#define putno return cout <<"NO", 0;
#define putyes return cout <<"YES", 0;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef map<int, int> mii;
//const ll MOD = 1e9 + 7;
const int N = 1e5 + 5;
//DSU
/*
int p[ N], r[N];
void init(int n) {
	For(i, n) {
		p[i] = i;
	}
}
int get(int x) {
	if (p[x] != x) {
		p[x] = get(p[x]);
	}
	return p[x];
}
bool uni(int x, int y) {
	x = get(x); y = get(y);
	if (x == y) {
		return false;
	}
	if (r[x] >= r[y]) {
		p[y] = x;
	}
	else {
		p[x] = y;
	}
	if (r[x] == r[y]) {
		r[x]++;
	}
	return true;
}
*/

// So mu
/*
int power(int x, unsigned int y, int p)
{
	int res = 1; // Initialize result

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

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

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

// ReadHexa
/*
bitset<16400> b[4101];
void readHexa()
{
	For(i, n)
	{
		string st;
		cin>> st;
		For(j, m/4)
		{
			int x;
			if (st[j] >= 'A' && st[j] <= 'F')
				x = st[j] - 'A' + 10;
			else x = st[j] - '0';
			for (int k = 4; k; --k, x >>= 1)
				b[i][j * 4 + k] = x & 1;
		}
	}
}
*/

// nChoosek
/*
ll nChoosek(ll n, ll k)
{
	if (k > n) return 0;
	if (k * 2 > n) k = n - k;
	if (k == 0) return 1;

	ll result = n;
	for (ll i = 2; i <= k; ++i) {
		result *= (n - i + 1);
		result /= i;
	}
	return result;
}
*/


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/*
MIKUNO - 15/02/1999
*/
int n, m, k, cnt, rs1, q;
//ll n, m, q, k, pos, t, cnt, rs1, check;
ll maxx = -1e9, minn = 1e9;
const int maxn = 6;
const ll MOD = 1e9 + 7;
ll rs;
ll a[300];
int main()
{
	fast_input();
	string s;
	cin >> n;
	cin >> s;
	For(i, s.length())
	{
		a[s[i] - 'a']	++;
	}
	rs = 1;
	For(i, 26)
	{
		if (a[i])
		{
			rs *= (a[i] + 1);
			rs = rs % MOD;
		}
	}
	cout << rs - 1;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n,m,q,dp[555][555];
int main()
{
	cin>>n>>m>>q;
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		dp[x][y]++;
	}
	for(int l=1;l<=n;l++)
	{
		for(int i=1;i+l<=n;i++)
		{
			int j=i+l;
			dp[i][j]+=dp[i+1][j]+dp[i][j-1]-dp[i+1][j-1];
		}
	}
	for(int i=0;i<q;i++)
	{
		int x,y;
		cin>>x>>y;
		cout<<dp[x][y]<<endl;
	}
	return 0;
}

Measured memory_bytes: 2048
#include <cstdio>

int main(void){
    int a=0,b=0;
    scanf("%d",&a);
    scanf("%d",&b);
    if(a==b){
        printf("a == b\n");
    }
    else if(a<b){
        printf("a < b\n");
    }
    else{
        printf("a > b\n");
    }
    return 0;
}


Measured memory_bytes: 2592
while True:
    try:
        s1 = input()
        s2 = input()
    except:
        break
    c = 0
    while True:
        try:
            i = s1.index("\"")
            if s1[:i] != s2[:i]:
                print("DIFFERENT")
                break
        except:
            if s1 == s2:
                if c == 0:
                    print("IDENTICAL")
                    break
                else:
                    print("CLOSE")
                    break
            else:
                print("DIFFERENT")
                break
        try:
            j1 = s1[i + 1:].index("\"")
            j2 = s2[i + 1:].index("\"")
        except:
            print("DIFFERENT")
            break
        if s1[i + 1:i + j1 + 1] != s2[i + 1:i + j2 + 1]:
            c += 1
        if c == 2:
            print("DIFFERENT")
            break
        s1 = s1[i + j1 + 2:]
        s2 = s2[i + j2 + 2:]


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

std::vector<long long> z_algorithm(std::string& s) {
	long long n = s.size();
	std::vector<long long> ret(n);
	ret[0] = n;
	long long cnt = 0;
	for (long long i = 1; i < n; i++) {
		for (long long j = i + cnt; j < n; j++) {
			if (s[j] != s[j - i]) {
				cnt = j - i;
				break;
			}
			if (j == n - 1) cnt = n - i;
		}
		ret[i] = cnt;
		if (cnt == 0) continue;
		for (long long j = i + 1; j < n; j++) {
			if (j - i + ret[j - i] < cnt) {
				ret[j] = ret[j - i];
				if (j == n - 1) return ret;
			}
			else {
				cnt -= j - i;
				i = j - 1;
				break;
			}
		}
	}
	return ret;
}

int main() {
	long long n;
	std::string s;
	std::cin >> n >> s;
	long long ans = 0;
	for (long long i = 0; i < n; i++) {
		std::string t = s.substr(i);
		std::vector<long long> v = z_algorithm(t);
		long long subans = 0;
		for (long long j = 0; j < v.size(); j++) {
			subans = std::max(subans, std::min(v[j], j));
		}
		ans = std::max(ans, subans);
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define double long double

using namespace std;

const int MAX_N = 2005;

double dp[MAX_N][3];
double p[MAX_N];
double pika[MAX_N];
double E[3][10005];

int main()
{
    int n,m;
    cin >> n >> m;
    vector<vector<int> > s(3,vector<int>(n));
    int c[3] = {5,3,2};
    rep(i,n){
        cin >> s[0][i] >> s[1][i] >> s[2][i];
    }
    double tm = 1.0;
    rep(i,m){
        tm *= 2.0/3.0;
    }
    rep(i,m+1){
        if(i) tm *= (double)(m-i+1)/(2*i);
        p[i] = tm;
    }
    pika[0] = p[0];
    rep(i,m){
        pika[i+1] = pika[i] + p[i+1];
    }
    rep(i,3){
        rep(j,m+1){
            int cri = s[i][0]*j;
            rep(k,n){
                rep(l,3){
                    dp[k][l] = 0.0;
                }
            }
            double make = 1.0;
            dp[0][0] = 1.0;
            if(cri){
                rep(k,n-1){
                    rep(l,3){
                        dp[k+1][l] += dp[k][l]*pika[min(m,(cri-1)/s[i][k+1])];
                        if(l < 2) dp[k+1][l+1] += dp[k][l]*(1.0-pika[min(m,(cri-1)/s[i][k+1])]);
                    }
                }
                rep(k,n-1){
                    make *= (1.0-pika[min(m,(cri-1)/s[i][k+1])]);
                }
            }else{
                make = 1.0;
            }
            E[i][j] = (dp[n-1][0]+dp[n-1][1]+dp[n-1][2])*c[i]-make;
        }
    }
    double ans = -1e10;
    rep(i,m+1){
        rep(j,m-i+1){
            ans = max(ans,E[0][i]+E[1][j]+E[2][m-i-j]);
        }
    }
    printf("%.12Lf\n",ans);
}



Measured memory_bytes: 3548
import java.util.Scanner;

public class Main {

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

		int n = in.nextInt();
		int l = in.nextInt();

		int min = Integer.MAX_VALUE;
		int minI = 0;

		for ( int i = 1; i <= n; i++ ) {
			if ( min > Math.abs(l + i - 1) ) {
				min = Math.abs(l + i - 1);
				minI = i;
			}
		}
		
		int sum = 0;
		for ( int i = 1; i <= n; i++ ) {
			if ( i != minI ) {
				sum += l + i -1;
			}
		}
		
		System.out.println(sum);
		in.close();
	}
}

Measured memory_bytes: 21716
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Reader sc = new Reader();
        PrintWriter pw = new PrintWriter(System.out);
        
        try {
            char[] s = sc.next().toCharArray();
            char[] c = sc.next().toCharArray();
            int n = s.length;
            int m = c.length;
            int min = Integer.MAX_VALUE;
            for(int i=0 ; i<n-m+1 ; i++) {
                int change = 0;
                for(int j=0 ; j<m ; j++) {
                    if(s[i+j] != c[j]) {
                        change++;
                    }
                }
                min = Math.min(change, min);
            }
            
            pw.println(min);
        }
        finally {
            pw.flush();
            pw.close();
        }
    }
    
    static class Reader {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while(!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException io) {
                    io.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 32696
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  string s;
  cin >> s;
  set<char> k;
  rep(i,0,s.size()) k.insert(s[i]);
  rep(i,0,26) {
    char t = 'a';
    t += i;
    if(!k.count(t)) {
      cout << t << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
#include<map>//map
using namespace std;
typedef long long LL; 
typedef pair<LL,LL> P;//Pでpair<-,->を表す。
const LL MAX=2000010;
const LL MOD=1000000007;
typedef map<LL,LL>::iterator Itr;

int main()
{ 
    LL n;
    cin>>n;
    LL a[n];
    for(int i=0;i<n;i++){cin>>a[i];}

    LL k=n/2;
    LL a1[k+1];//手前
    LL am[k+1];
    a1[0]=0;
    am[0]=0;
    for(int i=1;i<=k;i++){
        a1[i]=a1[i-1]+a[(i-1)*2];
        am[i]=max(am[i-1]+a[i*2-1],a1[i]);
    }
    if(n%2==0){cout<<am[k]<<endl;return 0;}

    LL b[n];
    for(int i=0;i<n;i++){b[i]=a[i];}
    reverse(b,b+n);
    LL b1[k+1];
    LL bm[k+1];
    b1[0]=0;
    bm[0]=0;
    for(int i=1;i<=k;i++){
        b1[i]=b1[i-1]+b[(i-1)*2];
        bm[i]=max(bm[i-1]+b[i*2-1],b1[i]);
        //cout<<b1[i]<<endl;
    }

    LL ans=0;
    for(int i=0;i<k;i++){
        ans=ans+a[i*2+1];
    }
    for(int i=0;i<k+1;i++){
        LL x=am[i]+bm[k-i];
        if(ans<x){ans=x;}
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()

using ll = long long;
using vint = vector<int>;

void Main() {
    int n, m;
    cin >> n >> m;
    vint left(m);
    vint right(m);

    rep(i, m) {
        cin >> left[i] >> right[i];
    }

    int lval = 1;
    int rval = n;
    rep(i, m) {
        lval = max(lval, left[i]);
        rval = min(rval, right[i]);
    }
    int ans = rval - lval + 1;
    if (ans <= 0) {
        cout << 0 << endl;
        return;
    }
    else {
        cout << ans << endl;
        return;
    }

}

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


Measured memory_bytes: 1024
n,k = map(int, input().split())
a = list(map(int, input().split()))
start = 1
end = max(a)
bs = 1
be = max(a)
while start != end:
    center = (start+end)//2
    tnp = 0
    for i in range(n):
        tnp += (a[i]-1)//center
    #print(start,end,center,tnp)
    if (tnp>k):
        start = center
    else:
        end = center
    if (start==bs and end==be):
        x = 0
        for j in range(n):
            x += (a[j]-1)//start
        y = 0
        for j in range(n):
            y += (a[j]-1)//end
        #print(x,y)
        #print(x,y)
        if (x<=k):
            print(start)
        else:
            print(end)
        exit()
    bs = start
    be = end
    
print(start)

Measured memory_bytes: 30848
import java.util.HashSet;
import java.util.Set;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Set<String> set = new HashSet<String>();
        int num=sc.nextInt();
        String str,si;

        for(int i=0;i<num;i++){
            si=sc.next();
            str=sc.next();
           if(si.equals("insert")){
                set.add(str);
            }else{
                if(set.contains(str)){
                    System.out.println("yes");
                }else{
                    System.out.println("no");
                }
            }
        }
        sc.close();
    }
}



Measured memory_bytes: 251480
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

int main()
{
    int n,count=0;
    scanf("%d",&n);
    while(n)
    {
      if(n%10==2)
        count++;
      n/=10;
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define VI vector<int>
#define PII pair<int, int>
#define FI first
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30;
const ll LINF=1LL<<60 ;
const ll MOD=1e9+7 ;
///////////////////

const int MXN = 100*1000 + 7;

class UnionFind {
private:
	unsigned size_; std::vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};

int p[MXN];

int main(){
	int n,m; cin >> n >> m;
	UnionFind uf(n+1);
	FOR(i,1,n){
		cin >> p[i];
	}
	FOR(i,1,m){
		int x,y; cin >> x >>y;
		uf.unite(x,y);
	}
	int ans=0;
	FOR(i,1,n){
		if(uf.same(i,p[i])) ans += 1;
	}

	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int n;
  while(cin >> n, n) {
    string a;
    cin >> a;
    while(n--) {
      string tmp;
      for (int i=0; i<a.size();) {
        int j;
        for (j=i;j<a.size() && a[i]==a[j]; ++j);
        stringstream ss;
        ss << j-i;
        tmp += ss.str();
        tmp += a[i];
        i = j;
      }
      //  cout << tmp << endl;
      a = tmp;
    }
    cout << a << endl;
  }
}

Measured memory_bytes: 1072
#include <iostream>
#include <array>
#include <algorithm>
    
int main(){
    std::array<u_int, 10> heights;
       
    for (int i = 0; i < 10; ++i){
        std::cin >> heights[i];
    }
       
    std::sort(heights.begin(), heights.end(), std::greater<u_int>());
       
    for (int i = 0; i < 3; ++i){
        std::cout << heights[i] << std::endl;
    }
      
    return 0;
}


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

int a[200005];
vector<int> adjList[200005];
int memoEnding[200005];
int memoLength[200005];

void dfs(int currVertex, int parent, int lisLength)
{
	int pos = lower_bound(memoEnding + 1, memoEnding + lisLength + 1, a[currVertex]) - memoEnding;
	int temp = memoEnding[pos];
	

	
	int newLisLength = lisLength;
	if(pos == lisLength + 1)
		newLisLength++;
	
	memoEnding[pos] = a[currVertex];
	memoLength[currVertex] = newLisLength;
		
	vector<int>::iterator itr;
	for(itr = adjList[currVertex].begin(); itr != adjList[currVertex].end(); itr++)
	{
		if(*itr == parent)
			continue;
			
		dfs(*itr, currVertex, newLisLength);
	}
	
	memoEnding[pos] = temp;
}

int main()
{
	int N;
	scanf("%d", &N);
	
	for(int i = 1; i <= N; i++)
		scanf("%d", &a[i]);
		
	for(int i = 1; i < N; i++)
	{
		int ui, vi;
		scanf("%d%d", &ui, &vi);
		
		adjList[ui].push_back(vi);
		adjList[vi].push_back(ui);
	}
	
	dfs(1, -1, 0);
	
	for(int i = 1; i <= N; i++)
		printf("%d\n", memoLength[i]);
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int a,b;
	cin>>a>>b;
	repi(i,1,2000){
		if(int(i*0.08)==a && int(i*0.1)==b){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
bool f[100010];
string a[4]={"dream","dreamer","erase","eraser"};
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    string s;
    cin>>s,f[0]=1;
    for(int i=0;i<s.size();i++)
	if(f[i]) {
	    if(s.substr(i,5)==a[0]||s.substr(i,5)==a[2])
		f[i+5]=1;
	    if(s.substr(i,6)==a[3])
		f[i+6]=1;
	    if(s.substr(i,7)==a[1])
		f[i+7]=1;
	}
    puts(f[s.size()]?"YES":"NO");
    return 0;
}

Measured memory_bytes: 512
N, X = map(int, input().split())

def ct(n, x):
    # print(n, x)
    if x == 1:
        if n == 0:
            return 1
        else:
            return 0
    elif x == L[n]//2+1:
        return P[n-1]+1
    elif x == L[n]:
        return P[n]
    elif x < L[n]//2+1:
        return ct(n-1,x-1)
    else:
        return P[n-1] + 1 + ct(n-1,x-(L[n]//2+1))

L = [1]
for i in range(50):
    L.append(L[-1]*2+3)
P = [1]
for i in range(50):
    P.append(P[-1]*2+1)

print(ct(N, X))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
#include <sstream>
#include <bitset>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int main(){
	ll n, k, i, sum=0;
    cin >> n >> k;
    ll p[n];
    for(i=0;i<n;i++) {
      cin >> p[i]; 
    }
    sort(p, p+n);
    for(i=0;i<k;i++) sum += p[i];
    cout << sum << endl;
}


Measured memory_bytes: 3640