akhauriyash/Code-Regression huggingface dataset:
/*      ex4_2
        Tarara  */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

double pow2(double x);

int main(void)
{
    int hour_hand_len;   //時針の長さ(cm)
    int minute_hand_len; //分針の長さ(cm)
    int hour;            //時計が指す時間
    int minute;          //時計が指す分

    scanf("%d %d %d %d", &hour_hand_len, &minute_hand_len, &hour, &minute);

    // 時針と分針の間の角度
    double rad = M_PI / 6 * fabs(hour - 11.0 * minute / 60);

    double length = sqrt(pow2(hour_hand_len) + pow2(minute_hand_len) - 2 * hour_hand_len * minute_hand_len * cos(rad));
    printf("%.13f\n", length); // 求める長さ(余弦定理を用いている)
    return 0;
}

// ２乗を計算する
double pow2(double x)
{
    return x * x;
}

Measured memory_bytes: 2528
#include<bits/stdc++.h>
using namespace std;
long long DP[3030][3030][5];
long long val[3030][3030];
int main()
{
	int R,C,N;
	cin>>R>>C>>N;
	for(int i=0;i<N;i++)
	{
		int x,y,v;
		cin>>x>>y>>v;
		val[x][y]=v;
	}
	if(val[1][1])
		DP[1][1][1]=val[1][1];
	for(int i=1;i<=R;i++)
		for(int j=1;j<=C;j++)
			for(int k=0;k<=3;k++)
			{
				if(j<C)
				{
					DP[i][j+1][k]=max(DP[i][j+1][k],DP[i][j][k]);
					if(val[i][j+1])
						DP[i][j+1][k+1]=max(DP[i][j+1][k+1],DP[i][j][k]+val[i][j+1]);
				}
				if(i<R)
				{
					DP[i+1][j][0]=max(DP[i+1][j][0],DP[i][j][k]);
					if(val[i+1][j])
						DP[i+1][j][1]=max(DP[i+1][j][1],DP[i][j][k]+val[i+1][j]);
				}
			}
	cout<<max(max(DP[R][C][0],DP[R][C][1]),max(DP[R][C][2],DP[R][C][3]))<<endl;
	return 0;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n;cin>>n&&n;){
		map<string,int> f;
		rep(i,n){
			string s; cin>>s;
			sort(all(s));
			f[s]++;
		}
		ll res=0;
		for(auto p:f){
			ll x=p.second;
			res+=(x-1)*x/2;
		}
		cout<<res<<endl;
	}
}


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

#define _GLIBCXX_DEBUG

//vector<int> A(M), B(M);
//vector<vector<char>> answer(N, vector<char>(N, '-'));

int main() {
  string s, t, u;
  int a, b;
  int ans_a, ans_b;
  
  cin >> s >> t >> a >> b >> u;
  
  if(u == s){
    ans_a = a - 1;
    ans_b = b;
  }
  else{
    ans_a = a;
    ans_b = b - 1;
  }
  
  cout << ans_a << " " << ans_b << endl;
  return 0;
}

Measured memory_bytes: 3624
N = int(input())
ana_list = {}

for i in range(N):
  letter = input()
  tmp = []
  for k in range(10):
    tmp.append(letter[k])
    
  tmp.sort()
  letter = ''.join(tmp)
  if letter in ana_list:
    ana_list['{}'.format(letter)] += 1
  else:
    ana_list['{}'.format(letter)] = 1

num_list = list(ana_list.values())

ans = 0
for i in range(len(num_list)):
  if num_list[i] >= 2:
    ans += num_list[i] * (num_list[i] - 1) / 2
    
print(int(ans))

Measured memory_bytes: 17804
#![allow(unused)]
use proconio::*;

// /////////////////////
// Disjoint Set Union //
// /////////////////////

struct DSU {
    len: usize,
    parent: Vec<usize>,
    rank: Vec<usize>,
}

impl DSU {
    fn new(len: usize) -> Self {
        let mut parent = Vec::with_capacity(len);
        for i in 0..len {
            parent.push(i);
        }
        Self {
            len,
            parent,
            rank: vec![1; len],
        }
    }
    fn find_parent(&mut self, u: usize) -> usize {
        assert!(u < self.len);

        let x = self.parent[u];

        if x == u {
            x
        } else {
            let parent = self.find_parent(x);
            self.parent[u] = parent;
            parent
        }
    }
    fn merge(&mut self, u: usize, v: usize) -> usize {
        assert!(u < self.len);
        assert!(v < self.len);
        let x = self.find_parent(u);
        let y = self.find_parent(v);

        if x == y {
            x
        } else {
            if self.rank[x] > self.rank[y] {
                self.rank[x] += self.rank[y];
                self.parent[y] = x;
                self.rank[y] = 0;
                x
            } else {
                self.rank[y] += self.rank[x];
                self.parent[x] = y;
                self.rank[x] = 0;
                y
            }
        }
    }
}

