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

typedef long long ll;

const int MOD = 1000000007;

using Graph = vector<vector<int>>;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int>A(M);
    vector<int>B(M);

    Graph G(N+1);
    
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
        A[i] = a;
        B[i] = b;
    }

    int cnt = 0;
    for (int i = 0; i < M; i++) {
        vector<int>dist(N+1, -1);
        dist[1] = 0;
        queue<int> que;
        que.push(1);

        while (!que.empty()) {
            int v = que.front();
            que.pop();
            for (auto nv : G[v]) {
                if ((v == A[i] && nv == B[i]) || (v == B[i] && nv == A[i])) {
                    continue;
                }
                if (dist[nv] != -1) continue;
                dist[nv] = dist[v] + 1;
                que.push(nv);
            }
        }
        for (int j = 1; j <= N; j++) {
            if (dist[j] == -1) {
                cnt++;
                break;
            }
        }
    } 
    cout << cnt << endl;
}



Measured memory_bytes: 256
uses crt;
var
       // f: text;
        x,p: array [-1..3000] of real;
        nhi: array [-1..3000,-1..3000] of real;
        i,j,n: longint;
        s: real;

begin
     //   assign (f, fi); reset(f);
        readln ( n);
        for i:=1 to n do read ( p[i]);
     //   close (F);

     //   assign (f, fo); rewrite (f);
        x[0]:=1;
        for i:=1 to n do
        for j:=i downto 0 do
        begin

                x[j]:= x[j]*(1 - p[i]) + x[j-1]*p[i];
                if (i=n) and (j > n div 2) then s:= s + x[j];

        end;

        writeln ( s);
        readln;
     //   close (f);

end.

Measured memory_bytes: 256
from bisect import *
 
N, M, K =map(int, input().split())
A  = list(map(int, input().split()))
B  = list(map(int, input().split()))

A_= [0]
for a in A:
  A_.append(A_[-1] + a)
#print(A_)

b_sum = 0
ans = 0
b_cnt = 0

while True:
  if b_sum > K:
    break
  else:
    k = K - b_sum
    ans = max(bisect_right(A_, k)-1 + b_cnt, ans)
    #print(bisect_right(A_, k)-1 + b_cnt, ans,  b_cnt)
    if b_cnt == M:
      break
    b_sum += B[b_cnt]
    b_cnt += 1
    

print(ans)

Measured memory_bytes: 40408
#include<bits/stdc++.h>
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 1e5 + 7;
const int maxm = 1e6 + 7;
const int mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-10;
int r, c, n;
stack<int> s;
struct node
{
    double deg;
    int num;
};
bool operator<(node a, node b)
{
    return a.deg < b.deg;
}
vector<node> v;
int main(int argc, char const *argv[])
{
    scanf("%d%d%d", &r, &c, &n);
    for (int i = 1; i <= n; i++)
    {
        int xx1, yy1, xx2, yy2;
        scanf("%d%d%d%d", &xx1, &yy1, &xx2, &yy2);
        if ((xx1 == r || xx1 == 0 || yy1 == 0 || yy1 == c) && (xx2 == r || xx2 == 0 || yy2 == 0 || yy2 == c))
        {
            v.push_back(node{atan2(yy1-c/2.0, xx1-r/2.0), i});
            v.push_back(node{atan2(yy2-c/2.0, xx2-r/2.0), i});
        }
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < v.size(); i++)
    {
        if (s.empty())
        {
            s.push(v[i].num);
        }
        else if (s.top() == v[i].num)
            s.pop();
        else
            s.push(v[i].num);
    }
    bool flag = 0;
    if (s.empty())
        flag = 1;
    while (!s.empty())
        s.pop();
    reverse(v.begin(), v.end());
    for (int i = 0; i < v.size(); i++)
    {
        if (s.empty())
        {
            s.push(v[i].num);
        }
        else if (s.top() == v[i].num)
            s.pop();
        else
            s.push(v[i].num);
    }
    if (s.empty())
        flag = 1;
    printf("%s\n", flag ? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 6384
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;


int main(){
  string s,t; cin>>s>>t;
  vector<int> a(26,-1);
  vector<int> b(26,-1);

  bool ans=1;
  rep(i,s.size()){
    int aa=s[i]-'a';
    int bb=t[i]-'a';

    if(a[aa]>=0){
      if(a[aa]!=bb){
        ans=0;
        break;
      }
    }if(b[bb]>=0){
      if(b[bb]!=aa){
        ans=0;
        break;
      }
    }if(a[aa]<0){
      a[aa]=bb;
    }if(b[bb]<0){
      b[bb]=aa;
    }
  }
  if(ans)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
int a[11];
int main()
{
  	int n;
  cin>>n;
  long long sum=0;
  for (int i=1;i<=n;i++)
  {
    	cin>>a[i];
    sum+=a[i];
  }
  int mx=-1;
  for (int i=1;i<=n;i++)
  {
    mx=max(a[i],mx);
  }
  sum-=mx/2;
  cout<<sum;
  return 0;
}

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

int main() {
  int L, R, d;
  
  cin >> L >> R >> d;

  int m = R / d;
  int n = (L-1) / d;
  
  cout << m - n << endl;
}

Measured memory_bytes: 3612
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n, x, y; cin>>n>>x>>y;
    map<ll,ll> mp;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            ll val= j-i;
            val=min(val,abs(x-i)+1+abs(y-j));
            val=min(val,abs(y-i)+1+abs(x-j));
            mp[val]++;
        }
    }
    for(int i=1;i<=n-1;i++) cout<<mp[i]<<endl;
}

Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))
S = [0] * (N + 1)
S[0] = A[0]

