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

int main(){
    int N,Q;
    cin >> N >> Q;
    vector<vector<int>> v(N+1);
    for(int i=0;i<N-1;i++){
        int a,b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    vector<int> q(N+1);
    for(int i=0;i<Q;i++){
        int p,x;
        cin >> p >> x;
        q[p] += x;
    }
    vector<int> ans(N+1);
    function<void(int,int,int)> dfs = [&](int n,int m,int value){
        ans[n] = value+q[n];
        for(auto x:v[n]) if(x!=m){
            dfs(x,n,value+q[n]);
        }
    };
    dfs(1,0,0);
    for(int i=1;i<=N;i++) cout << ans[i] << (i!=N? " ":"\n");
}

Measured memory_bytes: 33664
N = int(input())
S = input()

dp = [[0] * N for _ in range(N)]

ans = 0

for j in range(N - 1, 0, -1):
    sj = S[j]
    for i in range(j-1, -1, -1):
        si = S[i]
        if j == N - 1:
            if si == sj:
                dp[j][i] = 1
                ans = 1
        else:
            if si == sj:
                dp[j][i] = min(j - i, dp[j + 1][i + 1] + 1)
                ans = max(ans, dp[j][i])

print(ans)


Measured memory_bytes: 231432
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

vector<int> make(ll N, int y){
    if(N == 0)
        return {};
    if(N == 1){
        return {y, y};
    }
    if(N == 2){
        return {y + 1, y, y, y + 1};
    }
    vector<int> ff;
    if(N % 2 == 0){
        ff = make(N-1, y + 1);
        int m = ff.size();
        ff.insert(ff.begin() + m/2, y);
        ff.insert(ff.begin() + m/2, y);
    }
    else{
        ff = make(N/2, y + 1);
        int m = ff.size();
        ff.insert(ff.begin() + m/2, y);
        ff.insert(ff.begin(), y);
    }
    return ff;
}

int main(){
    fastIO;
    ll m;
    cin >> m;
    vector<int> res = make(m, 1);
    cout << res.size() << "\n";
    for(auto p : res)
        cout << p << " ";
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x: u32,
        y: u32,
    }
    let f = |x| {
        match x {
            2 => 3,
            4 | 6 | 9 | 11 => 2,
            _ => 1
        }
    };
    println!("{}",
        if f(x) == f(y) {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    ll n;
    std::cin >> n;
    vector<pair<ll,ll>> x(n);
    for (int i = 0; i < n; i++) {
        ll a,b;
        std::cin >> a>>b;
        x[i] = {a-b,a+b};
    }
    
    sort(x.begin(),x.end());
    
    auto now = x[0];
    ll res = 0;
    for (int i = 1; i < n; i++) {
        if(now.second<=x[i].first){
            now = x[i];
            continue;
        }
        res++;
        if(x[i].second <= now.second){
            now = x[i];
        }
        // std::cout << res<<" "<<i << std::endl;
    }
    std::cout << n-res << std::endl;
}

Measured memory_bytes: 1792
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      string s = Console.ReadLine();
      string[] alf = "a b c d e f g h i j k l m n o p q r s t u v w x y z".Split();
      bool flag =false;
      foreach (string j in alf){
        if (s.Contains(j)==false)
        {
          flag=true;
          Console.WriteLine(j);
          break;
        }
      }
      if (flag==false){
        Console.WriteLine("None");
      }
    }
}


Measured memory_bytes: 26172
def main():

    X = int(input())
    if 400 <= X < 600:
        return 8
    elif 600 <= X < 800:
        return 7
    elif 800 <= X < 1000:
        return 6
    elif 1000 <= X < 1200:
        return 5
    elif 1200 <= X < 1400:
        return 4
    elif 1400 <= X < 1600:
        return 3
    elif 1600 <= X < 1800:
        return 2
    elif 1800 <= X < 2000:
        return 1


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 61724
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#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++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  lli N,K;
  cin >> K >> N;
 vector<lli> A(N);
  vector<lli> dis(N);
  rep(i, N)
    cin >> A[i];
  sort(ALL(A))
  rep(i, N-1)
  {    
  dis[i]=abs(A[i]-A[i+1]);
  }
  dis[N-1]=K+A[0]-A[N-1];
  sort(ALL(dis));
  cout << K-dis[N-1] << endl;
}

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

