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

template <typename T>
struct Heap {
	Heap *l, *r;
	T val;
	Heap() {}
	Heap(int v) : l(nullptr), r(nullptr), val(v) {}
	void Init(int v) {
		l = nullptr; r = nullptr; val = v;
	}
};

template <typename T>
Heap<T>* meld(Heap<T>* a, Heap<T>* b) {
	if (a == nullptr) return b;
	if (b == nullptr) return a;
	if (a->val < b->val) swap(a, b);
	a->r = meld(a->r, b);
	swap(a->l, a->r);
	return a;
}

template <typename T>
Heap<T>* pop(Heap<T>* a) {
	return meld(a->l, a->r);
}

Heap<int> pool[2000000];
int it;

int main()
{
	cin.sync_with_stdio(false);
	int val;
	string S;
	Heap<int>* pq = nullptr;

	while (cin >> S, S != "end") {
		if (S == "extract") {
			printf("%d\n", pq->val);
			pq = pop(pq);
		}
		else {
			cin >> val;
			pool[it].Init(val);
			pq = meld(pq, &pool[it++]);
		}
	}
	return 0;
}

Measured memory_bytes: 38328
n,k=map(int,input().split())
A=list(map(int,input().strip().split(" ")))
dict={}

for i in A:
    if i in dict:
        dict[i] += 1
    else:
        dict[i] = 1

X=[]
sorted_A = sorted(dict.items(), key=lambda x: x[1], reverse=True)
for i,v in sorted_A:
    X.append(v)

ans=0
if len(X)>k:
    for i in X[k:]:
        ans+=i
print(ans)

Measured memory_bytes: 41296
#include <bits/stdc++.h>
using namespace std;
double dp[3001][3001],ans=0.0;
int n;

int main(){
	cin >> n;
	dp[0][0] = 1;
	for(int i = 1 ; i <= n ; i += 1){
		double a;
		cin >> a;
		for(int j = 0 ; j <= i ; j += 1){
			dp[i][j] = dp[i-1][j]*(1.0-a);
			if(j){
				dp[i][j] += dp[i-1][j-1]*a;
			}
		}
	}
	for(int i = n/2+1 ; i <= n ; i += 1){
		ans += dp[n][i];
	}
	cout << setprecision(9) << fixed;
	cout << ans << endl;
}

Measured memory_bytes: 68864
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int k;
    cin>>k;
    for (int i=0;i<s.size();i++) {
        if (i!=s.size()-1) {
            if (s[i]!='a') {
                if (27-(s[i]-96)<=k) {
                    k-=27-(s[i]-96);
                    s[i]='a';
                }
            }
        } else {
            k=k%26;
            int tmp=s[i]+k;
            if (tmp>122) {
                tmp-=26;
            }
            char c=tmp;
            s[i]=c;
        }
    }
    cout<<s<<endl;
}

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

int main()
{
int mx=0,cnt=0;
int n;
   cin>>n;
   if(n==1)cout<<"Hello World"<<endl;
   else 
   {
       int a,b;
       cin>>a>>b;
       cout<<a+b<<endl;
   }
    return 0;

}


Measured memory_bytes: 256
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}
__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

struct binary_inv {
    ll zero, one, inv;
    binary_inv(ll zero = 0, ll one = 0, ll inv = 0) : zero(zero), one(one), inv(inv) {}
};
using S = binary_inv;
S op(S a, S b) { return S{a.zero + b.zero, a.one + b.one, a.inv + b.inv + a.one * b.zero}; };
S e() { return S{0, 0, 0}; };
using F = bool;
S mapping(F f, S x) { return (f ? S{x.one, x.zero, x.zero * x.one - x.inv} : x); };
F composition(F f, F g) { return f ^ g; };
F id() { return false; };


int main() {
    int n, q;
    cin >> n >> q;
    vector<S> a(n);
    rep(i, n) {
        int x;
        cin >> x;
        if (x == 0) a[i].zero++;
        else a[i].one++;
    }
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);

    while (q--) {
        int t, l, r;
        cin >> t >> l >> r;
        l--; r--;
        if (t == 1) {
            seg.apply(l, r+1, true);
        } else {
            cout << seg.prod(l, r+1).inv << '\n';
        }
    }
}

Measured memory_bytes: 20424
# _*_ coding:utf-8 _*_
#  Atcoder_Grand_Contest027-a
#  https://atcoder.jp/contests/agc027/tasks/agc027_a

def  countJoyChild(haveCookie,joyMeterList):
	joyMeterList.sort()
	childsCount = len(joyMeterList)
	sendCookieRangeMax = range(0,childsCount,+1)
	sendCookieChilds = 0
	for i in sendCookieRangeMax :
		haveCookie = haveCookie-joyMeterList[i]
		if 0 <= haveCookie:
			sendCookieChilds = sendCookieChilds + 1
		else:
			break
	if 0 < haveCookie: # => 最後の一人が多すぎる
		sendCookieChilds = sendCookieChilds - 1

	answer = sendCookieChilds
	return answer


if __name__ == '__main__':
	_,X = map(int,input().strip().split(' '))
	A = list(map(int,input().strip().split(' ')))
	solution=countJoyChild(X,A)
	print("{}".format(solution))

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