for i in range(N):
    S[i+1] = S[i] + A[i]
S.sort()

ans = 0
cnt = 1
num = -10 ** 20

for i in range(N+1):
    if num != S[i]:
        ans += cnt * (cnt-1) // 2
        num = S[i]
        cnt = 1
    else:
        cnt += 1

ans += cnt * (cnt-1) // 2

print(ans)

Measured memory_bytes: 25976
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  ll N,X,M;
  cin>>N>>X>>M;
  VL A(M,-1),Y(min(M,N));
  ll tmp=X;
  ll P=min(N,M)-1;
  if(X==0){
    cout<<0<<endl;
    return 0;
  }
  rep(i,min(N,M)){
    if(A[tmp]>=0){
      P=i;
      break;
    }else{
      Y[i]=tmp;
      A[tmp]=i;
      tmp=tmp*tmp%M;
    }
  }
  ll ans=0;
  rep(i,P+1) ans+=Y[i];
  ll ans2=0;
  if(P+1!=N){
    rep(i,P-A[tmp]) ans2+=Y[A[tmp]+i];
    ans2=ans2*((N-P)/(P-A[tmp]));
    ans+=ans2;
    rep(i,(N-P)%(P-A[tmp])) ans+=Y[A[tmp]+i];
  }
  cout<<ans<<endl;
}




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