int main() {
  int N;
  int d[100003];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> d[i];

  sort(d, d + N);
  int sum = 0;
  int ans;
  for (int i = 0; i < N; i++) {
    sum++;
    if (N == 2 * sum) {
      ans = d[i + 1] - d[i];
      break;
    }
  }
  if (ans > 0) cout << ans << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 640
from itertools import product
N = int(input())
D = list(map(int,input().split()))
max2 = lambda x,y: x if x > y else y
min2 = lambda x,y: x if x < y else y

def solve():
    cnt = [0]*13
    for d in D:
        cnt[d] += 1

    if cnt[0] > 0 or any(c > 2 for c in cnt):
        return 0

    if N > 13:
        return 1

    res = 0
    for p in product(*((d, 24-d) for d in D)):
        p = [0]+sorted(p)
        r = min(b-a for a,b in zip(p,p[1:]))
        r = min2(r, p[0]-p[-1]+24)
        res = max2(res,r)
    return res

print(solve())

Measured memory_bytes: 68580
MAX = 10 ** 18

N = int(input())
liste = list(map(int, input().split()))
res = 1 
for i in range(N):
    if(liste[i] == 0):
        print(0)
        exit(0)

for i in range(N):
    res *= liste[i]
    #print(res, liste[i])
    if(res > MAX):
        print(-1)
        exit(0)

if(res > MAX):
    print(-1)
else: 
    print(res)


Measured memory_bytes: 21796
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if ((a + b) % 3 && a % 3 && b % 3) cout << "Impossible\n";
    else cout << "Possible\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <algorithm>
#include <tuple>

int main()
{
	long N, M;
	std::vector<long> X;
	std::vector<long> Y; // Y[i] = X[i+1] - X[i]
	long result;

	std::cin >> N >> M;
	X.resize(M);
	for (long i = 0; i < M; ++i) {
		std::cin >> X[i];
	}

	if (N >= M) {
		std::cout << "0\n";
		return 0;
	}

	std::sort(X.begin(), X.end());
	result = X.back() - X.front();

	Y.resize(M-1);
	for (int i = 0; i < M - 1; ++i) {
		Y[i] = X[i+1] - X[i];
	}

	std::sort(Y.begin(), Y.end(), std::greater<long>());
	for (long i = 0; i < N - 1; ++i) {
		result -= Y[i];
	}

	std::cout << result << "\n";
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
	int n,i;
	cin>>n>>i;
	cout<<n-i+1
	<<endl;
	return 0;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n,x;cin>>n>>x;
  while(n!=0||x!=0)
  {
    int ans=0;
    int i,j,k;
    for(i=1;i<=n;i++)
    {
      for(j=i+1;j<=n;j++)
      {
        for(k=j+1;k<=n;k++)
        {
          if(i==j||i==k||j==k)
          {
            continue;
          }
          if(i+j+k==x)ans++;
        }
      }
    }
    cout<<ans<<endl;
    cin>>n>>x;
  }
}




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

int main()
{
	long long h, w, k, sx, sy;
 
	std::cin >> h >> w >> k;
 
	std::vector<std::string> v(h);
 
	for (long long i = 0; i < h; i++) {
		std::cin >> v[i];
		auto pos = std::find(v[i].begin(), v[i].end(), 'S');
		if (pos != v[i].end()) {
			sx = i;
			sy = pos - v[i].begin();
		}
	}
 
	std::stack<std::pair<long long, long long> > s;
	s.push({ sx, sy });

	long long ans = 1000000000000;
 
	int xx[] = { 1,0,-1,0 }, yy[] = { 0,1,0,-1 };
	while (!s.empty()) {
		int x = s.top().first, y = s.top().second;
		s.pop();

		ans = std::min(ans, static_cast<long long>(std::ceil(1.0 * x / k)));
		ans = std::min(ans, static_cast<long long>(std::ceil(1.0 * (h - x - 1) / k)));
		ans = std::min(ans, static_cast<long long>(std::ceil(1.0 * y / k)));
		ans = std::min(ans, static_cast<long long>(std::ceil(1.0 * (w - y - 1) / k)));
		for (int i = 0; i < 4; i++) {
			// 範囲外アクセス
			if (x + xx[i] < 0 || x + xx[i] >= h || y + yy[i] < 0 || y + yy[i] >= w) {
				continue;
			}
			// K回以上の移動
			if (std::abs(x + xx[i] - sx) + std::abs(y + yy[i] - sy) > k) {
				continue;
			}
			if (v[x + xx[i]][y + yy[i]] == '.') {
				s.push({ x + xx[i], y + yy[i] });
				v[x + xx[i]][y + yy[i]] = '#'; // 一度行った場所に行かないようにする
			}
		}
	}
 
	std::cout << ans + 1 << std::endl;
 
	return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int,LL>;
const int INF = 1e6;

int main(){
	LL N, Q;
	cin >> N >> Q;
	set<P> ver, hor;
	ver.insert(P(INF,N));
	hor.insert(P(INF,N));
	LL ans=0;
	rep(i,Q){
		int q, x;
		cin >> q >> x;
		if(q==1){
			P p=*hor.lower_bound(P(x,0));
			ans+=p.second-2;
			ver.insert(P(p.second,x));
		}
		else{
			P p=*ver.lower_bound(P(x,0));
			ans+=p.second-2;
			hor.insert(P(p.second,x));
		}
	}
	cout << (N-2)*(N-2)-ans << endl;

	return 0;
}

Measured memory_bytes: 16076
#include <bits/stdc++.h>
using namespace std;
#define int 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 chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define all(v) (v).begin(),(v).end()
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

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

signed main(){
  int n;
  cin>>n;
  vi x(n);
  rep(i,n) cin>>x[i];
  int ans=INF;

  FOR(i,1,100){
    int ams=0;
    rep(j,n) ams+=(x[j]-i)*(x[j]-i);
    chmin(ans,ams);
  }
  cout<<ans<<endl;
  return 0;
}




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

using namespace std;

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

const int INF = 1000000000; //
const ll LINF = (ll) 4000000000000000000; //
const ll MOD = (ll) 1000000007; //
const double PI = 3.1415926535898; //

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define NP(v) next_permutation(v.begin(),v.end())

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

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

    ll cnt = 0;

    for (int i = n - 1; i >= 0; i--) {
        if ((a[i] + cnt) % b[i] == 0) continue;
        ll diff = b[i] - (a[i] + cnt) % b[i];
        cnt += diff;
    }

    cout << cnt << endl;
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<int> ss(n+1,0);
    reverse(s.begin(),s.end());
    int d = 1;
    rep(i,n){
        ss[i+1] += ss[i] + (s[i] - '0')*d;
        ss[i+1] %= 2019;
        d *= 10;
        d %= 2019;
    }
    int ans = 0;
    map<int,int> cnt;
    for(int i = 0; i <= n;i++){
        ans += cnt[ss[i]]++;
    }
    cout << ans << endl;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b;
	if(a>=13) cout<<b<<"\n";
	else if(a>=6) cout<<b/2<<"\n";
	else cout<<0<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S, sub, next;
  cin >> S;
  int flag = 1, count, ans = 200;
  for(int i = 0; i < 26; i++){
    flag = 1;
    sub = S;
    count = 0;
    while(flag && sub.size() != 1){
      flag = 0;
      for(int j = 0; j < sub.size(); j++){
        if(sub.at(j) != i + 'a'){
          flag = 1;
          break;
        }
      }
      if(flag == 0)break;
      next = "";
      for(int j = 0; j < sub.size() - 1; j++){
        if(sub.at(j) == 'a' + i || sub.at(j + 1) == 'a' + i)next += 'a' + i;
        else next += sub.at(j);
      }
      count++;
      sub = next;
    }
    ans = min(ans, count);
  }
  cout << ans << endl;
  return 0;
}

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

#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

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; }

