akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef pair<int, int> pii;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
const int INF = 0x3f3f3f3f;

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

const int N = 1e5+10;

int M;
int add(int a, int b) {return (a+b)%M;}
int sub(int a, int b) {return (a+M-b)%M;}
int mult(ll a, ll b) {return (a*b)%M;}

int n, dp[N], ans[N], par[N];
// dp[s] - # ways to have subtrees black including s
// par[s] - # ways to have parent of s and anything not a child of s (including s itself) black
vector<int> g[N], pre[N], suf[N];

void preprocess(int s, int p = 0) {
	int id = -1;
	REP(i, g[s].size()) {
		if(g[s][i] == p) {
			id = i;
		}
	}
	if(id != -1) {
		g[s].erase(g[s].begin()+id);
	}

	int children = g[s].size();
	pre[s].resize(children);
	suf[s].resize(children);

	for(int v : g[s]) {
		preprocess(v, s);
	}
}

void dfs(int s, int p = 0) {
	dp[s] = 1;
	for(int v : g[s]) {
		dfs(v, s);
		dp[s] = mult(dp[s], add(dp[v], 1));
	}
	int children = g[s].size();
	if(children) {
		pre[s][0] = add(dp[g[s][0]], 1);
		FOR(i, 1, children-1) pre[s][i] = mult(pre[s][i-1], add(dp[g[s][i]], 1));

		suf[s][children-1] = add(dp[g[s][children-1]], 1);
		FORD(i, children-2, 0) suf[s][i] = mult(suf[s][i+1], add(dp[g[s][i]], 1));

		// DEBUG(s);
		// for(int x : pre[s]) cout << x << ' ';
		// cout << endl;
		// for(int x : suf[s]) cout << x << ' ';
		// cout << endl;
	}

}

void dfs2(int s, int p = 0) {
	if(p == 0) {
		ans[s] = dp[s];
		par[s] = 1;
	} else {
		ans[s] = mult(dp[s], add(par[s], 1));
	}
	int children = g[s].size();
	REP(i, children) {
		int v = g[s][i];
		int leftHalf = i ? pre[s][i-1] : 1;
		int rightHalf = i < children-1 ? suf[s][i+1] : 1;
		par[v] = mult(add(par[s], p ? 1 : 0), mult(leftHalf, rightHalf));
		dfs2(v, s);
	}
}

signed main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    cin >> n >> M;
    REP(i, n-1) {
    	int u, v;
    	cin >> u >> v;
    	g[u].push_back(v);
    	g[v].push_back(u);
    }
    preprocess(1);
    dfs(1);
    dfs2(1);
    // FOR(i, 1, n) cout << par[i] << ' ';
    // cout << endl;
    // FOR(i, 1, n) cout << dp[i] << ' ';
    // cout << endl;
    FOR(i, 1, n) cout << ans[i] << endl;

    return 0;
}