int main(){
#ifndef ONLINE_JUDGE
	freopen("C:\\Users\\User\\Documents\\input.txt","r",stdin);
#endif
	int T,i,j;
	int n;
	cin>>n;

	vector<vector<int> > a(n,vector<int>(3) ),dp(n,vector<int>(3,0) );

	for(i=0;i<n;++i){
		scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);
	}
	dp[0][0]=a[0][0],dp[0][1]=a[0][1],dp[0][2]=a[0][2];

	for(i=1;i<n;++i){
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+a[i][2];		
	} 		
	printf("%d\n",max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) );
	return 0;
}

Measured memory_bytes: 14400
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll MOD=1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a,b;
	cin >> a >> b;
	cout << a + b/2 << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args)  {
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt(); 
        int []n=new int[N];
        for(int i=0; i<N; i++){
           n[i]=sc.nextInt();
        }
        int max=n[0];
        int min=n[0];
        for(int i=0; i<N; i++){
           if(max<n[i]){
               max=n[i];
           }
           if(min>n[i]){
               min=n[i];
           }
        }
        System.out.println(max-min);
    }    
}

Measured memory_bytes: 21844
a = [
    1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
]
k = int(input())

print(a[k-1])

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

int main() {
    char N[4];
    cin >> N;

    if (N[0] == N[1] && N[1] == N[2]) {
        cout << "Yes" << endl;
    }
    else if (N[1] == N[2] && N[2] == N[3]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>    
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll sml, big;

int main() {
	cin >> sml >> big;
	if(sml > big){
		ll tmp = sml;
		sml = big;
		big = tmp;
	}
	
	if(big-sml >= 2){cout << "Alice";}else{cout << "Brown";}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

string s;

int main()
{
	cin >> s;
	for (int i = 0; i + 1 < s.length(); i++)
		if (s[i] == 'A' && s[i + 1] == 'C') { printf("Yes\n"); return 0; }
	printf("No\n");
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int N, M, Q;
vi x;
int score = 0;
int a[100], b[100], c[100], d[100];
int cal(vi& q)
{
    int ans = 0;
    rep(i, Q)
    {
        if(q[b[i]]-q[a[i]] == c[i]) ans += d[i];
    }
    return ans;
}
void dfs(int v, int p){
    x[p] = v;
    if(++p >= N)
    {
        chmax(score, cal(x));
        return;
    }
    rep2(i, v, M+1)
    {
        dfs(i, p);
    }
}

int main()
{
    
    cin >> N >> M >> Q;
    x.assign(N, 0);
    
    rep(i, Q)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i];--b[i];
    }

    rep(i, N)
    {
        dfs(i+1, 0);
    }
    cout << score << endl;
    // vi A(N, 1);
    // int ans = 0;
    // int pos = 1;

    // while(1)
    // {
    //     int x = 0;
    //     rep(i, Q)
    //     {
    //         if(A[b[i]]-A[a[i]] == c[i]) x += d[i]
    //     }
    //     chmax(ans, x);
    //     rep2()

    //     bool ok = true;
    //     rep(i, N){
    //         if(A[i] > M) ok = false;
    //     }
    //     if(!ok) 
    //     {
    //         break;
    //     }
    // }
    
    
    return 0;
}



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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	LL k,a,b;
	cin >> k >> a >> b;
	if (b-a < 3) {
		cout << k+1 << endl;
		return 0;
	}
	if (k <= a) {
		cout << k+1 << endl;
		return 0;
	}

	cout << a + ((k - (a - 1))/2)*(b-a) + (k - (a - 1))%2 << endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
b=abs(t-a-h[0]*0.006)
ans=0
for i in range(1,n):
    if b>abs(t-a-h[i]*0.006):
        b=abs(t-a-h[i]*0.006)
        ans=i
print(ans+1)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

int main() {
  // https://atcoder.jp/contests/dp/tasks/dp_b

  int N, K;
  cin >> N >> K;
  vector<int> h(N+1);
  for (auto i = 1; i <= N; i++) {
    cin >> h[i];
  }

  // C[i] cost jump 1 -> i 
  vector<int> C(N+1, 0);
  C[0] = 0;
  C[1] = 0;

  for (int i=2; i <= N; i++ ) {

    C[i] = abs(h[i] - h[i-1]) + C[i-1];

    for (auto j=max(1, i-K) ;j <i; j++)  {
      C[i] = min( C[i] , C[j] + abs(h[i] - h[j]) );
    }
  }

  cout << C[N] << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
void solve() {
  int n;
  cin>>n;
  map<string,int>mp;
  for(int i=0;i<n;i++) {
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    mp[s]++;
  }
  long long ans=0;
  for(auto x:mp) {
    long long n=x.second;
    ans+=(1LL*n*(n-1))/2;
  }
  cout<<ans<<endl;

}
int main(int argc, char const *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    solve();
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a), t(b);
    rep(i, a) cin >> s[i];
    rep(i, b) cin >> t[i];
    
    rep(i, q) {
        ll x;
        cin >> x;
        auto it = lower_bound(all(s), x) - s.begin();
        auto it2 = lower_bound(all(t), x) - t.begin();
        ll ans = 1e18;
        if (it < sz(s) && it2 < sz(t)) {
            chmin(ans, abs(s[it] - x) + abs(t[it2] - s[it]));
            chmin(ans, abs(t[it2] - x) + abs(t[it2] - s[it]));
        }
        if (it > 0 && it2 < sz(t)) {
            chmin(ans, abs(s[it - 1] - x) + abs(t[it2] - s[it - 1]));
            chmin(ans, abs(t[it2] - x) + abs(t[it2] - s[it - 1]));
        }
        if (it < sz(s) && it2 > 0) {
            chmin(ans, abs(s[it] - x) + abs(t[it2 - 1] - s[it]));
            chmin(ans, abs(t[it2 - 1] - x) + abs(t[it2 - 1] - s[it]));
        }
        if (it > 0 && it2 > 0) {
            chmin(ans, abs(s[it - 1] - x) + abs(t[it2 - 1] - s[it - 1]));
            chmin(ans, abs(t[it2 - 1] - x) + abs(t[it2 - 1] - s[it - 1]));
        }
        cout << ans << endl;
    }
    
}


Measured memory_bytes: 2944
import java.io.*;
import java.util.StringTokenizer;
   
class Main{
   
static final PrintWriter out=new PrintWriter(System.out);

static class binarySearchTree{

static class Node{
int id;
Node p;
Node l;
Node r;
int deg;
Node(int id){
this.id=id; this.p=null; this.l=null; this.r=null; this.deg=0;
}
}

private static Node root;

binarySearchTree(){
root=null;
}

private static void insert(int v){
Node in=new Node(v);
if(root==null) root=in;
else __insert(in);
}

private static void __insert(Node z){
Node x=root;
Node y=null;
while(x!=null){
y=x;
if(z.id<x.id) x=x.l;
else x=x.r;
}
z.p=y;
if(z.id<y.id) y.l=z;
else y.r=z;
y.deg++;
}

static void print(){
inorder(root);
out.println();
preorder(root);
out.println();
}

static void preorder(Node now){
if(now==null) return;
out.print(" "+now.id);
preorder(now.l);
preorder(now.r);
}
 
static void inorder(Node now){
if(now==null) return;
inorder(now.l);
out.print(" "+now.id);
inorder(now.r);
}
 
static void postorder(Node now){
if(now==null) return;
postorder(now.l);
postorder(now.r);
out.print(" "+now.id);
}
}

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
binarySearchTree tree=new binarySearchTree();
int num=Integer.parseInt(br.readLine());
for(int i=0;i<num;i++){
st=new StringTokenizer(br.readLine());
String command=st.nextToken();
if("insert".equals(command)){
int n=Integer.parseInt(st.nextToken());
tree.insert(n);
}
else tree.print();
}
out.flush();
}
}

Measured memory_bytes: 182452
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=1055;
#define int  long long
int yuanx[maxn],yuany[maxn],X[maxn],Y[maxn],A[maxn],B[maxn],G[maxn][maxn],sum[maxn][maxn];
int K,n;
int size=(long long)9e18;
int haha()
{
	scanf("%llu%llu",&n,&K);
	for(int i=1;i<=n;i++)scanf("%llu%llu",&X[i],&Y[i]),yuanx[i]=X[i],yuany[i]=Y[i],A[i]=X[i],B[i]=Y[i];
	sort(A+1,A+n+1);sort(B+1,B+n+1);int cnt1=unique(A+1,A+n+1)-A,cnt2=unique(B+1,B+n+1)-B;
// cout<<cnt1<<" "<<cnt2<<endl;
	for(int i=1;i<=n;i++)X[i]=lower_bound(A+1,A+cnt1,X[i])-A,Y[i]=lower_bound(B+1,B+cnt2,Y[i])-B,G[X[i]][Y[i]]=1;
	for(int i=1;i<=cnt1;i++)
		for(int j=1;j<=cnt2;j++)
			sum[i][j]=G[i][j]+sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			for(int k=1;k<=n;k++)
				for(int l=1;l<=n;l++)
					if(i!=j||i!=k||i!=l||j!=k||j!=l||k!=l)
					{
						int maxx=max(max(X[i],X[j]),max(X[k],X[l])),maxy=max(max(Y[i],Y[j]),max(Y[k],Y[l]));
						int MAXX=A[maxx],MAXY=B[maxy];
						int minx=min(min(X[i],X[j]),min(X[k],X[l])),miny=min(min(Y[i],Y[j]),min(Y[k],Y[l]));
						int MINX=A[minx],MINY=B[miny];
						if(sum[maxx][maxy]-sum[minx-1][maxy]-sum[maxx][miny-1]+sum[minx-1][miny-1]>=K)
							size=min(size,(MAXX-MINX)*(MAXY-MINY));
					}
	printf("%llu\n",size);
}
#undef int
int sb=haha();
int main(){;}


Measured memory_bytes: 2560
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read


n,*ab = [int(i)-1 for i in read().split()]
n += 1
mp = iter(ab)

g = [[] for _ in range(n)]
for a,b in zip(mp,mp):
    g[a].append(b)
    g[b].append(a)

q = [0]
parent = [-1]*n
depth = [0]*n
#order = []

while q:
    v = q.pop()
    d = depth[v]
    #order.append(v)
    for c in g[v]:
        if c != parent[v]:
            q.append(c)
            parent[c] = v
            depth[c] = d+1

odd = [i for i,d in enumerate(depth) if d&1]
even = [i for i,d in enumerate(depth) if d&1==0]

s0 = list(range(3,n+1,3))
s1 = list(range(1,n+1,3))
s2 = list(range(2,n+1,3))

ans = [0]*n

m = n//3
if len(even) <= m:
    odd,even = even,odd

if len(odd) <= m:
    s2 += s1+s0
else:
    s2 += s0+s1

for i in odd:
    ans[i] = s2.pop()
for i in even:
    ans[i] = s2.pop()
    

print(*ans)




Measured memory_bytes: 70096
#include <iostream>
#include <vector>
#include <functional>
using namespace std;

template <typename T>
struct ReRooting
{
  using F = function<T(T, int)>;
  using F2 = function<T(T, T)>;
  static const int MAX_V = 200010;
  int V;
  vector<int> E[MAX_V];
  vector<T> dp[MAX_V];
  //f(v) = g(merge(f(dp_c1,c1), f(dp_c2,c2), ..., f(dp_ck,ck)) , v)
  F f, g;
  F2 merge;
  T mi; //identity of merge

  ReRooting(int V_, F f_, F2 merge_, T mi_, F g_ = [](T a, int b) { return a; })
      : V(V_), f(f_), merge(merge_), mi(mi_), g(g_) {}

  void add_E(int a, int b)
  {
    E[a].push_back(b);
    E[b].push_back(a);
  }

  T dfs1(int p, int v)
  {
    T res = mi;
    for (int i = 0; i < E[v].size(); ++i)
    {
      if (E[v][i] == p)
        continue;
      dp[v][i] = dfs1(v, E[v][i]);
      res = merge(res, f(dp[v][i], E[v][i]));
    }
    return g(res, v);
  }

  void dfs2(int p, int v, T add)
  {
    for (int i = 0; i < E[v].size(); ++i)
    {
      if (E[v][i] == p)
      {
        dp[v][i] = add;
        break;
      }
    }

    vector<T> pL(E[v].size() + 1), pR(E[v].size() + 1);
    pL[0] = mi;
    for (int i = 0; i < E[v].size(); ++i)
      pL[i + 1] = merge(pL[i], f(dp[v][i], E[v][i]));
    pR[E[v].size()] = mi;
    for (int i = E[v].size(); i > 0; --i)
      pR[i - 1] = merge(pR[i], f(dp[v][i - 1], E[v][i - 1]));

    for (int i = 0; i < E[v].size(); ++i)
    {
      if (E[v][i] == p)
        continue;
      T val = merge(pL[i], pR[i + 1]);
      dfs2(v, E[v][i], g(val, v));
    }
  }

  void calc(int root = 0)
  {
    for (int i = 0; i < V; ++i)
      dp[i].resize(E[i].size());
    dfs1(-1, root);
    dfs2(-1, root, mi);
  }

  T solve(int v)
  {
    T ans = mi;
    for (int i = 0; i < E[v].size(); ++i)
    {
      ans = merge(ans, f(dp[v][i], E[v][i]));
    }
    return g(ans, v);
  }
};

int main()
{
  int n, m;
  cin >> n >> m;
  auto f = [&](long long a, int v) {
    (void)v;
    return (a + 1) % m;
  };
  auto merge = [&](long long a, long long b) {
    return a * b % m;
  };
  ReRooting<long long> re(n, f, merge, 1);
  for (int i = 0; i < n - 1; ++i)
  {
    int x, y;
    cin >> x >> y;
    x--, y--;
    re.add_E(x, y);
  }
  re.calc();
  for (int i = 0; i < n; ++i)
    cout << re.solve(i) << endl;
  return 0;
}


Measured memory_bytes: 38528
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

int main(){
    string a,b;
    while(cin>>a>>b){
        if(a=="0" && b=="0")break;
        int h=0,m=0;
        rep(i,4){
            rep(j,4){
                if(a[i]==b[j]){
                    if(i==j)h++;
                    else m++;
                }
            }
        }
        cout<<h<<" "<<m<<endl;
    }
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<char> p(n);
    vector<char> q(n);

    vector<char> num;
    for(int i=0; i<n; i++) {
        cin>>p[i];
    }
    for(int i=0; i<n; i++) {
        cin>>q[i];
    }
    ll ans=0;
    for (ll i = 0; i < n; i++) {
        num.pb('1'+i);
    }

    ll porder=0;
    ll qorder=0;

    ll cnt = 0;

    do{
        cnt++;
        if(num == p) {
            porder = cnt;
        }
        if(num == q) {
            qorder = cnt;
        }
    }while(next_permutation(num.begin(),num.end()));

    ans = llabs(porder-qorder);

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


Measured memory_bytes: 256
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    ll n,m;
    std::cin >> n>>m;
        
    typedef pair<ll, ll> P;
     struct edge {
         ll to;
         ll cost;
     };
     vector<vector<edge>> G(200010);
     
     for (int i = 0; i < m; i++) {
         ll l,r,c;
         std::cin >> l>>r>>c;
         l--;r--;
         G[l].push_back({r,c});
    }
    
    
     for (int i = 1; i < n; i++) {
         G[i].push_back({i-1,0});
     }


     vector<ll> d(200010,1e16);
     // dを無限にしとかなあかんきがする
     // 距離、頂点のペア。距離が近い順に取り出される
     priority_queue<P, vector<P>, greater<P> > que;
     que.push(P(0, 0));
     d[0] = 0;
     while (!que.empty()) {
         P p = que.top();
         que.pop();
         int v = p.second;
         if (d[v] < p.first) continue;
    
         // 取り出される前に複数回queに追加される可能性がある
         // =は入れたらあかんきがする。更新されたときに次の更新分が入っているから
    	for (int i=0; i<G[v].size(); ++i) {
        	edge e = G[v][i];
             if (d[e.to] > d[v] + e.cost) {
                 d[e.to] = d[v] + e.cost;
                 que.push(P(d[e.to], e.to));
             }   
         }
     }
     
     if(d[n-1]==1e16){
         std::cout << -1 << std::endl;
     }else{
         std::cout << d[n-1] << std::endl;
     }
}

Measured memory_bytes: 12540
/**
 * Created by hiramekun at 21:38 on 2020-05-03.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<string> s(n);
    rep(i, n) cin >> s[i];

    vector<string> ans;
    auto rec = [&](auto &&f, ll idx, ll a_p, ll b_p, ll c_p) -> bool {
        if (idx == n) return true;
        string now = s[idx];
        if (now == "AB") {
            if (a_p > 0 && f(f, idx + 1, a_p - 1, b_p + 1, c_p)) {
                ans.eb("B");
                return true;
            }
            if (b_p > 0 && f(f, idx + 1, a_p + 1, b_p - 1, c_p)) {
                ans.eb("A");
                return true;
            }
            if (!ans.empty()) ans.pop_back();
            return false;
        } else if (now == "AC") {
            if (a_p > 0 && f(f, idx + 1, a_p - 1, b_p, c_p + 1)) {
                ans.eb("C");
                return true;
            }
            if (c_p > 0 && f(f, idx + 1, a_p + 1, b_p, c_p - 1)) {
                ans.eb("A");
                return true;
            }
            if (!ans.empty()) ans.pop_back();
            return false;
        } else { // now == "BC"
            if (b_p > 0 && f(f, idx + 1, a_p, b_p - 1, c_p + 1)) {
                ans.eb("C");
                return true;
            }
            if (c_p > 0 && f(f, idx + 1, a_p, b_p + 1, c_p - 1)) {
                ans.eb("B");
                return true;
            }
            if (!ans.empty()) ans.pop_back();
            return false;
        }
    };
    if (rec(rec, 0, a, b, c)) {
        cout << "Yes" << '\n';
        reverse(all(ans));
        cout << ans << '\n';
    } else {
        cout << "No" << '\n';
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 27768
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
goukei=sum(b)
for i in range(n-1):
  if a[i]==a[i+1]-1:
    goukei=goukei+c[a[i]-1]
print(goukei)

Measured memory_bytes: 3064
package main

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

func main() {

	var n, q int
	fmt.Scan(&n, &q)
	A := make([][]string, n)
	for t:=0; t<n; t++ {
		A[t] = append(A[t],"NULL")
	}
	
	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	//var writer = bufio.NewWriter(os.Stdout)

	for i:=0; i<q; i++ {
		
		scanner.Scan()
		query, _ := strconv.Atoi(scanner.Text())

		switch query {
		case 0 :
			scanner.Scan()
			t, _ := strconv.Atoi(scanner.Text())
			scanner.Scan()
			x := scanner.Text()
			if A[t][0] == "NULL" {
				A[t][0] = x
			} else {
				A[t] = append(A[t], x)
			}
		case 1 :
			scanner.Scan()
			t, _ := strconv.Atoi(scanner.Text())
			if A[t][0] != "NULL" {
				for idx:=0; idx<len(A[t]); idx++ {
					if idx==len(A[t])-1 {
						//fmt.Fprintln(writer, A[t][idx])
						fmt.Println(A[t][idx])
					} else {
						//fmt.Fprintf(writer, A[t][idx], " ")
						fmt.Print(A[t][idx], " ")
					}
				}
				//_ = writer.Flush()
			} else {
				fmt.Println()
			}
		case 2 :
			scanner.Scan()
			t, _ := strconv.Atoi(scanner.Text())
			A[t] = A[t][0:1]
			A[t][0] = "NULL"
		}	
	}
}



Measured memory_bytes: 43284
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
using namespace std;

int main() {
    int N;
    int count=1;

    cin>>N;
    vector<int> d(N);
    for(int i=0;i<N;i++)
    {
      cin>>d[i];
    }
    sort(d.begin(),d.end());
    reverse(d.begin(),d.end());
    int n=d[0];
    for(int i=1;i<N;i++)
    {
      if(d[i]<n)
      {
        count++;
        n=d[i];
      }
    }
  
    cout<<count<<endl;
    return 0;
}

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

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin >> s;
    int n = s.size();
    int res = n;
    for(int i = 0; i < n; i++)
        if(s[i] != s[i+1])
            res = min(res, max(i+1, n-i-1));

    cout << res;


    return 0;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

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


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B, XYC):
    ans = min(A) + min(B)
    for x, y, c in XYC:
        t = A[x-1] + B[y-1] - c
        ans = min(t, ans)
    return ans


def main():
    A, B, M = read_int_n()
    A = read_int_n()
    B = read_int_n()
    XYC = [read_int_n() for _ in range(M)]
    print(slv(A, B,XYC))


if __name__ == '__main__':
    main()


Measured memory_bytes: 40692
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in = new Scanner(System.in);
		while(in.hasNext())
		{
			int n=in.nextInt();
			if(n==0)
				return;
			int a[]=new int[n];
			int b[]=new int[n];

			for(int i=0; i<n;i++)
			{
				a[i]=in.nextInt();
				b[i]=in.nextInt();
			}
			for(int i=0;i<n;i++)
			{
				int m=i;
				for(int j=i;j<n; j++)
				{
					if(b[j]<b[m])
						m=j;
				}
				int tmp =b[i];
				b[i] = b[m];
				b[m] = tmp;
				tmp =a[i];
				a[i]=a[m];
				a[m]=tmp;
			}
			//for(int i=0;i<n; i++)
			//System.out.println(a[i]+" "+b[i]);
			boolean flag=true;
			int T=0;
			int W=0;
			for(int i=0;i <n;i++)
			{
				T+=a[i];
				W=b[i];
				if(T>W)
					flag=false;
			}
			if(flag)
				System.out.println("Yes");
			else
				System.out.println("No");
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
long long l,r,p[100003],n;
int main()
{
	scanf("%lld",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%lld",&p[i]);
	}
	l=r=2;
	for (int i=n;i;i--)
	{
		// printf("%lld %lld %lld\n",p[i],l,r);
		if (l%p[i])l=l-l%p[i]+p[i];
		if (r%p[i])r-=r%p[i];
		if (r-l<0)
		{
			printf("-1\n");
			return 0;
		}
		r+=p[i]-1;
		/*int tmp1=(l+p[i]-1)/p[i];
		int tmp2=r/p[i];
		if (l/p[i]==r/p[i]&&l%p[i]&&r%p[i])
		{
			printf("-1\n");
			return 0;
		}
		l=tmp1*p[i];
		r=(tmp2+1)*p[i]-1;*/
	}
	printf("%lld %lld\n",l,r);
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