const int MAX_N = 35;
//const int MAX_V = 100100;

int data[MAX_N]; 

int main(){
    int data_num=0;
    REP(i,MAX_N){
        cin >> data[i];
        data_num++; 
        if(data[i]==0) break;
    }
    int dp[MAX_N];
    dp[1] = 1;
    dp[2] = 2;
    dp[3] = 4;
    FOR(k,4,31){
        dp[k] = dp[k-1] + dp[k-2] + dp[k-3];
    }
    REP(i,data_num-1){
        cout << ceil(dp[data[i]]/3650.0) << endl;
    }
    
}


Measured memory_bytes: 3188
#define _USE_MATH_DEFINES
#include<iostream>
#include<complex>
#include<cmath>
#include <iomanip>
typedef   std::complex<double> Comp_d;
//using Comp_d = std::complex<double>;
void KochCurve(int n, Comp_d p1, Comp_d p2) {
	if (n == 0) { return; }
	Comp_d s = p1 + (p2 - p1) / 3.;
	Comp_d t = p1 + 2.*(p2 - p1) / 3.;
	Comp_d u = s + (t - s)*std::polar(1., M_PI / 3.);
	KochCurve(n - 1, p1, s);
	std::cout << std::fixed << std::setprecision(8) << s.real() << " " << s.imag() << std::endl;;
	KochCurve(n - 1, s, u);
	std::cout << std::fixed << std::setprecision(8) << u.real() << " " << u.imag() << std::endl;;
	KochCurve(n - 1, u, t);
	std::cout << std::fixed << std::setprecision(8) << t.real() << " " << t.imag() << std::endl;;
	KochCurve(n - 1, t, p2);
}
int main(void) {
	int n;
	std::cin >> n;
	std::cout << std::fixed << std::setprecision(8) << 0. << " " << 0. << std::endl;
	KochCurve(n, Comp_d(0., 0.), Comp_d(100., 0.));
	std::cout << std::fixed << std::setprecision(8) << 100. << " " << 0. << std::endl;
	//	system("pause");
	return 0;
}

Measured memory_bytes: 3264
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 998244353;
const ll INF = 0x3f3f3f3f;
const ll maxn = 2e5 + 5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
ll qpow(ll a, ll b) { ll s = 1; while (b > 0) { if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1; }return s; }
 
