akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; ++i)
typedef long long ll;
using namespace std;
const int INF = 1e9;

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

    ll sum = 0, cnt = 0;
    rep(i, n) {
        cin >> b[i];
        if (a[i] >= b[i])
            x.push_back(a[i] - b[i]);
        else {
            sum += b[i] - a[i];
            ++cnt;
        }
    }

    sort(x.begin(), x.end(), greater<ll>());

    rep(i, x.size()) {
        if (sum <= 0)
            break;
        sum -= x[i];
        ++cnt;
    }

    if (sum > 0)
        cout << -1 << endl;
    else
        cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3328
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

# 最高次は等しくないといけないので、
# y % x = y-xになる
# yがxを包含していればok

mod = 1000000007

def ca(x, y):
    ct = 0
    for i in range(x, y+1):
        for j in range(i, y+1):
            if j % i == (j^i):
                ct += 1
    return ct

ans = 0
l, r = na()

dp = [0] * 4
for i in range(60, -1, -1):
    ndp = [0] * 4
    base = 1<<i
    if base <= r and l < base*2:
        ptn = 0
        if base+1 <= l:
            ptn += 1
        if r < base*2-1:
            ptn += 2
        ndp[ptn] += 1

    if l>>i != r>>i:
        if (l>>i&1) == 0 and (r>>i&1) == 1:
            ndp[1] += dp[3]
            ndp[2] += dp[3]
    if ((l>>i)&(r>>i)) == (l>>i):
        ndp[3] += dp[3]

    if (l >> i & 1) == 0:
        ndp[0] += dp[1]
        ndp[1] += dp[1]
    ndp[1] += dp[1]

    if (r >> i & 1) == 1:
        ndp[0] += dp[2]
        ndp[2] += dp[2]
    ndp[2] += dp[2]

    ndp[0] += dp[0] * 3

    for k in range(4):
        ndp[k] %= mod
    dp = ndp
print(sum(dp) % mod)


Measured memory_bytes: 38420
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			int n = sc.nextInt();
			if (n == 0) break;
			int y = sc.nextInt();
			
			int bestB = 0;
			double bestValue = -1;
			
			for (int iii = 0; iii < n; iii++) {
				int b = sc.nextInt();
				int r = sc.nextInt();
				int t = sc.nextInt();
				double v = 0;
				if (t == 1) {
					v = 1 + y * r / 100.0; 
				} else {
					v = Math.pow(1.0 + r / 100.0, y);
				}
				if (bestValue < v) {
					bestValue = v;
					bestB = b;
				}
			}
			System.out.println(bestB);
		}
	}
}

Measured memory_bytes: 35668
N = int(input())
d = {}

a = [int(x) for x in input().split()]

for i in a :
    if i not in d.keys() :
        d[i] = 1
    else :
        d[i] += 1

s1 = sorted(d.items(), key = lambda x : x[0], reverse=True)

l1 = -1
l2 = -1

for i in range(N) :
    if s1[i][1] >= 4 and l1 == -1 and l2 == -1:
        l1, l2 = s1[i][0], s1[i][0]
        break
    elif s1[i][1] >= 2 and l1 == -1 :
        l1 = s1[i][0]
    elif s1[i][1] >= 2 and l1 != -1 :
        l2 = s1[i][0]
        break
        
if l1 == -1 or l2 == -1 :
    print("0")
else :
    print(l1 * l2)

Measured memory_bytes: 21772
#include <math.h>

#include <cmath>
#include <iostream>
using namespace std;
int main() {
    int n, k;
    cin >> n>>k;
    long long test[n] = {};
    for (int i = 0; i < n; i++) {
        cin >> test[i];
        if(i!=0)test[i]+=test[i-1];
    }
    if(test[k-1]<test[k]-test[0]){
        cout << "Yes" << endl;
    }else
        cout << "No" << endl;
 for (int i = k + 1; i <= n - 1; i++) {
        if (test[i] - test[i - k] > test[i - 1] - test[i - 1 - k]) {
            cout << "Yes" << endl;
        } else
            cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 5192
#include<cstdio>

int main(){
	int h,w,n;
	scanf("%d%d%d",&h,&w,&n);
	int x[10000];
	int a[10000];
	int cur = 0;
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<a[i];j++){
			x[cur] = i + 1;
			cur++;
		}
	}
	int c[100][100];
	for(int i=0;i<h*w;i++){
		int yoko = i / h;
		int tate = i % h;
		if(yoko%2==0){
			c[tate][yoko] = x[i];
		}else{
			c[h-1-tate][yoko] = x[i];
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			printf("%d",c[i][j]);
			if(j==w-1) printf("\n");
			else printf(" ");
		}
	}
}


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

cnt = 0

for i in range(1,n+1):
  if i < 10:
    cnt += 1
    continue
  if i >= 100 and not (i >= 1000):
    cnt += 1
    continue
  if i >= 10000 and i != 100000:
    cnt += 1
    continue

print(cnt)


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