#define SIZE 100000

struct process{
  char name[10];
  int time;
};

struct process p[SIZE];
int head,tail;

void enqueue(struct process x){
  p[tail] = x;
  if(tail+1==SIZE) tail = 0;
  else tail++;
}

struct process dequeue(){
  struct process y;
  y = p[head];
  if(head+1 == SIZE) head = 0;
  else head++;
  return y;
}


int main(void){
  int n,q;
  int i;
  int t = 0;
  struct process tmp;
  scanf("%d", &n);
  scanf("%d", &q);
  
  //  printf("n = %d, q = %d\n",n,q);
  for(i=0; i<n; i++){
    scanf("%s", p[i].name);
    scanf("%d", &p[i].time);
  }
  /*
  for(i=0; i<n; i++){
    printf("%s %d\n", p[i].name, p[i].time);
  }
  */  
  head = 0;
  tail = n;
  while(1){
    if(head==tail) break;
    tmp = dequeue();
    if(tmp.time <= q){//??????time???q??\?????????
      t += tmp.time;
      printf("%s %d\n", tmp.name, t);
    }
    else{ 
      tmp.time -= q;
      t += q;
      enqueue(tmp);
    }
  }
  
  return 0;
}

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

int main() {
  int a, b, c; cin >> a >> b >> c;
  if (a == b && b == c)
    puts("Yes");
  else
    puts("No");
}