fn main() {
    input! {
    n: usize,
        q: usize,
        a: [(usize,usize,usize);q],
    }

    let mut dsu = DSU::new(n);
    for &(t, u, v) in &a {
        if t == 0 {
            dsu.merge(u, v);
        } else {
            if dsu.find_parent(u) == dsu.find_parent(v) {
                println!("{}", 1);
            } else {
                println!("{}", 0);
            }
        }
    }
}


Measured memory_bytes: 10780
K, N = map(int, input().split())
A_lst = list(map(int, input().split()))
d = []
for i in range(N-1):
    d.append(A_lst[i+1]-A_lst[i])
d.append(K-A_lst[-1]+A_lst[0])
print(sum(d)-max(d))

Measured memory_bytes: 26444
N = int(input())
#N,A,B = map(int,input().split())
A_list = list(map(int,input().split()))
B_list = list(map(int,input().split()))
C_list = list(map(int,input().split()))
#X1_list = [int(input()) for i in range(N)]
#X2_list = [list(map(int,input().split())) for i in range(N)]

result= B_list[A_list[0] - 1]
for i in range(1,N):
    #print(result)
    result += B_list[A_list[i] -1]
    if A_list[i] -1 == A_list[i-1] :
        result += C_list[A_list[i-1] -1]
print(result)


Measured memory_bytes: 3064
def main():
	n , k = map(int, input().split())
	s = input()
	uh=0
	for i in range(0 , len(s)-1):
		if s[i]!=s[i+1]:
			uh=uh+1
	hp = n-1 - max(uh-2*k , 0)
	print(hp)


if __name__=="__main__":
	main()

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

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

    return 0;
}

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

#define ll long long 

using namespace std;

int n;
double r;