int main() {
  
  int S;
  cin>>S;
  
  int a=S/100;
  int b=S%100;

  if (a>12 && b>12) {
    cout << "NA" <<endl;
  }
  
  else if (a<=12 && b<=12) {
    if (a>=1 && b>=1) {
      cout <<"AMBIGUOUS"<<endl;
    }
    else if (a>=1 && b==0) {
      cout << "MMYY"<<endl;
    }
    else if (a==0 && b>=1) {
      cout <<"YYMM"<<endl;
    }
    else if (a==0 && b==0) {
      cout<<"NA"<<endl;
    }
  }
  
  else if (a>12 && b<=12) {
    if (b==0) {
      cout<<"NA"<<endl;
    }
    else {
      cout<<"YYMM"<<endl;
    }
  }
  else if (a<=12 && b>12) {
    if (a==0) {
      cout<<"NA"<<endl;
    }
    else {
      cout<<"MMYY" <<endl;
    }
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    int a[100010];
    cin >> n;
    int s = 0;
    imfor(i, n) {
        cin >> a[i];
        s += a[i];
    }
    a[n] = a[0];
    int x[100010];
    x[0] = s;
    for (int i = 1; i <= n - 2; i += 2) {
        x[0] -= 2 * a[i];
    }
    for (int i = 1; i <= n; i++) {
        x[i] = 2 * a[i - 1] - x[i - 1];
    }
    for (int i = 0; i < n; i++) {
        cout << x[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 2048
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    vector<string> s(3);
    cin >> s[0] >> s[1] >> s[2];
    
    vector<int> p(3);
    int state = 0;
    
    while ( s[state].size() - p[state] )
        state = s[state][p[state]++] - 'a';
    
    cout << static_cast<char> ( 'A' + state ) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int debt = 100000;
  for (int i = 0; i < n; i++) {
    debt *= 1.05;
    if (debt % 1000) debt = debt / 1000 * 1000 + 1000;
  }

  cout << debt << endl;

  return 0;
}

Measured memory_bytes: 3024
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  int d[n];
  for(int i = 0; i < n; i++)
    cin >> d[i];
  stable_sort(d, d+n);
  int ans = d[n/2]-d[n/2-1];
  cout << ans << endl;
  return  0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vvchar vector<vector<char>>
#define vchar vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vint a(n); 
    rep(i,n){
        cin>>a[i];
        a[i]--;
    }
    int now=0;
    rep(i,n){
        now=a[now];
        if(now==1){
            cout<<i+1<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 3976
n,m = map(int, input().split())
g = [[n] for i in range(n)]
for i in range(m):
  a,b = map(int, input().split())
  g[a-1].append(b-1)
k = 0
ans=0
while k <=n-1:
  e = n
  for i in g[k:]:
    e = min(e,min(i))
  if e==n:
    break
  ans+=1
  k = e
print(ans)

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

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


Measured memory_bytes: 256
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define all(v) v.begin(), v.end()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
const int MX = (2e5);
Long cnt[MX + 2];
Long f(Long x) {
  return x * (x - 1) / 2;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> v(n);
  fore(i, 0, n) {
    cin >> v[i];
    v[i]--;
    cnt[v[i]]++;
  }
  Long ans = 0;
  fore(i, 0, n) {
    ans += f(cnt[i]);
  }
  fore(i, 0, n) {
    Long last = cnt[v[i]];
    Long current = ans;
    current -= f(last);
    current += f(last - 1);
    cout << current << '\n';
  }

  return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){
long long a,b,x;
cin>>a>>b>>x;

long long ans;
    if(a!=0){
    ans=(b/x+1)-((a-1)/x+1);
    }

    else{
    ans=(b/x+1);
    }
cout<<ans<<endl;
return 0;
}
/*
4 8 2

3

0 5 1

6

9 9 2

0

1 1000000000000000000 3

333333333333333333

*/


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner in = new Scanner(System.in);
        long n = in.nextLong(), ans = 0;
        for (long i = 1; i * i <= n - 1; i++) {
            if ((n - 1) % i == 0) {
                if (i != 1)
                    ans++;
                if ((n - 1) / i != i)
                    ans++;
            }
        }
        for (long i = 2; i * i <= n; i++) {
            if (n % i == 0) {
                long x = n / i;
                while (x % i == 0) {
                    x /= i;
                }
                if (x % i == 1) {
                    ans++;
                }
            }
        }
        System.out.println(ans + 1);
    }

}


Measured memory_bytes: 23252
import sys
from collections import Counter

# sys.stdin = open('b1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


yes, no = 'Yes', 'No'


def solve(n, a):
    s = set(a)
    c = Counter(a)
    if len(s) == 1:
        a = list(s)[0]
        n_colors = a + 1
        if n_colors == n:
            return yes
        n_colors = a
        if 2 * n_colors <= n:
            return yes
    if len(s) == 2:
        a, b = sorted(s)
        if a + 1 == b:
            n_colors = b
            appear_once = c[a]
            appear_twice_or_more = n_colors - appear_once
            if appear_once < n_colors:
                if c[b] >= 2 * appear_twice_or_more:
                    return yes
    return no

n = read_int()
a = read_int_list()
res = solve(n, a)
print(res)



Measured memory_bytes: 24280
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T = lint>
struct Edge {
	int from, to;
	T cost;
	Edge() {}
	Edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};

template<class T>
vector<T> Bellman_Ford(vector<Edge<T>> &edges, int V, int st) {

	const T inf = numeric_limits<T>::max(); // different from INF!!!
	vector<T> dist(V, inf);
	dist[st] = 0;
	for (int i = 0; i < V - 1; i++) {
		for (const auto &e : edges) {
			if (dist[e.from] == inf) continue;
			dist[e.to] = min(dist[e.to], dist[e.from] + e.cost);
		}
	}

	for (int i = 0; i < V - 1; i++) {
		for (const auto &e : edges) { // finding negative loop
			if (dist[e.from] == inf) continue;
			if (dist[e.from] == -inf) dist[e.to] = -inf; // src is nloop -> dst is nloop
			if (dist[e.to] > dist[e.from] + e.cost) dist[e.to] = -inf; // chmin is possible -> nloop
		}
	}

	return dist;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

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

	int a, b, c;
	vector<Edge<int>> edges(M);
	for (int i = 0; i < M; i++) {
		cin >> a >> b >> c;
		a--, b--;
		edges[i] = { a, b, P - c };
	}

	auto dist = Bellman_Ford(edges, N, 0);
	DMP(dist);
	
	lint ans = -dist.back();
	DMP(ans);
	if (ans == numeric_limits<int>::max()) cout << "-1\n";
	else if (ans < 0) cout << "0\n";
	else cout << ans << "\n";

	return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define ll long long
using namespace std;

int main() {
  int N;
  cin >> N;
  if (N % 2 == 0) {
    cout << N / 2 << endl;
  }
  if (N % 2 == 1) {
    cout << N / 2 + 1 << endl;
  }

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

// 仲良しうさぎ
int main() {

    int N;
    cin >> N;
    
    vector<int> a(N);
    REP(i, N) cin >> a[i];
    
    int cnt = 0;
    for(int i = 0; i < N; i++) {
        // cout << a[i] << a[a[i]-1] << endl;
        if (a[a[i]-1] == i+1) {
            cnt++;
        }
    }

    cout << cnt/2 << endl;
    



    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<ll>;
using vec2 = vector<vector<ll>>;
ll inf = pow(2, 62);

int main(){
    string s;
    cin >> s;
    if(s[0] == 'R'  && s[1] == 'R' && s[2] == 'R'){
        cout << 3<< endl;
    }
    else if(s[0] == 'R' && s[1] == 'R'){
        cout << 2 << endl;
    }
    else if(s[1] == 'R' && s[2] == 'R'){
        cout << 2 << endl;
    }
    else if(s[0] == 'S' && s[1] == 'S' && s[2] == 'S'){
        cout << 0 << endl;
    }
    else{
        cout << 1 << endl;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const int inf = (1<<29);

int main() {

    int n;
    cin >> n;
    vector<double> a(n);
    REP(i, n) cin >> a[i];
    
    sort(RALL(a));

    double tmp = a[0] / 2;
    double ans = a[1];

    for(int i = 1; i < n; i++) {
        if (abs(ans-tmp) >= abs(a[i]-tmp)) {
            ans = a[i];
        }
    }

    cout << (int)a[0] << " " << (int)ans << endl;
    

    return 0;
}

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

const int N = 1000;

enum {wait=0,hang,talk,end};

bool sim(int n,int *M,int *L,int *K,int T,int op){
  int now=0,can=op;
  static int event[N],state[N];
  rep(i,n)event[i]=0,state[i]=hang;
  while(now <= T){
    int next=T+1;

    rep(i,n)if(state[i] != end)next=min(next,event[i]);

    if (next > T)break;
   
    rep(i,n){
      if (state[i] == talk && event[i] == next){
	state[i]=end;
	can++;
      }
    }
    
    rep(i,n){
      if (state[i] == hang && event[i] == next){
	state[i]=wait;
	event[i]=next+L[i];
      }
    }

    rep(i,n){
      if (state[i] == wait && can > 0){
	state[i]=talk;
	event[i]=next+M[i];
	can--;
      }
    }

    rep(i,n){
      if (state[i] == wait && event[i] == next){
	state[i]=hang;
	event[i]=next+K[i];
      }
    }

    now=next;
  }
  rep(i,n)if (state[i] != end)return false;
  return true;
}

int solve(int n,int *M,int *L,int *K,int T){
  int l=0,r=n-1, mid,ok=n;
  while(l <= r){
    mid=(l+r)/2;
    if (sim(n,M,L,K,T,mid))r=mid-1,ok=mid;
    else l=mid+1;
  }
  
  int ans=ok;
  for(int i=mid-1;i>0 && i >= mid-100;i--){
    if (sim(n,M,L,K,T,i))ans=i;
  }
  return ans;
}

main(){
  int n,t;
  int M[N],L[N],K[N];
  while(cin>>n>>t && n){
    rep(i,n)cin>>M[i]>>L[i]>>K[i];
    cout << solve(n,M,L,K,t) << endl;
  }
  return false;
}

Measured memory_bytes: 884
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const ll MOD = (ll)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

priority_queue<int, vector<int>, greater<int>> pq;
vector<int> v;

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    if (m%2==1) printf("No\n");
    else if (n*2 <= m && m <= 4*n) return !printf("Yes");
    else printf("No\n");
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N;
  cin >> N;
  int ans = 0;
  int maxA = -1;
  rep(i, N)
  {
    int A, B;
    cin >> A >> B;
    if (A > maxA)
    {
      ans = A + B;
      maxA = A;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>

using namespace std;

using ll = long long;
constexpr int MAX = 100;

ll com[MAX][MAX];

void make_com()
{
    memset(com, 0, sizeof(com));
    com[0][0] = 1;
    for (int i = 0; i < 65; i++) {
        for (int j = 0; j <= i; j++) {
            com[i + 1][j]     += com[i][j];
            com[i + 1][j + 1] += com[i][j];
        }
    }
}

void solve(ll N, ll s, ll M, ll n)
{
    while (s < M) {
        ll j = -1;
        for (ll i = n; i <= N; i++) {
            if (s + com[i][n] >= M) {
                s += com[i - 1][n];
                j = i;
                break;
            }
        }

        for (int i = 0; i < N - j; i++) {            
            cout << '0';
        }
        
        if (n > 0) {
            cout << '1';
        }

        n--;        
        N = j - 1;
    }

    cout << endl;
}

bool run()
{
    ll N, M;
    cin >> N >> M;
    if (N == 0 && M == 0) {
        return false;
    }

    if (M == 1) {
        cout << std::string(N, '0') << endl;
        return true;
    }
    
    make_com();
    
    ll sum = 1;    
    for (ll i = 1; i <= N; i++) {
        sum += com[N][i];
        if (sum >= M) {
            solve(N, sum - com[N][i], M, i);
            break;
        }
    }
    return true;
}

int main()
{
    while (run())
        ;    
    return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
    int n;
    cin >> n;
    if(cin.eof())break;
    int c=0;
    int x=0;
    for(int i=0;i<n/2;i++){
      int f=1;
      for(int j=0;j<i;j++){
	f*=3;
      }
      c+=f*2;
      x=f;
      //cout << c << endl;
    }
    if(n%2&&n!=1)c+=x*3;
    if(n==1)c+=1;
    
    cout << c << endl;
  }
  return 0;
}

Measured memory_bytes: 2976
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cassert>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
int fa[2222],a[2222];
int lb[2222],dep[2222];
int mx[2222],se[2222],son[2222];
int vis[2222];
struct edge
{
	int to;
	int next;
}e[4444];
int pe=2222;
void insert(int a,int to)
{
	e[pe]=(edge){to,e[a].next};
	e[a].next=pe++;
}
int op[33333],pp;
void dd(int o)
{
	op[++pp]=o;
	int now=o,la=a[0],tmp;
	while(1)
	{
		tmp=la,la=a[now],a[now]=tmp;
		if(!now)return;
		now=fa[now];
	}
}
int main()
{
	int n=io::F();
	for(register int i=1;i<n;++i)fa[i]=io::F(),insert(fa[i],i),dep[i]=dep[fa[i]]+1;
	for(register int i=0;i<n;++i)a[i]=io::F();
	for(register int i=n-1;i>=0;--i)
	{
		for(register int p=e[i].next;p;p=e[p].next)
			if(lb[e[p].to]>=mx[i])se[i]=mx[i],mx[i]=lb[e[p].to],son[i]=e[p].to;
				else cmax(se[i],lb[e[p].to]);
		if(mx[i]==se[i])lb[i]=mx[i]+1,son[i]=-1;
			else lb[i]=mx[i];
	}
	for(register int T=1;T<=lb[0];++T)
	{
		int cnt=0;
		for(register int i=0;i<n;++i)if(lb[i]==T)++cnt;
		while(cnt)
		{
			if(lb[a[0]]==T)
			{
				int now=a[0];
				while(son[now]!=-1&&vis[son[now]]==0)now=son[now];
				while(vis[now])now=fa[now];
				vis[now]=1;
				while(son[now]!=-1&&dep[a[son[now]]]<dep[a[0]])now=son[now];
				dd(now);
				--cnt;
			}
			else
			{
				int pl,dp=0;
				for(register int i=0;i<n;++i)
					if(vis[i]==0&&lb[a[i]]==T)
						if(cmax(dp,dep[i]))pl=i;
				dd(pl);
			}
		}
	}
	for(register int i=0;i<n;++i)assert(a[i]==i);
	assert(pp<=25000);
	printf("%d\n",pp);
	for(register int i=1;i<=pp;++i)printf("%d\n",op[i]);
	return 0;
}



Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#include <vector>

using namespace std;

class Nums {
   public:
    int a, b, c;

    Nums(int _a, int _b, int _c) {
        a = _a;
        b = _b;
        c = _c;
    }

    bool operator<(const Nums &other) const {
        return a < other.a;
    }
};

int main() {
    int x, y, z;
    int k;
    cin >> x >> y >> z;
    cin >> k;
    vector<long long> A(x), B(y), C(z);
    for (int i = 0; i < x; ++i) cin >> A[i];
    for (int i = 0; i < y; ++i) cin >> B[i];
    for (int i = 0; i < z; ++i) cin >> C[i];
    A.push_back((long long)-1e17);
    B.push_back((long long)-1e17);
    C.push_back((long long)-1e17);

    sort(A.begin(), A.end(), greater<long long>());
    sort(B.begin(), B.end(), greater<long long>());
    sort(C.begin(), C.end(), greater<long long>());

    priority_queue<pair<long long, Nums>> pq;
    pq.push(make_pair(A[0] + B[0] + C[0], Nums(0, 0, 0)));
    // pqに入れたかどうかを管理する
    set<int> s;
    s.insert(0);

    vector<long long> ans;
    while (ans.size() < k) {
        auto v = pq.top();
        pq.pop();
        ans.push_back(v.first);
        for (int i = 0; i < 3; ++i) {
            if (true) {
                int a = v.second.a;
                int b = v.second.b;
                int c = v.second.c;
                if (i == 0) a++;
                if (i == 1) b++;
                if (i == 2) c++;
                // hashを作る
                int hash = (a << 20) + (b << 10) + c;
                if (s.find(hash) == s.end()) {
                    s.insert(hash);
                    pq.push(make_pair(A[a] + B[b] + C[c], Nums(a, b, c)));
                }
            }
        }
    }
    for (int i = 0; i < k; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}

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

int H,W;
char S[71][71];
string maxs,DP[100][100];

int main()
{
  while(1){
    cin>>W>>H;
    if(W==0&&H==0)break;
    maxs.erase(maxs.begin(),maxs.end());
    for(int i=1;i<H+1;i++){
      for(int j=1;j<W+1;j++){
	cin>>S[i][j];
	DP[i][j].erase(DP[i][j].begin(),DP[i][j].end());
      }
    }
    for(int i=1;i<H+1;i++){
      for(int j=1;j<W+1;j++){
        if(S[i][j]=='0' && DP[i-1][j].empty() && DP[i][j-1].empty())continue;
	if(S[i][j]>='0' && S[i][j]<='9'){
	  if(DP[i-1][j].length()>DP[i][j-1].length())DP[i][j]=DP[i-1][j]+S[i][j];
	  else if(DP[i-1][j].length()<DP[i][j-1].length())DP[i][j]=DP[i][j-1]+S[i][j];
          else if(DP[i-1][j]>DP[i][j-1])DP[i][j]=DP[i-1][j]+S[i][j];
	  else DP[i][j]=DP[i][j-1]+S[i][j];
	  if(maxs.length()<DP[i][j].length())maxs=DP[i][j];
          else if(maxs.length()==DP[i][j].length() && maxs<DP[i][j])maxs=DP[i][j];
	}
      }
    }
    cout<<maxs<<endl;
  }
  return 0;
}

Measured memory_bytes: 1432
#include <stdio.h>

int main() {
	int N, i, count, ans = 0, j;

	scanf("%d", &N);
	
	for (i = 105; i <= N; i += 2) {
		count = 0;
		for (j = 1; j <= i; j++) {
			if (i % j == 0) {
				count++;
			}
		}
		if (count == 8) {
			ans++;
		}
	}

	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(void) {
	int n;
	cin >> n;
	for(int cake = n / 4;cake >= 0;cake--) {
		if((n - (cake * 4)) % 7 == 0) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mul(a,b,c) a*b%c
using namespace std;

typedef long long ll;

const ll prime[]={2,3,5,7,11,13,17,37};

ll qpow(ll x,ll y,ll p)
{
    ll res=1;
    while(y)
    {
        if(y&1)res=mul(res,x,p);
        x=mul(x,x,p);
        y>>=1;
    }
    return res;
}

bool MillerRabin(ll n,ll a)
{
    ll d=n-1,r=0;
    while(!(d&1))d>>=1,r++;
    ll z=qpow(a,d,n);
    if(z==1)return 1; 
    for(int i=0;i<r;i++)
    {
        if(z==n-1)return 1;
        z=mul(z,z,n);
    }
    return 0;
}

bool Miller_Rabin(ll n)
{
    if(n<=1)return 0;
    for(int i=0;i<8;i++)
    {
        if(n==prime[i])return 1;
        if(n%prime[i]==0)return 0; 
        if(!MillerRabin(n,prime[i]))return 0;
    }
    return true;
}

inline int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(!isdigit(ch))
    {
        if(ch=='-')f=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        s=(s<<3)+(s<<1)+ch-48;
        ch=getchar();
    }
    return s*f;
}

inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10^48);
}

int n;

int main()
{
    n=read();
    while(!Miller_Rabin(n))n++;
    write(n);
    return 0;
}


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

void small(int paper[][14], int x, int y){
    paper[x][y]++;
    paper[x-1][y]++;
    paper[x+1][y]++;
    paper[x][y-1]++;
    paper[x][y+1]++;
}

void middle(int paper[][14], int x, int y){
    small(paper, x, y);
    paper[x-1][y-1]++;
    paper[x-1][y+1]++;
    paper[x+1][y-1]++;
    paper[x+1][y+1]++;
}

void large(int paper[][14], int x, int y){
    small(paper, x, y);
    paper[x-1][y-1]++;
    paper[x-1][y+1]++;
    paper[x+1][y-1]++;
    paper[x+1][y+1]++;
    paper[x-2][y]++;
    paper[x+2][y]++;
    paper[x][y-2]++;
    paper[x][y+2]++;
}

int main(){
    int paper[14][14]={};
    int x, y, Size;
    while(scanf("%d,%d,%d", &x, &y, &Size) != EOF){
        x += 2;
        y += 2;
        switch(Size){
            case 1 : small(paper, x, y); break;
            case 2 : middle(paper, x, y); break;
            case 3 : large(paper, x, y); break;
        }
    }
    int mx=0, plain=0;
    for(int i=2; i<12; i++){
        for(int j=2; j<12; j++){
            if(paper[i][j] > mx) mx = paper[i][j];
            if(paper[i][j] == 0) plain++;
        }
    }
    cout << plain << endl << mx << endl;
    return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <algorithm>

using namespace std;

void solve() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n + 1);
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	sort(a.begin() + 1, a.begin() + n + 1);
	
	int ans = 0;
	for (int i = 1; i <= k; ++i) ans += a[i];
	cout << ans;
}

signed main() {
	int t = 1;
	while (t--) 
		solve();
}


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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef pair<ll, ll> PLL;

const ll M = 1000000007;

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

    // dp[i][j]: iからnまでの文字を見た時にパターン数、jはどこまでみたか（3ならCまでみた）
    // i=0はsの先頭、i==nは終端文字
    vector<vector<ll>> dp(n+10, vector<ll>(4));

    for (ll i=n; i>=0; i--) {
        for (ll j=3; j>=0; j--) {
            if (i==n && j==3) {
                //すでに処理が終了している
                dp[n][3]=1;
            } else if (i==n && j<3) {
                // ABCの3文字を見つけられなかった
                dp[n][j]=0;
            } else if (i<n && j==3) {
                ll m = s[i]=='?'? 3: 1;
                dp[i][3]=m*dp[i+1][3];
            } else {
                ll m1 = s[i]=='?'? 3: 1;
                dp[i][j] += m1*dp[i+1][j]; // ここで文字を選択しない

                ll m2 = (s[i]=='?' || s[i]=="ABC"[j])? 1 : 0;
                dp[i][j] += m2*dp[i+1][j+1]; // ここで文字を選択する
            }
            dp[i][j]%=M;
        }
    }
    cout<<dp[0][0]<<endl;
    return 0;
}


Measured memory_bytes: 7424
#■標準入力ショートカット


def get_next_int():
    return int(float(input()))


def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_str():
    return input()


def get_next_strs(delim=" "):
    return tuple(input().split(delim))


def get_next_by_types(*value_types, delim=" "):
    return tuple([t(x) for t, x in zip(value_types, input().split(delim))])


def solve():
    A, B, C, X, Y = get_next_ints()

    proper = (A * X) + B * Y
    if X > Y:
        smaller = Y
        remainder = X - Y
        value = A
    else:
        smaller = X
        remainder = Y - X
        value = B
    mixed = C * smaller * 2 + min(remainder * value, remainder * C * 2)

    print(min(proper, mixed))


solve()

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#define int long long
using namespace std;
int n,L,R,a[55],ans1,ans2,cnt1,cnt2;
bool cmp(int a,int b){return a>b;}
int C[55][55];
void init(){
    C[0][0]=1;
    for(int i=1;i<=50;i++){
        C[i][0]=1;
        for(int j=1;j<=i;j++)
        C[i][j]=C[i-1][j]+C[i-1][j-1];
    }
}
signed main(){
    init();
    cin>>n>>L>>R;
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    sort(a+1,a+1+n,cmp);//从大到小排序
    for(int i=1;i<=L;i++) ans1+=a[i];//求和，求平均值
    for(int i=1;i<=n;i++) if(a[i]==a[L]) cnt1++;//临界值数个数
    for(int i=1;i<=L;i++) if(a[i]==a[L]) cnt2++;//1~L中临界值数个数
    if(a[1]==a[L])//特判
        for(int i=L;i<=R;i++) ans2+=C[cnt1][i];
    else ans2=C[cnt1][cnt2];
    printf("%lf\n%lld",(double)ans1/L,ans2);
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int n;
int cnt[26];
vector<char> cs;

int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    memset(cnt,0,sizeof(cnt));
    cs.clear();
    rep(i,n){
      char c;
      cin>>c;
      cs.push_back(c);
    }
    bool done=false;
    rep(i,n){
      int crt=cs[i]-'A';
      cnt[crt]++;
      bool ok=false;
      rep(j,26){
        bool okk=true;
        rep(k,26)if(j!=k&&cnt[k]+n-1-i>=cnt[j])okk=false;
        if(okk){
          ok=true;
          break;
        }
      }
      if(ok){
        done=true;
        int ans=0;
        rep(j,26)if(cnt[ans]<cnt[j])ans=j;
        cout<<(char)(ans+'A')<<" "<<i+1<<endl;
        break;
      }
    }
    if(!done){
      cout<<"TIE"<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3068
import math

a, b, h, m = map(int, input().split())

short_l = h*math.pi/6 + m*math.pi/360
long_r = m*math.pi/30

ans = math.sqrt(a**2+b**2-2*a*b*math.cos(abs(short_l-long_r)))

print(ans)

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

using namespace std;

int main()
{
    int n;

    cin >> n;

    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            if (i * j == n) {
                cout << "Yes" << endl;
                return (0);
            }
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 256
N = int(input())
W = [input() for _ in range(N)]

ans = 'Yes'
if len(W) != len(set(W)):
    ans = 'No'

if ans == 'Yes':
    for i in range(N - 1):
        if W[i][-1] != W[i + 1][0]:
            ans = 'No'
            break

print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
int main(){
	int n,i,k,j,o,flag=0;
	scanf("%d",&n);
	int data[n][3],copy_data[n][3],sum[n];
	for(i = 0;i < n;i++){
		sum[i] = 0;
		for(k = 0;k < 3;k++){
			scanf("%d",&data[i][k]);
		}
	}
	for(i = 0;i < n;i++){
		for(k = 0;k < 3;k++){
			for(j = i+1;j < n;j++){
				if(data[i][k] == data[j][k]){
					data[j][k] = 0;
					flag = 1;
				}
			}
			if(flag == 1){
				data[i][k] = 0;
				flag = 0;
			}

		}
	}
	for(i = 0;i < n;i ++){
		for(k = 0;k < 3;k++){
			sum[i] += data[i][k];
		}
	}
	for(i = 0;i < n;i++){
		printf("%d\n",sum[i]);
	}
	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	int64_t ans; cin>>ans;
	for(int i=1;i<n;++i){
		int64_t t; cin>>t;
		ans=ans/__gcd(ans,t)*t;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,m;
	cin>>n>>m;
	vi cnt(100010);
	rep(i,n){
		int a;
		cin>>a;
		cnt[a]++;
	}
	vi in1(m),in2(m);
	rep(i,100010){
		int t=cnt[i];
		in1[i%m]+=t%2;
		in2[i%m]+=t/2*2;
	}
//	rep(i,m)cout<<in1[i]<<" "<<in2[i]<<endl;
	int out=(in1[0]+in2[0])/2;
	loop(i,1,(m+1)/2){
		int t=m-i;
		int mi=min(in1[i]+in2[i],in1[t]+in2[t]);
		out+=mi;
		int a=mi;
		a-=in1[i];
		out+=(in2[i]-(a>0?a:0))/2;
		a=mi;
		a-=in1[t];
		out+=(in2[t]-(a>0?a:0))/2;
//		cout<<out<<endl;
	}
	if(m%2==0){
		out+=(in1[m/2]+in2[m/2])/2;
	}
	cout<<out<<endl;
}








Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1000000000000 ;
const ll mod=1000003 ;

int main(){
  ll n,k;
  cin >> n >> k;
  cout << max(n-k,max(n*k,n+k)) << endl;
return 0;}

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

int main(){
    int n; cin>>n;
    int t[2]={},x[2]={},y[2]={};

    string ans="Yes";
    int dis;
    for(int i=0;i<n;i++){
        cin>>t[0]>>x[0]>>y[0];
        dis=abs(x[0]-x[1])+abs(y[0]-y[1]);
        if(dis>(t[0]-t[1])) ans="No";
        else if(dis%2!=((t[0]-t[1])%2)) ans="No";
        t[1]=t[0];
        x[1]=x[0];
        y[1]=y[0];
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(void){
    int d;
    cin >> d;

    if(d == 25){
        cout << "Christmas" << endl;
    }else if(d == 24){
        cout << "Christmas Eve" << endl;
    }else if(d == 23){
        cout << "Christmas Eve Eve" << endl;
    }else {
        cout << "Christmas Eve Eve Eve" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 1000000007;

int64_t dp[575][10];
// memo[i][j] := iからjにいくまでの引き方の総数
int memo[10][10];

int main() {
  int H, W, K;
  cin >> H >> W >> K;

  memset(memo, 0, sizeof(memo));

  for (int bit=0; bit<(1<<(W-1)); ++bit) {
    vector< int > digit(W-1, 0);
    for (int i=0; i<W-1; ++i) {
      if ((bit>>i) & 1) digit[i] = 1;
    }
    bool ok = true;
    for (int i=0; i<W-2; ++i) {
      ok &= ((digit[i+1] != digit[i]) | (digit[i+1] == 0) | (digit[i] == 0));
    }
    if (!ok) continue;

    vector< int > per(W);
    iota(per.begin(), per.end(), 0);
    for (int wi=0; wi<W-1; ++wi) {
      if (digit[wi]) swap(per[wi], per[wi+1]);
    }
    for (int wi=0; wi<W; ++wi) memo[wi][per[wi]]++;
  }
 

  
  dp[0][0] = 1;
  // (hi, wi)： 今いるとこ, wj: 次行くとこ
  for (int hi=0; hi<H; ++hi) {
    for (int wi=0; wi<W; ++wi) {
      for (int wj=0; wj<W; ++wj) {
        (dp[hi+1][wj] += dp[hi][wi] * memo[wi][wj]) %= MOD;
      }
    }
  }

  int64_t ans = dp[H][K-1] % MOD;
  cout << ans << endl;

  /*
  for (int hi=0; hi<=H; ++hi) {
    for (int wi=0; wi<W; ++wi) {
      cout << dp[hi][wi] << " ";
    }
    cout << endl;
  }
  
  for (int i=0; i<W; ++i) {
    cout << i << ":" << memo[i] << endl;
  }
*/


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;

int ex(int x,int n){
  int y;
  rep(i,n){
    y = x%10;
    x /= 10;
  }
  return y;
}
  
int main() {
  int n,m;
  cin >> n >> m;
  vector<int>s(m),c(m);
  rep(i,m) cin >> s[i] >> c[i];
  if(n == 1){
    for(int i=0;i<10;i++){
      bool x = true;
      rep(j,m){
        if(ex(i,n-s[j]+1) != c[j])
          x = false;
         
      }
        if(x){
          cout << i << endl;
          return 0;
        }
      
    }
  }
  if(n == 2){
    for(int i=10;i<100;i++){
      bool x = true;
      rep(j,m){
        if(ex(i,n-s[j]+1) != c[j])
          x = false;
         
      }
        if(x){
          cout << i << endl;
          return 0;
        }
      
    }
  }
  if(n == 3){
    for(int i=100;i<1000;i++){
      bool x = true;
      rep(j,m){
        if(ex(i,n+1-s[j]) != c[j])
          x = false;
        }
        if(x){
          cout << i << endl;
          return 0;
        }
      
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
<?php

while (true) {
    fscanf(STDIN, '%d %d %d', $points['m'], $points['f'], $points['r']);
    if (array_count_values($points) == array('-1' => 3)) { break; }

    $result[] = getGrade($points);
}

echo implode(PHP_EOL, $result), PHP_EOL;

function getGrade($points)
{
    $sum = $points['m'] + $points['f'];

    if (isAbsence($points['m']) || isAbsence($points['f'])) { return 'F'; }
    if ($sum < 30)                                          { return 'F'; }

    if ($sum >= 80)               { return 'A'; }
    if (65 <= $sum && $sum < 80)  { return 'B'; }
    if (50 <= $sum && $sum < 65)  { return 'C'; }
    if (30 <= $sum && $sum < 50)  {
        return ($points['r'] >= 50) ? ('C') : ('D');
    }
}

function isAbsence($point)
{
    return ($point == -1);
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int n;
double v[50000];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    double r = 0;
    for (int i = 0; i < n; i++) r += 1 / v[i];
    r = 1 / r;
    printf("%.9f", r);
}


Measured memory_bytes: 256
while True:
    n,x = map(int,input().split())
    if n==x==0:
        break
    cnt = 0
    for i in range(1,n-1):
        for j in range(i+1,n):
            for k in range(j+1,n+1):
                if i+j+k == x:
                    cnt += 1
    print(cnt)
            
        


Measured memory_bytes: 5596
import heapq

N = int(input())
a = list(map(int, input().split()))

suma = sum(a[:N])
maxr = [suma] * (N + 1)
hq = a[:N]
heapq.heapify(hq)

for i in range(N, 2*N):
  mina = heapq.heappushpop(hq, a[i])
  suma = suma - mina + a[i]
  maxr[i - N + 1] = suma

suma = sum(a[2 * N : 3 * N])
minr = [suma] * (N + 1)
hq = list(map(lambda x: -x, a[2*N:3*N]))
heapq.heapify(hq)

for i in range(2 * N - 1, N - 1, -1):
  maxa = heapq.heappushpop(hq, -a[i])
  suma = suma + maxa + a[i]
  minr[i - N] = suma

print(max([maxr[i] - minr[i] for i in range(N + 1)]))

Measured memory_bytes: 39260
#include <bits/stdc++.h>
#define ll unsigned long long 
#define vec vector<ll>
using namespace std;
int main(){
	ll a,b,m;
	cin>>a>>b>>m;
	vec ref,ov;
	while(a--){
		ll in;
		cin>>in;
		ref.push_back(in);
	}
	while(b--){
		ll in;
		cin>>in;
		ov.push_back(in);
	}

	ll x = *min_element(ref.begin(),ref.end());
	ll y = *min_element(ov.begin(),ov.end());

	ll Min = x+y ;
	ll total = 0;
	while(m--){
		ll ai,bi,ci;
		cin>>ai>>bi>>ci;
		ai--;bi--;
		total = ref[ai] + ov[bi] - ci;
		//ll tmin = ref[0]+ov[0];

		if(total<Min){
			Min = total;	
		} 
		//else if(total<Min)Min = total;


	}
	cout<<Min<<endl;

}

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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

const ll MOD = (ll)1e9+7; //change it for other mods

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve(ll testnum)
{
    ll MX = 1000001;
    vll spr(MX, 0);
    for(int i = 2; i < MX; i++) {
        if(spr[i] == 0) {
            for(int j = i; j < MX; j+=i) {
                spr[j] = i;
            }
        }
    }
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i <= n-1; i++) {
    	ll temp = n - i;
    	ll res = 1;
        while(temp > 1) {
            ll curr = spr[temp];
    		ll tempcnt = 1;
            while(temp > 1 && (temp % curr) == 0) {
                temp/=curr;
                tempcnt++;
            }
            res = (res*tempcnt);
        }
        ans += res;
    }
    cout << ans << "\n";
}

int main()
{
    FAST_IO;
    #ifdef STIO 
      freopen("input.txt" , "r", stdin);
      freopen("output.txt" , "w", stdout);
    #endif
    ll t = 1;
    // cin >> t;
    for (ll i = 1; i <= t; i++) {
        // cout << "Case #" << i << ": ";
        solve(i);
    }
}

Measured memory_bytes: 11056
# ABC133B - Good Distance
import sys
input = sys.stdin.readline

def main():
    N, D = list(map(int, input().rstrip().split()))
    X = tuple(tuple(map(int, input().rstrip().split())) for _ in range(N))
    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            r = sum(abs(a - b) ** 2 for a, b in zip(X[i], X[j]))
            if r ** 0.5 == int(r ** 0.5):
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()

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

int main(){
 int n;
  cin >> n;
  int ans = 0;
  for(int i=1;i<=n;i++){
    if(1<=i && i<=9){
      ans ++;
    }
    if(100<=i && i<=999){
      ans++;
    }
    if(10000<=i && i<=99999){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256