int main(){
	// in;
	// out;
	ll N,A,B;
	cin>>N>>A>>B;
	cout<<(N/(A+B)*A)+min(A,N%(A+B))<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define INPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.in"
#define OUTPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.out"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

vector<ll> a, b, c, v;

void solve()
{
    int n, m;
    cin >> n >> m;
    
    a.resize(n);
    b.resize(n);
    c.resize(n);
    
    for(int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    
    v.resize(n);
    
    ll ans = 0;
    for(int mask = 0; mask < 8; mask++)
    {
        for(int i = 0; i < n; i++)
        {
            int x1 = ((mask >> 0) & 1) ? 1 : -1;
            int x2 = ((mask >> 1) & 1) ? 1 : -1;
            int x3 = ((mask >> 2) & 1) ? 1 : -1;
            v[i] = x1 * a[i] + x2 * b[i] + x3 * c[i];
        }
        
        sort(v.begin(), v.end());
        ll temp = 0;
        for(int i = 0; i < m; i++)
        {
            temp += v[n - 1 - i];
        }
        ans = max(ans, temp);
    }
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
    //freopen(INPUT, "r", stdin);freopen(OUTPUT, "w", stdout);
    //freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    int t = 1;
    //cin >> t;
    
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const ll mod=1e+9+7;
int main(void){
    int n;cin>>n;
    map<pair<ll,ll>,int> mp;
    int zero=0;
    rep(i,n){
        ll a,b;cin>>a>>b;
        if(a==0&&b==0){
            zero++;
            continue;
        }
        ll g=gcd(a,b);//片方が0だともう片方の絶対値が出てくる
        a/=g;b/=g;
        /*if(b<0||(b==0&&a<0)){
            b*=-1;a*=-1;//第3象限と第4象限の座標をそれぞれ第1象限と第2象限にまとめる
        }*/
        mp[{a,b}]++;
    }
    vector<ll> s(2*n+1,1);
    rep(i,n*2){
        s[i+1]=s[i]*2;
        s[i+1]%=mod;
    }
    ll res=1;
    for(auto& p:mp){
        ll a=p.first.first,b=p.first.second;
        int x=p.second;
        if(x==-1)continue;//すでにtで見られている
        x+=mp[{-a,-b}];
        int t=mp[{-b,a}]+mp[{b,-a}];
        ll tmp=1;
        tmp+=s[x]-1;tmp%=mod;
        tmp+=s[t]-1;tmp%=mod;
        res*=tmp;res%=mod;
        mp[{-b,a}]=-1;mp[{-a,-b}]=-1;mp[{a,b}]=-1;mp[{b,-a}]=-1;
        //cout<<a<<" "<<b<<" "<<x<<" "<<t<<" "<<res<<endl;
    }
    res+=zero;
    res=(res+mod-1)%mod;
    cout<<res<<endl;
}

Measured memory_bytes: 56156
#include <boost/multiprecision/cpp_int.hpp>
using mint = boost::multiprecision::cpp_int;
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using vi = vector<li>;
using vs = vector<string>;


int main()
{
    mint n,a,ans=1;
    cin>>n;
    rep(i,n) {
        cin>>a;
        ans=a*ans/__gcd(a,ans);
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <bits/stdc++.h>
#include <queue>
#include<map>
#define lli long long int
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(i=a;i<n;i++)
using namespace std;
int main(){
    lli n;
    cin>>n;
    if(n<=99) cout<<min(n,9ll);
    else if(n<=999)cout<<9+n-100+1;
    else if(n<=9999) cout<<909;
    else if(n<=99999) cout<<909+n-10000+1;
    else cout<<90909;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){ return a/gcd(a, b)*b; };
 
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Unique(a) a.erase(unique(Range(a)), a.end());
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cin(int, n);
    int n1 = 0, n4 = 0;
    Rep(n){
        Cin(int, a);
        if(a % 4 == 0) n4 ++;
        if(a % 2 != 0) n1 ++;
    }
    CoutYn(n1 <= n4 || (n1+n4 == n && n4 == n1-1));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int len=S.size();
  string ans="";
  ans+=S[0];
  ans+=S[len-1];
  cout<<S[0]<<len-2<<S[len-1]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define ll long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const ll MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);


//変数
int N, M;
vector<pair<int, int>> edge;






//サブ関数
//入力
void input()
{
	cin >> N >> M;
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		edge.push_back({ b,a });
	}
}


//計算
void calc()
{
	sort(edge.begin(), edge.end());
	int res = 0;
	int b = 0;
	for (auto p : edge)
	{
		if (b < p.second+1) {
			b = p.first;
			res++;
		}
	}
	cout << res << endl;
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 1400
(defun solver ()
  (let* ((n (read)) (x (read))
         (mi (make-array n :fill-pointer 0))
         m-temp (m-min 1001)
         (answer n))
    (loop repeat n do
          (vector-push (read) mi))
    (loop for i from 0 below n do
          (setf m-temp (aref mi i))
          (decf x m-temp)
          (when (< m-temp m-min) (setf m-min m-temp)))
    (incf answer (floor x m-min))
    (format t "~a~%" answer)))

(solver)


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

using namespace std;

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

	int sum = 0;

	if (n >= a) { sum += a; n -= a;
		if (n >= b) { n -= b; } {
			if (n) sum -= n;
		}
	}
	else sum += n;

	cout << sum;
}


Measured memory_bytes: 3576
b,c[9<<20],n;main(a){for(;++a<9e6;)for(n=a;n<2e6;)c[n+=a]+=!c[a];for(;scanf("%d",&n)*n;b=!printf("%d\n",b))for(a=1;a++<n/2;)c[a]+c[n-a]||b++;}

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

using namespace std;

constexpr int64_t geta = 100000000LL;

enum class currency_t { jpy, btc };

int64_t solve(const std::vector<int64_t>& xs,
              const std::vector<currency_t>& us) {
  int const n = xs.size();
  int64_t ret = 0;
  for (int i = 0; i < n; ++i) {
    if (us[i] == currency_t ::jpy) {
      ret += xs[i] * geta;
    } else {
      ret += 380000LL * xs[i];
    }
  }
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n;
  std::cin >> n;
  std::vector<int64_t> xs(n);
  std::vector<currency_t> us(n);
  for (int i = 0; i < n; ++i) {
    std::string x;
    std::cin >> x;
    std::string u;
    std::cin >> u;
    if (u == "JPY") {
      xs[i] = std::atoi(x.c_str());
      us[i] = currency_t::jpy;
    } else {
      xs[i] = std::atof(x.c_str()) * geta;
      us[i] = currency_t::btc;
    }
  }
  auto const ret = solve(xs, us);
  std::cout << scientific << setprecision(8) << (1.0 * ret / geta) << std::endl;
  return 0;
}


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

int main(){
	long long int  x,a,b;
	cin>>x;
	for(long long i=-1000;i<1000;i++){
		for(long long j=-1000;j<1000;j++){
			long long int a=pow(i,5);
			long long int b=pow(j,5);
			if(b-a==x){
				cout<<-1*i<<" "<<-1*j<<endl;
				return 0;
			}

		}
	}
	return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
int child[100005];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	int n=s.size();
	if(s[n-1]=='1'){
		cout<<-1;
		return 0;
	}
	if(s[0]=='0'){
		cout<<-1;
		return 0;
	}
	vector<int>v;
	for(int i=0;i<n-1;i++){
		if(s[i]!=s[n-2-i]){
			cout<<-1;
			return 0;
		}
		if(s[i]=='1') v.push_back(i+1);
	}
	v.push_back(n);
	vector<pair<int, int>>edges;
	int cur=2, tmp=1;
	for(int i=0;i<v[0]-1;i++){
		edges.push_back({tmp, cur++});
	}
	for(int i=1;i<v.size();i++){
		edges.push_back({cur, tmp});
		tmp=cur;
		cur++;
		for(int j=0;j<v[i]-v[i-1]-1;j++){
			edges.push_back({tmp, cur++});
		}
	}
	for(auto i:edges){
		cout<<i.first<<" "<<i.second<<'\n';
	}
}

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

using namespace std;

#define INP "solve"
#define OUT "solve"

const int QQ = 3e5 + 10;
const int maxN = 3e5 + 100;
const int maxM = 3e5 + 10;
const long long oo = 1e15;
const int module = 1e9 + 7;
const long double du = 1e-9;

void doc() {
    freopen(INP ".inp","r",stdin);
    freopen(OUT ".out","w",stdout);
}

long long IT[maxN * 4];
void up(int i, int L, int R, int u, long long val) {
    if (L > u || R < u) return;
    if (L == R) {
        IT[i] = val;
        return;
    }
    int mid = (L + R) >> 1;
    up(i << 1, L, mid, u, val);
    up(i << 1 | 1, mid + 1, R, u, val);
    IT[i] = max(IT[i << 1], IT[i << 1 | 1]);
}
long long Get(int i, int L, int R, int u, int v) {
    if (L > v || R < u) return 0;
    if (L >= u && R <= v) return IT[i];
    int mid = (L + R) >> 1;
    long long Left = Get(i << 1, L, mid, u, v);
    long long Right = Get(i << 1 | 1, mid + 1, R, u, v);
    return max(Left, Right);
}
void solve() {
    int n;
    cin >> n;
    vector <int> B;
    int h[n], a[n];
    for (int i = 0; i < n; i++) {
        cin >> h[i];
        B.push_back(h[i]);
    }
    sort(B.begin(), B.end());
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
        int id = lower_bound(B.begin(), B.end(), h[i]) - B.begin();
        long long mxF = Get(1, 0, n - 1, 0, id - 1);
        up(1, 0, n - 1, id, mxF + a[i]);
    }
    cout << IT[1];
}
int main(int argc,char *argv[]) {
    //srand(time(nullptr));
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //doc();
    solve();
}


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

typedef long long ll;

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int X = max({A, B, C});
    int Y = 1;
    rep(i, K) Y *= 2;
    cout << A + B + C + X * (Y - 1) << "\n";
}

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

#define ll long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++);
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/

using namespace std;

int gcd(int a, int b) {
	int c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}
map<string, int> memo;


int main() {
	//sort(a.begin(),a.end());
	int n, m;
	cin >> n >> m;
	if (n == m) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	 
	return 0;
}









Measured memory_bytes: 764
#include <bits/stdc++.h>
#define ll long long
#define mk make_pair
#define hash hashh
using namespace std;

const int N = 3e5;
const int inf = 1e9;

int n, k, a[N], B[N];
ll ans, s[N], b[N], c[N];

bool cmp(int i, int j) {
	if (b[i] == b[j]) return i < j;
	return b[i] < b[j];
}

void ins(int x) {
	while (x <= n + 1) {
		B[x]++;
		x += x & -x;
	}
}

int ask(int x) {
	int res = 0;
	while (x) {
		res += B[x];
		x -= x & -x;
	}
	return res;
}

int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) scanf("%d", a + i);
	for (int i = 1; i <= n; i++) {
		s[i] = s[i - 1] + a[i];
		b[i] = s[i]- (ll)k * i;
		c[i] = i;
	}
	sort(c, c + 1 + n, cmp);
	for (int i = 0; i <= n; i++) {
		ans += ask(c[i] + 1);
		ins(c[i] + 1);
	}
	cout << ans;
}