Measured memory_bytes: 256
const config = {
    input: '/dev/stdin',
    newline: '\n'
};

const line = require('fs').readFileSync(config.input, 'utf-8').split(config.newline);

let count = 0;

const bsort = arr => {
    let flag = true;
    while (flag) {
        flag = false;
        for (let i = arr.length-1; i > 0; i--) {
            if (arr[i] < arr[i-1]) {
                const tmp = arr[i];
                arr[i] = arr[i-1];
                arr[i-1] = tmp;
                flag = true;
                count++;
            }
        }
    }

    return arr;
};

console.log(bsort(line[1].split(' ').map(x => parseInt(x))).join(' '));
console.log(count);



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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b && b==c)cout << "No" << endl;
  else if((a==b)||(b==c)||(a==c))cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = [[int(x) for x in input().split()] for _ in range(n)]
b = [int(input()) for _ in range(m)]
for i in range(n):
    ans=0
    for j in range(m):
        ans += a[i][j] * b[j]
    print(ans)


Measured memory_bytes: 6016
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<int,int> P;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int dh[4]={0,1,0,-1};
int dw[4]={1,0,-1,0};

int H,W;
int N;
int a[10002];
vector<int> mochi;
int c[103][103];
int main (){
      cin>>H>>W>>N;
      rep1(i,N) cin>>a[i];
      rep1(i,N)rep1(j,a[i]){
            mochi.push_back(i);
      }
      int j=1;
      rep0(i,H+2)rep0(j,W+2){
            if(i==0||i==H+1||j==0||j==W+1)c[i][j]=-1;
            else c[i][j]=0;
      }
      int h=1,w=1,d=0;
      rep0(i,H*W){
            if(c[h][w]==0){
                  c[h][w]=mochi[i];
                  h+=dh[d];
                  w+=dw[d];
            }
            else{
                  h-=dh[d];
                  w-=dw[d];
                  d=(d+1)%4;
                  h+=dh[d];
                  w+=dw[d];
                  c[h][w]=mochi[i];
                  h+=dh[d];
                  w+=dw[d];
            }
      }
      rep1(i,H){
            rep1(j,W){
                  if(j==W) cout<<c[i][j]<<endl;
                  else cout<<c[i][j]<<" ";
            }
      }
      return 0;
}


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

