akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int n,ma;
    cin>>n>>ma;
    vector<int>v(n+1);
    for(int i=1;i<=n;i++) cin>>v[i];
    map<int,set<int> >m;
    for(int i=0;i<ma;i++) {
        int a,b;
        cin>>a>>b;
        m[a].insert(v[b]);
        m[b].insert(v[a]);
    }
    int ans = 0;
    for(int i=1;i<=n;i++) {
        if(m[i].size()==0) ans++;
        else{
            if(v[i]>*(m[i].rbegin())) ans++;
        }
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 22372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N), num(N, 0);
    rep(0, i, N - 1)
    {
        cin >> A.at(i);
        num.at(A.at(i) - 1) += 1;
    }
    rep(0, i, N)
    {
        cout << num.at(i) << endl;
    }
}

Measured memory_bytes: 6340
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n;
  vector<string> vec1(n);
  for(int i=0;i<n;i++){
    cin>>vec1[i];
  }
  cin>>m;
  vector<string> vec2(m);
  for(int i=0;i<m;i++){
    cin>>vec2[i];
  }
  int c=0,max=0;
  for(int i=0;i<n;i++){
    for(int j=0;i+j<n;j++){
      if(vec1[i]==vec1[i+j]){
        c++;
      }
    }
    for(int k=0;k<m;k++){
      if(vec1[i]==vec2[k]){
        c--;
      }
    }
      if(c>max){
        max=c;
      }
    c=0;
  }
      cout<<max<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;