double dist(int x2,int y2,int x1,int y1){
    return (double)(sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    vector <int> x(n);
    vector <int> y(n);
    for(int i=0; i<n; i++){
        cin>>x[i];
        cin>>y[i];
    }
    vector <int> p(n);
    int prod=1;
    for (int i=0; i<n; i++){
        p[i]=i+1;
        prod*=(i+1);
    }
    
    do{
        
        for (int i=1; i<p.size(); i++){
            r+=dist(x[p[i]-1],y[p[i]-1],x[p[i-1]-1],y[p[i-1]-1]);
        }
    }while(next_permutation(p.begin(),p.end()));
    
    cout<<fixed<<setprecision(10);
    cout<<r/prod;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
bool comp(const pii& p1, const pii& p2)
{
	if (p1.first != p2.first)
		return p1.first < p2.first;
	else
		return p1.second < p2.second;
}
int main()
{
	int a[4];
	cin >> a[0] >> a[1] >> a[2] >> a[3];
	vector<pii> vp;
	vp.emplace_back(pii(a[0], a[1]));
	vp.emplace_back(pii(a[2], a[3]));
	sort(vp.begin(), vp.end(),comp);
	int start = 0;
	int end=0;
	if (vp[1].first < vp[0].second)
	{
		start = max(vp[0].first, vp[1].first);
		end = min(vp[0].second, vp[1].second);
	}
	cout << end - start << endl;
	return 0;
}

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

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

    double denominator = 0;
    for(int a: A){
        denominator += 1.0/a;
    }
    cout << setprecision(12) << 1.0/denominator << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) ((x).begin(), (x).end())
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

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

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

    ll k, n;
    cin >> k >> n;
    V<ll> a(n);
    ll ans = -1;
    rep(i, n) {
        cin >> a[i];
        if(i) chmax(ans, a[i] - a[i - 1]);
    }
    chmax(ans, a.front() + k - a.back());
    cout << k - ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

int main()
{ 
    ll m1,d1,m2,d2;
    cin>>m1>>d1>>m2>>d2;

    ll last[12]={0,31,28,31,30,31,30,31,31,30,31,30};

    if(m1==m2)
    	cout<<0<<endl;
    else
    {
    	if(d1==last[m1])
    		cout<<1<<endl;
    	else cout<<0<<endl;
    }


   }

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

int main() {
    int X,Y;
    cin >> X >> Y;
    bool flag = false;
    for (int i=0; i<=X; i++) {
        for (int j=0; j<=X-i; j++) {
            if (i==0 && j==0) continue;
            int leg = i*2 + j*4;
            int total = i + j;
            if (leg==Y && total==X) {
                flag = true;
                break;
            }
        }
        if (flag == true) break;
    }
    if (flag == true) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    S=[]
    for i in range(n):
        S.append(int(input()))
    from functools import reduce
    from fractions import gcd

    def lcm(A, B):
        return A * B // gcd(A, B)


    print(reduce(lcm, S))
resolve()

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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debug(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
#define allr(v) v.rbegin(),v.rend() 
//#define endl '\n'  
typedef  long long ll; 
typedef  unsigned long long ull; 
typedef vector< ll > edge; 
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1000000007;
const ll inf=1e15;
const ll N=2e5+10;

int main()
{
  boost;
  ll n,m;
  cin>>n>>m;
  std::vector<ll> a(n);
  for(auto &i:a) cin>>i;
  std::vector<mypair> v;
  for(ll i=0;i<m;i++)
  {
  	ll x,y;
  	cin>>x>>y;
  	v.pb(mp(y,x));
  }	
  sort(all(a));
  sort(all(v));
  reverse(all(v));
  auto lo=0;
  auto hi=n-1;
  for(auto i:v)
  {
  	ll count=0;
  	while( lo<=hi and a[lo]<i.ff and count<i.ss) a[lo]=i.ff,lo++,count++; 
  }
  ll ans=0;
  for(auto i:a) ans+=i;
  cout<<ans;	

  return 0;
}

Measured memory_bytes: 3188
N = int(input())
result = 0
for i in range(1, (N + 1)):
    if i % 15 == 0:
        'Fizz Buzz'
    elif i % 3 == 0:
        'Fizz'
    elif i % 5 == 0:
        'Buzz'
    else:
        result = result + i
print(result)

Measured memory_bytes: 9008
def nibutan(f_id,e_id,f_num,count):
    
    
    m_id = int((f_id + e_id) / 2)
    m_num = n_lis[m_id]

   
    if (f_id > e_id):
        return count
    else:
        count += 1

        if m_num > f_num:
            return(nibutan(f_id,m_id -1,f_num,count))
        elif m_num < f_num:
            return(nibutan(m_id + 1,e_id,f_num,count))
        else:
            return count
                
while True:
    global n_lis

    n = int(input())
    if n == 0:
        break
    n_lis = []
    for i in range(n):
        n_lis.append(int(input()))
    f_n = int(input())
    ans = nibutan(0,n - 1,f_n,0)
    print(ans)

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)

using namespace std;


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

    ll maxx = 0;
    rep(i, 17){
        if(pow(10, i)-1 <= n){
            maxx = 9*i;
            ll b = pow(10, i)-1;
            rep(j, 10){
                if(j == 0)  continue;
                ll it = j*b+j-1;
                if(it <= n) maxx = 9*i + j-1;
                else        break;
            }
        }
        else break;
    }

    cout << maxx << endl;


    return 0;
}


Measured memory_bytes: 384
N = int(input())
a = list(map(int,input().split()))

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

for i in range(N-1, -1, -1):
    for j in range(i, N):
        dp[i][j] = max(a[i]-dp[i+1][j],a[j]-dp[i][j-1])

print(dp[0][N-1])

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

int main(){

  int N, M, i, j, a, b;
  cin>>N>>M;
  vector<vector<int>> r(N+1);
  for(i=0; i<M; i++){
    cin>>a>>b;
    r[a].push_back(b);
  }
  
  for(i=0; i<(int)r[1].size(); i++){
    for(j=0; j<(int)r[r[1][i]].size(); j++){
      if(r[r[1][i]][j]==N){
        cout<<"POSSIBLE"<<endl;
        return 0;
      }
    }
  } 
  cout<<"IMPOSSIBLE"<<endl;
  return 0;
}

Measured memory_bytes: 11444
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(void) {
	int num, i = 0, j, sum = 0;
	cin >> num;
	vector<int> x(num), y(num);
	map<pair<int, int>, int> mp;
	for (; i < num; i++)
		scanf("%d%d", &x[i], &y[i]);
	for (i = 0; i < num - 1; i++) {
		for (j = i + 1; j < num; j++) {
			if (x[i] < x[j])
				sum = max(sum, ++mp[make_pair(x[j] - x[i], y[j] - y[i])]);
			else if(x[i] > x[j])
				sum = max(sum, ++mp[make_pair(x[i] - x[j], y[i] - y[j])]);
			else
				sum = max(sum, ++mp[make_pair(0, abs(y[i] - y[j]))]);
		}
	}
	cout << num - sum << "\n";
	return 0;
}

Measured memory_bytes: 384
n,k,*l=map(int,open(0).read().split())
for _ in range(k):
  s=[0]*(n+1)
  for i in range(n):
    s[max(i-l[i],0)]+=1
    s[min(i+l[i]+1,n)]-=1
  for i in range(n):
    s[i+1]+=s[i]
  s.pop()
  if s==l: break
  l=s
print(*l)

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
const ll MOD = 1e9+7;

vector<ll> fact, ifact, invs, v;
ll combmod(int n, int k, ll MOD, int M = 1e5){
    if (!fact.size()){
        fact.resize(M+1); ifact.resize(M+1); invs.resize(M+1);
        fact[0] = ifact[0] = invs[0] = fact[1] = ifact[1] = invs[1] = 1;
        for(int i = 2; i <= M; i++){
            fact[i] = fact[i-1] * i % MOD;
            invs[i] = MOD - MOD / i * invs[MOD % i] % MOD;
            ifact[i] = ifact[i-1] * invs[i] % MOD;
        }
    }
    return fact[n] * ifact[k] % MOD * ifact[n-k] % MOD;
}

ll arr(int n, int k){
    return fact[n] * ifact[n-k] % MOD;
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int n, m;
    cin >> n >> m;
    combmod(1, 1, MOD, 1e6);

    ll sol = arr(m, n) * arr(m, n) % MOD;
    FOR1(k, n){
        ll ds = combmod(n, k, MOD) * arr(m, k) % MOD * arr(m-k, n-k) % MOD * arr(m-k, n-k) % MOD;
        if (k%2)
            sol += MOD - ds;
        else
            sol += ds;
        sol -= (sol >= MOD)*MOD;
    }
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

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

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

bool check_level(vector<int> level, int x){
    int l = level.size();
    for(int i = 0; i < l; i++){
        if(level.at(i) < x){
            return false;
        }
    }
    
    return true;
}
    
    
int main(void){
    int n, m, x; cin >> n >> m >> x;
    vector<vector<int>> matrix(n, vector<int>(m+1));
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m+1; j++){
            cin >> matrix.at(i).at(j);
        }
    }
    
 //   for(int i = 0; i < n; i++){
//       for(int j = 0; j < m+1; j++){
//           cout <<  matrix.at(i).at(j) << " ";
//        }
//        cout << endl;
//    }
    
    int total_comb = pow(2, n);
//    cout << total_comb << endl;
    int ans = -1;
    bool flag = true;
    
    for(int i = 0; i < total_comb; i++){
        bitset<12> s(i);
      //  cout << s << endl;
        
        int sum = 0;
        vector<int> level(m);
        
        for(int index = 0; index < n; index++){
            if(s.test(index) == 1){
                sum = sum + matrix.at(index).at(0);
                for(int j = 0; j < m; j++){
                    level.at(j) = level.at(j) + matrix.at(index).at(j+1);
                }
            }
//            cout << s.test(index) << " ";
        }
 //       cout << sum << " ";
        
   //     for(int i = 0; i < m; i++){
  //          cout << level.at(i) << " ";
    //    }
     //   cout << endl;
      
        if(check_level(level, x)){
            if(sum < ans || flag){
                ans = sum;
                flag = false;
            }
        }
    }
    
    cout << ans << endl;
        
        
}


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