Measured memory_bytes: 8704
#include <iostream>
#include <cstdio>

using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a + b < 3) {
    cout << "Impossible" << endl;
  } else if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! get_chars {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().chars().collect::<Vec<_>>()
        }
    };
    ($n:expr) => {
        {
            (0..$n)
                .map(|_| get_chars!())
                .collect::<Vec<_>>()
        }
    };
}

fn main() {
    let k = get!(i64);
    let (a, b) = get!(i64, i64);

    for i in a..=b {
        if i % k == 0 {
            println!("OK");
            std::process::exit(0);
        }
    }
    println!("NG");
}


Measured memory_bytes: 2144
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a,b,c = LI()
    if a+b >= c:
        return 'Yes'

    return 'No'


print(main())




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

#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MAXN 500100

using namespace std;

const int INF = 1e9 + 7;

struct item{
	ll sum;
};

struct SegTree{
	int sz, n;
	vector<item> values;

	//-----<Set up the neutral element, single, and merge for current item>-----//
	item NEUTRAL_ELEMENT = {0};

	item merge(item a, item b){
		return {a.sum + b.sum};
	}

	item single(int v){
		return {v};
	}
	//-----</Set up the neutral element, single, and merge for current item>-----//

	void init(int n){
		sz = 1;
		while(sz < n) sz*=2;
		values.assign(sz*2, NEUTRAL_ELEMENT);
		return;
	}