int main(){
    int n,a;
    set<int> s;
    vector<int> v;
    
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        s.insert(a);
        v.push_back(a);
    }
    int len=v.size()-s.size();
    if(len%2) cout<<v.size()-len-1<<endl;
    else cout<<v.size()-len<<endl;
}

Measured memory_bytes: 5368
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<numeric>
#include<cmath>

#define forf(i, a, b, c) for(int i=a; i<b; i=i+c)
#define forb(i, a, b, c) for(int i=a; i>=b; i=i-c)

typedef long long ll;

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> h(n);
	forf(i, 0, n, 1){
		cin >> h[i];
	}

	vector<int> dp(n);
	dp[0] = 0;
	forf(i, 1, n, 1){
		dp[i] = dp[i-1] + abs(h[i] -h[i-1]);
		if(i >= 2){
			dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
		}
	}
	cout << dp.back() << "\n";

	return 0;
}

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

long long lucas[87];

void lucas_init(){
  lucas[0] = 2LL;
  lucas[1] = 1LL;
  
  for(int i=2; i<87; i++){
    lucas[i] = lucas[i-1] + lucas[i-2];
  }
}

int main() {
  int N;
  cin >> N;
  
  lucas_init();
  
  cout << lucas[N] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <math.h>
#include <fstream>


using namespace std;

int main()
{
 int a;
 int num1,num2;
 cin>>num1;
 cin>>num2;
if(num1%2==0)a=num1/2;
else if(num1%2==1)a=(num1+1)/2;
if(num2<=a)cout<<"YES"<<endl;
if(num2>a)cout<<"NO"<<endl;
return 0;
}	


Measured memory_bytes: 256
N, K = map(int, input().split())
DD = []
AA = []
for _ in range(K):
  d = int(input())
  DD.append(d)
  A = list(map(int, input().split()))
  a = len(A)
  for i in range(a):
    AA.append(A[i])
AAA = list(set(AA))
aaa = len(AAA)

print(N-aaa)



Measured memory_bytes: 9188
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
template<typename T>
T minch(T& l, T& r) {
    return l = min(l, r);
}
template<typename T>
T maxch(T& l, T& r) {
    return l = max(l, r);
}
template<typename T>
void output(const T& val) {
    cout << val << endl;
}
template<typename T>
void output(const vector<T>& vec, const bool newline = false) {
    for (const T& val : vec)cout << val << (newline ? '\n' : ' '); cout << endl;
}
template<typename T>
void output(const vector<vector<T>>& mat) {
    for (const auto& row : mat)output(row);
}
// ============ template finished ============


vector<int> doubles;
int mpow(int size) {
    int res = 1;
    rep(i, size)res *= 2;
    return res;
}

int buttle(
    const string& s,
    const vector<int>& P,
    int l,
    int r
) {
    const int M = P.size();
    if (P[l] > P[r])swap(l, r);
    return s[P[r] - P[l] - 1] == '0' ? l : r;
}

int dfs(
    const string& s,
    const vector<int>& P,
    vector<vector<int>>& memo,
    int L,
    int size
) {
    const int M = P.size();
    if (memo[L][size] != -1)return memo[L][size];
    if (size == 1) return memo[L][size] = buttle(s, P, L, (L + 1) % M);

    int nsize = size - 1;
    int mid = (L + doubles[nsize]) % M;
    int winl = dfs(s, P, memo, L, nsize);
    int winr = dfs(s, P, memo, mid, nsize);
    return memo[L][size] = buttle(s, P, winl, winr);
}

int main()
{
    // input
    int N;
    string s;
    cin >> N >> s;
    const int M = mpow(N);
    vector<int> P(M);
    rep(i, M) cin >> P[i];

    // process
    rep(i, 25)doubles.push_back(mpow(i));
    vector<vector<int>> memo(M, vector<int>(N + 1, -1));
    rep(i, M) {
        cout << P[dfs(s, P, memo, i, N)] << endl;
    }

    return 0;
}



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

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

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

	cout << "NA" << endl;
}