int main() {
  int H, W, M;
  cin >> H >> W >> M;
  vector<vector<int>> V(M, vector<int>(2));
  for (int i=0; i<M; i++) {
    cin >> V.at(i).at(0) >> V.at(i).at(1);
  }
  
  vector<int> BH(H, 0);
  vector<int> BW(W, 0);
  
  for (int i=0; i<M; i++) {
    BH.at(V.at(i).at(0)-1)++;
    BW.at(V.at(i).at(1)-1)++;
  }
  
  
  vector<int> HMI(0);
  vector<int> WMI(0);
  
  int mh=0, mw=0;
  for (int i=0; i<H; i++) {
    mh = max(mh, BH.at(i));
  }
  
  for (int i=0; i<W; i++) {
    mw = max(mw, BW.at(i));
  }
  
  int64_t ch=0, cw=0;
  for (int i=0; i<H; i++) {
    if (BH.at(i) == mh) {
      ch++;
    }
  }
  
  for (int i=0; i<W; i++) {
    if (BW.at(i) == mw) {
      cw++;
    }
  }
  
  
  int finish = 1;
  int64_t C=0;   
  
  for (int k=0; k<M; k++) {
    if (BH.at(V.at(k).at(0)-1) == mh && BW.at(V.at(k).at(1)-1) == mw) {
      C++;
    }
  }
  if (cw * ch > C) {
    finish = 0; 
  }
  else {
    finish = 1;
  }
  
  cout << mh + mw - finish << endl;
  
}


Measured memory_bytes: 21984
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import deque
import pprint

inf = 10**18
mod = 10**9+7

n = int(input())
a = list(map(int, input().split()))
a.sort()
if n == 1:
    print(1)
    sys.exit()
if n == 2:
    if a[0] == a[1]:
        print(0)
    elif a[1]%a[0] == 0:
        print(1)
    else:
        print(2)
    sys.exit()

b = []
pre = a[0]
if a[0] != a[1]:
    if pre == 1:
        print(1)
        sys.exit()