int main()
{
	long long x, y; cin >> x >> y;

	long long ans = 0;

	while (true) {

		if (x <= y) {
			ans++;
		}
		else {
			break;
		}
		x *= 2;

	}

	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <string>
#include <numeric>
using namespace std;

int main()
{
	int N,K;
	cin >> N >> K;
	int l[60];
	for (int i = 0;i < N;i++) {
		cin >> l[i];
	}
	int res = 0;
	sort(l, l + N, greater<int>());
	for (int i = 0;i < K;i++) {
		res += l[i];
	}
	cout << res << endl;
}

Measured memory_bytes: 256
using System;

namespace A___Sum_of_Two_Integers
{
    class Program
    {
        static void Main (string[] args)
        {
            var n = int.Parse (Console.ReadLine ());
            var count = 0;
            var j = n - 1;
            for (var i = 1; i <= n - 1; i++)
            {
                if (i + j == n && i != j)
                {
                    count++;
                }
                j--;
            }
            Console.WriteLine (count / 2);
        }
    }
}

Measured memory_bytes: 13140
a, b = map(int, input().split())

if a <= 0 and b >= 0:
    print("Zero")
elif a > 0 and b > 0:
    print('Positive')
elif a < 0 and b < 0:
    if (b - a + 1) % 2:
        print('Negative')
    else:
        print('Positive')
        

Measured memory_bytes: 2940
#include<iostream>

int main()
{
    int a,b;
    std::cin>>a>>b;
    if(a==b){
        std::cout<<"Draw"<<std::endl;
    }
    else if(a<b && a==1 || a>b && b!=1){
        std::cout<<"Alice"<<std::endl;
    }
    else{
        std::cout<<"Bob"<<std::endl;
    }
}


Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int k, s;
	cin >> k >> s;
	ll ans = 0;
	REP(x, k + 1)
	{
		REP(y, k + 1)
		{
			int z = s - x - y;
			if (z < 0 || z > k) continue;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	ll n, u, v;
	cin >> n >> u >> v;
	--u; --v;
	
	vector<vector<ll>> to(n);
	rep(i,n-1){
		int a,b;
		cin >> a >> b;
		--a; --b;
		to[a].emplace_back(b);
		to[b].emplace_back(a);
	}
	
	vector<ll> daoki(n,-1);
	queue<ll> q;
	q.push(v);
	daoki[v] = 0;
	while(!q.empty()){
		auto p = q.front();
		q.pop();
		for(auto pp : to[p]){
			if(daoki[pp] != -1) continue;
			q.push(pp);
			daoki[pp] = daoki[p]+1;
		}
	}
	
	vector<ll> dtakahashi(n,-1);
	q.push(u);
	dtakahashi[u] = 0;
	while(!q.empty()){
		auto p = q.front();
		q.pop();
		for(auto pp : to[p]){
			if(dtakahashi[pp] != -1) continue;
			q.push(pp);
			dtakahashi[pp] = dtakahashi[p]+1;
		}
	}
	
	ll res = 0;
	rep(i,n){
		if(dtakahashi[i] < daoki[i]){
			res = max(res, daoki[i]-1);
		}
	}
	
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 8064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n, _ := strconv.Atoi(nextLine())
	fmt.Println((n - 2) * 180)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  sort(s.begin(),s.end());
  if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,ans=0;
  cin >> N >> M;
  if(N >= 2) ans += ((N-1)*(N-1)+N-1)/2;
  if(M >= 2) ans += ((M-1)*(M-1)+M-1)/2;
  cout << ans << endl;
}

Measured memory_bytes: 256
fn read_as_vec(buf: &mut String) -> Vec<i32> {
    std::io::stdin().read_line(buf).ok();
    buf.split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let mut buf = String::new();
    let nmc = read_as_vec(&mut buf);
    buf.clear();
    let (n, _, c) = (nmc[0], nmc[1], nmc[2]);
    let b = read_as_vec(&mut buf);

    let mut count = 0;
    let mut sum: i32;
    let mut a: Vec<i32>;
    for _ in 0..n {
        buf.clear();
        a = read_as_vec(&mut buf);
        sum = a.iter().zip(b.iter()).map(|x| x.0 * x.1).sum();
        if sum > -c {
            count += 1;
        }
    }
    println!("{}", count);
}


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

int main () {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    
    int A = 0;
    int B = 0;
    for (int i = 0; i < a.size(); i++) {
        if (i % 2 == 0) {
            A += a.at(i);
        }
        else {
            B += a.at(i);
        }
    }
    cout << A - B << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);


int main(){
    IOS;
    string s;cin>>s;
    reverse(s.begin(),s.end());
    vector<ll>rem;
    f(i,0,s.size()){
        rem.pb(((s[i]-'0')*modpow(10,i,2019))%2019);
    }
    ll n=s.size();
    ll pre[n];
    pre[0]=rem[0];
    f(i,1,n){
        pre[i]=(pre[i-1]+rem[i])%2019;
    }
    map<ll,ll>mp;
    ll ans=0;
    f(i,0,n){
        if(pre[i]==0)ans++;
        ans+=mp[pre[i]];
        mp[pre[i]]++;
    }
    cout<<ans;
    return 0;  
} 





Measured memory_bytes: 6460
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, x, t;
    cin >> n >> x >> t;
    int ans = t*((n-1)/x+1);
    
    pr(ans);
    return 0;
}


Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;

int main(void){
  int A,B;
  cin >> A >> B;
  if(A==B)cout << A+B << endl;
  else cout << 2*max(A,B)-1 << endl;
  return 0;
}


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

int main() {
  string S;
  cin >> S;
  vector<string> devide = {"dream","dreamer","erase","eraser"};
  
  reverse(S.begin(), S.end());
  for(int i = 0;i<4;i++){
    reverse(devide[i].begin(), devide[i].end());
  }
 bool can = true;

  for(int i = 0;i<S.size();){
   bool can2 = false; // 4 個の文字列たちどれかで divide できるか
   for(int j = 0;j<4;j++){
    string d = devide[j];
     if(S.substr(i,d.size()) == d){
       can2 = true;
       i = i + d.size();
     }
   }
     if(!can2){// 4個の文字列のどれかでdivide できなかったら
       can = false;
       break;
     }
  }
    
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
}

  

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
# b

def main():
    n = int(input())
    height_mountains = [ int(_)  for _ in input().split() ]

    height_highest = 0
    count_see_sun = 0

    for mountain in height_mountains:
        if mountain >= height_highest:
            height_highest = mountain
            count_see_sun += 1

    print(count_see_sun)

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if((100*a+10*b+c)%4==0){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifndef LOCAL
#define endl '\n'
#endif

#define fr(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = a; i >= b; i--)
#define pf push_front
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound

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

int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }
int bt(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))
int bt(ll x) { return 63 - __builtin_clzll(x); } // floor(log2(x))
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
ll cdiv(ll a, ll b) { return a / b + !(a < 0 || a % b == 0); }
int nxt_C(int x) { int c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }
ll nxt_C(ll x) { ll c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }

