akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	string s; cin >> s;
	int n = s.size();
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (i & 1) {
			ans += s[i] == 'g';
		}
		else {
			ans -= s[i] == 'p';
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
import math
import sys,collections
from sys import stdin, stdout  
#MAXN = 10000001

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip() 
def input(): return sys.stdin.readline().strip()
#spf = [0 for i in range(MAXN)] 
def file():
	sys.stdin = open('input.py', 'r')
	sys.stdout = open('output.py', 'w') 
def is_subsequence(x, y):
    """Test whether x is a subsequence of y"""
    x = list(x)
    for letter in y:
        if x and x[0] == letter:
            x.pop(0)

    return not x    
def sieve(): 
	spf[1] = 1
	for i in range(2, MAXN): 
		spf[i] = i 
	for i in range(4, MAXN, 2): 
		spf[i] = 2

	for i in range(3, mt.ceil(mt.sqrt(MAXN))): 
		if (spf[i] == i): 
			for j in range(i * i, MAXN, i): 
				if (spf[j] == j): 
					spf[j] = i 
def getFactorization(x): 
	ret = list() 
	while (x != 1): 
		ret.append(spf[x]) 
		x = x // spf[x] 

	return ret 
def getFloor(A, x):

    (left, right) = (0, len(A) - 1)

    ind,floor = -1,-1
    while left <= right:
        mid = (left + right) // 2
        '''if A[mid] == x:
            return mid'''
        if x < A[mid]:
            right = mid - 1
        else:
            floor = A[mid]
            ind=mid
            left = mid + 1
            
    return ind
def check(st) : 
  
    # Compute sum of digits 
    n = len(st) 
    digitSum = 0
      
    for i in range(0,n) : 
        digitSum = digitSum + (int)(st[i]) 
  
    # Check if sum of digits 
    # is divisible by 9. 
    return (digitSum % 9 == 0)     
def isPowerOfTwo(n): 
    if (n == 0): 
        return False
    while (n != 1): 
            if (n % 2 != 0): 
                return False
            n = n // 2
            
              
    return True
def kitte(n):
	c=0
	while(n!=0):
		n=n//2
		c+=1
	return c	
def aa(b,c):
	m=min(b,c)
	b-=m
	c-=m
	if(c>0 and b>0):
		return(m+((b+c)//3))
	else:
		return(m)
def bb(a,c):
	m=min(a,c)
	a-=m
	c-=m
	if(c>0 and a>0):
		return(m+((a+c)//3))
	else:
		return(m)
def cc(b,a):
	m=min(b,a)
	b-=m
	a-=m
	if(a>0 and b>0):
		return(m+((b+a)//3))
	else:
		return(m)		
#file()
#sieve() 
mod=(10**9)+7	
def main():
	d,s,t=get_ints()
	if(s*t>=d):
		print("Yes")
	else:
		print("No")


	



	

	
			


		




		






		







			



	

	




	





















	




















		
			


		

			

		





			

	























				

	















	

	










if __name__ == '__main__':
    main()

Measured memory_bytes: 9500
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	int n;
	ld t, a, h;
	int ans = 0;
	ld res = inf;
	cin >> n >> t >> a;
	for (int i = 0; i < n; i++) {
		cin >> h;
		ld p = t - h * 0.006;
		if (abs(p - a) < res) {
			res = abs(p - a);
			ans = i;
		}
	}
	cout << ans + 1 << endl;
}

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
int a[100005], b[100005], c[100005];
long long sum[100005];

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
    for(int i = 1; i <= n; i++) scanf("%d",&b[i]);
    for(int i = 1; i <= n; i++) scanf("%d",&c[i]);
    std::sort(a+1,a+1+n);
    std::sort(b+1,b+1+n);
    std::sort(c+1,c+1+n);
    int p = 0;
    for(int i = 1; i <= n; i++){
        while(p+1<=n && a[p+1]<b[i]) p++;
        sum[i] = sum[i-1]+(long long)p;
    }
    p = 0;
    long long ans = 0;
    for(int i = 1; i <= n; i++){
        while(p+1<=n && b[p+1]<c[i]) p++;
        ans += (long long)sum[p];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

int main(){
  string S1, S2; cin >> S1 >> S2;
  rep(i,S2.size()){
    cout << S1[i] << S2[i];
 }
  if(S1.size() > S2.size()) cout << S1[S1.size()-1];
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int a,b,c,d;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if(a*c<=b){
        cout<<c<<endl;
    }else{
        cout<<b/a<<endl;
    }
    

}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  long long x[109],y[109],h[109];
  long long mx=0,mi=1000000000;
  cin>>n;
  for(long long i=0;i<n;i++){
    cin>>x[i]>>y[i]>>h[i];
    mx=max(mx,h[i]);
    mi=min(mi,h[i]);
  }
  mx+=200;
  for(long long i=0;i<=100;i++){
    for(long long j=0;j<=100;j++){
      for(long long l=mi;l<=mx;l++){
	int cnt=0;
	for(long long k=0;k<n;k++){
	  if(h[k]==max(l-abs(x[k]-i)-abs(y[k]-j),0LL))cnt++;
	}
	if(cnt==n){
	  cout<<i<<' '<<j<<' '<<l<<endl;
	  return(0);
	}
      }
    }
  }
  return(0);
}


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

int main(void){
    int a[11][W+2]={};
    int cnt=1,score,H;

    while(cin>>H, H){
        score=0;
        rep1(j,H)rep1(i,W)cin>>a[j][i];

        while(1){
            bool combo=false;

            /*???????¶???????????????¢????????????*/
            repr(j,H){
                rep1(i,W){
                    //????????§???????????¨????????????
                    if(a[j][i] && (a[j][i]==a[j][i+1]))++cnt;
                    else{
                        if(cnt>=3){
                            score+=a[j][i]*cnt;
                            combo=true;
                            //?¶????????????¨?????????0?????\??????
                            while(cnt--)a[j][i-cnt]=0;
                        }
                        cnt=1;
                    }
                }
            }

            if(!combo || H==1)break;

            /*????????????*/
            repr(j,H){
                rep1(i,W){
                    if(!a[j][i]){
                        repr(k,j-1){
                            if(a[k][i]){
                                a[j][i]=a[k][i];
                                a[k][i]=0;
                                break;
                            }
                        }
                    }
                }
            }
        }
        cout<<score<<endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
const int maxn = 200005;
ll a[maxn]={0};
ll b[maxn]={0};
ll num;
int n;
int cando(ll m,ll k){
    for(int i=0;i<n;i++){
        if(a[i]*b[i]<=m){
            continue;
        }
        else{
            num=m/b[i];
            k=k-a[i]+num;
            if(k<0)
                return 0;
        }
    }
    return 1;
}

int main() {
    ll k;
    //cout <<asin(1) <<endl;
    scanf("%d%lld",&n,&k);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=0;i<n;i++)
        scanf("%d",&b[i]);
    sort(a,a+n);
    sort(b,b+n,greater<int>());
    //cout << cando(100,k) <<endl;
    ll ans = 0;
    ll l=0,r=10000000000000ll;
    while(l<r){
        ll m=(l+r)/2;
        if(cando(m,k)){
            ans=m;
            r=m;
        }
        else
            l=m+1;
        //cout << l << " " << r <<endl;
    }
    printf("%lld\n",ans);
    return 0;
}


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

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

  int n;
  cin >> n;
  vector<int> w(n);
  for (int i = 0; i < n; i++) {
    cin >> w[i];
  }
  for (int i = 0; i < n - 1; i++) {
    w[i+1] += w[i];
  }
  int s = w[n-1];
  int res = s;
  for (int i = 0; i < n; i++) {
    res = min(res, abs(s - 2 * w[i]));
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 256
open Hashtbl
let n = read_int ()
let h, a_s = create n, Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let _ = Array.iter (fun a -> replace h a @@ try find h a + 1 with _ -> 1) a_s; length h - (fold (fun _ c s -> s + 1 - c mod 2) h 0) mod 2 |> Printf.printf "%d\n"

Measured memory_bytes: 8192
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 k = sc.nextInt();
        int cnt = 0;
        for (int i = 100; i > 0; i--) {
            if(a % i == 0 && b % i == 0) cnt++;
            if(cnt == k){
                System.out.println(i);
                break;
            }
        }

        sc.close();
    }

}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdlib>

using namespace std;

typedef long long ll;

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

ll calc(ll n, ll x, ll y) {
    return n - n / x - n / y + n / (x / gcd(x, y) * y);
}

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

    cout << calc(b, c, d) - calc(a - 1, c, d) << endl;

    return 0;
}

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

using namespace std;

#define pb push_back
typedef long long ll;

int main(){
    int n;
    cin >> n;
    double res;
    double a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a,a+n);
    res = (a[0]+a[1])/2;
    for(int i = 2; i < n; i++) res = (res+a[i])/2;

    cout << res;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;
	int ans = 0;
	FOR_LE(i, 1, n) {
		int a; cin >> a;
		if ((i & 1) && (a & 1)) ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int A,B;
	cin>>A>>B;
	if(A>=B){
		if(A==B){
			ce("Draw")
		}else if(B==1){
			ce("Bob")
		}else{
			ce("Alice")
		}
	}else{
		if(A==1){
			ce("Alice")
		}else{
			ce("Bob")
		}
	}
	
}

Measured memory_bytes: 636
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX-1;
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };

int a[101010];
int memo[101010][2];
int n, k;


int rec(int turn, int remain) {
	if (remain < 0) {
		return turn;
	}else if (remain == 0) {
		return !turn;
	}

	if (memo[remain][turn] != -1)return memo[remain][turn];

	bool win = 0;
	rep(i, 0, n) {
		if (rec(!turn, remain - a[i]) == turn)win = 1;
	}
	if (win)return memo[remain][turn] = turn;
	else return memo[remain][turn] = !turn;
}

int main(){
	cin >> n >> k;
	rep(i, 0, n)cin >> a[i];

	memset(memo, -1, sizeof(memo));

	int check = rec(0, k);

	if (check == 0) {
		cout << "First" << endl;
	}else if(check == 1){
		cout << "Second" << endl;
	}

	return 0;
}

Measured memory_bytes: 8832
use std::io::*;
fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();
    let mut ans = 1;
    for _ in 0..n {
        if ans * 2 > ans + k {
            ans += k;
        } else {
            ans *= 2;
        }
    }
    println!("{}", ans);
}


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

void dfs(int u, int p, vector<vector<int>>& g, vector<int>& cnt) {
	for (auto v : g[u]) {
		if (v == p)
			continue;
		// printf("u %d v %d\n", u, v);
		cnt[v] += cnt[u];
		dfs(v, u, g, cnt);
	}
}

int main(int argc, char const *argv[])
{
	int n, q; cin >> n >> q;
	vector<int> a(n), b(n);
	rep(i, n - 1) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}
	vector<int> p(q), x(q);
	rep(i, q) {
		cin >> p[i] >> x[i];
		p[i]--;
	}

	vector<vector<int>> g(n);
	rep(i, n - 1) {
		g[a[i]].emplace_back(b[i]);
		g[b[i]].emplace_back(a[i]);
	}

	vector<int> cnt(n);
	rep(i, q) {
		cnt[p[i]] += x[i];
	}

	dfs(0, -1, g, cnt);

	for (auto t : cnt)
		cout << t << " ";
	cout << endl;

	return 0;
}


Measured memory_bytes: 32896
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    string s;
    cin >> s;
    cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
    return 0;
}


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

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


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

int main() {
    long long k, n, h[100100], mn = 1000010000;
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> h[i];
    sort(h, h + n);

    for (int i = 0; i < n - k + 1; i++) {
        mn = min(mn, h[k - 1 + i] - h[i]);
    }

    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long n,k;
long long tri[2000+10][2000+10];
int main()
{
    cin>>n>>k;
    tri[0][0]=1;
    for(int i=1;i<=2000;i++)
    {
        for(int j=1;j<=2000;j++)
        {
            tri[i][j]=(tri[i-1][j-1]+tri[i-1][j])%mod;
        }
    }
    for(int i=1;i<=k;i++)
    {
        cout<<(tri[k][i]*(2*tri[n-k][i]+tri[n-k][i+1]+tri[n-k][i-1]))%mod<<endl;
    }
    return 0;
}

Measured memory_bytes: 31744
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W,h,w;
    cin>>H>>W>>h>>w;
    cout<<(H-h)*(W-w)<<endl;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    int h;
    cin >> h;
    cnt += h >= K ? 1 : 0;
  }
  cout << cnt << '\n';
  return 0;
}


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