else:
    if pre == 1:
        print(0)
        sys.exit()

judge = [False for i in range(10**6+1)]
for num in a:
    judge[num] = True
for i in range(1,(10**6)):
    if judge[i]:
        for j in range(i*2,10**6+1,i):
            judge[j] = False
ans = 0
for i in range(1,10**6+1):
    if judge[i]:
        ans+=1
subans = 0
c = collections.Counter(a)
for k,v in c.items():
    if v > 1 and judge[k]:
        subans+=1
print(ans-subans)

Measured memory_bytes: 169204
ipt = input().split()
val_str = ipt[0] + ipt[1]
val = int(val_str)
ans = False
for x in range(val):
    if x * x == val:
        ans = True
        break
    elif x * x > val:
        break
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<T> vt;
//inline int in() { int x; scanf("%d",&x); return x;}
inline ll in() { ll x; cin >> x; return x; }
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
#define chmin(x,y) x = min(x,y)

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}

vector<int> to[2505];
vector<int> rto[2505];
bool reachablefrom1[2505];
bool reachableToN[2505];
bool ok[2505];

void dfs(int v) {
  if (reachablefrom1[v]) return;
  reachablefrom1[v] = true;
  for (int u : to[v]) {
    dfs(u);
  }
}
void rdfs(int v) {
  if (reachableToN[v]) return;
  reachableToN[v] = true;
  for (int u : rto[v]) {
    rdfs(u);
  }
}

