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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

struct UnionFind {
    static const int MAX = 1000000;
    ll par[MAX];
    void init(int N) {
        for (int i=0; i<N; ++i) {
            par[i] = -1;
        }
    }
    void init() {
        for (int i=0; i<MAX; ++i) {
            par[i] = -1;
        }
    }
    ll find(int x) {
        if (par[x] < 0) return x;
        else return par[x] = find(par[x]);
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (par[x] > par[y]) {
            int tmp = x;
            x = y;
            y = tmp;
        }
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    // そのグループの木の大きさを返す
    ll size(int x) {
        return -par[find(x)];
    }
};

int main()
{
    ll N, M;
    cin >> N >> M;
    UnionFind uf;
    uf.init(N);

    vector<ll> a(M), b(M);
    rep(i, M) cin >> a[i] >> b[i];

    vector<ll> ans;
    ans.push_back(N*(N-1)/2);
    ll prev = N*(N-1)/2;
    for (int i=M-1; i>0; --i) {
        int u = a[i], v = b[i];
        if (i == M-1) {
            prev--;
        }
        else {
            if (uf.same(u, v)) ;
            else  {
                prev -= (ll)uf.size(u)*uf.size(v);
            }
        }
        uf.unite(u, v);
        ans.push_back(prev);
    }

    reverse(ans.begin(), ans.end());
    rep(i, ans.size()) cout << ans[i] << endl;

}


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

int main() {
  int N,i,s=0;
  cin >> N;
  vector<int> B(N-1);
  for(i=0; i<N-1; i++)
    cin >> B.at(i);
  
  s = B.at(0) + B.at(N-2);
  for(i=0; i<N-2; i++)
    if(B.at(i) < B.at(i+1))
      s += B.at(i);
    else
      s += B.at(i+1);
  
  cout << s << endl;
}

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

using namespace std;

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

int main() {
	int n, a, b; scanf("%d%d%d", &n, &a, &b);
	int m; scanf("%d", &m);
	vector<tuple<int, int, int>> v;
	FOR(i, m) {
		int x, y, z; scanf("%d%d%d", &x, &y, &z);
		v.emplace_back(x, y - 1, z - 1);
	}
	int k; scanf("%d", &k); k--;
	reverse(v.begin(), v.end());
	for (auto& xyz : v) {
		int x, y, z; tie(x, y, z) = xyz;
		if (x == 0) {
			if (y <= k && k <= z) k = y + z - k;
		}
	}
	reverse(v.begin(), v.end());
	int val = a + b * k;
	for (auto& xyz : v) {
		int x, y, z; tie(x, y, z) = xyz;
		if (x == 0) {
			if (y <= k && k <= z) k = y + z - k;
		} else if (x == 1) {
			if (y <= k && k <= z) val++;
		} else {
			if (y <= k && k <= z) val /= 2;
		}
	}
	cout << val << endl;
}

Measured memory_bytes: 5940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		int n = sc.nextInt();
		int[] array = new int[n+1];
		int max_dis = -1;

		for(int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		array[n] = k+array[0];

		for(int i = 1; i < n+1; i++) {
			int temp = array[i]-array[i-1];
			if(temp > max_dis) {
				max_dis = temp;
			}
		}
		System.out.println(k-max_dis);
	}
}