void solve() {
	int n; cin >> n;
	vector<ll> v(n);
	ll sum = 0;
	rep(i, n) {
		cin >> v[i];
		sum += v[i]; sum -= i + 1;
	}
	cout << sum << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(4);
	//init();
	solve();
	stop
		return 0;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    string S;
    cin >> S;
    string abc = "abc";
    do {
        if(S == abc) {
            cout << "Yes" << endl;
            return 0;
        }
    } while(next_permutation(abc.begin(), abc.end()));
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
/*    ####################  */
/*   # I_LOVE_THUY_LINH #  */
/*  ####################  */
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define ii pair<int,int>
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define matrix vector<vector<ll>>
#define fir first
#define sec second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define sz(a) int((a).size())
#define ms(s,val) memset(s,val,sizeof(s))
#define bitcount(n) __builtin_popcountll(n)
#define getbit(s,k) ((s >> k)&1)
#define turnbit(s,k) (s | (1<<k))
#define offbit(s,k) (s & ~(1<<k))
#define flipbit(s,k) (s ^ (1<<k))
#define prec(n) fixed<<setprecision(n)
#define sqr(x) (ll)(x)*(ll)(x)
#define lcm(a,b) ((ll)a/__gcd((ll)a,(ll)b)*(ll)(b))
#define gcd(a,b) __gcd(a,b)
using namespace std;
const int INF = int(1e9);

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(all(a));
    uni(a);
    if (a.size() == 2) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax=2e5;
int N, A[Nmax];

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

	vector<vector<int> > c(N+2, vector<int>(20));

	for(int i=1; i<=N; i++){
		for(int j=0; j<20; j++){
			c[i][j] = c[i-1][j];
			c[i][j] += (A[i-1]>>j)&1;
			//cout << c[i][j] << " ";
		}
		//cout << endl;
	}

	for(int j=0; j<20; j++){
		c[N+1][j] = 1e8;
	}

	ll ans = 0;
	for(int i=0; i<N; i++){
		int k=N-1;
		int lb=i, ub=N+1;
		while(ub-lb>1){
			int mid=(lb+ub)/2;
			bool flag=true;
			for(int j=0; j<20; j++){
				if(c[mid][j]-c[i][j]>1){
					flag=false;
				}
			}

			if(flag){
				lb=mid;
			}
			else{
				ub=mid;
			}
		}
		//cout << i << " " << lb << " " << ub << endl;
		ans += lb-i;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 26496
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <numeric> //lcm

//#include "BIT.h"

#define ERROR() cout << "ERROR!!" << endl; return 0;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 29; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline bool maxch(int &a, int b) { if (a < b) {a = b; return true;} else return false;}

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

  ll h, n;
	cin >> h >> n;

	int sum = 0;
	rep(i, n) {
		int a;
		cin >> a;
		sum += a;
	}

	//vector<vector<int>> work(m, vector<int>());
	if (sum >= h) cout << "Yes" << endl;
	else cout << "No" << endl;
}




Measured memory_bytes: 256
#include<cstdio>

int main(void) {
  int i, j, k;
  int A[3][3];
  int map[3][3] = { {}, {}, {} };
  int N;
  int *b;
  scanf("%d %d %d", &A[0][0], &A[0][1], &A[0][2]);
  scanf("%d %d %d", &A[1][0], &A[1][1], &A[1][2]);
  scanf("%d %d %d", &A[2][0], &A[2][1], &A[2][2]);
  scanf("%d", &N);
  b = new int[N];
  for(i = 0; i < N;i++) scanf("%d", b + i);
  for(i = 0;i < 3;i++) {
    for(j = 0;j < 3;j++) {
      for(k = 0;k < N;k++) {
        if(A[i][j] == b[k]) map[i][j] = 1;
      }
    }
  }
  for(i = 0;i < 3;i++) {
    if((map[i][0] && map[i][1] && map[i][2]) || (map[0][i] && map[1][i] && map[2][i])) {
      puts("Yes");
      return 0;
    }
  }
  if((map[0][0] && map[1][1] && map[2][2]) || (map[2][0] && map[1][1] && map[0][2])) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

struct Edge{
    // 始点, 終点, 重み, 最大量
    long long src, dst, weight, capacity;
    Edge(): src(0), dst(0), weight(0), capacity(0) {}
    Edge(long long s, long long d, long long w): src(s), dst(d), weight(w) {}
    Edge(long long s, long long d, long long w, long long c): src(s), dst(d), weight(w), capacity(c) {}
};

class Graph{
public:
    long long size;
    vector<vector<Edge>> node;
    Graph(long long n): size(n), node(n) {}
    void addEdge(long long s, long long d, long long w = 1){
        node[s].emplace_back(s, d, w);
        node[d].emplace_back(d, s, w);
    }
};

int main(){
    Init();
    /* ----------入力---------- */
    ll n; cin >> n;
    Graph g(n);
    rep(i, n-1){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        g.addEdge(a, b);
    }
    vi c(n);
    rep(i, n) cin >> c[i];

    /* ----------ノード0を根として、bfsで降順にciを割り当てていく---------- */
    sort(all(c), greater<ll>());
    ll sum = 0, pos = 0;
    vi ans(n), chk(n, 0);
    queue<ll> que;
    que.push(0);
    chk[0] = 1;
    while(que.size()){
        auto f = que.front();
        que.pop();
        ans[f] = c[pos];
        if(f) sum += ans[f];
        pos++;
        for(auto &edge: g.node[f]){
            if(chk[edge.dst]) continue;
            else{
                chk[edge.dst] = 1;
                que.push(edge.dst);
            }
        }
    }
    cout << sum << endl;
    for(ll i=0; i<n; i++) cout << ans[i] << (i == n-1 ? endl : " ");
}

Measured memory_bytes: 4784
#include<stdio.h>
main()
{
  int a,i,j = 0;
  scanf("%d",&a);
  for(i=1;i<10;i++){
    if(a/i<10 && a%i==0)
      j++;
  }
  if(j>0)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

  if(W < x + r){
    printf("No\n");
  }else if(0 > x - r){
    printf("No\n");
  }else if(H < y + r){
    printf("No\n");
  }else if(0 > y - r){
    printf("No\n");
  }else{
    printf("Yes\n");
  }

  return 0;
}

Measured memory_bytes: 584
a=input()
b=[]
total=0
while True:
    c=input().strip(".").split()
    if c==["END_OF_TEXT"]:
        break
    else:
        b.append(c)
for i in range(len(b)):
    for j in b[i]:
        if a==j.lower():
            total+=1
print(total)


Measured memory_bytes: 5560
import sys
input = sys.stdin.buffer.readline

H, W = map(int, input().split())
sh, sw = map(lambda x: int(x)-1, input().split())
gh, gw = map(lambda x: int(x)-1, input().split())
state = [list(input().rstrip()) for _ in range(H)]

def nexts1(h, w):
    ret = []
    if h != 0: ret.append((h-1, w))
    if h != H-1: ret.append((h+1, w))
    if w != 0: ret.append((h, w-1))
    if w != W-1: ret.append((h, w+1))
    return ret

def nexts2(h, w):
    ret = []
    for nh in range(h-2, h+3):
        for nw in range(w-2, w+3):
            if 0 <= nh < H and 0 <= nw < W:
                ret.append((nh, nw))
    return ret


def bfs():
    checked = [[-1]*W for _ in range(H)]
    P = {(sh, sw)}
    cnt = 0
    while P:
        q = []
        for h, w in P:
            if checked[h][w] == -1:
                checked[h][w] = 1
                q.append((h, w))
        P = set()
        while q:
            qq = []
            for h, w in q:
                if h == gh and w == gw:
                    return cnt
                for nh, nw in nexts1(h, w):
                    if state[nh][nw] == ord(".") and checked[nh][nw] == -1:
                        checked[nh][nw] = checked[h][w]
                        qq.append((nh, nw))
                for nh, nw in nexts2(h, w):
                    if checked[nh][nw] == -1 and state[nh][nw] == ord(".") and not (nh, nw) in P:
                        P.add((nh, nw))
            q = qq
        cnt += 1
    return -1

def main():
    print(bfs())


if __name__ == "__main__":
    main()

Measured memory_bytes: 112344
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << " : " << x << endl

namespace atcoder {
	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000007;
	const int tenfive = 100000;
}

using namespace atcoder;

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

	array<int, 4> a;
	cin >> a[0] >> a[1] >> a[2] >> a[3];
	if (count(a.begin(), a.end(), 1) == 1 &&
		count(a.begin(), a.end(), 4) == 1 &&
		count(a.begin(), a.end(), 7) == 1 &&
		count(a.begin(), a.end(), 9) == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

ll combination(ll n, ll i){
	ll count = 0;
	ll multi = 1;
	ll div =1;
	int limit = i;
	while(count < limit){
		multi *= n;
		n--;
		multi/= count+1;
		count ++ ;
	}
	return multi / div;
}

int main()
{
	cout <<setprecision(10);
	int n; cin >> n;
	int p ; cin >> p;
	int odd = 0;
	int even = 0;
	rep(i,n){
		int a;
		cin >> a;
		if(a%2==0) even ++;
		else odd ++;
	}
	if(p==0){
		ll ans = 0;
		rep(i,even+1){
			//evenの選び方は evenCi通り = (E);
			ll E = combination(even,i);
			//oddの選び方は、2,4,6…と偶数個選ぶしかない
			ll O = 0;
			for(int j = 0 ; j <= odd ; j+=2){
				O += combination(odd,j);
			}
			ans += E * O ;
		}
		cout << ans << endl;
	}
	else{
		ll ans = 0;
		//evenは何個選ぼうが偶奇は変わらない
		rep(i,even+1){
			ll E = combination(even,i);
			//oddの選び方は、1,3,5...と奇数個選ぶしかない
			ll O = 0;
			for(int j = 1; j<= odd; j+=2){
				O += combination(odd,j);
			}
			ans += E * O ;
		}
		cout << ans << endl;
	}

}


Measured memory_bytes: 256
from collections import Counter
n=int(input())
s=[]
for _ in range(n):
    temp=sorted(list(input()))
    s.append("".join(temp))
s_count=Counter(s)
ans=0
for i in s_count:
    ans+=((s_count[i])*(s_count[i]-1))//2
print(ans)

Measured memory_bytes: 24216
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
ll dp[61][200005];
int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    vector<int>nx(n,-1);
    map<int,int>mp;
    for(int i = n - 1; i >= 0; i--){
        if(mp.count(a[i])){
            nx[i] = mp[a[i]] - i + 1;
        }else{
            
        }
        mp[a[i]] = i;
    }
    show(nx);
    rep(i,n){
        if(nx[i] == -1){
            if(mp[a[i]] == i){
                nx[i] = n + 1;
            }else{
                nx[i] = n - i + 1 + mp[a[i]];
            }
        }
    }
    show(nx);
    ll ma = n * k + 100;
    for(int j = 0; j < 61; j++){
        for(int i = 0; i < n; i++){
            if(j == 0){
                dp[j][i] = nx[i];
            }else{
                dp[j][i] = dp[j-1][i] + dp[j-1][(i+dp[j-1][i])%n];
                if(dp[j][i] > ma)dp[j][i] = ma;
            }
        }
    }
    ll pos = 0;
    ll sum = 0;
    while(true){
        bool flag = false;
        for(int j = 60; j >= 0; j--){
            show(j,dp[j][pos]);
            if(sum + dp[j][pos] <= (ll)n*k-1){
                sum += dp[j][pos];
                pos = (pos + dp[j][pos]) % n;
                flag = true;
                break;
            }
        }
        show(sum);
        if(!flag)break;
    }
    show(pos,sum);
    vector<int>res;
    set<int>st;
    for(ll i = pos; i < n; i++){
        if(st.count(a[i])){
            while(st.count(a[i])){
                st.erase(res.back());
                res.pop_back();
            }
        }else{
            res.push_back(a[i]);
            st.insert(a[i]);
        }
    }
    rep(i,res.size()){
        cout << res[i] << " \n"[i == res.size() - 1];
    }
}

Measured memory_bytes: 117876
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#define B 4
#define F 3
#define R 10

int main() {
	int d[B][F][R] = { 0 };
	int b, f, r, v;
	int n, i, j, k;

	scanf("%d", &n);
	for (i=0;i<n;i++) {
		scanf("%d%d%d%d", &b, &f, &r, &v);
		d[b - 1][f - 1][r-1] += v;
	}
	for (i=0;i<B;i++) {
		for (j=0;j<F;j++) {
			for (k=0;k<R;k++)printf(" %d", d[i][j][k]);
			putchar('\n');
		}
		if(i!=3)
		puts("####################");
	}
	return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  if (a <= k) {
    k -= a;
    a = 0;
    b = max(b - k, 0LL);
  } else {
    a -= k;
  }
  cout << a << ' ' << b << endl;
}


Measured memory_bytes: 256
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())

p = (a1 - b1) * t1
q = (a2 - b2) * t2
if p > 0:
    p = -1 * p
    q = -1 * q

if p + q < 0:
    print(0)
elif p + q == 0:
    print('infinity')
else:
    s = -p // (p+q)
    t = -p % (p+q)
    if t == 0:
        print(2*s)
    else:
        print(2*s+1)

Measured memory_bytes: 3064
import java.nio.charset.IllegalCharsetNameException;
import java.util.*;
import java.lang.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.next();
		}
		int[][] abc = new int[26][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < s[i].length(); j++) {
				abc[s[i].charAt(j) - 'a'][i]++;
			}
		}
		int[] min = new int[26];
		for (int i = 0; i < 26; i++) {
			min[i] = 50;
		}
		for (int i = 0; i < 26; i++) {
			for (int j = 0; j < n; j++) {
				min[i] = Math.min(abc[i][j], min[i]);
			}
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < 26; i++) {
			for (int j = 0; j < min[i]; j++) {
				sb.append((char)(i + 'a'));
			}
		}
		System.out.println(sb);
	}
}

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