int main() {
  ll n = in();
  string s; cin >> s;
  if (n % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }
  ll n2 = n / 2;
  int ans = 0;
  rep(i, n2) {
    if (s[i] != s[i+n2]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main()
{
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if(s < t){
        cout << "Yes";
    }
    else{
        cout<< "No";
    }
}



Measured memory_bytes: 380
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  set<string> st;
  while (n--) {
    string s; cin >> s;
    st.emplace(s);
  }
  cout << st.size() << '\n';
  return 0;
}


Measured memory_bytes: 19240
n, a, b = map(int, input().split())
MOD = 10 ** 9 + 7

def power_func(a, n, mod):
  bi = bin(n)[2:]
  res = 1
  for i in range(len(bi)):
    res = (res * res) % mod
    if bi[i] == "1":
      res = (res * a) % mod
  return res

def modinv(a, mod):
    return pow(a, mod-2, mod)

def combination(n, r, mod):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

def main():
    ans = power_func(a=2, n=n, mod=MOD) - 1
    ans -= combination(n=n, r=a, mod=MOD)
    ans -= combination(n=n, r=b, mod=MOD)
    ans %= MOD
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9
int grid[20][20];
int d, w;
int calc(int top, int bottom, int left, int right) {
  int mi = INF;
  for (int i = left; i <= right; i++) {
    mi = min(grid[top][i], mi);
    mi = min(grid[bottom][i], mi);
  }
  for (int i = top; i <= bottom; i++) {
    mi = min(grid[i][left], mi);
    mi = min(grid[i][right], mi);
  }

  int ans = 0;
  for (int i = 0; i < bottom-top-1; i++) {
    for (int j = 0; j < right-left-1; j++) {
      if (mi <= grid[i+top+1][j+left+1]) {
	return -1;
      }
      ans += (mi-grid[i+top+1][j+left+1]);
    }
  }
  
  return ans;
}

signed main() {
  while (cin>>d>>w, d+w) {
    for (int i = 0; i < d; i++) {
      for (int j = 0; j < w; j++) {
	cin >> grid[i][j];
      }
    }
    int ans = -1;
    for (int i = 0; i < d; i++) {
      for (int j = d-1; j >= 0; j--) {
	for (int k = 0; k < w; k++) {
	  for (int l = w-1; l >= 0; l--) {
	    if (i == j || k == l) break;
	    ans = max(ans, calc(i, j, k, l));
	  }
	}
      }
    }
    cout << ans << endl;
  }
}




Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}

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

  string ans = "";
  repi(i, 1, 20)
  {
    if (n <= pow(26, i))
    {
      n -= 1;
      rep(j, i)
      {
        ans += 'a' + (n % 26);
        n /= 26;
      }
      break;
    }
    n -= pow(26, i);
  }

  reverse(ans.begin(), ans.end());
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4108
#define _GLIBCXX_DEBUG
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <random>
#include <utility>
#include <map>
#include <vector>
#include <queue>
#include <bitset>
#include <sstream>

using namespace std;

#define REP(i,x) for(int i=0; i<(x); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n;
    cin >> n;

    queue<pair<string, char>> p;
    p.push(make_pair("a",'a'));
    
    while(p.size()>0){
        string s;
        char a;
        tie(s, a) = p.front();
        p.pop();
        if(s.size() == n){
            cout << s << endl;
            continue;
        }
        for(char i = 'a'; i<=a+1; i++){
            if(i<=a){
                p.push(make_pair(s+i, a));
            } else {
                p.push(make_pair(s+i, a+1));
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 8832
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    for(int i=0; i<=7; ++i){
        string t = s.substr(0, i) + s.substr(n-7+i, 7-i);
        if(t == "keyence"){
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
N, K = list(map(int, input().strip().split(" ")))
A = list(map(int, input().strip().split(" ")))
min_index = A.index(min(A))
action = 0

q, mod = divmod(min_index, K-1)
m = q
if((mod != 0) or (mod == 0 and q == 0)):
    m += 1
action += m 
res_list_length = N - (K + (m - 1)*(K - 1)) 
if(res_list_length != 0):
    res_list_length += 1
q, mod = divmod(res_list_length - 1, K-1)
m = q
if((mod != 0)  or (mod == 0 and q == 0)):
    m += 1
action += m 
print(action)

Measured memory_bytes: 14008
#include <iostream>
#include <string>

using namespace std;

int main()
{
  string s;
  cin>>s;
  int result=0;
  for(int i=1;i<s.size();i++)
  {
    if(s[i]!=s[i-1])
    {
      result++;
    }
    
  }

  cout<<result<<endl;
}

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

const int maxn = (1 << 16) + 10;

typedef long long ll;

ll dp[maxn];


ll a[17][17];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0 ; i < n ; i++)
    {
        for(int j = 0 ; j < n ; j++)
        {
            scanf("%lld",&a[i][j]);
        }
    }

    for(int mask = 0; mask < (1 << n); mask++)
    {
        ll c = 0;
        for(int i = 0; i < n ; i++)
        {
            if((mask & (1 << i)) == 0)
                continue;
            for(int j = i+1; j < n; j++)
            {
                if(mask & (1 << j))
                {
                    c += a[i][j];
                }
            }
        }
        dp[mask] = c;
        for(int sub = mask ; sub > 0; sub = mask & (sub-1))
        {
            dp[mask] = max(dp[mask], dp[sub] + dp[mask ^ sub]);
        }
    }

    printf("%lld\n",dp[(1 << n) - 1]);

    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
int main()
{
    int d, t, s;
    cin >> d >> t >> s;
    if (s*t >= d) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3620
x,n= map(int, input().split())

if n == 0:
  print(x)
  exit(0)
  
p = [int(x) for x in input().split()]

a = x
b = x

if x not in p:
  print(x)
  exit(0)

for i in range(1,101):
  a = a + 1
  b = b - 1
  if b not in p:
    print(b)
    exit(0)
  elif a not in p:
    print(a)
    exit(0)

Measured memory_bytes: 9208
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
     ll n,i,j,k,s=0;
     vector<ll>v;
     cin>>n;
     for(i=0;i<n;i++)
     {
         cin>>k;
         v.push_back(k);
     }
     sort(v.begin(),v.end());
     for(i=0;i<n-1;i++)
     {
         s+=v[i];
     }
     if(v[n-1]<s)
     {
         cout<<"Yes"<<endl;
     }
     else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int buy, ch, seets;
	int i;
	int coin[6] = {500,100,50,10,5,1};
	
	while (scanf("%d", &buy), buy){
		
		ch = 1000 - buy;
		seets = 0;
		
		for (i = 0; i < 6; i++){
			seets += ch/coin[i];
			ch = ch%coin[i];
		}
		
		printf("%d\n", seets);
	}	
	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a + b + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod = 1e9 + 7;
long long INF = 1e7;
double EPS = 1e-12;
typedef long long int lld;
long double tick(){static clock_t oldt; clock_t newt=clock();
    long double diff=1.0L*(newt-oldt)/CLOCKS_PER_SEC; oldt = newt; return diff; }
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
inline lld sc() { lld a; scanf("%lld", &a); return a; }
inline int scd() { int a; scanf("%d", &a); return a; }
inline double scf() { double a; scanf("%lf",&a); return a; }
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) (c).begin(), (c).end()
#define sz(a) ((int)a.size())
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }
#define errorpair(a) cout<<#a<<" = ( "<<((a).first)<<" , "<<((a).second)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll

typedef pair<lld,lld> PA;

lld powP(lld x, lld y) {
    lld ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}
 
bool bitSet(lld n, lld bit){
    if((n & (1LL << bit)) != 0) return true;
    else return false;
}
 
lld findGcd(lld a, lld b){
    while(a != 0) { lld temp = b % a; b = a; a = temp; }
    return b;
}

#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
lld A[lim],B[lim],C[lim];
map<lld,lld> M;

int main(){
    lld n = sc();
    lld ans = 0;
    rep(i,1,n) {
        A[i] = sc();
        ans += M[i - A[i]];
        M[A[i] + i]++;
    }
    prL(ans);
    return 0;
}


Measured memory_bytes: 27996
fun main() = Thread(null, ::abc173f, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc173f() {
    val n = readLine()!!.toInt()
    val edges = (1 until n).map {
        val (u, v) = readLine()!!.split(' ').map { it.toLong() }.sorted()
        u to v
    }

    val sum = (1L..n).map { (it * (n - it + 1)) }.sum()
    val minus = edges.map { (u, v) -> u * (n - v + 1) }.sum()

    val answer = sum - minus

    println(answer)
}


Measured memory_bytes: 83776
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(int i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<P,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
struct edge{
	ll cost;
	int num;
	vector<int> roa;
	bool operator<(const edge& e)const{
		return cost==e.cost?num<e.num:cost<e.cost;
	}
	bool operator>(const edge& e)const{
		return cost==e.cost?num>e.num:cost>e.cost;
	}


};
const int MAX_N=100005;
struct road{ll cost;int to;};
int n;
ll k;
vector<ll> a;
ll v[100]={};
ll s[100]={};
void bis(int m,ll c){
	if(c!=0){
		s[m]=c%2;
		bis(m+1,c/2);
	}
}
void biv(int m,ll c){
	if(c!=0){
		v[m]+=c%2;
		biv(m+1,c/2);
	}
}
ll reg(int m,bool d,ll z){
	if(m==-1)return 0;
//	cout<<m<<" "<<v[m]<<endl;
	if(d)return reg(m-1,d,z/2)+max(n-v[m],v[m])*z;
	if(n-v[m]<v[m]){
		if(s[m]==0)return reg(m-1,0,z/2)+v[m]*z;
		return reg(m-1,1,z/2)+v[m]*z;
	}
	if(s[m]==0)return reg(m-1,0,z/2)+v[m]*z;
	return max(reg(m-1,0,z/2)+(n-v[m])*z,reg(m-1,1,z/2)+v[m]*z);
}
int main() {
	cin>>n>>k;
	bis(0,k);
	a.resize(n);
	rep(i,0,n){
		cin>>a[i];
		biv(0,a[i]);
	}
	cout<<reg(40,0,ll(pow(2,40)))<<endl;
	return 0;
}








Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int s[11],i;
    for(i=0;i<10;i++){
        scanf("%d",&s[i]);
    }
    sort(s,s+10);
    for(i=9;i>6;i--){
        printf("%d\n",s[i]);
    }
 return 0;
}

Measured memory_bytes: 1204
// abc078_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int x,y,z;
  cin>>x>>y>>z;
  cout<<(x-z)/(y+z)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        double r;
        double p=3.141592653589;
        cin>>r;
        printf("%.8f %.8f\n",r*r*p,r*2*p);
        return 0;
}

Measured memory_bytes: 1228
#include<stdio.h>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<queue>
#include<functional>
using namespace std;
int main(){
	int a;
	int b;
	int s;
	int t;
	vector<int> n[10000];
	int nn[10000];
	vector<int> x[10000];
	priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > >y;
	vector<pair<int, int> >::iterator yy;
	int z;
	int d[10000];
	int e;
	int c[10000];
	int zz;
	pair<int, int>pai;
	for (int i = 0; i < 10000; i++){
		d[i] = 1000000009;
		c[i] = 0;
	}
	scanf("%d", &a);
	for (int i = 0; i < a; i++){
		scanf("%d %d", &s, &b);
		for (int j = 0; j < b; j++){
			scanf("%d %d", &t, &e);
			n[s].push_back(t);
			nn[s]++;
			x[s].push_back(e);

		}
	}
	d[0] = 0;
	y.push(std::make_pair(d[0], 0));
	for (int i = 0; y.empty() == 0; i++){
		zz = 0;
		for (int j = 0; y.empty() == 0 && zz == 0; j++){
			pai = y.top();
			z = pai.second;
			if (c[z] == 0)zz++;
			else y.pop();
		}
		if (zz == 0)break;
		c[z] = 1;
		for (int j = 0; j < nn[z]; j++){
			if (d[z] + x[z][j] < d[n[z][j]])
			{
				d[n[z][j]] = d[z] + x[z][j];
				y.push(std::make_pair(d[n[z][j]], n[z][j]));
			}
		}
		y.pop();
	}
	for (int i = 0; i<a; i++)printf("%d %d\n",i,d[i]);
		return 0;
}

Measured memory_bytes: 3252
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
struct Edge
{
	int to,next;
}edge[400001];
int n,m,head[200001],cnt,x,y,l[200001],p;
bool book[200001];
void add_edge(int u,int v)
{
	cnt++;
	edge[cnt].to=v;
	edge[cnt].next=head[u];
	head[u]=cnt;
	return;
}
void dfs(int u)
{
	book[u]=true;
	for(int i=head[u];i;i=edge[i].next)
	{
		int v=edge[i].to;
		if(!book[v])
		{
			l[v]+=l[u];
			dfs(v);
		}
	}
	return;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		add_edge(x,y);
		add_edge(y,x);
	}
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&p,&x);
		l[p]+=x;
	}
	dfs(1);
	for(int i=1;i<=n;i++)
		printf("%d ",l[i]);
	return 0;
}

Measured memory_bytes: 13568
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

bool cmp(pair<int, long long int> x, pair<int, long long int> y) {
    if(x.second!=y.second) {
        return x.second > y.second;
    } else {
        return x.second < y.second;
    }
}

int main() {
    int N, K;
    cin >> N >> K;
    
    vector<pair<int, long long int> > TD(N);
    for(int n=0; n<N; n++) {
        cin >> TD[n].first >> TD[n].second;
    }
    
    sort(TD.begin(), TD.end(), cmp);
    // cout << TD[0].second << endl;
    
    vector<long long int> ans(N+1, 0);
    long long int tmp_ans=0;
    auto c = [](pair<int, long long int> x, pair<int, long long int> y) {
        if(x.second!=y.second) {
            return x.second > y.second;
        } else {
            return x.first < y.first;
        }
    };
    priority_queue<pair<int, long long int>, vector<pair<int, long long int> >, decltype(c)> que(c);
    vector<int> group_counter(N+1, 0);
    int V=0;
    for(int k=0; k<K; k++) {
        if(group_counter[TD[k].first]==0) V++;
        group_counter[TD[k].first]++;
        que.push(TD[k]);
        tmp_ans += TD[k].second;
    }
    ans[V] = tmp_ans;
    // cout << que.top().second << endl;
    // cout << group_counter[1] << endl;
    
    int cur_k=K;
    int v=V;
    while(!que.empty() && cur_k<N) {
        tmp_ans = ans[v];
    
        while(!que.empty() && group_counter[que.top().first]==1) {
            que.pop();
        }
        
        if(que.empty()) break;
        
        tmp_ans -= que.top().second;
        group_counter[que.top().first]--;
        que.pop();

        while(cur_k<N && group_counter[TD[cur_k].first]>0) {
            cur_k++;
        }
        if(cur_k<N) {
            group_counter[TD[cur_k].first]++;
            tmp_ans += TD[cur_k].second;
            v++;
            ans[v] = tmp_ans;
        }
        
        
        cur_k++;
    }

    long long int max_ans=0;
    for(int vi=V; vi<=v; vi++) {
        max_ans = max(max_ans, ans[vi]+(long long int)vi*vi);
    }
    
    cout << max_ans << endl;

    return 0;
    
}

Measured memory_bytes: 5876
/*
これを入れて実行
g++ code.cpp
./a.out
*/

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = { -1, 0, +1, 0 };
int dx4[4] = { 0, +1, 0, -1 };
int dy8[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
int dx8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}

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

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

ll nCr(ll n, ll r){
	if (r == 0 || r == n){
		return 1;
	}
	else if (r == 1){
		return n;
	}
	return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
	r = n - r;
	ll ret = 1;
	for (ll i = n; i >= r + 1; i--) ret *= i;
	return ret;
}

//-----------------------ここから-----------
int n;
vector<int> a;
int ans = 0;

void dfs(int cnt, int total){
	if (cnt == n ){
		if (total % 2 == 0){
			ans++;
		}
		return;
	}

	dfs(cnt + 1, total * a[cnt]);
	dfs(cnt + 1, total * (a[cnt] - 1));
	dfs(cnt + 1, total * (a[cnt] + 1));


}

int main(void){
	cin >> n;

	a.resize(n);

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

	dfs(0, 1);

	cout << ans << endl;


} 


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;


class Program{
    public static void Main(){
        int cost = 0;
        string[] s = Console.ReadLine().Split(' ');
        int[] A = new int[3];
        for(int a = 0; a < 3; a++){
            A[a] = int.Parse(s[a]);
        }

        Array.Sort(A);
        Array.Reverse(A);

        cost = 0 + System.Math.Abs(A[1] - A[0]) + System.Math.Abs(A[2] - A[1]);

        Console.WriteLine(cost);
    }
}


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

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

#define pb push_back
#define in ,
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int n;
  while(cin >> n) {
    if(n == 0) return 0;
    int a, f = 0, ans = n;
    rep(i, 0, n) {
      cin >> a;
      if(a == 0) ans--;
      else if(a != 1) f = 1;
    }
    if(n == 1) ans = 1;
    if(f) cout << ans + 1 << endl;
    else cout << "NA" << endl;

  }
}

Measured memory_bytes: 3144
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int d, t, s;
	cin >> d >> t >> s;
	if((s * t) >= d) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3648