Measured memory_bytes: 68244
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    
    auto f = [](int n){
        while(n >= 100){
            n /= 100; 
        }
        if(n >= 10) return false;
        else return true;
    };

    int ans = 0;
    REP(i, N){
        if(f(i+1))ans++;
    }
    pr(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main()
{
    Hello
    int n;
    cin >> n;
    int a[n + 5], b[n + 5];
    ll ans = 0;
    for(int i = 0; i <= n; i++) cin >> a[i];
    for(int i = 0; i <  n; i++) cin >> b[i];
    for(int i = 0; i <  n; i++){
        ans += (min(a[i], b[i]));
        b[i] -= min(a[i], b[i]);
        ans += (min(a[i + 1], b[i]));
        a[i + 1] -= min(a[i + 1], b[i]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4384
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
lis = []
for i in range(N):
  for _ in range(A[i]):
    lis.append(str(i+1))
ans= []
for i in range(H):
  if i%2==0:
    add = lis[:W]
  else:
    add = lis[:W][::-1]
  ans.append(' '.join(add))
  lis = lis[W:]
print(*ans,sep='\n')

Measured memory_bytes: 39792
# 2020/02/11
# AtCoder Beginner Contest 103 - C

import math
import fractions

# Greatest Common Divisor(GCD)  
def gcd_fgf(a, b):
    return fractions.gcd(a, b)

# Least Common Multiple(LCM)
def lcm_fgf(a, b):
    return int(a * b // fractions.gcd(a, b))

# Input
n = int(input())
a = list(map(int,input().split()))

# Calc Co-LCM
work_lcm = a[0]
for i in range(1, len(a)):
    work_lcm = lcm_fgf(work_lcm, a[i])

m = work_lcm - 1

# Sum remains
fm = 0
for i in range(len(a)):
    fm = fm + (m % a[i])

ans = fm    
# Output
print(ans)

Measured memory_bytes: 5340
#include <bits/stdc++.h>
using namespace std;
bool mark[26];
int main()
{
	string s;
	cin>>s;
	int n=s.size();
	if(n==26)
	{
		for(int i=n-1;i>=0;i--)
		{
			memset(mark,0,sizeof(mark));
			for(int j=0;j<i;j++)
			{
				mark[s[j]-'a']=1;
			}
			int nxt=s[i]-'a'+1;
			while(nxt<26 && mark[nxt])
				nxt++;
			if(nxt==26)
				continue;
			string t="";
			for(int j=0;j<i;j++)
				t+=s[j];
			t+=char(nxt+'a');
			mark[nxt]=1;
			cout<<t<<"\n";
			return 0;
		}
	}
	else
	{ 
		for(int i=0;i<s.size();i++)
		{
			mark[s[i]-'a']=1;
		}
		int nxt=0;
		while(mark[nxt])
			nxt++;
		s+=char(nxt+'a');
		cout<<s<<"\n";
		return 0;
	}
	cout<<"-1\n";
 	return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int x = Integer.parseInt(sc.next());
		boolean flag = true;
		
		int lim = (int)Math.sqrt(2 * x);
		
		for(int i = 0; i < 2*x; ++i) {
		    for(int j = 2; j < lim; ++j) {
		        
		        if((x + i) % j != 0) {
		            flag = true;
		            continue;
		        }
		        else {
		            flag = false;
		            break;
		        }
		    }
		    
		    if(flag) {
		        System.out.println(x + i);
		        break;
		    }
		    else continue;
		}
    }
}

Measured memory_bytes: 23124
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
    string str;
    cin >> str;
    if(str=="Sunny")    cout << "Cloudy";
    else if(str=="Cloudy")  cout << "Rainy";
    else    cout << "Sunny";
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

typedef long long LL;
const int Mod = 998244353;
const int MN = 100005;

int N;
char Str[3 * MN];
int sr[MN], cr;
int sg[MN], cg;
int sb[MN], cb;
int A[3 * MN];
int Ans;

int main() {
	scanf("%d", &N), Ans = 1;
	scanf("%s", Str + 1);
	for (int i = 1; i <= 3 * N; ++i) {
		if (Str[i] == 'R') sr[++cr] = i;
		if (Str[i] == 'G') sg[++cg] = i;
		if (Str[i] == 'B') sb[++cb] = i;
	}
	for (int i = 1; i <= N; ++i)
		A[std::min(sr[i], std::min(sg[i], sb[i]))] = 1,
		A[std::max(sr[i], std::max(sg[i], sb[i]))] = 2,
		Ans = (LL)Ans * i % Mod;
	for (int i = 1, S = 0; i <= 3 * N; ++i) {
		if (!A[i]) Ans = (LL)Ans * S % Mod, --S;
		if (A[i] == 1) ++S;
	}
	for (int i = 3 * N, S = 0; i >= 1; --i) {
		if (!A[i]) Ans = (LL)Ans * S % Mod, --S;
		if (A[i] == 2) ++S;
	}
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 2816
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int n;string s;
int main(){
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	in(n);cin>>s;
	if(n>=3200)cout<<s<<endl;
	else cout<<"red"<<endl;
	return 0;
}

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

#define ll long long
#define debug(x) cout<<x<<"DE"<<endl;

using namespace std;

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

    ll n,x=0,y=0;
    cin>>n;
    ll l1[n+1];
    for(int i=1;i<=n;i++){
        cin>>l1[i];
        if(l1[i]>=x)x=l1[i],y++;
    }
    cout<<y<<endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int

void solve(long long N, long long X, long long T) {
  cout << (N+X-1)/X*T<<endl;
}

signed main() {
  long long N;
  scanf("%lld", &N);
  long long X;
  scanf("%lld", &X);
  long long T;
  scanf("%lld", &T);
  solve(N, X, T);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 3660
// Created by Kshitij Anand NSIT
#include <bits/stdc++.h>


using namespace std;


#define int long long
#define pb push_back
#define P pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define vc vector<char>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mp(a, b) make_pair(a, b)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define fill(arr,val) memset(arr,val,sizeof(arr))
#define db(x)  cout<<#x<<" : "<<x<<endl


const int N = 1000000007;

void solve(){

    int n,a,b,c, ans=0, count=0, sum=0;
    cin>>n;
    int arr[n];
    unordered_map<int , int> freq;
    for(int i=0;i<n;i++){
      cin>>arr[i];
      freq[arr[i]]++;
    }

    unordered_map<int , bool> multiples;

    for(auto x : freq){

        for(int i=2*x.F; i<=1e6; i+= x.F) {
            multiples[i] = true;
        }
    }

    for(int i=0; i<n; i++) {

        if(freq[arr[i]] ==1 && !multiples[arr[i]]){
            ans++;
        }
    }

    cout<<ans<<endl; 
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    
  //  int t; cin>>t; while(t--)
    {     
      solve();
    }

  return 0;
}


Measured memory_bytes: 52292
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)
{
	int n, x, a[100001], i;
	long long int ans = 0;
	scanf("%d%d", &n,&x);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		ans += a[i];
	}
	for (i = 0; i < n; i++) {
		if (a[i] + a[i + 1] > x) {
			if (a[i] + a[i + 1] - x <= a[i + 1]) {
				a[i + 1] -= a[i] + a[i + 1] - x;
				//ans += a[i] + a[i + 1] - x;
			}
			else {
				a[i + 1] = 0;
				a[i] -= a[i] - x;
				//ans += a[i] + a[i + 1] - x;
			}
		}
	}
	for (i = 0; i < n; i++) {
		ans -= a[i];
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
   int n;
   cin >> n;
   int x=0;
   int w=n;
   while (n){
      x+=n%10;
      n/=10;
   }
   if (w%x==0)cout << "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;



int main(){
    ll N; cin >> N;
    string S; cin >> S;
    map<char, ll> M;
    for(auto ch : S) M[ch]++;
    ll ans = 0;
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            for(int k = 0; k < 10; k++){
                char s1 = 48+i, s2 = 48+j, s3 = 48+k;
                ll idx = 0;
                bool flag = false;
                for(; idx < N; idx++){
                    if(S[idx] == s1){idx++; break;}
                }
                for(;idx < N; idx++){
                    if(S[idx] == s2){idx++; break;}
                }
                for(; idx < N; idx++){
                    if(S[idx]== s3){
                        idx++; flag = true; break;
                    }
                }
                if(flag) ans++;

            }
        }
    }
    cout << ans << endl;


} 


Measured memory_bytes: 3712
'use strict'
function main(input) {
  input = input.trim().split('\n')
  const NM = input.shift().split(' ').map(v => Number(v))
  input = input.map(v => Number(v))
  
  let ans = new Array(NM[0]+1).fill(1)
  let broken = -1
  let NG = false

  input.forEach(n => {
    if (broken + 1 === n) { NG = true }
    ans[n] = 0
    broken = n
  })
  if (NG) { console.log(0); return }
  
  for (let n = 2; n <= NM[0]; n++) {
    ans[n] = ans[n] * (ans[n-2] + ans[n-1]) % 1000000007
  }
  console.log(ans[NM[0]])
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 16740
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<ll>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc ll t; cin >> t; while(t--)

using namespace std;
string repeat(string s, ll n) {
    string s1 = "";
    for (ll i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
ll gcd(ll a, ll b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
vector<ll> v(10000005,1);
void  solve(){
  ll n;
  cin>>n;
  ll a[n];
  ll money=1000;
  rep(i,0,n) cin>>a[i];
  ll mx=money;
  ll stocks=0;
  ll buy=1;
  for(ll i=0;i<n;){

    if(buy){
      while(i!=n-1 && a[i]>=a[i+1]){ i++;}
      if(i==n-1){
        money+=stocks*a[n-1];
        mx=max(mx,money);
        cout<<mx<<endl;
        return;
      }
      // cout
      stocks+= money/a[i];
      // cout<<stocks<<endl;
      money%=a[i];
      buy=0;
    }
    else{
      while(i!=n-1 && a[i]<=a[i+1]){ i++;}
      if(i==n-1){
        money+=stocks*a[n-1];
        mx=max(mx,money);
        cout<<mx<<endl;
        return;
      }
      money+=stocks*a[i];
      stocks=0;
      mx=max(mx,money);
      buy=1;
    }
    // cout<<stocks<<endl;
  }
  // cout<<stocks<<endl;
  money+=stocks*a[n-1];
  cout<<mx<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


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



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

	int ans=0,Alice=0,Bob=0;
	vector<int> A(n);

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

	sort(A.begin(), A.end(),greater<int>());

	for(int i=0;i<n;i++){
		if(i%2==0){
			Alice += A[i];
		}else{
			Bob += A[i];
		}

	}


	ans = Alice-Bob;
	cout << ans;
	
	
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  in(ll, n);
  V<ll> a(n);
  rep(i, n) cin >> a[i];
  rep(i, n) a[i] -= i + 1;
  sort(all(a));
  ll ans = 0;
  rep(i, n) ans += abs(a[i] - a[n / 2]);
  if (n % 2 == 0) {
    ll sum = 0;
    rep(i, n) sum += abs(a[i] - a[n / 2 - 1]);
    ans = max(ans, sum);
  }
  out(ans);
}

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

using namespace std;

int main() {
    int count0=0, count1=0;
    string str;
    
    cin >> str;
    
    for(int i=0; i<str.size(); i++) {
        if(str[i]=='0') {
            count0++;
        } else {
            count1++;
        }
    }
    
    if(count1>count0) {
        cout << count0*2 << endl;
    } else {
        cout << count1*2 << endl;
    }

    return 0;
    
}

Measured memory_bytes: 512
n ,y = map(int,input().split())

for i in range(n+1):
    for j in range(n+1):
        noguti = (y - (i * 10000 + j * 5000)) // 1000
        if noguti + i + j == n and noguti >= 0:
            print(i,j,noguti)
            quit()

print(-1,-1,-1)

Measured memory_bytes: 3060
from collections import defaultdict

N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]

base = K - Q

d = defaultdict(int)
for a in A:
    d[a] += 1

for i in range(N): 
    if base > 0:
        print('Yes')
    else:
        n = i + 1
        if base + d[n] > 0:
            print('Yes')
        else:
            print('No')
        

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

using namespace std;

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

int min(int X, int Y) {
    return X < Y ? X : Y;
}

int main() {
    int X, Y, Z, K; cin >> X >> Y >> Z >> K;
    long A[X], B[Y], C[Z];
    REP(0, i, X) cin >> A[i];
    REP(0, i, Y) cin >> B[i];
    REP(0, i, Z) cin >> C[i];

    vector<long> v;
    REP(0, i, X) REP(0, j, Y) {
        v.push_back(A[i] + B[j]);
    }

    sort(v.begin(), v.end(), greater<long>());

    vector<long> w;
    REP(0, i, min(3000, v.size())) {
        REP(0, j, Z) {
            w.push_back(v[i] + C[j]);
        }
    }

    sort(w.begin(), w.end(), greater<long>());

    REP(0, i, K) cout << w[i] << endl;

    return 0;
}


Measured memory_bytes: 43236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const ll INF = 1LL << 60;
const ll MOD = (ll) 1e9 + 7;

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >>d;
    if (a != c) {
        cout << 1 << "\n";
    }
    else {
        cout << 0 << "\n";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long zh[55][55];
long long two[55];
int main()
{
    int n,p,ji,ou,i,j;
    int a[55];
    long long ans;
    cin>>n>>p;ji=ou=0;ans=0;
    for(i=0;i<=50;i++)
    {
        zh[i][0]=1;
        for(j=1;j<=i;j++)
            zh[i][j]=zh[i-1][j]+zh[i-1][j-1];
    }
    two[0]=1;
    for(i=1;i<=50;i++)
        two[i]=two[i-1]*2;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        if (a[i]%2==0) ou++;
        else ji++;
    }
    if (p==0)
    {
        for(i=0;i<=ji;i+=2)
            ans+=zh[ji][i];
        ans*=two[ou];
    }
    else
    {
        for(i=1;i<=ji;i+=2)
            ans+=zh[ji][i];
        ans*=two[ou];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  Chokudai_Contest_004
//
//  Created by tolemy on 2019/08/31.
//  Copyright © 2019 tolemy. All rights reserved.
//

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef pair<int ,int> job;

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

    vector<job> jobs;
    for(int i=0;i<n;i++)
    {
        job j;
        cin >> j.first >> j.second;
        jobs.push_back(j);
    }

    //期限が近い仕事から順番にやっていく。
    auto comp = [](job a, job b){return a.second < b.second || (a.second == b.second && a.first < b.first);};
    sort(jobs.begin(), jobs.end(), comp);

    long long int time = 0;
    for(job j :jobs)
    {
        time += j.first;

        //期限を超えたら終了
        if(time > j.second)
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 2420
package main
import (
  "fmt"
  "sort"
)
func main() {
  as := make([]int, 3)
  for i := 0; i < 3; i++ {
    fmt.Scan(&as[i])
  }
  sort.Ints(as)
  result := as[2] - as[0]
  fmt.Println(result)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define Little 1
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,w=0,n=0,m=0,o=0;
  rep(i,5){
    std::cin >> x;
    if(x==0){
      std::cout << i+1 << '\n';
      return 0;

    }
  }
}


Measured memory_bytes: 3564
#include<iostream>

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;


int main () {
  int n;
  int count[4][3][10] = {{{0}}};
  int b, f, r, v;
  int i,j,k;

  // input
  cin >> n;
  rep(i,n) {
    cin >> b >> f >> r >> v;
    count[b-1][f-1][r-1] += v;
  }

  // output
  rep(i,4) {
    rep(j,3) {
      rep(k,10) {
	cout << " " << count[i][j][k];
      }
      cout << endl;
    }
    if (i < 3) {
      rep(k,20) {
	cout << '#';
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

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

using namespace std;
using llng = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
template<class T> using hset = unordered_set<T>;
template<class Key, class T> using hmap = unordered_map<Key, T>;

int main() {
    llng N, A, B, C, D; cin >> N >> A >> B >> C >> D;

    llng base, sup, inf;
    for (llng i = 0; i < N; i++) {
        base = A + C * (N - 1 - 2*i);
        sup = base + (D - C) * (N - 1 - i);
        inf = base - (D - C) * i;
        if (inf <= B && B <= sup) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

#define rep(i, n) for(int i = 0;i < (n);i++)
#define rrep(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)

using namespace std;
using ll = long long;

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

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


//////////////////////////////////////////////////



int main() {
    int n, q; cin >> n >> q;
    string s;
    cin >> s;
    vector<int> l(q), r(q);
    for (int i = 0; i < q; i++)
    {
        cin >> l[i] >> r[i];
    }

    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'A' && s[i+1] == 'C') a[i] = 1;
    }
    vector<int> sum(n+1);
    for (int i = 0; i < n; i++)
    {
        sum[i+1] = sum[i] + a[i];
    }
    
    for (int i = 0; i < q; i++)
    {
        cout << sum[r[i]-1] - sum[l[i]-1] << endl;
    }
    

    return 0;
}


Measured memory_bytes: 2688
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

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

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

x=n_in()
n=100
cnt = 0

while n < x:
    n= int(n*1.01)
    cnt+=1

print(cnt)


Measured memory_bytes: 63724
#include<vector>
using namespace std;

bool topological_sort(const vector< vector<int> >& g, vector<int>& res){
    const int v = (int)g.size();
    res.clear();

    vector<int> deg(v, 0);
    for(int i = 0 ; i < v ; ++i){
        for(auto to : g[i]){
            ++deg[to];
        }
    }

    vector<int> st;
    for(int i = 0 ; i < v ; ++i){
        if(deg[i] == 0){
            st.emplace_back(i);
        }
    }

    while(!st.empty()){
        int k = st.back();
        st.pop_back();
        res.emplace_back(k);
        for(auto to : g[k]){
            --deg[to];
            if(deg[to] == 0){
                st.emplace_back(to);
            }
        }
    }

    return (int)res.size() == v;
}

#include<iostream>
#include<cassert>

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

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

    int v, e;
    cin >> v >> e;

    vector< vector<int> > g(v);
    for(int i = 0 ; i < e ; ++i){
        int u, v;
        cin >> u >> v;
        g[u].emplace_back(v);
    }
    
    vector<int> ans;
    assert(topological_sort(g, ans));

    for(int i = 0 ; i < v ; ++i){
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3684
#include <iostream>

typedef long long ll;

bool Sol(ll N, ll Y){
  for(ll i=0; i<=N; i++){
    if ( 10000*i > Y ) return false;
    for(ll j=0; j<=N-i; j++){
      if ( 10000*i + 5000*j > Y ) continue;
      ll k = N - i - j;
      if ( k >= 0 && 10000*i+5000*j+1000*k == Y ) {
        std::cout << i << " " << j << " " << k << std::endl;
        return true;
      }
    }
  }
  return false;
}

int main (void){
  ll N, Y; std::cin >> N >> Y;
  if(!Sol(N,Y)) std::cout << -1 << " " << -1 << " " << -1 << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
int a[4],b[4];
int n;
int main(){
	cin >> n;
	REP(i,4) {
		b[i] = n % 10;
		n /= 10;
	}
	REP(i,4) {
		a[3 - i] = b[i];
	}

	REP(S,1<<3) {
		int sum = a[0];
		REP(i,3) {
			if(S & (1 << i)) {
				sum += a[i + 1];
			}else
				sum -= a[i + 1];
		}
		if(sum == 7) {
			cout << a[0];
			REP(i,3) {
				if(S & (1 << i)) {
					cout << "+";
				}
				else
					cout << "-";
				cout << a[i + 1];
			}
			cout << "=7" << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<time.h>
typedef long long LL;
const int e[]={0,1,1,2,2,2,3,3,3,3,4,4,4,4,4,5,5,5,5,5,
               5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8};
const LL UnUseMethod=1e9;
LL count[2]={0};
LL IN(void)
{
  LL x=0;short f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
LL GCD(LL a,LL b){return !b?a:GCD(b,a%b);}
LL Mult(LL x,LL y,LL mod)
{LL temp=x*y-(LL)((long double)x/mod*y+1e-8)*mod;return temp<0?temp+mod:temp;}
LL BinaryModularPower(LL base,LL pow,LL mod)
{
  LL x=1;
  while(pow){if(pow&1){x=Mult(x,base,mod);}base=Mult(base,base,mod);pow>>=1;}
  return x;
}
LL f(LL x,LL mod,LL c){return (Mult(x,x,mod)+c)%x+1;}
void Exp(LL x,LL y){count[1]=0;while(!(x%y)){count[1]++;x/=y;}count[0]=x;return;}
int MillerRabin(const LL a)
{
  if(a==2)return 1;
  if(a%2==0||a==1)return 0;
  static int pr[]={2,325,9375,28178,450775,9780504,1795265022};
  int c=7;
  LL u=a-1,t=0,p=1;
  while(!(u&1)){u>>=1;t++;}
  for(int i=0;i<c;++i)
  {
    p=pr[i]%a;
    if(!p)return 1;
    LL x=BinaryModularPower(p,u,a);
    if(x==1)continue;
    for(int j=0;x!=a-1&&j<t;++j)
    {
      x=Mult(x,x,a);
      if(x==1)return 0;
    }
    if(x==a-1)continue;
    return 0;
  }
  return 1;
}
LL PollardRho(LL n,LL a)
{
  srand((unsigned int)time(NULL));
  LL x=rand()%n,y=x,gcd=1,k=0,i=1;
  while(gcd==1)
  {
    k++;
    x=Mult(x,x,n)+a;if(x>=n)x-=n;
    gcd=GCD(x>y?x-y:y-x,n);
    if(k==i){y=x;i<<=1;}
  }
  if(gcd==n)return PollardRho(n,a+1);
  return gcd;
}
int main(void)
{
  LL a=0,p=1,q=-1,N=IN();
  if(N<=1)return puts("0"),0;
  Exp(N,2);a=e[count[1]];N=count[0];
  Exp(N,3);a+=e[count[1]];N=count[0];
  while(q*q<=UnUseMethod)
  {
    p+=6,q+=6;
    Exp(N,p);a+=e[count[1]];N=count[0];
    Exp(N,q);a+=e[count[1]];N=count[0];
  }
  if(N<=UnUseMethod){if(N>1){a++;}return printf("%lld\n",a),0;}
  if(MillerRabin(N)){a++;return printf("%lld\n",a),0;}
  while(N>=UnUseMethod)
  {
    p=PollardRho(N,0);
    while(!MillerRabin(p))p=PollardRho(p,p);
    Exp(N,p);a+=e[count[1]];N=count[0];
  }
  if(MillerRabin(N)){a++;}return printf("%lld\n",a),0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  vi a(n); rep(i, n) std::cin >> a[i];
  int ans = inf;
  srep(y, -100, 101) {
    int sum = 0;
    rep(i, n) {
      sum += (a[i]-y)*(a[i]-y);
    }
    chmin(ans, sum);
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ri register int
using namespace std;
const int rlen = 1 << 20 | 5;
char buf[rlen], *ib = buf, *ob = buf;
#define gc() (((ib == ob) && (ob = (ib = buf) + fread(buf, 1, rlen, stdin))), ib == ob ? -1: *ib++)
inline int read() {
  static int ans;
  static char ch;
  for (ans = 0, ch = gc(); !isdigit(ch); ch = gc());
  while (isdigit(ch)) {
    ans = ((ans << 2) + ans << 1) + (ch ^ 48);
    ch = gc();
  }
  return ans;
}
typedef long long ll;
typedef vector <int> poly;
#define pb push_back
#define rez resize
const int N = 5e5 + 5, inf = 0x3f3f3f3f;
int n, A, B;
int main() {
  #ifdef ldxcaicai
  freopen("lx.in", "r", stdin);
  #endif
  n = read();
  A = read();
  B = read();
  cout << ((A ^ B) & 1 ? "Borys" : "Alice");
  return 0;
}

Measured memory_bytes: 3624
n,k = map(int,input().split())
a = list(map(int,input().split()))
l = max(len(bin(k)[2:]),len(bin(max(a))[2:]))
c = [0]*l

for i in a:
    b_a = bin(i)[2:].zfill(l)
    for j in range(l):
        if b_a[j]=='1':
            c[j] += 1

x = 0
for i in range(l):
    e = l-i-1
    if n-c[i]>c[i] and x+2**e<=k:
        x += 2**e

ans = 0
for i in a:
    ans += i^x
print(ans)

Measured memory_bytes: 14712
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int r = sc.nextInt();
		sc.close();
		int ans = 0;
		int max = 1;
		while (true) {
			max *= r;
			ans++;
			if (max > n) {
				break;
			}
		}
		System.out.println(ans);
	}

	public static int arrayMax(int[] array) {
		int ans = Integer.MIN_VALUE;
		for (int i = 0; i < array.length; i++) {
			if (array[i] > ans)
				ans = array[i];
		}
		return ans;
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static Integer[] arrayInteger(Scanner sc, int n) {
		Integer[] array = new Integer[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}
}

Measured memory_bytes: 22356
unittest
{
//	assert( [ "2", "1 2" ].parse.expand.solve == "1 4\n5 4" );
//	assert( [ "3", "3 2 1" ].parse.expand.solve == "1 2 3\n5 3 1" );
//	assert( [ "3", "2 3 1" ].parse.expand.solve == "5 10 100\n100 10 1" );
}



import std.conv;
import std.format;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto ps = input.front.split.to!( long[] );
	return tuple( ps );
}

auto solve( long[] ps )
{
	auto as = new long[ ps.length ];
	auto bs = new long[ ps.length ];
	foreach( i, ref p; ps )
	{
		as[ p - 1 ] = i + 1;		// 順番を付ける
	}
	for( auto i = 1L; i < ps.length; i++ )
	{
		as[ i ] += as[ i - 1 ];		// as[ i - 1 ] < as[ i ] になるように累積和にする
	}
	bs[ 0 ] = as[ $ - 1 ];
	for( auto i = 1L; i < ps.length; i++ )
	{
		bs[ i ] = as[ $ - 1 ] - as[ i - 1 ];		// 累積和分を打ち消して順番だけ残るようにする
	}
	return format( "%s\n%s", as.to!( string[] ).join( " " ), bs.to!( string[] ).join( " " ) );
}


Measured memory_bytes: 5372
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  int a[n], sum=0;
  map<ll, ll> mp;
  mp[0]=1;
  for (int i=0; i<n; i++) {
    cin >> a[i];
    sum += a[i];
    sum %= m;
    mp[sum]++;
  }
  ll ans=0;
  for(auto it=mp.begin(); it != mp.end(); it++) {
    ans += it->second * (it->second - 1) / 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4608
//============================================================================
// Name        : 34B.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;


int main() {

	string s = "";
	string ad = "";
	cin >> s;
	for(int i = 0; i < s.length(); ++i){
		if(s[i] == 'B' && s[i + 1] == 'C'){
			ad += 'D';
			++i;
		}
		else{
			ad += s[i];
		}
	}


	long long count = 0;
	for(int i = 0; i < ad.length(); ++i){
		static int noA = 0;
		if(noA != 0 && ad[i] == 'D'){
			count += noA;
		}
		else if(noA != 0 && (ad[i] == 'B' || ad[i] == 'C')){
			noA = 0;
		}
		else if(ad[i] == 'A')++noA;
	}
	cout << count << endl;

	return 0;
}



Measured memory_bytes: 776
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class EConnected {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    int R, C, N;

    bool onLine(int x, int y) {
        return x == 0 || x == R || y == 0 || y == C;
    }

    int convert(int x, int y) {
        if (x == 0) {
            return y;
        }
        if (x == R) {
            return C - y + C + R;
        }
        if (y == 0) {
            return R - x + 2 * C + R;
        }
        if (y == C) {
            return x + C;
        }
        return 0;
    }

    void solve(std::istream& cin, std::ostream& cout) {
        cin >> R >> C >> N;
        set<P> s;
        REP(i, N) {
            int x1, y1, x2, y2;
            cin >> x1 >> y1 >> x2 >> y2;

            if (onLine(x1, y1) && onLine(x2, y2)) {
                s.insert({convert(x1, y1), i});
                s.insert({convert(x2, y2), i});
            }
        }

        stack<int> st;
        for (auto kv : s) {
            if (!st.empty() && kv.second == st.top()) {
                st.pop();
                continue;
            }
            st.push(kv.second);
        }

        cout << (st.empty() ? "YES" : "NO") << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    EConnected solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 13568
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define lint long long
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = 1e-9;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	if (!b)return T(1);
	if (b & 1)return mypow(a, b - 1) * a;
	T memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int main(){
	lint n;
	std::cin>>n;
	int ans=0;
	for(lint i=2;i*i<=n;i++){
		int cnt=0;
		while(n%i==0){
			cnt++;
			n/=i;
		}
		REP(j,100){
			if(cnt<j)break;
			cnt-=j;
			ans++;
		}
	}
	if(n!=1)ans++;
	std::cout<<ans<<std::endl;
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

bool MM(string s){
  if(s[0] == '0' && s[1] == '0')return false;
  if(s[0] >= '1' && s[1] >= '3')return false;
  if(s[0]>='2')return false;
  return true;
}
bool YY(string s){
  return true;
}
int main() {
  string s;
  cin >> s;
  string l = s.substr(0,2);
  string r = s.substr(2,4);
  if((!MM(l) && !YY(l)) || (!MM(r) && !YY(r)) || !(MM(r)||MM(l))) cout<<"NA"<<endl;
  else if((!MM(l) && !YY(r)) || (!MM(r) && !YY(l))) cout<<"NA"<<endl;
  else if(MM(l) && YY(r) && MM(r) && YY(l)) cout<<"AMBIGUOUS"<<endl;
  else if(MM(l) && YY(r)) cout<<"MMYY"<<endl;
  else if(MM(r) && YY(l))cout <<"YYMM"<<endl; 
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
#define int ll
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int n,m,v,p,ans;
int a[100005];
inline int check(int x)
{
    if(a[x]>=a[p])return 1;
    reg int y,t=0,i;
    y=v-(n-x+1);
    for(i=1;i<x;++i)
        if(a[i]>a[x]+m)++t;
    if(t>=p)return 0;
    y-=t;if(y<=0)return 1;
    reg ll s=1ll*m*y;
    for(i=t+1;i<x;++i)
        s-=1ll*(a[x]+m-a[i]);
    if(s<=0)return 1;
    for(i=t+1;i<x;++i)
    {
        s-=min(s,1ll*(a[i]-a[x]));++t;
        if(s==0)return t<p;
    }
}
signed main()
{
    n=read(),m=read(),v=read(),p=read();
    reg int i,l,r,mid;
    for(i=1;i<=n;++i)a[i]=read();
    sort(a+1,a+1+n);reverse(a+1,a+1+n);
    l=1;r=n+1;
    while(l<r-1)
    {
        mid=(l+r)>>1;
        if(check(mid))l=mid;
        else r=mid;
    }cout<<r-1<<"\n";
	return 0;
}


Measured memory_bytes: 1024
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N, M;
ll arr[100005];
ll dp[100005];
ll marked[100005];

ll rec(int ind) {
	if(ind == N) {
		return 1;
	}
	if(ind > N) {
		return 0;
	}
	ll &ans = dp[ind];
	if(ans != -1) {
		return ans;
	}
	// int flag = 0;
	// for(int i = 0; i < M; i++) {
	// 	if(ind + 1 == arr[i]) {
	// 		flag = 1;
	// 		break;
	// 	}
	// }
	
	// if(!flag) {
	// 	ans = rec(ind + 1);
	// 	ans %= MOD;
	// }
	// flag = 0;
	// for(int i = 0; i < M; i++) {
	// 	if(ind + 2 == arr[i]) {
	// 		flag = 1;
	// 		break;
	// 	}
	// }

	// if(!flag) {
	// 	ans = (ans + rec(ind + 2)) % MOD;
	// 	ans %= MOD;
	// }
	if(marked[ind + 1] != -1 && marked[ind + 2] == -1) {
		ans = rec(ind + 1);
		ans %= MOD;
	}
	else if(marked[ind + 1] == -1 && marked[ind + 2] != -1) {
		ans = rec(ind + 2);
		ans %= MOD;
	}
	else if(marked[ind + 1] != -1 && marked[ind + 2] != -1) {
		ans = (rec(ind + 1) + rec(ind + 2)) % MOD;
	}
	else {
		return 0;
	}
	// ans = (rec(ind + 1) + rec(ind + 2)) % MOD;
	return ans;

}

int main() {
	scanf("%lld %lld", &N, &M);
	for(int i = 0; i < M; i++) {
		scanf("%lld", &arr[i]);
		marked[arr[i]] = -1;
	}
	for(int i = 1; i <= N; i++) {
		if(marked[i] != -1) {
			marked[i] = i;	
		}
	}
	memset(dp, -1, sizeof(dp));
	ll finalAns = rec(0);
	printf("%lld\n", finalAns);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 4992