using ll=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, k;
  cin >> a >> b >>k;
  vector<int> num;
  int i = 1;
  while(min(a,b)/i){
    if(a%i==0 && b%i==0) num.push_back(i);
    i++;
  }
  reverse(num.begin(),num.end());
  cout << num[k-1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <deque>
#include <vector>
#include <cstdio>
#include <cstring>
#include <utility>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <numeric>

#define i64 long long
#define ui64 unsigned long long
#define REP(i,n) for(int (i)=0;(i)<(n);i++)
#define REP2(i,k,n) for(int (i)=(k);(i)<(n);i++)
#define MDIST(a,b) abs(a-b)
#define DIST(a,b) sqrt((a)*(a)+(b)*(b))
#define ATCODER 1000000007
using namespace std;
 
////////////////////////

class point{
public:
  int x,y,id;
  point(int x_,int y_,int i_):x(x_),y(y_),id(i_){}
  point():x(0),y(0){}
};

bool compx(const point &b,const point &a){
  return b.x==a.x?b.y<a.y:b.x<a.x;
}
bool compy(const point &b,const point &a){
  return b.y==a.y?b.x<a.x:b.y<a.y;
}

class edge{
public:
  int f,t,c;
  bool operator<(const edge &a){
    return c<a.c;
  }
  edge(int f_,int t_,int c_):f(f_),t(t_),c(c_){}
};

class uf{
public:
  vector<int> r;
  uf(int n):r(n,-1){};
  int find(int x,int y){
    // cout << root(x) << " " << root(y) << endl;
    if(root(x)==root(y))return 0;
    if(root(x)<root(y))return -1;
    if(root(x)>root(y))return 1;
  }
  int root(int x){
    if(r[x]==-1)return x;
    else return r[x]=root(r[x]);
  }
  void join(int x,int y){
    x=root(x);y=root(y);
    if(x!=y){
      r[x]=y;
    }
  }
};

class graph{
public:
  int vnum;
  vector<edge> E;
  uf u;
  graph(int n):vnum(n),u(n){};
  int kraskal(){
    int res=0;
    sort(E.begin(),E.end());
    for(int i=0,c=0;i<E.size()&&c<vnum-1;i++){
      // cout << E[i].c << endl;
      if(u.find(E[i].f,E[i].t)){
        u.join(E[i].f,E[i].t);
        // cout << E[i].f << " " << E[i].t << endl;
        res+=E[i].c;
        c++;
      }
    }
    return res;
  }
};

int main(){
  int v,e;
  cin >> v >> e;
  graph g(v);
  int f,t,c;
  for(int i=0;i<e;i++){
    cin >> f >> t >> c;
    g.E.push_back(edge(f,t,c));
  }
  cout << g.kraskal() << endl;
}


// int main(){
//   int n;
//   cin >> n;
//   int x,y;
//   vector<point> p;
//   for(int i=0;i<n;i++){
//     cin >> x >> y;
//     p.push_back(point(x,y,i));
//   }
//   graph g(n);
//   sort(p.begin(),p.end(),compx);
//   for(int i=0;i<n-1;i++){
//     g.E.push_back(edge(p[i].id,p[i+1].id,min(abs(p[i].x-p[i+1].x),abs(p[i].y-p[i+1].y))));
//   }
//   sort(p.begin(),p.end(),compy);
//   for(int i=0;i<n-1;i++){
//     g.E.push_back(edge(p[i].id,p[i+1].id,min(abs(p[i].x-p[i+1].x),abs(p[i].y-p[i+1].y))));
//   }
//   // for(int i=0;i<g.vnum;i++){
//   //   cout << g.u.r[i] << endl;
//   // }
//   cout << g.kraskal() << endl;
// }

Measured memory_bytes: 4540
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;


int main(){
    int N;
    cin >> N;
    int AB=0;
    
    int a=0,b=0,ab=0;
    for(int i=0; i<N; i++){
        string s;
        cin >> s;
        
        for(int i=0; i<=s.length()-2; i++){
            if(s[i]=='A'&&s[i+1]=='B'){
                AB++;
            }
        }
        
        if(s[0]=='B'){
            b++;
        }
        
        if(s[s.length()-1]=='A'){
            a++;
        }
        
        if(s[0]=='B'&&s[s.length()-1]=='A'){
            ab++;
        }
        
    }

//    cout<<AB<<endl;
//    cout<<a<<endl;
//    cout<<b<<endl;
//    cout<<ab<<endl;
    
    b-=ab;
    a-=ab;
    
    if(ab>0){
        AB+=ab-1;
        ab=1;
        
        if(a>0){
            AB++;
            a--;
        }
        if(b>0){
            AB++;
            b--;
        }
        
        AB+=min(a,b);
    }else{
        AB+=min(a,b);
    }
    
    cout<<AB<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define ld long double
// 217
// 44

using namespace std;



int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int n, i;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> n;
    int ans = 0;
    for(i = 1; i <= n; i++) {
        int x;
        cin >> x;
        ans += (x & 1);
    }
    if(ans == 0) {
        cout << "second";
    }
    else {
        cout << "first";
    }
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<numeric>
#include<algorithm>
#include<tuple>
#include<cmath>

typedef unsigned long long ull;
typedef long long ll;

ll DENOM = 1000000000LL + 7LL;
using namespace std;

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

Measured memory_bytes: 3048
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MOD = 1000000007;


int main(){
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    ll now = 1000;
    ll stock = 0;
    rep(i,N-1){
        now += stock * A[i];
        stock = 0;

        if (A[i] <= A[i+1]){
            stock = now/A[i];
            now = now%A[i];
        }
    }
    now += stock*A[N-1];

    cout << now << endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<cassert>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


int N;
int keta;
vector<int>v;
const int a[3] = { 3,5,7 };

void dfs(int num) {
	int k;
	if (num == 0)k = 0;
	else k = log10(num)+ 1;
	if (k == keta) {
		v.push_back(num);
		return;
	}
	else v.push_back(num);
	for (int i = 0; i < 3; i++) {
		int n = num * 10 + a[i];
		if (n > N)continue;
		dfs(n);
	}
}

signed main() {
	cin >> N;
	keta = log10(N) + 1;
	dfs(0);
	int ans = 0;
	rep(i, v.size()) {
		map<int, int>m;
		while (1) {
			if (v[i] == 0)break;
			m[v[i] % 10]++;
			v[i] /= 10;
		}
		if (m[3] && m[5] && m[7])ans++;
	}
	cout << ans << endl;
}

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

using namespace std;

bool solve(const std::vector<int>& ls) {
  int const n = ls.size();
  int sum = 0;
  for (int i = 0; i < n - 1; ++i) {
    sum += ls[i];
  }
  return sum > ls.back();
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n;
  std::cin >> n;
  std::vector<int> ls(n);
  for (auto& l : ls) {
    std::cin >> l;
  }
  std::sort(ls.begin(), ls.end());
  std::cout << (solve(ls) ? "Yes" : "No") << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

signed main(){
	int n;
	cin>>n;
	vector<int>a(n),b(n),c(n-1);
	vector<int>m;
	int ans=0;
	rep(i,n){
		cin>>a[i];
		if(i!=0){
			if(a[i]==a[i-1]+1)m.pb(a[i-1]-1);
		}
	}

	rep(i,n){
		cin>>b[i];
		ans+=b[i];
	}
	rep(i,n-1){
		cin>>c[i];
		rep(j,m.size())if(m[j]==i)ans+=c[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    if((N == 1 && A != B) || A > B)
        cout << 0 << endl;
    else
        cout << (B * (N - 1) + A) - (A * (N - 1) + B) + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n <= 9) System.out.println(n);
        else if(n <= 99)System.out.println(9);
        else if(n <= 999)System.out.println(n-90);
        else if(n <= 9999)System.out.println(909);
        else if(n <= 99999)System.out.println(n-9090);
        else System.out.println(90909);
    }
}

Measured memory_bytes: 23764
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>

namespace IO {
    template <typename _T>
    inline bool read (_T& x) {
        x = 0;
        _T y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-') y = -1;
            c = getchar();
        }
        if (c == EOF) return false;
        while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
        x *= y;
        return true;
    }

    template <typename _T>
    inline _T input () {
        _T x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-') y = -1;
            c = getchar();
        }
        if (c == EOF) return 0;
        while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
        x *= y;
        return x;
    }
};
using namespace IO;

namespace modular {
    const int MOD = 1000000007;

    inline int add (int x, int y) { return (x += y) >= MOD ? x -= MOD : x; }

    inline void inc (int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; }

    inline int mul (int x, int y) { return 1LL * x * y % MOD; }

    inline int qpow (int x, int y) {
        int ans = 1;
        for (; y; y >>= 1, x = mul(x, x)) if (y & 1) ans = mul(ans, x);
        return ans;
    }
};
using namespace modular;

#define reg register
#define MAX_N 200007
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, l, r) for(int i = l; i <= r; ++i)
#define lep(i, l, r) for(int i = l; i < r; ++i)
#define irep(i, r, l) for(int i = r; i >= l; --i)
#define ilep(i, r, l) for(int i = r; i > l; --i)
typedef long long ll;

int N, X, Y;
int c[MAX_N], w[MAX_N], mn[MAX_N], pre[MAX_N], suf[MAX_N];
int fac[MAX_N], ifac[MAX_N];
std::vector<int> vc[MAX_N];

inline int getmn (int x) { return std::min(pre[x - 1], suf[x + 1]); }

int main () {
#ifdef LOCAL
    FIN("2.in");
#endif
    read(N), read(X), read(Y);
    rep (i, 1, N) mn[i] = 1e9;
    rep (i, 1, N) {
        read(c[i]), read(w[i]), vc[c[i]].push_back(w[i]);
        mn[c[i]] = std::min(mn[c[i]], w[i]);
    }
    pre[0] = suf[N + 1] = 1e9;
    rep (i, 1, N) pre[i] = std::min(pre[i - 1], mn[i]);
    irep (i, N, 1) suf[i] = std::min(suf[i + 1], mn[i]);
    rep (i, 1, N) if (!vc[i].empty()) {
        std::sort(vc[i].begin(), vc[i].end());
        if (vc[i][0] + getmn(i) > Y) vc[i].clear();
        else {
            irep (j, vc[i].size() - 1, 1) {
                if (vc[i][j] + getmn(i) > Y && vc[i][j] + vc[i][0] > X) vc[i].pop_back();
            }
        }
    }
    fac[0] = ifac[0] = 1;
    rep (i, 1, N) fac[i] = mul(fac[i - 1], i);
    ifac[N] = qpow(fac[N], MOD - 2);
    irep (i, N, 2) ifac[i - 1] = mul(ifac[i], i);
    int res = 1, sum = 0;
    rep (i, 1, N) if (!vc[i].empty()) {
        res = mul(res, ifac[vc[i].size()]);
        sum += vc[i].size();
    }
    res = mul(res, fac[sum]);
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 14720
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int d = Integer.parseInt(sc.next());

		System.out.println(Math.min(a, b) + Math.min(c, d));
	}
}