int main(){
	int n,d;
	cin >> n >> d;
	int max = 2*d + 1;
	int ans;
	if(n%max == 0){
		ans = n/max;
	}else{
		ans = n/max + 1;
	}
	cout << ans;
	return 0;
}


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

int main(){
	//char a[200000];
	int i,j,k=0;
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(b/a > c ){
		printf("%d\n",c);
	}else {
		printf("%d\n",b/a);
	}
	
	
	

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main () {
	int a, b, c, d; cin >> a >> b >> c >> d;
	if (a < c) {
		if (b < c)
			cout << 0 << endl;
		else if (d > b)
			cout << b - c << endl;
		else
			cout << d - c << endl;
	}
	else {
		if (d < a)
			cout << 0 << endl;
		else if (d < b)
			cout << d - a << endl;
		else
			cout << b - a << endl;
	}


	return 0;
}

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

using ll=long long; 



void solve(){
	int n;
	cin>>n;
	vector<int>d(n);
	for(int i=0; i<n; i++){
		cin>>d[i];
	}	
	int m;
	cin>>m;
	vector<int>t(m);
	for(int i=0; i<m; i++)cin>>t[i];
	sort(d.begin(), d.end());
	sort(t.begin(), t.end());
	int u=0, v=0;
	while(v<m){
		if(d[u]>t[v]){
			cout<<"NO"<<endl;
			return;
		}
		if(d[u]==t[v]){
			u++;
			v++;
		}
		else{
			u++;
		}
	}
	cout<<"YES"<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = System.Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = 0;
            for (int i = 0; i < sS.Length; i++)
            {
                iOut += sS.Substring(i, 1) == "+" ? 1 : -1;
            }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

string S;

const int N_MAX = 10e5;
int a, b;
int flg = 0;
string ans;
int tmpa, tmpb;
int tmpaval, tmpbval;
int amax = 0;
int buse = 0;
int cCount = 0;
int main()
{
    cin >> a >> b;
    if ((a * b) % 2 == 0)
    {
        ans = "Even";
    }
    else
    {
        ans = "Odd";
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  string s; cin >> s;
  ll n = SZ(s);
  cout << s.substr(0,n-8) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
ll dp[100001];
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int main(void) {
  int mo[6]={1,5,10,50,100,500},ans=0,a;
  FOR(6){
    scanf("%d",&a);
    ans+=a*mo[i];
  }
  PRN(ans>=1000);
  return 0;
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>

using namespace std;

int main() {
  string s,t = "";
  cin >> s;
  
  for(int i = 0; i < s.size(); i++) {
    if(s[i] == '0') t += "0";
    if(s[i] == '1') t += '1';
    if(s[i] == 'B') {
      if(t.size() == 0) continue;
      else t.erase(t.size()-1,1);
    }
  }
  cout << t << endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include <bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;


vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}


int main(){
    long long N;
    cin >> N;
    int ans=0;
    const auto &res = prime_factorize(N);
    for(auto p:res){
        for(int i=1; p.second >= i;i++){
            ans+=1;
            p.second -=i;
        }
    }
    cout <<ans <<endl;
    return 0;
}



Measured memory_bytes: 3628
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n\r\t', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

get_numbers_2(0, _, []).
get_numbers_2(N1, N2, [X|Xs]) :- 
    get_numbers(N2, X), 
    N12 is N1 - 1, 
    get_numbers_2(N12, N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

get_i_to_x_rbtree0(N, T) :-
    rb_empty(T2),
    get_i_to_x_rbtree(N, 0, T2, T).

get_i_to_x_rbtree1(N, T) :-
    rb_empty(T2),
    get_i_to_x_rbtree(N, 1, T2, T).

get_i_to_x_rbtree(0, _, T, T).
get_i_to_x_rbtree(N, I, T2, T) :-
    get_number(X),
    rb_insert(T2, I, X, T3),    
    N2 is N - 1,
    I2 is I + 1,
    get_i_to_x_rbtree(N2, I2, T3, T).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    length(S, L),
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 

    sort(Key, Order, List, Sorted): Keyは通常0?, Orderは=なしが重複削除，=は重複保持
    \+ P(X) : not P(X)

    sum_list(Xs, Sum)

    orは!忘れに注意(末尾再帰なら直前)

    include(f, Xs, Ys) : filter f
*/

/* [L,R) */
range_list(L, R, []) :- L >= R, !.
range_list(L, R, [L|Xs]) :- L2 is L + 1, range_list(L2, R, Xs).

min_list([X|Xs], Z) :- min_list(Xs, X, Z).
min_list([], C, C).
min_list([X|Xs], C, Z) :- C2 is min(X, C), min_list(Xs, C2, Z).

min_list_by_f([X|Xs], F, Z) :- min_list_by_f(Xs, F, X, Z).
min_list_by_f([], _, C, C).
min_list_by_f([X|Xs], F, C, Z) :- call(F, X, XV), call(F, C, CV), XV < CV, !, min_list_by_f(Xs, F, X, Z). 
min_list_by_f([_|Xs], F, C, Z) :- min_list_by_f(Xs, F, C, Z). 

f(X, Y) :- Y is abs(X).

main :-
    get_number(N, L),
    range_list(L, L+N, Xs),
    sum_list(Xs, S),
    min_list_by_f(Xs, f, M),
    Z is S - M,
    writeln(Z).

    % statistics(inferences, IC), writeln(IC).


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

int is_prime(int n)
{
    for(int i=2;i*i<=n;i++)
        if(n%i==0) return 0;
    return 1;
}
int prime[1002];
ll mod = 1e9 + 7;
int main()
{
    int n,p[1002];
    int count = 0;
    for(int i=2;i<=1002;i++)
        if(is_prime(i)) prime[count++]=i;
    ll res;
    while(cin >> n)
    {
        res = 1;
        memset(p,0,sizeof(p));
        int maxp=0;
        for(int i=1;i<=n;i++)
        {
            int m=i;
            for(int j=0;j<count;j++)
                while(m%prime[j]==0)
            {
                m/=prime[j];
                p[j]++;
                if(j>maxp)
                    maxp=j;
            }
        }
        for(int i=0;i<=maxp;i++)
            res = (res * (p[i] + 1)) % mod;
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 256
class Arrow
  attr_reader :source, :sink, :label

  def initialize(source, sink, label)
    @source = source
    @sink = sink
    @label = label
  end
end

def push(queue, label)
  size = queue.size
  index = queue.index{|entry| entry[0] >= label} || size
  return queue[index][1] if index < size && queue[index][0] == label

  return nil if index > 0 && !label.start_with?(queue[index - 1][0])
  queue.slice!(index..-1) if index < size && !queue[index][0].start_with?(label)

  nodes = {}
  queue.insert(index, [label.dup, nodes])
  nodes
end

def calc(n, arrows, start, goal)
  ins = Array.new(n){[]}
  arrows.each do |arrow|
    ins[arrow.sink] << arrow.source
  end

  reachable_from = {}
  stack = [goal]
  until stack.empty?
    node = stack.pop
    reachable_from[node] = true
    ins[node].each do |source|
      stack << source unless reachable_from[source]
    end
  end

  return nil unless reachable_from[start]
  arrows.select!{|arrow| reachable_from[arrow.sink]}

  outs = Array.new(n){[]}
  arrows.each do |arrow|
    outs[arrow.source] << [arrow.sink, arrow.label] if reachable_from[arrow.sink]
  end

  limit = n * arrows.map{|arrow| arrow.label.size}.max

  result = ''
  queue = [['', {start => true}]]
  until queue.empty?
    label, nodes = queue.shift
    result << label
    return result if nodes[goal]
    return nil if result.size > limit

    size = label.size
    queue.each do |next_label, _|
      next_label.slice!(0...size)
    end

    nodes.each do |node, _|
      outs[node].each do |sink, label|
        new_nodes = push(queue, label)
        new_nodes[sink] = true if new_nodes
      end
    end
  end
  nil
end

loop do
  n, a, s, g = gets.split.map(&:to_i)
  break if n == 0

  arrows = a.times.map{
    x, y, lab = gets.split
    Arrow.new(x.to_i, y.to_i, lab)
  }

  puts calc(n, arrows, s, g) || 'NO'
end

Measured memory_bytes: 9784
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,su=0;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<k;i++)
    su+=a[i];
    cout<<su;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main()
{
  int n, i, x;
  int d = 100;
  int flag = 0;
  
  scanf("%d", &n);
  
  x = n;
  
  for(i = 0; i < 3; i++)
  {
    x /= d;
    if(x == 7)
      flag = 1;
    
    n -= x * d;
    x = n;
    d /= 10;   
  }
  if(flag == 1)
    printf("Yes");
  
  else
    printf("No");
  
  return 0;
}

Measured memory_bytes: 1696
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;


int n;


void solve() {
    cin >> n;
    bool flag = false;
    while (n > 0) {
        if (n % 10 == 7) {
            flag = true;
            break;
        }
        n /= 10;
    }

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


int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <math.h>
#include <queue>

using namespace std;

//I read the chiebukuro's article about Hitohudegaki
//http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q1090450460

int main(){

	int from,to,table[101] = {0};
	bool FLG;

	while(scanf("%d %d",&from,&to) != EOF){
		if(from == 0 && to == 0){
			if(table[1]%2 == 1 && table[2] %2 == 1){
				FLG = true;
				for(int i = 3; i <= 100; i++){
					if(table[i] % 2 == 1){
						FLG = false;
						break;
					}
				}
				if(FLG)printf("OK\n");
				else{
					printf("NG\n");
				}
			}else{
				printf("NG\n");
			}
			for(int i = 0; i < 101;i++)table[i] = 0;
			continue;
		}else{
			table[from]++;
			table[to]++;
		}
	}


    return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Network{
	private:
	int V;
	struct edge{
		int to,cap,rev;
	};
	vector<vector<edge> > g;
	int DFS(int v,int t,int f,vi& iter,vi level){
		if(v==t) return f;
		for(int &i=iter[v];i<g[v].size();i++){
			edge &e=g[v][i];
			if(e.cap>0&&level[v]<level[e.to]){
				int d=DFS(e.to,t,min(f,e.cap),iter,level);
				if(d>0){
					e.cap-=d;
					g[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	void BFS(int s,vi& level){
		level=vi(V,-1);
		queue<int> que;
		level[s]=0;
		que.push(s);
		while(!que.empty()){
			int v=que.front();
			que.pop();
			for(int i=0;i<g[v].size();i++){
				edge &e=g[v][i];
				if(e.cap>0&&level[e.to]<0){
					level[e.to]=level[v]+1;
					que.push(e.to);
				}
			}
		}
	}
	public:
	Network(int v){
		V=v;
		g=vector<vector<edge> >(v);
	}
	void add_edge(int s,int t){
		g[s].push_back(edge{t,1,(int)g[t].size()});
		g[t].push_back(edge{s,1,(int)g[s].size()-1});
	}
	int Dinic(int s,int t){
		int res=0;
		while(1){
			vi iter(V),level;
			BFS(s,level);
			if(level[t]<0) return res;
			int f;
			while((f=DFS(s,t,inf,iter,level))>0) res+=f;
		}
	}
	void Open(map<P,int> m){
		int res=0;
		vi a;
		for(int i=0;i<V;i++) for(int j=0;j<g[i].size();j++){
			edge &e=g[i][j];
			int v=e.to,I=m[{i,v}];
			if(I&&e.cap==2){
				a.push_back(I);
				res++;
			}
		}
		cout<<res<<endl;
		for(int i=0;i<res;i++) cout<<a[i]<<endl;
	}
};

int n,m,s,t;

int main(){
	cin>>n>>m;
	Network nt(n);
	map<P,int> M;
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		M[{u,v}]=i+1;
		nt.add_edge(u,v);
	}
	cin>>s>>t;
	cout<<nt.Dinic(s-1,t-1)<<endl;
	nt.Open(M);
}

Measured memory_bytes: 3424
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
string str,ans="",ans2="";
map < string,int > tab;
int main(){
  while(cin>>str){
    if(str.size()>ans2.size())ans2=str;
    tab[str]++;
    if(tab[ans]<tab[str])ans=str;
  }
  cout<<ans<<' '<<ans2<<endl;
  return 0;
}


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

int main(){
  string s;
  cin >> s;
  int l= s.size();
  if(l == 2) cout << s<<endl;
  else{
    string ans ="";
    for(int i=0;i<3;i++){
      ans += s[2-i];
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
#define ll long long int
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define rep(i,l,r) for(i=l;i<r;i++)
#define bep(i,l,r) for(i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
int main()
{
    io;
    int n,d;
    cin>>n>>d;
    d=2*d+1;
    if(n%d)
        cout<<n/d+1;
    else
        cout<<n/d;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b&&a!=c){
		printf("Yes\n");
	}
	else if(a==b&&b!=c){
		printf("Yes\n");
	}
	else if(b==c&&a!=b){
		printf("Yes\n");
	}
	else if(b==c&&a!=c){
		printf("Yes\n");
	}
	else if(a==c&&a!=b){
		printf("Yes\n");
	}
	else if(a==c&&b!=c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<vector>
#include<cmath>

using namespace std;

int main()
{
    int N;
    float ave = 0;
    int loss1 = 0;
    int loss2 = 0;
    vector<int> X;
    cin >> N;
    X.resize(N);
    for (int i = 0; i < N; i++){
        int x;
        cin >> x;
        X[i] = x;
        ave += x;
    }
    ave /= N;
    int ave1 = floor(ave);
    int ave2 = ceil(ave);

    for (int i = 0; i < N; i++){
        loss1 += (ave1 - X[i]) * (ave1 - X[i]);
        loss2 += (ave2 - X[i]) * (ave2 - X[i]);
    }

    cout << min(loss1, loss2) << endl;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

vector<vi> graph;
vi perm;

vi found_inds;
vi found_pers; 
vi temp;
vector<bool> visited;

void dfs(int pos) {
	found_inds.push_back(pos);
	found_pers.push_back(perm[pos]);
	visited[pos] = true;

	for (int n : graph[pos]) {
		if (visited[n]) continue;
		dfs(n);
	}
}

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

	int N, M; cin >> N >> M;

	perm.resize(N); 
	graph.resize(N);
	visited.resize(N);
	temp.resize(N);

	for (int i = 0; i < N; ++i) {cin >> perm[i]; --perm[i];}

	for (int i = 0; i < M; ++i) {
		int a, b; cin >> a >> b; --a; --b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	int ans = 0;

	for (int i = 0; i < N; ++i) {
		if (visited[i]) continue;

		found_inds.clear();
		found_pers.clear();
		temp.clear(); 
		
		dfs(i);

		temp.resize(found_inds.size() + found_pers.size());
		
		sort(found_inds.begin(), found_inds.end());
		sort(found_pers.begin(), found_pers.end());

		auto it = set_intersection(found_inds.begin(), found_inds.end(), found_pers.begin(), found_pers.end(), temp.begin());
		ans += it - temp.begin();
	}
	print(ans);
}

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

using namespace std;

#define INF 1000000000
#define INFLL 0x3f3f3f3f3f3f3f3fLL 
#define EPS 10e-9
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define st first
#define nd second
#define sz(v) int(v.size())
#define all(X) (X).begin(), (X).end()
#define FOR(I, A, B) for(int I = A; I < B; I++)
#define RFOR(I, A, B) for(int I = A; I >= B; I--)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<iii> viii;
typedef vector<ll> vll;

int main(){
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	while(a > 0 && c > 0){
		c -= b;
		if(c <= 0){
			cout << "Yes\n";
			return 0;
		}
		a -= d;
		if(a <= 0){
			cout << "No\n";
			return 0;
		}
	}
	return 0;
}




Measured memory_bytes: 3748
A,B,C = map(int, input().split())

ans = 0
for ans in range(1000):
    if A&1 or B&1 or C&1:
        print(ans)
        break
    A,B,C = (B+C)//2, (C+A)//2, (A+B)//2
else:
    print(-1)

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

// Description: ????????????
// Verifyed: various problem 
const R INF = 1E40L;
const R PI = acos(-1.0L);
using P=complex<R>;
const P O=0.0L;
using L=struct{P s,t;};
using VP=vector<P>;
using C=struct{P p;R c;};

istream& operator >> (istream& is,P& p){ R x,y;is >> x >> y; p=P(x,y); return is;}
ostream& operator << (ostream& os,P& p){ os << real(p) << " " << imag(p); return os;}

inline R dot(P o,P a,P b){return real(conj(a-o)*(b-o));}
inline R det(P o,P a,P b){return imag(conj(a-o)*(b-o));}
inline int sdot(P o,P a,P b){return sgn(dot(o,a,b));}
inline int sdet(P o,P a,P b){return sgn(det(o,a,b));}

//projection verify AOJ CGL_1_A
P proj(L l,P p){ R u=real((p-l.s)/(l.t-l.s)); return (1-u)*l.s+u*l.t;}

// convex_hull Verify AOJ CGL_4_A
VP convex_hull(VP pol){
	int n=pol.size(),k=0;
	sort(begin(pol),end(pol),[](P a,P b)->bool{return sgn(real(a)-real(b))?sgn(real(a)-real(b))<0:sgn(imag(a)-imag(b)<0);});
	VP res(2*n);

	// down
	rep(i,n){
		while(k>1&&sdet(O,res[k-1]-res[k-2],pol[i]-res[k-1])>=1) k--;
		res[k++]=pol[i];
	}
	
	// up
	int t=k;
	rrep(i,n-1){
		while(k>t&&sdet(O,res[k-1]-res[k-2],pol[i]-res[k-1])>=1) k--;
		res[k++]=pol[i];
	}
	res.resize(k-1);
	return res;
}

int main(void){
	int n;
	cin >> n;
	VP pol;
	rep(i,n){
		P p;
		cin >> p;
		pol.push_back(p); 
	}
	VP res=convex_hull(pol);
	int m=res.size(),idx=0;
	rep(i,m){
		if(imag(res[i])<imag(res[idx])) idx=i;
		if(imag(res[i])==imag(res[idx])&&real(res[i])<real(res[idx])) idx=i;
	}
	cout << m << endl;
	rep(i,m) cout << res[(idx-i+m)%m] << endl;
	return 0;
}

Measured memory_bytes: 15332
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int a, b, c;
  ci(a, b, c);
  if(b - a == c - b){
    co("YES");
  }
  else{
    co("NO");
  }
}

Measured memory_bytes: 256
N = int(input())
b_list = [input() for _ in range(N)]
b_set = set(b_list)
M = int(input())
r_list = [input() for _ in range(M)]
ans = 0

for i in b_set:
	ans = max(ans, b_list.count(i)-r_list.count(i))

print(ans)



Measured memory_bytes: 3060
from sys import stdin

def main():
    N = int(input())
    A, B, C = (input() for _ in [0] * 3)

    ans = 0
    for i in range(N):
        l = len(set([A[i], B[i], C[i]]))
        if l == 3:
            ans += 2
        elif l == 2:
            ans += 1
    print(ans)

input = lambda: stdin.readline().rstrip()
main()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    string s;
    cin >> s;
    string a, b, c;
    rep(i, s.size()) {
        if (i < 5) a.push_back(s.at(i));
        else if (i > 5 && i < 13) b.push_back(s.at(i));
        else if (i > 13 && i < s.size()) c.push_back(s.at(i));
    }
    cout << a << " " << b << " " << c << endl;
}

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

int main(){
    int n;
    while(cin >> n, n != 0){
        int sum = 0, maxi = 0, mini = 1000;
        for(int i=0;i<n;++i){
            int s;
            cin >> s;
            sum += s;
            maxi = max(maxi, s);
            mini = min(mini, s);
        }
        cout << (sum- maxi - mini) / (n - 2) << endl;
    }

    return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int a,b;

int main()
{
    cin >> a >> b;
    cout << (a + b) % 24 << endl;
}

Measured memory_bytes: 256
n = int(input())
arr = [list(map(int, input().split())) for i in range(n)]
arr = [ [0, 0, 0] ] + arr
ans = "No"

for i in range(n):
 if arr[i][0]%2 != (arr[i][1]+arr[i][2])%2: break
 if abs(arr[i][1]-arr[i+1][1])+abs(arr[i][2]-arr[i+1][2])>arr[i+1][0]-arr[i][0]: break
 if i==n-1: ans="Yes"

print(ans)

Measured memory_bytes: 28068
#![allow(non_snake_case,unused_imports)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let N:usize = iter.next().unwrap().parse().unwrap();
    let mut D = HashSet::new();
    let _ = (0..N).map(|_| D.insert(iter.next().unwrap().parse::<usize>().unwrap())).collect::<Vec<_>>();

    let ans = D.len();

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

Measured memory_bytes: 4352