// Easy things to check:
// - LONG LONGS (WA)
// - const int N is correct (WA, RTE) CHECK IF IT SHOULD BE 2*N!!!!
// - small n edge cases (WA)

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    int nlist[10] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
    REP(i, 0, M) {
        cin >> A[i];
    }
    sort(rbegin(A), rend(A));
    auto dp = make_v(N + 1, N, false);
    dp[0][0] = true;
    REP(i, 0, N) {
        REP(j, 0, N - 1) {
            if (dp[i][j]) {
                REP(k, 0, M) {
                    int cnt = nlist[A[k] - 1];
                    if (i + cnt <= N) {
                        dp[i + cnt][j + 1] = true;
                    }
                }
            }
        }
    }
    int digit = 0;
    REP(i, 0, N) {
        if (dp[N][i]) {
            digit = i;
        }
    }
    dump(digit);
    dp = make_v(N + 1, digit + 1, false);
    dp[N][digit] = true;
    for (int i = N; i > 0; i--) {
        for (int j = digit; j > 0; j--) {
            if (dp[i][j]) {
                REP(k, 0, M) {
                    int cnt = nlist[A[k] - 1];
                    if (i - cnt >= 0) {
                        dp[i - cnt][j - 1] = true;
                    }
                }
            }
        }
    }
    int R = 0;
    REP(d, 0, digit) {
        REP(i, 0, M) {
            int cnt = nlist[A[i] - 1];
            if (R + cnt <= N && dp[R + cnt][d + 1]) {
                digit++;
                R += cnt;
                cout << A[i];
            }
        }
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 19584
/*
    author: Salam_35
    Created at :

*/

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() int t;cin >> t;while(t--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}

typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

int main()
{
   int n,m;
   cin >> n >> m;
   int sum=0;
   int arr[n+10];
   for (int i = 0; i < n; ++i)
   {
   		cin >> arr[i];
   		sum+=arr[i];
   }
   int b=4*m;
   int a=sum/b;
   if(sum%b!=0)a++;
   int cnt=0;
   for (int i = 0; i < n; ++i)
   {
   		if(arr[i]>=a)
   		{
   			cnt++;
   		}
   }
   if(cnt>=m)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n = int(input())
    bl = list(map(int, input().split()))
    al = [0] * n

    al[0] = bl[0]
    al[-1] = bl[-1]
    for i in range(1, n - 1):
        al[i] = min(bl[i], bl[i-1])
    print(sum(al))


if __name__ == '__main__':
    main()


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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    REP(i, n) cin >> d[i];
    sort(d.begin(), d.end());
    int mid_u = n/2;
    int mid_d = mid_u-1;
    cout << d[mid_u] - d[mid_d] << endl;
    return 0;
}


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

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

  int cnt = 0;
  for (int i = a; i <= b; i++) {
    int num = i;
    int rnum = 0;
    while (num > 0) {
      rnum = rnum * 10 + num % 10;
      num /= 10;
    }
    if (i == rnum) {
      cnt++;
    }
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

const int MAX_N = 1e5 + 5;

vector<int> adj [MAX_N];
int mask [MAX_N];

void dfs (int u, int p) {
  int chb = 0;
  for (int nxt : adj[u]) {
    if (nxt != p) {
      dfs(nxt, u);
      if (mask[u] & mask[nxt]) {
        chb = max(chb, 31 - __builtin_clz(mask[u] & mask[nxt]));
      }
      mask[u] |= mask[nxt];
    }
  }

  while (mask[u] & 1 << chb) {
    chb++;
  }

  mask[u] += 1 << chb;
  mask[u] -= mask[u] % (1 << chb);
}

int main () {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;

    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  dfs(1, 0);

  cout << 31 - __builtin_clz(mask[1]) << endl;
}


Measured memory_bytes: 15008
n = int(input())
lst = [[i+1 for i in range(13)] for j in range(4)]
for p in range(n):
    suit_num = list(input().split())
    suit, num = suit_num[0],int(suit_num[1])
    if suit =="S":
        lst[0].remove(num)
    elif suit == "H":
        lst[1].remove(num)
    elif suit == "C":
        lst[2].remove(num)
    else:
        lst[3].remove(num)

for q in range(4):
    if q == 0:
        suit = "S"
    elif q == 1:
        suit = "H"
    elif q == 2:
        suit = "C"
    else:
        suit ="D"
    for j in lst[q]:
        print(suit + " " + str(j))


Measured memory_bytes: 5604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

ll a[111];
int n;

int main(){
	while (cin >> n&&n){
		REP(i, 100)a[i] = 0;
		ll co = 0;
		REP(i,n){
			cin >> a[i];
		}
		for (int i = n; i > 0; i--){
			for (int j = 0; j < i - 1; j++){
				if (a[j] > a[j + 1]){
					ll k = a[j];
					a[j] = a[j + 1];
					a[j + 1] = k;
					co++;
				}
			}
		}
		//cout << "!";
		cout<< co << endl;

	}
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int s,i,p[30],t=0;
    string a;
    char b[105];
    cin>>a;
    s=a.size();
    for(i=1; i<=26; i++)
    {
        p[i]=0;
    }
    for(i=0; i<s; i++)
    {
        if(a[i]=='a')
            p[1]++;
        else if(a[i]=='b')
            p[2]++;
        else if(a[i]=='c')
            p[3]++;
        else if(a[i]=='d')
            p[4]++;
        else if(a[i]=='e')
            p[5]++;
        else if(a[i]=='f')
            p[6]++;
        else if(a[i]=='g')
            p[7]++;
        else if(a[i]=='h')
            p[8]++;
        else if(a[i]=='i')
            p[9]++;
        else if(a[i]=='j')
            p[10]++;
        else if(a[i]=='k')
            p[11]++;
        else if(a[i]=='l')
            p[12]++;
        else if(a[i]=='m')
            p[13]++;
        else if(a[i]=='n')
            p[14]++;
        else if(a[i]=='o')
            p[15]++;
        else if(a[i]=='p')
            p[16]++;
        else if(a[i]=='q')
            p[17]++;
        else if(a[i]=='r')
            p[18]++;
        else if(a[i]=='s')
            p[19]++;
        else if(a[i]=='t')
            p[20]++;
        else if(a[i]=='u')
            p[21]++;
        else if(a[i]=='v')
            p[22]++;
        else if(a[i]=='w')
            p[23]++;
        else if(a[i]=='x')
            p[24]++;
        else if(a[i]=='y')
            p[25]++;
        else
            p[26]++;
    }
    for(i=1; i<=26; i++)
    {
        if(p[i]%2==1)
        {
            t=1;
            break;
        }
    }
    if(t==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;



    return 0;
}



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

using namespace std;

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

	sort(arr.begin(), arr.end());

	int maxEl = arr[n - 1];

	int sum = 0;
	for (int i = 0; i < n - 1; i++)
	{
		sum += arr[i];
	}

	cout << (maxEl < sum ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

day = ['SUN', 'MON','TUE','WED','THU','FRI','SAT']
s = input()
for x in range(len(day)):
    if day[x] == s:
        print(7 - x)
        sys.exit()

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, A, B, C;
    cin >> N >> A >> B >> C;
    vector<string> queries;

    for (int i = 0; i < N; ++i) {
        string str;
        cin >> str;
        queries.emplace_back(move(str));
    }

    string buf;
    function<bool(int, array<int, 3>)> dfs = [&](int idx, array<int, 3> cnt) -> bool {
        while (idx < N) {
            int i = queries[idx][0] - 'A';
            int j = queries[idx][1] - 'A';
            if (cnt[i] == cnt[j]) {
                if (cnt[i] == 0) return false;
                if (cnt[i] > 1) {
                    ++cnt[j];
                    --cnt[i];
                    buf.push_back(j + 'A');
                }
                else {
                    ++cnt[j];
                    --cnt[i];
                    buf.push_back(j + 'A');
                    if (dfs(idx + 1, cnt)) return true;
                    buf = buf.substr(0, idx);
                    cnt[j] -= 2;
                    cnt[i] += 2;
                    buf.push_back(i + 'A');
                    return dfs(idx + 1, cnt);
                }
            } else if (cnt[i] > cnt[j]) {
                ++cnt[j];
                --cnt[i];
                buf.push_back(j + 'A');
            } else {
                ++cnt[i];
                --cnt[j];
                buf.push_back(i + 'A');
            }
            ++idx;
        }

        return true;
    };

    array<int, 3> init = {A, B, C};
    if (dfs(0, init)) {
        cout << "Yes" << endl;
        for (char ch : buf) cout << ch << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 11564
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    vvint a(3, vint(3));
    vvbool c(3, vbool(3, false));
    rep(i, 3) rep(j, 3) cin >> a[i][j];
    int n;
    cin >> n;
    rep(k, n) {
        int b;
        cin >> b;
        rep(i, 3) rep(j, 3) {
            if (a[i][j] == b) c[i][j] = true;
        }
    }

    bool ans = false;
    rep(i, 3) {
        bool check = true;
        rep(j, 3) {
            if (!c[i][j]) check = false;
        }
        if (check) ans = true;
    }

    rep(j, 3) {
        bool check = true;
        rep(i, 3) {
            if (!c[i][j]) check = false;
        }
        if (check) ans = true;
    }

    if (c[0][0] && c[1][1] && c[2][2]) ans = true;
    if (c[0][2] && c[1][1] && c[2][0]) ans = true;

    if (ans) puts("Yes");
    else puts("No");
    return 0;
}

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

int main(void){
  char S[4];
  cin >> S;
  int x[26] = {0};
  int cnt = 0;
  for(int i = 0; i < 4; i++){
    x[S[i] - 65]++;
  }
  for(int i = 0; i < 26; i++)
    if(x[i]) cnt++;
  if(cnt == 2) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


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

int main() {
	long long a,b,c;cin >>a >>b>>c;
	if(c-a-b<=0){
		cout << "No" << endl;
	} else {
		if(4*a*b < (c-a-b) * (c-a-b)){
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
	return 0;
}

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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define VECCIN(x)            \
	for (auto &youso_ : (x)) \
	cin >> youso_
#define mp make_pair
#define All(a) (a).begin(), (a).end()
template <typename T = long long>
inline T IN()
{
	T x;
	cin >> x;
	return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail)
{
	cin >> head;
	CIN(move(tail)...);
}
#define CINT(...)    \
	int __VA_ARGS__; \
	CIN(__VA_ARGS__)
#define LCIN(...)   \
	ll __VA_ARGS__; \
	CIN(__VA_ARGS__)
#define SCIN(...)       \
	string __VA_ARGS__; \
	CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

string S;

int main()
{
	cin >> S;
	int black = 0, white = 0;
	REP(i, S.length())
	{
		if (i % 2 == 0)
		{
			if (S[i] == '1')
			{
				black++;
			}
			else
			{
				white++;
			}
		}
		else
		{
			if (S[i] == '1')
			{
				white++;
			}
			else
			{
				black++;
			}
		}
	}
	cout << min(black, white) << "\n";
	return 0;
}

Measured memory_bytes: 512
n,m = map(int,input().split())
a = list(map(int,input().split()))

s = [0]
for i in range(n):
    s.append((s[i]+a[i])%m)

from collections import Counter
d = Counter(s)

temp = 0
for i in d.values():
    temp+=i*(i-1)//2

print(temp)

Measured memory_bytes: 63384
#include <iostream>
#include <stack>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;
typedef pair<int, int> pii;

string S;
int N;

int main(void) {
  while(cin >> S >> N) {
    if(S[0] == '0' && N == 0) break;
    int p = 0, cnt = 0;
    stack<pii> stk;

    char ans = '0';
    while(p < S.length()) {
      if('0' <= S[p] && S[p] <= '9') {
        int itr = 0;
        for(; '0' <= S[p] && S[p] <= '9'; p++) itr = itr * 10 + (S[p] - '0');
        if(S[p] == '(') {
          p++;
          stk.push(pii(itr, p));
        } else {
          while(itr--) {
            if(cnt == N) {
              ans = S[p];
              goto PRINT;
            }
            cnt++;
          }
          p++;
        }
      } else if('A' <= S[p] && S[p] <= 'Z') {
        if(cnt == N) {
          ans = S[p];
          goto PRINT;
        }
        p++, cnt++;
      } else if(S[p] == ')') {
        stk.top().first--;
        if(stk.top().first > 0) p = stk.top().second;
        else {
          stk.pop();
          p++;
        }
      }
    }

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

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

signed main() {
	int h, w, s, t;
	cin >> h >> w >> s >> t;
	if(h * w % 2 == 0 || (s + t) % 2 == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,W,H,sum=0,num=0,flag=0;string S,T;
  cin >> S;
  rep(i,0,3)if(S[i]=='7')flag=1;
  if(flag)Out("Yes");
  else Out("No");
}

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

int main()
{
    data_type n;
    cin>>n;
    vector<vector<data_type> > vc(n,vector<data_type>(3));
    for(auto &i:vc)
        {
            for(auto &j:i)
                cin>>j;
        }
    for(int i=n-2; i>=0; i--)
        {
            for(int j=0; j<3; j++)
                {
                    data_type m=-1;
                    for(int k=0; k<3; k++)
                        {
                            if(j==k)
                                continue;
                            m=max(m,vc[i+1][k]);
                        }
                    vc[i][j]+=m;
                }
        }
    cout<<max(vc[0][0],max(vc[0][1],vc[0][2]))<<endl;

    return 0;
}


Measured memory_bytes: 8792
import sys
sys.setrecursionlimit(10**6)
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
ans = 0
K = int(input())
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            d = gcd(a,b)
            e = gcd(d,c)
            ans += e
print(ans)


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

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

const long long INF = 1LL<< 60;
//入力
int N;
long long W, weight[110], value[110]; //品物の個数は100個なので、少し余裕をもたせてサイズ110に

//DPテーブル
long long dp[110][100100] = {0};

int main(){
    cin >> N >> W;
    for(int i=0;i<N;++i)cin>> weight[i] >> value[i];

    //DPループについて
    for(int i=0;i<N;++i){
        for(int sum_w = 0;sum_w <= W;++sum_w){
            //i番目の品物を選ぶ場合
            if(sum_w - weight[i] >= 0){
                chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]]+value[i]);
            }

            //i番目の品物を選ばない場合
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

    //最適値の出力
    cout << dp[N][W] << endl;
}


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

using namespace std;

int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            int x = 1;
            if ((i <= b && j <= a) || (i > b && j > a))
                x = 0;
            cout << x;
        }
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 1280
n, m = map(int, input().split())
h = list(map(int, input().split()))
low = set()
for i in range(m):
    a, b = map(int, input().split())
    if h[a - 1] <= h[b - 1]:
        low |= set([a])
    if h[a - 1] >= h[b - 1]:
        low |= set([b])
print(n - len(low))

Measured memory_bytes: 20152
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

string fc(int fr, int to, int co){
  string ret;
  ret += to_string(fr);
  ret.push_back(' ');
  ret += to_string(to);
  ret.push_back(' ');
  ret += to_string(co);
  
  return ret;
}

int main(){
  int l;
  cin >> l;
  int r = log2(l);
  vector<string> ans;
  rep(i, r){
    ans.push_back(fc(i+1, i+2, 0));
    ans.push_back(fc(i+1, i+2, (1 << i)));
  }
  rrep(i, r+1){
    if(i == 0) break;
    int t = i;
    // cerr << t << endl;
    if(l - (1 << (t - 1)) >= (1 << r)){
      ans.push_back(fc(t, r+1, (l - (1 << (t-1)))));
      l -= (1 << (t-1));
    }
  }
  cout << r+1 << " " << ans.size() << endl;
  for(auto s : ans){
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i, N)
  {
    cin >> A[i];
  }

  for (int i = K - 1; i < N - 1; i++)
  {
    if (A[i - K + 1] < A[i + 1])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 4048
# coding: utf-8

a, b = map(int, raw_input().split())

if a > 0:
  print "Positive"

elif b >= 0:
  print "Zero" #Fate/Zeroは神アニメ

else:

  if (b - a) % 2 == 0:
    print "Negative"

  else:
    print "Positive"

Measured memory_bytes: 2568
#include<cstdio>
#include<algorithm>
using namespace std;
int n,h[100002];
long long s[100002];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&h[i]);
	s[1]=0;
	s[2]=abs(h[1]-h[2]);
	for(int i=3;i<=n;i++){
		s[i]=min(s[i-1]+abs(h[i-1]-h[i]),s[i-2]+abs(h[i-2]-h[i]));
	}
	printf("%lld",s[n]);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define vll vector<ll>
#define G vector<vll >
#define F first
#define S second
#define pll pair<ll,ll>
#define RFOR(i,a,b) for(int i=a;i>=b;i--)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define endl '\n'
#define clr(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
#define rll read_ll();
#define gc getchar
#define pc putchar
#define deb2(a,b,c,d) cout<<a<<":"<<b<<" "<<c<<":"<<d<<endl;
typedef long long ll;
template<class T> inline T lcm(T a,T b){
        return a/gcd(a,b)*b;
}

ll read_ll(){char c=gc();while((c<'0'||c>'9')&&c!='-')c=gc();ll ret=0;int neg=0;if(c=='-')neg=1,c=gc();while(c>='0'&&c<='9'){ret=10*ret+c-48;c=gc();}return neg?-ret:ret;}
const int N = 1e5+5;
map<pair<ll,ll>, ll> dist;
ll n;
vector<ll>g[N];
ll val[N];
bool visited[N];

void make_set(vector<ll>&rank,vector<ll>&id,ll n)
{
  FOR(i,1,n)
    rank[i] = 1, id[i] = i;
}

ll find_set(vector<ll>&id,ll p)
{
  ll child = p;
  while(id[p]!=p)
  {
  	//cout<<p<<":"<<id[p]<<endl;
    p = id[p];
  }
  
  while(child!=p)
  {
    ll newchild = id[child];
    id[child] = p;
    child = newchild;
  }
  return p;
}

ll merge_set(vector<ll>&rank,vector<ll>&id,ll u, ll v)
{
	ll rootu = find_set(id,u);
  	ll rootv = find_set(id,v);
  	if(rank[rootu] > rank[rootv])
      id[rootv] = rootu, rank[rootu] += rank[rootv];
  	else 
      id[rootu] = rootv, rank[rootv] += rank[rootu];
}

void dfs(int u,int p)
{
	if(visited[u]) return;
  visited[u] = true;
  //cout<<"->"<<u;
  for(auto v:g[u])
  {
    if(v==p)continue;
    val[v] = val[u] + dist[mp(u,v)];
    dfs(v,u);
  }
}

int main()
{
	int qq;
  cin>>n>>qq;
  vector<ll>rank(n+1),id(n+1);
  vector<pair<pair<ll,ll>, ll > >q(qq+1);
  make_set(rank,id,n);
  clr(val);
  clr(g);
  clr(visited);
  
  FOR(i,1,qq)
  {
  	//cout<<i<<":";
	  cin>>q[i].F.F>>q[i].F.S>>q[i].S;
    dist[mp(q[i].F.F,q[i].F.S)] = q[i].S;
    dist[mp(q[i].F.S,q[i].F.F)] = -q[i].S;
	
      g[q[i].F.F].pb(q[i].F.S);
      g[q[i].F.S].pb(q[i].F.F);
    
  }
  //cout<<"DONE";int tt;cin>>tt;

    FOR(i,1,n)
    {
      if(!visited[i])
        val[i] = 0,dfs(i,-1);//cout<<" DPNE"<<i<<endl;
    }
  
 /* FOR(i,1,n)
    if(visited[i])
    cout<<val[i]<<" "<<i<<endl;
   */ 
  FOR(i,1,qq){
  	if(val[q[i].F.S]-val[q[i].F.F]!=q[i].S)
  	{
  		cout<<"No";return 0;
	}
  }
  cout<<"Yes";
  
  return 0;
}











Measured memory_bytes: 48384
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  int N, T, A;
  cin >> N >> T >> A;
  // cout << T << endl;
  int H[1001];
  int best, diff, ans;
  best = pow(10,6);
  for(int i = 0; i<N;i++)cin >> H[i];
  for(int i = 0; i< N ; i++){
    // cout << T << "T" << " " << A<< endl;
    diff = std::abs((T*1000 - H[i]*6) - A*1000);
    // cout << diff<< endl;
//    cout << H[i]<< "is H" << i<< endl;
    if(best > diff)best = diff, ans = i;
  }
  cout << (ans+1) << endl;
}


Measured memory_bytes: 256
import sys


def norm2d(vec):
    return (vec[0]**2 + vec[1]**2)**0.5

def normalize(vec):
    l = norm2d(vec)
    vec[0] /= l
    vec[1] /= l
    return vec

lineNumber = 0

#for line in ["2", "0.0 0.0 -9.0 -9.0 1.0 0.0 2.0 1.0", "3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0"]:
for line in sys.stdin.readlines():
    lineNumber += 1

    if lineNumber == 1: continue

    # get data
    List = map(float, line.strip().split(" "))

    # set data
    a = [List[0], List[1]]
    b = [List[2], List[3]]
    c = [List[4], List[5]]
    d = [List[6], List[7]]

    vec1 = [a[0]-b[0], a[1]-b[1]]
    vec2 = [c[0]-d[0], c[1]-d[1]]

    #print vec1, vec2

    if vec1[0] < 0:
        vec1[0] *= -1
        vec1[1] *= -1
    if vec2[0] < 0:
        vec2[0] *= -1
        vec2[1] *= -1

    #print vec1, vec2

    vec1 = normalize(vec1)
    vec2 = normalize(vec2)

    #print vec1, vec2


    if     abs( vec1[0] - vec2[0] ) < 10**(-10) \
       and abs( vec1[1] - vec2[1] ) < 10**(-10):
        print "YES"
    else:
        print "NO"

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

int main(void)
{
	string str;
	while (cin >> str)
	{
		while (str.find("@") != -1)
		{
			int x = str.find("@");
			string temp;
			for (int i = 0; i < str[x + 1] - '0'; i++) temp += str[x + 2];
			str.replace(x, 3, temp);
		}
		cout << str << endl;
	}
	return 0;
}


Measured memory_bytes: 3072
def resolve():
    N = int(input())
    A = []
    C = []
    for _ in range(N):
        a = int(input())
        A.append(a)
        C.append(a)
    B = max(A)
    C.remove(B)
    D = max(C)
    for i in range(N):
        if B != A[i]:
            print(B)
        else:
            print(D)
resolve()

Measured memory_bytes: 14088
#include <iostream>

using namespace std;

int main()
{
    int k, s;
    cin >> k >> s;
    
    auto res = 0;
    for (auto x = 0; x <= k; x += 1) {
        for (auto y = 0; y <= k; y += 1) {
            auto z = s - x - y;
            res += (0 <= z && z <= k ? 1 : 0);
        }
    }

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


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const long long MOD = 1000000007;

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

    int h, a;
    cin >> h >> a;
    if (h % a == 0)
        cout << h / a;
    else
        cout << (h / a) + 1;
    return 0;
}

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

int score(char t, uint R, uint S, uint P){
    if (t == 'r') return R;
    if (t == 's') return S;
    if (t == 'p') return P;
    return 0;
}

char winHand(char t){
    if (t == 'r') return 'p';
    if (t == 's') return 'r';
    if (t == 'p') return 's';
    return 0;

}

int main(){
    uint N, K, R, S, P;
    string T;
    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;

    int ans = 0;

    vector<int> winHands = {};
    
    for (uint i = 0; i < N; i++){
        if (i >= K) {
            if (winHands.at(i - K) != winHand(T[i])){
                // 勝ち
                winHands.push_back(winHand(T[i]));
            } else {
                // 負けかあいこ
                winHands.push_back('-');
            }

        } else {
            winHands.push_back(winHand(T[i]));
        }
    }
    for (int i = 0; i < winHands.size(); i++) {
        ans += score(winHands.at(i), R, S, P);
    }
    std::cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1020
#include <iostream>
#include <vector>
int main() {
	int n, s;
	std::cin >> n >> s;
	std::vector<int> nums(n);
	for (auto &num : nums) {
		std::cin >> num;
	}
	int left{ 0 }, right{ 0 }, sum{ 0 };
	int min_length = n + 1;
	while (left < n) {
		while (sum < s && right < n) {
			sum += nums[right++];
		}
		if (sum >= s) {
			if (min_length > right - left) min_length = right - left;
			sum -= nums[left++];
		}
		else {
			break;
		}
	}
	if (min_length == n + 1) std::cout << 0 << std::endl;
	else std::cout << min_length << std::endl;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

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; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){


    ll n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);

    rep(i, n){
        cin >> a[i];
    }
    rep(i, n){
        cin >> b[i];
    }
    rep(i, n){
        cin >> c[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll ans = 0ll;

    rep(i, n){
        ll anum = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        ll cnum = n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin());
        ans += anum*cnum;
    }
    ppp(ans);

    return 0;
}


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

int main(){
	
	int n,i;
	cin>>n;
	
	vector<int>arr(n);
	for(i=0;i<n;i++) cin>>arr[i];
	
    if(n&1){
	 cout<<"1";return 0;
    }
    
    sort(arr.begin(),arr.end());
    
    cout<<(arr[n/2]-arr[n/2-1]);

	
	return 0;
}

Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main(){
  long long N,K,ans;
  long long b,s;
  
  cin>>N>>K;
  b=N;
  s=0;
  
  b=N%K;
  s=K-b;
  
  ans=min(s,b);
  cout<<ans;
  
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



int main(){
    int n;
    cin >> n;
    int p[n];
    rep(i,n) cin >> p[i];

    int ans = 0;
    bool check = false;

    for(int i=0;i<n;i++){
        if(i+1==p[i]){
            ans++;
            if(check){
                ans--;
                check = false;
            }else{
                check = true;
            }
        }else{
            check = false;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


class UnionFind:
    def __init__(self, node: int) -> None:
        self.n = node
        self.par = [i for i in range(self.n)]
        self.rank = [0 for i in range(self.n)]

    def find(self, x: int) -> int:
        if x == self.par[x]:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x: int, y: int) -> bool:
        if self.isSame(x, y):
            # print("x and y has already united")
            return False

        rx = self.find(x)
        ry = self.find(y)

        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = self.par[ry]
        else:
            self.par[ry] = self.par[rx]

            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

        return True

    def isSame(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)


n,m = li()
uf = UnionFind(n)
for _ in range(m):
    x,y,z = li()
    x -= 1
    y -= 1
    uf.unite(x,y)

pars = set()
for i in range(n):
    uf.find(i)
    pars.add(uf.par[i])

print(len(pars))

Measured memory_bytes: 13992
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

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

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

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

using namespace std;

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

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

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	int n;
	cin >> n;
	int a,b;
	cin >> a >> b;
	vector<int> ary(3,0);

	rep(i,n){
		int p;
		cin >> p;
		ary[(p <= a) + (p <= b)]++;
	}

	int ans = n;
	rep(i,3) chmin(ans, ary[i]);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please



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


	int N;
	cin >> N;

	int kotae = 1;
	rep(i, N) {
		int a;
		cin >> a;
		if (a % 2) kotae = 0;
	}
	if (kotae) co("second");
	else co("first");

	Would you please return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
using namespace std;
long long n,m,i,j,a[2500005],b[2500005],ad,bd,mod,ans=0x1212121212121212ll;
long long calc(long long x,long long y)
{
	return (n-x)*(m-y)+a[x]+b[y];
}
int main()
{
	cin>>n>>m>>a[1]>>ad>>b[1]>>bd;
	fz(i,2,n){
		a[i]=(58ll*a[i-1]+ad)%(m+1);
	}
	fz(i,2,m){
		b[i]=(58ll*b[i-1]+bd)%(n+1);
	}
//	a[0]=b[0]=0;
	sort(a+1,a+n+1);
	sort(b+1,b+m+1);
	fz1(i,n){
		a[i]+=a[i-1];
	}
	fz1(i,m){
		b[i]+=b[i-1];
	}
	j=n;
	fz0g(i,m){
		while(j>0&&calc(j,i)>=calc(j-1,i))j--;
		ans=min(ans,calc(j,i)); 
	}
	cout<<ans<<endl; 
	return 0;
}


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

struct fenwick {
  int N;
  vector<int> bit;

  fenwick(int n = 1e5) {
    N = n + 5;
    bit.assign(N, 0);
  }

  void resize(int n) {
    N = n + 5;
    bit.assign(N, 0);
  }

  void update(int x, int val) {
    while (x < N) {
      bit[x] += val;
      x += x&-x;
    }
  }

  int query(int x) {
    int ret=0;
    while (x > 0) {
      ret += bit[x];
      x -= x&-x;
    }
    return ret;
  }
};

int main() {

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

  int n, k;
  cin >> n >> k;

  long long ans = 0;
  map<long long, int> cc;
  vector<long long> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i] -= k;

    if (i) a[i] += a[i-1];
    cc[a[i]];
  }

  cc[0];
  int tmp = 0;
  for (auto &i : cc) i.second = ++tmp;
  for (auto &i : a) i = cc[i];

  fenwick bit(tmp);
  bit.update(cc[0], 1);
  for (int i = 0; i < n; ++i) {
    ans += bit.query(a[i]);
    bit.update(a[i], 1);
  } 

  cout << ans << '\n';
}


Measured memory_bytes: 15104
#include <iostream>

using namespace std;

int main(void){

  int N, M;
  int NM;
  int ans;

  cin >> N >> M;
  
  // NM C 2 の計算
  NM = N + M;
  ans = NM * (NM-1) / 2;

  // N C 1 + M C 1 は必ず奇数である
  if(N+M>2){
    ans-=N*M;
  } else ans-=1;

  cout << ans << endl;

  return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

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

  repi(x, 1, 4000) repi(y, 1, 4000){
    if((ll)4*x*y-n*(x+y) != 0) if((ll)n*x*y % (4*x*y-n*(x+y)) == 0){
      ll z = (ll)n*x*y / (4*x*y-n*(x+y));
      if(z > 0){
        printf("%d %d %lld\n", x, y, z);
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split(" ")))

ans = 0
c = 0
for i in range(1, n):
    if h[i-1] < h[i]:
        ans = max(ans, c)
        c = 0
    else:
        c += 1
ans = max(c, ans)
print(ans)


Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i=shoki; i<n; i++)
#define _GLIBCXX_DEBUG
int main(){
    int n,x;
    cin>>n>>x;
    vector<int> m(n);
    rep(0,i,n) cin>>m[i];

    int res = n;
    int min_m = m[0];
    x -= m[0];
    
    rep(1,i,n){
        x -= m[i];
        if(m[i]<min_m){
            min_m=m[i];
        }
    }
    res += x/min_m;

    cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int MOD=1000003;
int x0;
int n, m;
int a[50000], b[50000];
vector<int> g[50001];
ll dp[50001], s[2][50001];
bool used[50001];
void dfs(int x){
	dp[x]=1;
	s[0][x]=s[1][x]=1;
	for(auto y:g[x]){
		dfs(y);
		dp[x]*=s[(b[x]+1)&1][y];
		dp[x]%=MOD;
		s[1][x]*=s[1][y];
		s[1][x]%=MOD;
		s[0][x]*=s[0][y];
		s[0][x]%=MOD;
	}
	s[b[x]&1][x]+=dp[x];
	s[b[x]&1][x]%=MOD;
}
ll solve(){
	if(n&1) return 0;
	if(m==0) return 2;
	vector<int> ind;
	int dmn=n, i0;
	for(int i=0; i<m; i++){
		int d1=abs(b[i]-a[i]);
		if(d1%2==0) continue;
		ind.push_back(i);
		if(dmn>min(d1, n-d1)){
			i0=i;
			dmn=min(d1, n-d1);
		}
	}
	if(ind.empty()) return 2;
	if(abs(b[i0]-a[i0])<=n/2){
		x0=(a[i0]+b[i0])/2;
	}else{
		x0=n-(a[i0]+b[i0])/2;
	}
	vector<int> v[50001];
	for(auto i:ind){
		a[i]=(a[i]-x0+n)%n, b[i]=(b[i]-x0+n)%n;
		if(a[i]>b[i]) swap(a[i], b[i]);
		v[b[i]].push_back(i);
	}
	for(int i=0; i<n; i++){
		sort(v[i].begin(), v[i].end(), [&](int x, int y){ return a[x]>a[y];});
	}
	vector<int> w;
	for(int i=0; i<n; i++){
		for(auto j:v[i]){
			while(!w.empty()){
				int y=w.back();
				if(b[y]<=a[j]) break;
				g[j].push_back(y);
				w.pop_back();
			}
			w.push_back(j);
		}
	}
	dfs(i0);
	for(int i=0; i<n; i++) g[i].clear();
	return (s[0][i0]+s[1][i0])%MOD;
}

int main()
{
	while(1){
		cin>>n>>m;
		if(n==0) return 0;
		for(int i=0; i<m; i++){
			cin>>a[i]>>b[i];
			a[i]--; b[i]--;
		}
		cout<<solve()<<endl;
	}
	return 0;
}


Measured memory_bytes: 9896
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
using namespace std;

int main()
{
    char x, y;
    
    cin >> x >> y;
    
    if(int(x) == int(y)) {
        cout << "=\n";
    } else if(int(x) > int(y)) {
        cout << ">\n";
    } else {
        cout << "<\n";
    }
    
    return 0;
}

Measured memory_bytes: 256