Measured memory_bytes: 22868
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		 	int n = sc.nextInt();
			long sum = 0;

			for (int i = 1;i<=n ;i++ ) {
				if (i%3==0||i%5==0) {

				}else{
					sum+=i;
				}
			}
			System.out.println(sum);


	}
}


Measured memory_bytes: 35588
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let (count5, count7, countx) = input.split_whitespace().fold((0, 0, 0), |(c5, c7, cx), token| {
        let len: i32 = token.parse().unwrap();
        if len == 5 {
            (c5 + 1, c7, cx)
        } else if len == 7 {
            (c5, c7 + 1, cx)
        } else {
            (c5, c7, cx + 1)
        }
    });
    if count5 == 2 && count7 == 1 && countx == 0 {
        println!("YES")
    } else {
        println!("NO")
    }
}


Measured memory_bytes: 4352
def resolve():
    import bisect
    n = int(input())
    a = sorted(list(map(int, input().split())))
    b = sorted(list(map(int, input().split())))
    c = sorted(list(map(int, input().split())))
    ans = 0
    for i in range(n):
        btest = b[i]
        aind = bisect.bisect_left(a,btest)
        cind = bisect.bisect_right(c, btest)
        ans += aind * (len(c)-cind)
    print(ans)
resolve()

Measured memory_bytes: 107108
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      final var line = Arrays.stream(br.readLine().split(" "))
        .mapToInt(Integer::parseInt)
        .sorted()
        .toArray();

      System.out.println(line[0] == 5 && line[1] == 5 && line[2] == 7 ? "YES" : "NO");
    }
  }
}