	void set(int i, int v, int x, int lx, int rx){

		if(rx - lx == 1){
			values[x] = single(v); //base case, set bottom level
			return;
		}

		int m = lx + (rx - lx)/2;

		if(m > i) set(i, v, 2*x + 1, lx, m); //go left
		else set(i, v, 2*x + 2, m, rx); //go right

		//-----<Do associative operation>-----//
		values[x] = merge(values[x*2 + 1], values[x*2 + 2]);
		//-----</Do associative operation>-----//
	}

	void set(int i, int v){
		set(i, v, 0, 0, sz);
		return;
	}

	item calc_range(int l, int r, int x, int lx, int rx){

		//Case 1: segment outside l, r
		if(lx >= r || rx <= l) return NEUTRAL_ELEMENT; //Neutral Element
		//Case 2: segment completely inside l, r
		if(lx >= l && rx <= r) return values[x];
		//Case 3: segment partly inside, partly outside l, r
		
		int m = lx + (rx - lx) / 2;

		item left = calc_range(l, r, 2*x + 1, lx, m);
		item right = calc_range(l, r, 2*x + 2, m, rx);

		//-----<Do associative operation>-----//
		return merge(left, right);
		//-----</Do associative operation>-----//
	}

	item calc_range(int l, int r){
		return calc_range(l, r, 0, 0, sz);
	}

};


int main(void)
{ 
	FAST
	int n, m; cin >> n >> m;
	vector<int> a(n), last(MAXN, -1), ans(m);
	vector<pair<pair<int, int>, int>> q(m);

	SegTree st;
	st.init(MAXN);

	for(int &t : a) cin >> t;

	for(int i = 0; i< m; i++){
		int l, r;
		cin >> l >> r;
		l--; r--;
		q[i] = {{r, l}, i};
	}

	sort(q.begin(), q.end());
	int pos = 0;

	for(int i = 0 ; i < n; i++){
		if(last[a[i]] >= 0){
			st.set(last[a[i]], 0);
			st.set(i, 1);
			last[a[i]] = i;
		} else{
			st.set(i, 1);
			last[a[i]] = i;
		}
		while(q[pos].first.first == i){
			ans[q[pos].second] = st.calc_range(q[pos].first.second, q[pos].first.first+1).sum;
			pos++;
		}
	}
	for(int i : ans) cout << i << '\n';

	return 0;
}


Measured memory_bytes: 23632
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;	//using vi = vector<int>;

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