Measured memory_bytes: 256
N = input()
A = list(map(str, input().split()))
B=[]
C=[]
l=[]
m=[]
n=0
i=0
for a in range(int(N)):
    if int(A[a])%2==0:
       B.append(A[a])
       i=i+1
for a in range(int(i)):
    if int(B[a])%3==0 or int(B[a])%5==0:
       n=n+1
if n==i:
   print("APPROVED")
else:
   print("DENIED")


Measured memory_bytes: 3064
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	cnt := map[int]int{}
	for i := 0; i < n; i++ {
		cnt[nextInt()]++
	}

	ok := (cnt[0] == n) || (len(cnt) == 2 && cnt[0] == n/3)
	if !ok && len(cnt) == 3 {
		ok = true
		nums := make([]int, 0)
		for k, v := range cnt {
			if v != n/3 {
				ok = false
			}
			nums = append(nums, k)
		}
		ok = ok && (nums[0]^nums[1]^nums[2] == 0)
	}

	if ok {
		puts("Yes")
	} else {
		puts("No")
	}
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


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

typedef long long ll;
ll H, W, A, B;

int main() {
  cin >> H >> W >> A >> B;
  for (ll i = 0; i < H; ++i) {
    for (ll j = 0; j < W; ++j) {
      cout << ((i < B) == (j < A) ? 0 : 1);
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
	int main(){
      int n;
      cin >> n;
      int countAC=0, countWA=0, countTLE=0, countRE=0;
      vector<string> s(n);
      for (int i = 0; i < n; i++ ){
        cin >> s.at(i);
      }
      for (int j = 0; j < n;  j++){
        if(s.at(j) == "AC"){
           countAC++;
        }
      }
        for (int j = 0; j < n;  j++){
                if(s.at(j) == "WA"){
          countWA++;
        }
        }
        for (int j = 0; j < n;  j++){
                if(s.at(j) == "TLE"){
          countTLE++;
        }
        }

       countRE = n-countAC -countWA -countTLE;
      cout <<"AC"<< " " << "x" << " "<<countAC<< endl;
      cout <<"WA"<< " " << "x" <<" "<<countWA<< endl;
      cout <<"TLE"<< " " << "x" <<" "<<countTLE<< endl;
      cout <<"RE"<< " " << "x" <<" "<<countRE<< endl;
    }

Measured memory_bytes: 6424
N = int(input())
S = list(map(int, input().split()))

def battle(s):
  tmp = [i for i in s if i > 0]
  if len(tmp) == 1:
    return tmp[0]
  p = min(tmp)
  f = False
  for i in range(N):
    if not f and s[i] == p:
      f = True
    else:
      s[i] = s[i] % p
  return battle(s)

print(battle(S))


Measured memory_bytes: 64024
#include<bits/stdc++.h>
using namespace std;
pair<bool, int> a[100000];
int main() {
	int n, m, ans = 0;
	cin >> n >> m;
	a[0].first = true;
	for (int i = 0; i < n; i++) {
		a[i].second = 1;
	}
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		if (a[x-1].first == true&&a[x-1].second>0) {
			a[y-1].first = true;
		}
		a[y - 1].second++;
		a[x - 1].second--;
		if (a[x - 1].second == 0) {
			a[x - 1].first = false;
		}
	}
	for (int i = 0; i < n; i++) {
		if (a[i].first == true) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
mod = 10 ** 9 + 7

N = INT()
A = LIST()

tmp = A[0]
 
for i in range(1, N):
    tmp = tmp*A[i]//gcd(tmp, A[i])

ans = 0
for x in A:
    ans += tmp//x
print(ans%mod)


Measured memory_bytes: 6212
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int n,m,a,b;
long long lst;
const long long md=1e9+7;
long long p[200010];
long long qmul(long long x,int p)
{
	if(p==0)return 1LL;
	if(p==1)return x;
	long long res=qmul(x,p/2);
	res=res*res%md;
	if(p&1)res=res*x%md;
	return res;
}
long long C(int x,int y)
{
	if(x<y)return 0LL;
	return p[x]*qmul(p[x-y]*p[y]%md,md-2)%md;
}
long long gtans(int x,int y)
{
	return C(x+y-2,y-1);
}
int main()
{
	scanf("%d%d%d%d",&n,&m,&a,&b);
	p[0]=1LL;
	for(int i=1;i<=200010;i++)p[i]=p[i-1]*i%md;
	long long ans=gtans(n,m);
	a=n+1-a;
	while(a<=n && b>0)
	{
		ans=ans+md-gtans(a,b)*gtans(n+1-a,m+1-b)%md;
		if(ans>=md)ans-=md;
		a++;
		b--;
	}
	printf("%lld",ans);
	return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define pr(a, b) pair<a, b>
#define si set<int>
#define sl set<long long>
#define pq prioirty_queue
#define all(v) v.begin(),v.end()
#define left  (2*idx)+1
#define right (2*idx)+2
#define frt(i,a,b) for(ll i=a; i<b; i++)
#define rew(i,a,b) for(ll i=a; i>=b; i--)
#define fre(i,a,b) for(ll i=a; i<=b; i++)

#define mod %
#define N 100007
#define MOD (ll)(1e9 + 7)
#define test if(true)


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

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

	frt(i, 0, n+1)
	{
		cin >> a[i];
	}

	frt(i, 0, n)
	{
		cin >> b[i];
	}

	ll cnt = 0;
	rew(i, n-1, 0)
	{
		if(a[i+1] >= b[i])
		{
			cnt+=b[i];
		}
		else
		{
			b[i]-=a[i+1];
			cnt+=a[i+1];

			cnt+=min(a[i], b[i]);
			a[i] = a[i] - min(a[i], b[i]);
			
		}
	}

	cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 1792