vector<int> get_bits(int mask) {
	vector<int> bb;
	while(mask) { int b = bt(mask); bb.pb(b); mask ^= (1 << b); }
	reverse(all(bb));
	return bb;
}

int get_mask(vector<int> v) {
	int mask = 0;
	for(int x : v) { mask ^= (1 << x); }
	return mask;
}

template<typename T>
void uniq(vector<T> &v) { sort(all(v)); v.resize(unique(all(v)) - v.begin()); }

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

ll rand(ll l, ll r){
	uniform_int_distribution<ll> uid(l, r);
	return uid(rng);
}

void sc() {}

template <typename Head, typename... Tail>
void sc(Head &H, Tail &... T) { cin >> H; sc(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L:" << __LINE__ << "][" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// #ifndef LOCAL
// string to_string(__int128 x) {
// 	string s = "";
// 	bool neg = 0;
// 	if(x < 0) { s += "-"; neg = 1; x = -x; }
// 	if(!x) s += '0';
// 	while(x) {
// 		int rem = x % 10;
// 		s += to_string(rem);
// 		x /= 10;
// 	}
// 	reverse(s.begin() + neg, s.end());
// 	return s;
// }
// #endif

const int mod = 1e9 + 7; // 998244353;

int pwr(int a,ll b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
	Read problem statement carefully!!!
*/

const int N = 1e5 + 5;
int a[N];

void solve() {
	int n, L;
    sc(n, L);
    fr(i, 1, n) {
        sc(a[i]);
    }
    int pos = 0;
    fr(i, 1, n - 1) {
        if(a[i] + a[i + 1] >= L) {
            pos = i;
        }
    }
    if(!pos) {
        cout << "Impossible";
        return;
    }
    cout << "Possible" << endl;
    fr(i, 1, pos - 1) {
        cout << i << endl;
    }
    rf(i, n - 1, pos + 1) {
        cout << i << endl;
    }
    cout << pos << endl;
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3992
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
const int MAX_N = 2000010;

int N, Q;
P v[2 * MAX_N - 1];

void init(int _n){
  N = 1;
  while(N < _n) N *= 2;
  REP(i, 2 * N - 1) v[i] = P(0, 0);
  REP(i, _n) v[i + N - 1].second = i * -1;
}

void update(int k, int a){
  k += N - 1;
  v[k].first += a;
  while(k > 0){
    k = (k - 1) / 2;
    v[k] = max(v[k * 2 + 1], v[k * 2 + 2]);
  }
}

int main() {
  cin >>N >>Q;
  init(N);
  REP(i, Q){
    int a, b; cin >>a >>b;
    update(a - 1, b);
    cout <<v[0].second * -1 + 1 <<" " <<v[0].first <<endl;
  }
  return 0;
}

Measured memory_bytes: 32408
/*input
3 3
abc


*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=405;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;

ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
inline ll add(ll a,ll b){
	return ((a%MOD)+(b%MOD))%MOD;
}
inline ll sub(ll a,ll b){
	a -= b;
	if(a < 0)a += MOD;
	return a%MOD;
}
ll dp[maxn][maxn],pref[maxn],arr[maxn];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    pref[0]=0;
    FILL(dp,INF);
    for(int i=1;i<=n;i++){
    	cin>>arr[i];
    	pref[i]=pref[i-1]+arr[i];
    	dp[i][i]=0;
    }
    
    for(int i=n;i>=1;i--){
    	for(int j=i+1;j<=n;j++){
    		for(int k=i;k<j;k++){
    			dp[i][j]=min(dp[i][k]+dp[k+1][j]+pref[j]-pref[i-1],dp[i][j]);
    		}
    	}
    }
    cout<<dp[1][n];
}

Measured memory_bytes: 1536
#include <stdio.h>

int main(void){

  long long A,B,C,D;
  scanf("%lld %lld %lld %lld",&A,&B,&C,&D);
  
  if(A*B<=C*D){
  	printf("%lld",C*D);
  }
  else printf("%lld",A*B);
  
  return 0;
  
}


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


int main(){
    string s;
    cin>>s;
    ll n=s.size();
    string a,b;
    a=s.substr(0,(n-1)/2);
    ll x=a.size();
    b=s.substr((n+3)/2-1);
    ll y=b.size();
    //cout<<a<<endl;
    //cout<<b<<endl;

    ll flag=0;

    ll count=0;
    for(ll i=0;i<n/2;++i){
        if(s[i]==s[n-i-1]){
            count++;
        }
    }
    if(count==n/2){
        flag++;
    }

    count=0;
    for(ll i=0;i<x/2;++i){
        if(a[i]==a[x-i-1]){
            count++;
        }
    }
    //cout<<x<<endl;
    if (count==x/2){
        flag+=1;
    }

    count=0;
    for(ll i=0;i<y/2;++i){
        if(b[i]==b[y-i-1]){
            count++;
        }
    }
    //cout<<y<<endl;
    if(count==y/2){
        flag+=1;
    }

    if(flag==3){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

#define MAX 1000

int desc(const void *a, const void *b) {
  long long int *a_cast = (long long int *)a;
  long long int *b_cast = (long long int *)b;
  if(*a_cast < *b_cast) return 1;
  if(*a_cast > *b_cast) return -1;
  return 0;
}

int main() {
  int x, y, z;
  long long int A[MAX], B[MAX], C[MAX];
  long long int *A_B;
  long long int *a_b;
  long long int *A_B_C;
  long long int *a_b_c;
  int k;
  int i, j;

  scanf("%d %d %d %d", &x, &y, &z, &k);
  for(i = 0; i < x; i++) scanf("%lld", &A[i]);
  for(i = 0; i < y; i++) scanf("%lld", &B[i]);
  for(i = 0; i < z; i++) scanf("%lld", &C[i]);

  A_B = (long long int *)malloc(x * y * sizeof(long long int));
  a_b = A_B;

  for(i = 0; i < x; i++) {
    for(j = 0; j < y; j++) {
      *a_b = A[i] + B[j];
      a_b++;
    }
  }
  qsort(A_B, x * y, sizeof(long long int), desc);

  int num = (x * y < k) ? x * y : k;
  A_B_C = (long long int *)malloc(num * z * sizeof(long long int));
  a_b_c = A_B_C;

  for(i = 0; i < num; i++) {
    for(j = 0; j < z; j++) {
      *a_b_c = A_B[i] + C[j];
      a_b_c++;
    }
  }
  qsort(A_B_C, num * z, sizeof(long long int), desc);

  for(i = 0; i < k; i++) printf("%lld\n", A_B_C[i]);

  return 0;
}


Measured memory_bytes: 54920
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define int ll

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 1e5 + 20 ;
int n , d[N] , sz[N] ;
map <int , int> mp ;
vector <int> g[N] ;
vector <pii> edges ;

void err () {
	cout << -1 << '\n' ;
	exit(0) ;
}

int sum = 0 ;
void dfs (int v , int h = 0) {
	sum += h ;
	for (int u : g[v]) dfs(u , h + 1) ;
}

int32_t main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;

	cin >> n ;

	for (int i = 0 ; i < n ; i ++) cin >> d[i] , mp[d[i]] = i , sz[i] = 1 ;

	sort(d , d + n , greater<int>()) ;

	for (int i = 0 ; i < n - 1 ; i ++) {
		int v = mp[d[i]] ;
		int k = d[i] - n + 2 * sz[v] ;

		if (k >= d[i] || !mp.count(k)) err() ;

		int p = mp[k] ;

		sz[p] += sz[v] ;
		edges.push_back({p , v}) ;
	
		g[p].push_back(v) ;
	}

	dfs(mp[d[n - 1]]) ;

	if (d[n - 1] != sum) err() ;

	for (pii p : edges) cout << p.F + 1 << ' ' << p.S + 1 << '\n' ;
}


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

int main()
{
  long long n;cin>>n;
  for (long long i = sqrt(n); i >= 0; i--)
  {
    if (n % i == 0)
    {
      cout << i + n / i - 2LL << endl;
      return 0;
    }
  }
  
}

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

struct bar
{
  int p, q, r, b;
  void in(int _p, int _q, int _r, int _b)
  {
    p = _p;
    q = _q;
    r = _r;
    b = _b;
    return;
  }
};

int n;
bar mobile[101];
bool parent_check[101];
int parent;

int gcd(int a, int b)
{
  if(a % b)
    return gcd(b, a % b);
  return b;
}

int solve(bar br)
{
  int heavy_r = br.r ? solve(mobile[br.r]) : 1;
  int heavy_b = br.b ? solve(mobile[br.b]) : 1;

  int moment_r = heavy_r * br.p;
  int moment_b = heavy_b * br.q;
  
  int gcd_moment = gcd(moment_r, moment_b);
  moment_r /= gcd_moment;
  moment_b /= gcd_moment;

  heavy_r *= moment_b;
  heavy_b *= moment_r;

  return heavy_r + heavy_b;
}

void main_b()
{
  memset(parent_check, false, sizeof parent_check);
  
  for(int i = 1; i <= n; i++){
    int p, q, r, b;
    cin >> p >> q >> r >> b;
    
    int gcd_long = gcd(p, q);
    p /= gcd_long;
    q /= gcd_long;
    
    mobile[i].in(p, q, r, b);
    parent_check[r] = parent_check[b] = true;
  }

  for(int i = 1; i <= n; i++)
    if(!parent_check[i])
      parent = i;

  cout << solve(mobile[parent]) << endl;
  return;
}

int main()
{
  while(cin >> n && n)
    main_b();
  return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>

int main()
{
  int a, b;
  
  scanf("%d", &a);
  scanf("%d", &b);

  if (a < b) {
    printf("a < b\n");
  } else if (a > b){
    printf("a > b\n");
  } else {
    printf("a == b\n");
  }

  return 0;
}

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

long long n, m, parent[100004], size[100004], rank1[100004];

void init(){
	for(int i = 0; i<=100000;i++){
		parent[i] = i;
		size[i] = 1;
		rank1[i] = 0;
	}
}

int find(int p){
	if(parent[p] == p)	return p;
	return parent[p] = find(parent[p]);
}

void uni(int p, int q){
	p = find(p);
	q = find(q);
	if(p == q)	return;
	if(rank1[p]<rank1[q]){
		size[q] += size[p];
		parent[p] = q;
	}
	else	parent[q] = p, size[p] += size[q];
	if(rank1[p] == rank1[q])
		rank1[p]++;
}

int main() {
	cin>>n>>m;
	pair<long long, long long> e[m];
	for(int i = 0;i<m;i++)
		cin>>e[i].first>>e[i].second;
	long long ans[m];
	ans[m-1]= n*(n-1)/2;
	init();
	for(int i = m-1;i>=1;i--){
		int p = e[i].first, q = e[i].second;
		long long tmp = ans[i];
		p = find(p), q = find(q);
		if(find(p) != find(q)){
			tmp -= size[p]*size[q];
			uni(p, q);
		}
		ans[i-1] = tmp;
	}
	for(int i = 0;i<m;i++)
		cout<<ans[i]<<'\n';
	return 0;
}

Measured memory_bytes: 6016
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001
#define MOD 1000000007

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int main(){
    ll now = -2e9;
    ll ans = 0;
    int N;
    cin >> N;
    vector<pair<ll, ll>> v(N);
    rep(i, N){
        ll x, l;
        cin >> x >> l;
        v[i] = {x + l, x - l};
    }
    sort(v.begin(), v.end());
    rep(i, N){
        if(v[i].second < now) continue;
        else{
            now = v[i].first;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4788
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	try {
    		final int N = sc.nextInt();
    		double[] array = new double[N];
    		for (int i=0; i<array.length; i++) {
    			array[i] = 1.0/sc.nextDouble();
    		}

    		double sum = 0.0;
    		for (int i=0; i<array.length; i++) {
    			sum += array[i];
    		}
    		System.out.println(1.0/sum);

    	} finally {
    		sc.close();
    	}
    }
}



Measured memory_bytes: 24660
n = int(input())

csfn = [None] * (n - 1)
for i in range(n - 1):
    csfn[i] = list(map(int, input().split(' ')))

result = [0] * n

for i in range(n - 1):
    for j in range(0, i + 1):
        if csfn[i][1] > result[j]:
            result[j] += (csfn[i][1] - result[j])
        else:
            result[j] += (-result[j] % csfn[i][2])
        result[j] += csfn[i][0]
        
for r in result:
    print(r)


    


Measured memory_bytes: 40432
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

// 2^n
mint f(int n){
	if(n == 0) return 1;
	mint x = f(n/2);
	x *= x;
	if(n%2 == 1) x *= 2;
	return x;
}

// nCa
mint choose(int n, int a){
	mint x = 1, y = 1;
	rep(i,a){
		x *= n-i;
		y *= i+1;
	}
	return x / y;
}

struct Combination{
	vector<mint> fact, ifact;
	Combination(int n):fact(n+1),ifact(n+1){
		assert(n < mod);
		fact[0] = 1;
		for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
		ifact[n] = fact[n].inv();
		for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i;
	}
	mint operator()(int n, int k){
		if(k < 0 || k > n) return 0;
		return fact[n]*ifact[k]*ifact[n-k];
	}
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    map<char, ll> mp;
    rep(i,n) ++mp[s[i]];
    mint ans = 1;
    for(auto p : mp) ans *= (p.second + 1);
    ans -= 1;
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 3772
N = int(input())
a = []
for i in range(N):
    a = list(map(int, input().split()))
 
    side_a = a[0]
    side_b = a[1]
    side_c = a[2]
    if side_a ** 2 + side_b ** 2 == side_c ** 2 \
        or side_c ** 2 + side_b ** 2 == side_a ** 2 \
        or side_a ** 2 + side_c ** 2 == side_b ** 2:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 7668
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N; cin >> N;
    vector<int> L(N), R(N);
    for(int i=0;i<N;i++) cin >> L[i] >> R[i];
    int l = *max_element(L.begin(), L.end());
    int r = *min_element(R.begin(), R.end());
    int res = 0;
    for(int i=0;i<N;i++){
        if(L[i] != l || R[i] != r) res = max(res, max(r-l+1, 0) + R[i]-L[i]+1);
    }
    vector<pair<int, int>> vp;
    for(int i=0;i<N;i++){
        vp.emplace_back(max(0, R[i]-l+1), -max(0, r-L[i]+1));
    }
    sort(vp.rbegin(), vp.rend());
    vector<int> mr(N);
    mr[N-1] = -vp.back().second;
    for(int i=N-2;i>=0;i--) mr[i] = min(-vp[i].second, mr[i+1]);
    int ml = 1000000000;
    for(int i=0;i<N-1;i++){
        ml = min(ml, vp[i].first);
        res = max(res, ml+mr[i+1]);
    }
    cout << res << endl;
}

Measured memory_bytes: 2168
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

type drink struct {
	taste int
}

type drinkList []drink

func (d drinkList) Len() int {
	return len(d)
}

func (d drinkList) Swap(i, j int) {
	d[i], d[j] = d[j], d[i]
}

func (d drinkList) Less(i, j int) bool {
	return d[i].taste > d[j].taste
}

func dif(dList drinkList, index int) int {
	return dList[index].taste - dList[index+1].taste
}

func min(a, b int) int {
	if a > b {
		return b
	}

	return a
}

func main() {
	io := NewIo()
	defer io.Flush()

	X := io.NextInt()
	Y := io.NextInt()
	Z := io.NextInt()
	K := io.NextInt()

	listA := make(drinkList, X)
	for i := range listA {
		listA[i].taste = io.NextInt()
	}
	listB := make(drinkList, Y)
	for i := range listB {
		listB[i].taste = io.NextInt()
	}
	listC := make(drinkList, Z)
	for i := range listC {
		listC[i].taste = io.NextInt()
	}

	sort.Sort(listA)
	sort.Sort(listB)
	sort.Sort(listC)

	result := make(drinkList, 0, min(K, X*Y*Z))

	for i := 0; i < X; i++ {
		for j := 0; j < Y; j++ {
			for k := 0; k < Z; k++ {
				if (i+1)*(j+1)*(k+1) <= 3000 {
					result = append(result, drink{listA[i].taste + listB[j].taste + listC[k].taste})
				}
			}
		}
	}

	sort.Sort(result)

	for i := 0; i < min(K, X*Y*Z); i++ {
		io.PrintLn(result[i].taste)
	}
}


Measured memory_bytes: 7740
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int c = A - B;
		int d = A + B;
		int e = A*B;
		int ans = 0;
		if(c > d){
			ans = c;
		}else{
			ans = d;
		}
		if(ans > e){
			System.out.println(ans);
		}else{
			System.out.println(e);
		}
	}
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

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

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<int>vec[8];
bool visited[8];
int dfs(int now,bool){

}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A=in();
    int B=in();
    int ans;ans=0;
    if(B==1){
        ans=0;
    }else{
        int tap;tap=1;
        REP(i,20){
            tap-=1;
            tap+=A;
            if(tap>=B){
                ans=i+1;
                break;
            }
        }
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 256
using System;
    class Program
    {
      static void Main(string[] args)
      {
        // スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        var a = int.Parse(input[0]);
        var b = int.Parse(input[1]);
        var ans = ((a - b) > 0)? a - b : 0;
        //出力
        Console.WriteLine(ans);
      }
    }

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

int main() {
    int n; cin >> n;
    char c = char(n);
    int ans;
    if (isupper(c)) ans = 1;
    else if (islower(c)) ans = 2;
    else ans = 0;
    cout << ans << endl;
}


Measured memory_bytes: 3108
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.next();
        sc.close();
        int a = Integer.parseInt(input.substring(0, 1));
        int b = Integer.parseInt(input.substring(1, 2));
        int c = Integer.parseInt(input.substring(2, 3));
        int d = Integer.parseInt(input.substring(3, 4));

        String op[][] = {{"+", "-"}, {"+", "-"}, {"+", "-"}};
        String op1 = "";
        String op2 = "";
        String op3 = "";
        // 7 = a +- b +- c +- d
        boolean ans = false;
        for (int i = 0; i < 2; i++) {
            op1 = op[0][i];
            int z = 0;
            if (op1.equals("+")) {
                z = a+b;
            } else {
                z = a-b;
            }
            for (int j = 0; j < 2; j++) {
                op2 = op[1][j];
                int y = 0;
                if (op2.equals("+")) {
                    y = z+c;
                } else {
                    y = z-c;
                }
                for (int k = 0; k < 2; k++) {
                    op3 = op[2][k];
                    int x = 0;
                    if (op3.equals("+")) {
                        x = y+d;
                    } else {
                        x = y-d;
                    }
                    if (x == 7) {
                        System.out.println(a+op1+b+op2+c+op3+d+"=7");
                        ans = true;
                        break;
                    }
                }
                if (ans) {
                    break;
                }
            }
            if (ans) {
                break;
            }
        }
    }
}


Measured memory_bytes: 22868
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
  ll H, W;
  cin >> H >> W;
  if(H == 1 || W == 1) {
    cout << 1 << endl;
    return 0;
  }
  ll ans = ((H + 1LL) / 2LL) * ((W + 1LL) / 2LL);
  ans += (H / 2LL) * (W / 2LL);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll X, A, B;
  cin >> X >> A >> B;
  string ans;
  if (B - A <= 0) {
    ans = "delicious";
  } else if (B - A <= X) {
    ans = "safe";
  } else {
    ans = "dangerous";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,m;
    cin >> n >> m;
  int a,b;
    vector<int> good(n,1);
    vector<int> hi(n);
    for(int i = 0; i < n; i++) {
        cin >> hi.at(i);
    }
    for(int i = 0; i < m; i++) {
      cin >> a >> b;
        if(hi.at(a-1) > hi.at(b-1)) {
            good.at(b-1) = 0;
        }
        else if(hi.at(a-1) < hi.at(b-1)) {
          good.at(a-1) = 0;
        }
        else {
          good.at(a-1) = 0;
          good.at(b-1) = 0;
        }
    }
    int sum = 0;
  
    for(int i = 0; i < n; i++) {
      sum += good.at(i);
    }
    cout << sum << endl;
}



Measured memory_bytes: 4048
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

A_dict = {}
for item in A:
    if item in A_dict:
        A_dict[item] += 1
    else:
        A_dict[item] = 1

A_dict_sorted = sorted(A_dict.items(), key=lambda x:x[1])
result = 0
for i in range(len(A_dict)-K):
    result += A_dict_sorted[i][1]

print(result)

Measured memory_bytes: 39044
x, y = map(int, input().split())

abc = [[1, 3, 4, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]

result = "No"
for i in abc:
    if (x in i) and (y in i):
        result = "Yes"
        break

print(result)

Measured memory_bytes: 3060
# coding:utf-8
import math

N=int(input())

while N!=0:
    sigma=0
    s=list(map(int,input().split()))

    ave=float(sum(s)/N)

    for i in s:
        sigma=sigma+(i-ave)**2/N

    print('%.6f'%math.sqrt(sigma))
 
    N=int(input())
    

    

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

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

int main(){
	int a,b;
	cin>>a>>b;
	for(int i=0;i<20;i++){
		if(a*i-i+1 >= b){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}



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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a * b) / 2 << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int n; cin >> n;
    long long ans = 1;
    for (int i = 1; i <= n; ++i) {
        ans *= i;
        ans %= (int)1e9 + 7;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  string N;
  cin >> N;
  if(N.at(0)==N.at(1) && N.at(1)==N.at(2))  cout << "Yes" << endl;
  else if(N.at(1)==N.at(2) && N.at(2)==N.at(3))  cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n, m, x[112345], y[112345], a[112345], b[112345];

    cin >> n >> m;
    REP(i, m)
    cin >> x[i] >> y[i];

    fill(a, a + n + 1, 0);
    fill(b, b + n + 1, 1);

    a[1] = 1;

    REP(i, m)
    {
        if (a[x[i]])
            a[y[i]] = 1;

        b[x[i]]--;
        b[y[i]]++;

        if (!b[x[i]])
            a[x[i]] = 0;
    }

    int res = 0;
    REP(i, n)
    {
        res += a[i + 1] > 0;
    }

    cout << res << endl;

    return 0;
}

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

using ll = long long;

void solve(long long N, std::vector<std::string> S){
    map<string, int> mp;
    for(int  i = 0;i < N;i++)mp[S[i]]++;
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 6416
#include<stdio.h>
#define N 100
int main(){
  int n;
  int a[1000];
  int i,j,v,c;
  while(1){
    scanf("%d",&n);
    if(n<=N && 1<=n) break;
  }
  for(i = 0 ; i < n ; i++){
    scanf("%d",&a[i]);
  }
  for(i=1 ; i<=n ;i++){
    for(c=0 ; c< n ; c++){
      if(c<n-1) printf("%d ", a[c]);
      else printf("%d\n", a[c]);
    }
    v = a[i];
    j = i-1;
    while(j>=0 && a[j] >v){
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
  }
}



Measured memory_bytes: 2056