Measured memory_bytes: 34448
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
  int a[10] = {0};
  int k;
  for (int i = 0; i < 5; i++) scanf("%d", &a[i]);
  scanf("%d", &k);
  for (int i = 0; i < 5; i++)
    for (int j = i + 1; j < 5; j++)
      if (abs(a[i] - a[j]) > k) {
        puts(":(");
        return 0;
      }
  puts("Yay!");
  return 0;
}

Measured memory_bytes: 128
def addAndDeleteMin():
	global ans
	global p
	minv = min(p)
	ans += minv
	p.remove(minv)

n,k = map(int,input().split())
p = [int(x) for x in input().split()]
ans = 0
for i in range(k):
	addAndDeleteMin()
print(ans)

Measured memory_bytes: 9120
from functools import reduce

def combinations_count_mod(n, r, m):
    num = reduce(lambda x, y: x * y % m, range(n, n - r, -1))
    den = reduce(lambda x, y: x * y % m, range(1, r + 1))
    return num * pow(den, m - 2, m) % m

N, A, B = map(int, input().split())

MOD = 10 ** 9 + 7
 
answer = pow(2, N, MOD) - 1 - combinations_count_mod(N, A, MOD) - combinations_count_mod(N, B, MOD)
answer %= MOD
print(answer)

Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