int main()
{
	int n, k,ans;
	ans = 1;
	cin >> n >> k;

	for (int i = 0; i < n; i++) {
		if (ans * 2 < ans + k) ans *= 2;
		else ans += k;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
/********************************************
 *Author*        :Kwansy
 *Created Time*  : 2018年12月22日 星期六 20时04分56秒
 * Ended  Time*  : 2018年12月22日 星期六 20时18分05秒
*********************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main()
{
    LL N,H,W, cnt = 0;
    cin >> N >> H >> W;

    LL A,B;
    for (LL i = 0; i < N; i++)
    {
        cin >> A >> B;
        if (A>=H && B >= W) cnt++;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
/*#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
const long long inf=1LL<<50;
int N,M;
long long d[1000][1000];
void wf(){
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            if(d[i][k]==inf)continue;
            for(int j=0;j<N;j++){
                if(d[k][j]==inf)continue;
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
}
int main(void){
    cin>>N>>M;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            d[i][j]=((i==j)?0:inf);
                    }
    }
    for(int i=0;i<M;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        d[a][b]=-c;
    }
    wf();
    bool negative=false;
    for(int i=0;i<N;i++){
        if(d[i][i]<0)negative=true;
    }
    if(negative){
        printf("inf\n");
    }else{
        printf("%lld\n",-d[0][N-1]);
    }
}*/
#include <iostream>
#include <stdio.h>
#include <vector>
const long long INF=1LL<<50;
using namespace std;
const long long inf=1LL<<50;
int N,M;
int main(void){
    const int NMAX=1000;
    const int MMAX=2000;
    int a[MMAX],b[MMAX];
    long long  dist[NMAX];
    cin>>N>>M;
    long long c[MMAX];
    for(int i=0;i<M;i++){
        cin>>a[i]>>b[i]>>c[i];
        c[i]=-c[i];
    }
    for(int i=0;i<N;i++){
        dist[i]=INF;
    }
    dist[0]=0;
    for(int loop=0;loop<N-1;loop++){
        for(int i=0;i<M;i++){
            if(dist[a[i]-1]==INF)continue;
            if(dist[b[i]-1]>dist[a[i]-1]+c[i])
                dist[b[i]-1]=dist[a[i]-1]+c[i];
        }
    }
    long long ans=dist[N-1];
    bool negative[NMAX];
    for(int i=0;i<N;i++){
        negative[i]=false;
    }
    for(int loop=0;loop<N;loop++){
        for(int i=0;i<M;i++){
            if(dist[a[i]-1]==INF)continue;
            if(dist[b[i]-1]>dist[a[i]-1]+c[i]){
                dist[b[i]-1]=dist[a[i]-1]+c[i];
                negative[b[i]-1]=true;
            }
        }
    }
    if(negative[N-1])
        cout<<"inf"<<endl;
    else cout<<-ans<<endl;
}

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

// queue を考えて, 同じ数字は入れるときに順番を決めて, 出てきた順に値を更新する
#define mod 1000000007
#define MAX_N 1000001 // = MAX_H
ll fact[MAX_N]; // iの階乗
ll fact_sum[MAX_N]; // i>0での累積和

// 最大値がi個の時の場合の数
ll dp[MAX_N];

int main() {
    int N, H, D;
    cin >> N >> H >> D;

    // 階乗計算
    fact[0]=1;
    for(int i = 1; i < MAX_N; ++i) {
        fact[i] = fact[i-1] * i % mod;
        fact_sum[i] = (fact_sum[i-1] + fact[i]) % mod;
    }

    dp[0] = fact[N]; // 0をN個queueに入れる
    ll sum = 0; // Dの幅でしゃくとり
    for (int i = 1; i <= H; ++i) {
        sum += dp[i-1]; // dp[i-D] から dp[i-1] まで
        if(i > D) sum = sum + mod - dp[i-D-1];
        sum %= mod;
        dp[i] = sum * fact_sum[N] % mod; // i個の塔の個数が1からNまで
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 23680
import sys
def PrimNum(p):
    i = 0
    while True:
        if len(l) <= i: break
        if l[i] > p: break
        i+=1
    return i
def PrimeList(p) -> list:
    if p == 2: return 1
    elif p > 2:
        l = list(range(2, p+1))
        i = 0
        while pow(l[i], 2) <= p:
            # 2~pまでの数字の表を作って、2からpに向けて一つずつその倍数となる数を消していく。消されずに残っているものは素数である。
            # 入力の内の最大数のみを取り出して、この関数にかける。他の値はリストの中から
            l = [ l[j] for j in range(0, len(l)) if j <= i or l[j] % l[i] != 0] 
            i+=1
    return l
a = [int(line) for line in sys.stdin]
l = PrimeList(max(a)) # 最大値のみを渡す
for i in a: print(PrimNum(i))


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


    class Program
    {
        static void Main(string[] args)
        {
            string[] Input = Console.ReadLine().Split(' ');
            int H1 = int.Parse(Input[0]);
            int M1 = int.Parse(Input[1]);
            int H2 = int.Parse(Input[2]);
            int M2 = int.Parse(Input[3]);
            int K = int.Parse(Input[4]);
            
            int ans = (H2 * 60 + M2) - (H1 * 60 + M1) - K;
            Console.WriteLine(ans);
        }
    }



Measured memory_bytes: 17852
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int t = 0;
		int i = 1;
		while(t==0){
			var N = int.Parse(Console.ReadLine());
			if(N==0){
				t = 1;
			} else {
				Console.WriteLine("Case " + i + ": " + N);
				i += 1;
			}
		}
	}
}


Measured memory_bytes: 9324
/**

  @@@@@@@  @@@@  @@@@  @@@@  @@@@  @
  @  @  @  @  @  @  @  @  @  @  @  @
  @  @  @  @  @  @  @  @  @  @  @  @
  @  @  @  @  @  @  @  @  @  @  @  @
  @  @  @  @@@@  @@@@  @@@@  @  @  @

**/
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define str string
#define pi pair
#define tup tuple
#define vec vector
#define temp template
#define tn typename

#define ff first
#define ss second
#define SZ(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rsz resize
#define ins insert
#define fr front
#define bc back
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mk make_pair

#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ROF(i, a, b) for (ll i = (a); i >= (b); i--)
#define trav(a, x) for (auto &a : x)
#define popcount __builtin_popcountll
#define ctz __builtin_ctzll
#define clz __builtin_clzll
#define gcd __gcd

#define max(a, b) max((ll) a, (ll) b)
#define min(a, b) min((ll) a, (ll) b)

// DEBUG
#define ts to_string
temp<tn A, tn B> str ts(pi<A, B> p);
temp<tn A, tn B, tn C> str ts(tup<A, B, C> p);
str ts(const str& s) { return '"' + s + '"'; }
str ts(const char* s) { return ts((str) s); }
str ts(bool b) { return (b ? "true" : "false"); }
str ts(vec<bool> v) { bool f = true; str res = "{";
FOR(i, 0, static_cast<ll>(v.size()) - 1)
{ if (!f) res += ", "; res += ts(v[i]);
f = false; } res += "}"; return res; }
temp<size_t N> str ts(bitset<N> v) { str res = "";
trav(a, v) { res += (char) ('0' + a); } return res; }
temp<tn A> str ts(A v) { bool f = true; str res = "{";
trav(x, v) { if (!f) res += ", "; res += ts(x);
f = false; } res += "}"; return res; }
temp<tn A, tn B> str ts(pi<A, B> p) {
  return "(" + ts(p.ff) + ", " + ts(p.ss) + ")"; }
temp<tn A, tn B, tn C> str ts(tup<A, B, C> t) {
  return "(" + ts(get<0>(t)) + ", " + ts(get<1>(t)) + ", " + ts(get<2>(t)) + ")"; }
void DBG() { cerr << endl; }
temp<tn H, tn... T> void DBG(H h, T... t) { cerr << " " << ts(h); DBG(t...); }
#ifdef LOCAL
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", DBG(__VA_ARGS__);
#else
#define dbg(...) 42
#endif

// INPUT AND OUTPUT
temp<tn T> void re(T& x) { cin >> x; };
temp<tn H, tn... T> void re(H& h, T&... t) { re(h); re(t...); }
temp<tn T> void pr(T x) { cout << x; };
temp<tn H, tn... T> void pr(H h, T... t) { pr(h); pr(t...); }
temp<tn T> void pri(T x) { cout << x; cout << endl; }; // used for interactives
temp<tn H, tn... T> void pri(H h, T... t) { pri(h); pri(t...); }

const ll N = (ll) 1e6 + 10;

ll cnt[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  re(n);
  vec<ll> a(n);
  FOR(i, 0, n - 1) {
  	re(a[i]);
  	++cnt[a[i]];
	}
	ll ans = 0;
	FOR(i, 0, n - 1) {
		ll x = a[i];
		--cnt[x];
		bool ok = true;
		for (ll j = 1; j * j <= x; j++) {
			if (x % j != 0) {
				continue;
			}
			ok &= !(cnt[j] || cnt[x / j]);
		}
		ans += ok;
		++cnt[x];
	}
	pr(ans, '\n');
  return 0;
}




Measured memory_bytes: 12656
A = int(input())
B = int(input())
C = int(input())
X = int(input())

number_of_combination = 0


for k in range(0,A+1):
    number_of_a = k
    for j in range(0,B+1):
        number_of_b = j
        for i in range(0,C+1):
            number_of_c = i
            sum = 500*number_of_a + 100*number_of_b + 50*number_of_c
            if sum == X:
                number_of_combination += 1

print(number_of_combination)

Measured memory_bytes: 3188
n, nSubms = map(int, input().split())
waCnt = [0] * (n + 1)
ac = [0] * (n + 1)
for _ in range(nSubms):
    id, res = input().split()
    id = int(id)
    if res == 'WA':
        if not ac[id]:
            waCnt[id] += 1
    elif res == 'AC':
        if not ac[id]:
            ac[id] = 1
    else:
        raise Exception
for i in range(n + 1):
    if waCnt[i] and not ac[i]:
        waCnt[i] = 0
print('%d %d' % (sum(ac), sum(waCnt)))


Measured memory_bytes: 4596