i64 solve() {
    i64 k, s, ans = 0;
    cin >> k >> s;
    for (i64 x = 0; x <= k; ++x) {
        for (i64 y = 0; y <= k; ++y) {
            i64 z = s - x - y;
            if (0 <= z && z <= k) ++ans;
        }
    }
    return ans;
}

int main() {
    int t = 1;
    // cin >> t;
    while (t--) cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        for(int i=1; i<10;i++) {
            for(int j=1; j<10; j++) {
                if(a == i*j) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 21844
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
#include "string"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)

int main() {
	int n;
	cin >> n;
	int a = 1000;
	while (a < n) {
		a += 1000;
	}
	cout << a - n << endl;
	return 0;
}

Measured memory_bytes: 3636
# coding:utf-8

import sys
import math
import time
import numpy as np
import collections

ABK = str(raw_input()).split()
A = int(ABK[0])
B = int(ABK[1])
K = int(ABK[2])


#for i in xrange(K):
#  if(A > 0):
#    A -= 1
#  elif(B > 0):
#    B -= 1

if(A < K):
  K -= A
  A = 0
  if(B < K):
    B = 0
  else:
    B -= K
else:
  A -= K



print(str(A)+ " " + str(B));


Measured memory_bytes: 16144
#include "bits/stdc++.h"

using namespace std;

void Main() {
    long long N, M;
    cin >> N >> M;
    vector<long long> H(N, 0LL);
    for (int i = 0; i < N; ++i) {
        cin >> H[i];
    }
    vector<long long> A(M, 0LL), B(M, 0LL);
    for (int i = 0; i < M; ++i) {
        cin >> A[i] >> B[i];
    }

    for (int i = 0; i < M; ++i) {
        A[i] -= 1;
        B[i] -= 1;
    }

    map<long long, long long> peakDiff;
    for (int i = 0; i < M; ++i) {
        if (peakDiff.count(A[i])) {
            peakDiff[A[i]] = min(peakDiff[A[i]], H[A[i]] - H[B[i]]);
        }
        else {
            peakDiff.insert(make_pair(A[i], H[A[i]] - H[B[i]]));
        }
        if (peakDiff.count(B[i])) {
            peakDiff[B[i]] = min(peakDiff[B[i]], H[B[i]] - H[A[i]]);
        }
        else {
            peakDiff.insert(make_pair(B[i], H[B[i]] - H[A[i]]));
        }
    }

    long long cntGood = 0;
    long long nb = 0;
    for (auto e : peakDiff) {
        if (e.second > 0) {
            ++cntGood;
        }
        ++nb;
    }
    cntGood += (N - nb);
    cout << cntGood << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 10912
import java.util.*;

class Main{
  static public void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String str1=sc.nextLine(),str2=sc.nextLine();
    int num=0;
    for(int i=0;i<str1.length();i++)
      if(str1.charAt(i)!=str2.charAt(i))
        num++;
   
    System.out.println(num);
  }
}

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

using namespace std;

int isprime(int x){
    if(x==2) return 1;
    else if(x<2||x%2==0) return 0;
    
    int i=3;
    while(i<=sqrt(x)){
        if(x%i==0) return 0;
        i = i+2;
    }
    return 1;
}

int main(){
    int n;
    cin >> n;
    int x[10001];
    
    int cnt=0;    
    for(int i=0;i<n;++i){
        cin >> x[i];
        cnt += isprime(x[i]);
    }

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


Measured memory_bytes: 3116
n = int(input())
a = list(map(int, input().split()))
tot = sum(a) // 2
ans = [-1] * n
now = sum(a[:n - 1:2])
i = 0
j = n - 1
while ans[j] == -1:
    ans[j] = tot - now
    now += a[j] - a[i]
    j = (j + 2) % n
    i = (i + 2) % n
print(*map(lambda x: 2 * x, ans))


Measured memory_bytes: 16968
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
using ll = long long;
int main(){ 
    ll x;
    cin>>x;
    if(x%11==0){
        cout<<x/11*2;
    }else if(x%11>6){
        cout<<(x/11+1)*2;
    }else{
        cout<<x/11*2+1;
    }
    return 0;
}

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

const int N = 100005;
typedef long long ll;
int n, tot = 1, u[N], v[N], nxt[2 * N], fst[N], to[2 * N], size[N];
ll s[N], w[N], res;

void dfs(int u, int fa)
{
	size[u] = 1;
	for (int i = fst[u]; i; i = nxt[i])
		if (to[i] != fa)
		{
			dfs(to[i], u);
			size[u] += size[to[i]];
			if (size[to[i]] * 2 != n)
				w[i >> 1] = (s[u] - s[to[i]]) / (2 * size[to[i]] - n);
		}
}

void bf(int u, int fa)
{
	size[u] = 1;
	for (int i = fst[u]; i; i = nxt[i])
		if (to[i] != fa)
			bf(to[i], u), res += size[to[i]] * w[i >> 1], size[u] += size[to[i]];
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i < n; i++)
	{
		scanf("%d%d", u + i, v + i);
		nxt[++tot] = fst[u[i]]; fst[u[i]] = tot; to[tot] = v[i];
		nxt[++tot] = fst[v[i]]; fst[v[i]] = tot; to[tot] = u[i];
	}
	for (int i = 1; i <= n; i++) scanf("%lld", s + i);
	dfs(1, 0);
	for (int i = 1; i < n; i++)
		if (!w[i])
		{
			bf(u[i], v[i]), bf(v[i], u[i]);
			w[i] = (s[u[i]] - res) / size[v[i]];
		}
	for (int i = 1; i < n; i++) printf("%lld\n", w[i]);
	return 0;
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
#pragma optimize("-O3")
#define int long long int
#define pb push_back
#define f first
#define s second
#define endl '\n'

main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, d;
	cin>>n>>d;
	int ans=0;
	for(int i=0; i<n; i++){
		int x, y;
		cin>>x>>y;
		if(x*x+y*y<=d*d){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3652
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
	if(!b)return 1;	if(b&1)return modpow(a,b-1,m)*a%m;
	int memo = modpow(a,b>>1,m);
	return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b;
  cin>>a>>b;
  out(a*b);
}

Measured memory_bytes: 3748
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    string s; int k;
    cin >> s >> k;
    vector<string> dics;
    vector<string> dic[6];
    for(int p = 1; p <= min(5, (int)s.size()); p++){
        for(int i = 0; i < s.size(); i++){
            string a = "";
            for(int j = 0; j < p; j++){
                if(i + j < s.size()){
                    a += s[i+j];
                }
            }
            if(a.size() == p){
                dic[p].push_back(a);
            }
        }
        sort(dic[p].begin(), dic[p].end());
        dic[p].erase(unique(dic[p].begin(), dic[p].end()), dic[p].end());
        for(int i = 0; i < dic[p].size(); i++){
            dics.push_back(dic[p][i]);
        }
    }
    sort(dics.begin(), dics.end());
    cout << dics[k-1] << endl;
    return 0;
}


Measured memory_bytes: 1280
//テスト用ファイル
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(void) {

  int n, c;
  scanf("%d", &n);

  if ((n<1)||(10000<n)) {
    return -1;
  }

  c = n%1000;
  if (c != 0) {
    c = 1000-c;
  }

  printf("%d\n", c);

  return 0;
}


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

using namespace std;

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

    int a, sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> a;
        sum += a;
    }

    cout << ((H - sum > 0) ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int k,n;
	long long sum=0;
	while(cin>>k,k){
		sum=0;
		rep(i,k*(k-1)/2){
			cin>>n;
			sum+=n;
		}
		sum/=(k-1);
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156