akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int N, L, T;
int pos1;
vector<int> X;
vector<char> W;
vector<int> P;
vector<int> ans;

void calcu_last_pos(void) {
	P.resize(N);
	for (int i = 0; i < N; ++i) {
		int pos = (W[i] == '+') ? X[i] + T : X[i] - T;
		pos %= L;
		if (pos < 0)
			pos += L;
		P[i] = pos;
		if (i == 0)
			pos1 = pos;
	}
}

int calcu_cross_count(void) {
	int cnt = 0;
	if (W[0] == '+') {
		for (int i = 1; i < N; ++i) {
			if (W[i] == '+')
				continue;
			int d = 2 * T - (X[i] - X[0]);
			if (d > 0) {
				++cnt;
				int k =  d / L;
				cnt += k;
			}
		}
	}
	else {
		for (int i = 1; i < N; ++i) {
			if (W[i] == '-')
				continue;
			int d = 2 * T + (X[i] - X[0]) - L;
			if (d > 0) {
				++cnt;
				int k = d / L;
				cnt += k;
			}
		}
	}
	return cnt;
}

void set_ans(int k, int m) {
	for (int i = 0; i < N; ++i) {
		ans[m - 1] = P[k];
		++k;
		if (k >= N)
			k = 0;
		++m;
		if (m > N)
			m = 1;
	}
}

void solve(void) {
	ans.resize(N, 0);
	for (int i = 0; i < N; ++i) {
		if (P[i] == pos1) {
			int num;
			int cnt;
			if (W[0] == '+') {
				cnt = calcu_cross_count();
				num = (1 + cnt) % N;
				if (num == 0)
					num = N;
				if (i < N - 1 && P[i] == P[i + 1])
					i += 1;
			}
			else {
				cnt = calcu_cross_count();
				num = (1 - cnt) % N;
				num += N;
				num %= N;
				if (num == 0)
					num = N;
				if (i < N - 1 && P[i] == P[i + 1] && (num - cnt == 1))
					i += 1;
			}
			set_ans(i, num);
			break;
		}
	}
}

int main(void) {
	cin >> N >> L >> T;
	X.resize(N);
	W.resize(N, '+');

	for (int i = 0; i < N; ++i) {
		int dir;
		cin >> X[i] >> dir;
		if (dir == 2)
			W[i] = '-';
	}

	calcu_last_pos();
	sort(P.begin(), P.end());
	solve();

	for (int i = 0; i < N; ++i)
		cout << ans[i] << '\n';
	return 0;
}


Measured memory_bytes: 2432
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int main()
{
	int n[100],sol[100],point[31];
	vector<int> s;
	int count=0,p,q;
	while(1)
	{
		scanf("%d,%d",&p,&q);
		if(p==0&&q==0)break;
		n[count]=p;
		sol[count]=q;
		s.pb(q);
		count++;
	}
	sort(s.begin(),s.end(),greater<int>());
	count=1;
	for(int i=0;i<s.size();i++)
	{
		if(i==s.size()-1)
		{
			point[s[i]]=count;
			continue;
		}
		if(s[i]==s[i+1])
		{
			point[s[i]]=count;
		}
		else
		{
			point[s[i]]=count;
			count++;
		}
	}
	while(cin>>p)
	{
		for(int i=0;i<101;i++)
		{
			if(n[i]==p)
			{
				q=i;
				break;
			}
		}
		cout << point[sol[q]] << endl;
	}
	return 0;
}

Measured memory_bytes: 1268
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int h,i;
  int a[25],b[25],c[25],n;
  int sm,cr;
  while(cin>>n&&n){
    sm=0;
    for(i=0;i<n;i++){
      cin>>a[i]>>b[i];
      sm+=a[i];
    }
    memset(c,0,sizeof(c));

    for(h=0;h<n;h++){
      cr=-1;
      for(i=0;i<n;i++){
	if(c[i]==0){
	  if(b[i]>=sm){
	    if(cr==-1||a[cr]<a[i])
	      cr=i;
	  }
	}
      }
      if(cr==-1)
	break;
      else{
	sm-=a[cr];
	c[cr]=1;
      }
    }
    if(h==n)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main(){
    char a;
    cin >> a;
    if('a' <= a && a <= 'z' ) cout << 'a' << endl;
    else cout << 'A' << endl;
}

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

int main(){
	int a,b,c,d; cin>>a>>b>>c>>d;
	cout<<min(a,b)+min(c,d)<<endl;
}

Measured memory_bytes: 3640
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        List<Integer> b = new ArrayList<Integer>();
        for (int i = 0; i < n; i++) {
            b.add(sc.nextInt());
        }
        sc.close();

        List<Integer> output = new ArrayList<Integer>();

        while (b.size() != 0) {
            int beforeSize = b.size();
            for (int i = b.size(); i > 0; i--) {
                if (b.get(i - 1) == i) {
                    b.remove(i - 1);
                    output.add(i);
                    break;
                }
            }
            if (beforeSize == b.size()) {
                System.out.println("-1");
                System.exit(0);
            }
        }
        for (int i = output.size() - 1; i >= 0; i--) {
            System.out.println(output.get(i));
        }
    }
}


Measured memory_bytes: 23764
# Code for C - Peaks
# Use input() to fetch data from STDIN
[n, m] = map(int, input().split())
h = list(map(int, input().split()))
a = [0 for x in range(m)]
b = [0 for x in range(m)]
for i in range(m):
    [a[i], b[i]] = map(int, input().split())

e = [[] for x in range(n)]
for i in range(m):
    e[a[i] - 1] += [h[b[i] - 1]]
    e[b[i] - 1] += [h[a[i] - 1]]

total = 0
for i in range(n):

    if len(e[i]) == 0:
        total += 1
        continue

    if h[i] > max(e[i]):
        total += 1

print(total)


Measured memory_bytes: 31012
# -*- coding: utf-8 -*-
colors = input()

start_0 = 0
start_1 = 0

for i in range(len(colors)):
	color = int(colors[i])
	if i % 2:
		if color == 1:
			start_0 += 1
		else:
			start_1 += 1
	else:
		if color == 1:
			start_1 += 1
		else:
			start_0 += 1

print(min(start_0, start_1))

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


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

template<typename T>
struct Segment_Tree {
	typedef function<T(T, T)> F;

	ll n;
	F f;//モノイドとしての演算(最小値、和　など)
	T unit;//単位元

	ll size;
	vector<T> seg;

	Segment_Tree(ll n0, F f0, T unit0) {
		n = n0;
		f = f0;
		unit = unit0;

		size = 1;
		while (size < n) {
			size *= 2;
		}
		seg.assign(2 * size, unit);
	}


	void update(ll k, T x) {//k番目の要素をxに更新
		k += size - 1;
		seg[k] = x;
		while (k > 1) {
			k /= 2;
			seg[k] = f(seg[2 * k], seg[2 * k + 1]);
		}
	}



	T query_prep(ll a, ll b, ll k, ll l, ll r) {//[a,b)とkに対応する区間[l,r)の共通部分でクエリ
		if (b <= l || a >= r) { return unit; }
		if (a <= l && r <= b) { return seg[k]; }

		T v1 = query_prep(a, b, 2 * k, l, (l + r) / 2);
		T v2 = query_prep(a, b, 2 * k + 1, (l + r) / 2, r);
		return f(v1, v2);

	}

	T query(ll a, ll b) {
		return query_prep(a, b, 1, 1, size + 1);
	}

};

struct path {
	ll l;ll r; ll c;
};

bool cmp(path x, path y) {
	return x.l < y.l;
}

int main() {
	
	ll N, M;
	cin >> N >> M;

	vector<path> p(M + 1);

	repn(i, M) { cin >> p[i].l >> p[i].r >> p[i].c; }

	sort(++p.begin(), p.end(),cmp);

	Segment_Tree<ll> sg(N, [](ll a, ll b) {return min(a, b); }, INF);
	
	sg.update(1, 0);

	repn(i, M) {
		ll x = sg.query(p[i].l, N + 1) + p[i].c;
		
		ll y = sg.query(p[i].r, p[i].r + 1);

		sg.update(p[i].r, min(x, y));
	}

	ll ans = sg.query(N, N + 1);
	if (ans == INF) { ans = -1; }

	cout << ans;
	system("PAUSE");
}


Measured memory_bytes: 4856
using System;
using System.Linq;

namespace ABC078_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var XY = Console.ReadLine().Split().ToArray();
            var c = string.Compare(XY[0], XY[1]);
            Console.WriteLine(c == 0 ? "=" : (c < 0 ? "<" : ">"));
        }
    }
}


Measured memory_bytes: 11360
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cerr<<' ';cerr<<elem;}cerr<<endl;}

inline void YESNO(bool ans){cout<<(ans?"YES":"NO")<<endl;}
inline void YesNo(bool ans){cout<<(ans?"Yes":"No")<<endl;}
inline void yesno(bool ans){cout<<(ans?"yes":"no")<<endl;}

int main(){
	int n,k;
	cin>>n>>k;
	
	vi a(n);
	REP(i,n) cin>>a[i];
	
	for(int i=k;i<n;++i){
		bool ans=(a[i-k]<a[i]);
		YesNo(ans);
	}
}

Measured memory_bytes: 3980
N, W = map(int, input().split())
Data = [list(map(int, input().split())) for _ in range(N)]
sum_value_aploximate = N * 10**3 + 1

dp = [[None for _ in range(sum_value_aploximate)] for _ in range(N+1)]
temp = float("inf")
dp[0] = [temp for _ in range(sum_value_aploximate)]
dp[0][0] = 0

for i in range(1, N+1):
    for j in range(sum_value_aploximate):
        if Data[i-1][1] <= j:
            dp[i][j] = min(dp[i-1][j], (dp[i-1][j-Data[i-1][1]] + Data[i-1][0]))
        else:
            dp[i][j] = dp[i-1][j]

ans = 0
for j in range(sum_value_aploximate):
    if dp[N][j] <= W:
        ans = max(ans, j)

print(ans)


Measured memory_bytes: 275168
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var ai = Sarray();
            var min = 0L;
            for (var i = 1; i < 9; ++i)
                if (ai.Any(a => (i - 1) * 400 <= a && a < i * 400)) ++min;
            var max = min + ai.Count(a => 3200 <= a);
            WriteLine($"{Max(1, min)} {max}");
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28260
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


void bfs(const vector<vector<int> > &G, int v, vector<int> &dist){
    for (int i = 0; i < (int) dist.size(); i++) dist[i] = -1;
    queue<int> que;
    dist[v] = 0;
    que.push(v);
    while (!que.empty()) {
        v = que.front();
        que.pop();
        for (int next_v : G[v]) {
            if (dist[next_v] != -1) continue;
            dist[next_v] = dist[v] + 1;
            que.push(next_v);
        }
    }
}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    vector<int> A(M), B(M);
    Graph G(N);
    REP (i, N) {
        cin >> H[i];
    }
    REP (i, M) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
        G[A[i]].PB(B[i]);
        G[B[i]].PB(A[i]);
    }
    int chk ;
    REP(i,N) {
        chk = 1;
        for (int j : G[i]) if (H[i] <= H[j]) chk = 0;
        if (chk) ans++;
    }
    cout << ans << endl;


    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc166/abc166_c && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc166/abc166_c && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc166/abc166_c && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 11380
#include<bits/stdc++.h>
using namespace std;
int main() {
    int i, j, k, n, t;
    string s;
    map <string, int> mp;
    map <string, int> :: iterator it;
    cin>>t;
    while(t--) {
        cin>>s;
        mp[s]+=1;
    }
    n=0;
    for(it=mp.begin(); it!=mp.end(); it++) {
        j=it->second;
        if(n<j) n=j;
    }
    for(it=mp.begin(); it!=mp.end(); it++) {
        if(it->second==n) cout<<it->first<<endl;
    }
    return 0;
}


Measured memory_bytes: 25216
#include <iostream>

int main()
{
	int n;
	int h,m,ans;
	ans = 0;
	std::cin >> n;
	m = -1;
	for (int i = 0; i < n; i++) {
		std::cin >> h;
		if (h >= m) {
			m = h;
			ans++;
		}
	}
	std::cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long int a,b,c,d,ans;
  cin >> a >> b >> c >> d;
  
  
     ans = a * c;
    if(ans < a * d){
      ans = a * d;
    }
    if(ans < b * c){
      ans = b * c;
    }
    if(ans < b * d){
      ans = b * d;
    }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3624
/*---> 11 January 2020 <--- > 05:03:40 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;

int32_t main(){__
	int k,x;
	cin>>k>>x;
	if(k*500>=x)
	cout<<"Yes\n";
	else
	cout<<"No\n";
return 0;
}

Measured memory_bytes: 256
N=int(input())
List=[int(input()) for i in range(N)]
List.sort()
LIst=[]
total=sum(List)
for i in List:
  if i % 10 != 0:
      LIst.append(i)
      
if total % 10 != 0:
    print(total)
elif LIst == []:
    print(0)
else:
    print(total-LIst[0])

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    int n;
    LL ans=0;
    vector<LL> a;
    LL tmp_a;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmp_a;
        a.push_back(tmp_a);
    }

    sort(a.begin(), a.end());
    LL count=1;
    for(int i=1; i<n; i++){
        if(a[i-1]==a[i]){
            count++;
        }else{
            if(a[i-1]>count){
                ans+=count;
            }else{
                ans+=count-a[i-1];
            }
            count=1;
        }
    }
    if(a[n-1]>count){
        ans+=count;
    }else{
        ans+=count-a[n-1];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1400
// #include<iostream>
// #include<vector>
// #include<algorithm>
// #include<map>
// #include<cstring>
// #include<math.h>
// #include<bitset>
// #include<queue>
// #include<set>
// #include<iomanip>
// #include<math.h>
// #include<assert.h>
// #include<string>
// #include<cstdlib>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  int cnt_2=0,cnt_4=0,cnt_0=0;
  for(int i=0; i<N; i++){
    if(a[i]%4==0){
      cnt_4++;
    }else if(a[i]%2==0){
      cnt_2++;
    }else{
      cnt_0++;
    }
  }
  if(cnt_0==0){
    cout << "Yes" << endl;
    return 0;
  }
  if(cnt_2){
    if(cnt_0 <= cnt_4){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    if(cnt_0-1 <= cnt_4){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 998244353;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<ll> a(100005);
	ll sum = 0;
	rep(i, n) {
		int p;
		cin >> p;
		a[p]++;
		sum += p;
	}
	int q;
	cin >> q;
	rep(i, q) {
		ll b, c;
		cin >> b >> c;
		sum += (c - b) * a[b];
		a[c] += a[b];
		a[b] = 0;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3988
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  string s;
  cin >> s;

  int n = s.size();

  if (s[n-1] == 's') s += "es";
  else s += "s";

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vb   = vector<bool>;
using vvb  = vector<vb>;
using pii  = pair<int,int>;
using vpii = vector<pii>;
 
int main() {
    int ans = 0;
    char n;cin >> n;
    while(!cin.eof()){
        int tmp = (n - '0');
        ans = (ans + tmp) % 9;
        cin >> n;
    }
    if(ans == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3548
def primes(n):
    from math import sqrt
    p = [1] * (n + 1)
    for x in range(2, int(sqrt(n)) + 1):
        if p[x]:
            p[x * 2:n + 1:x] = [0] * ((n - x) // x)
    return (i for i in range(2, n + 1) if p[i])

ps = list(primes(55555))

answer = [p for p in ps if p % 5 == 1]

N = int(input())

print(" ".join(str(n) for n in answer[:N]))

Measured memory_bytes: 3900
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int a,b,x;

void input(){
    cin >> a >> b >> x;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    if(a <= x && x <= (a+b)) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ri register int
#define fi first
#define se second
#define pb push_back
using namespace std;
const int rlen=1<<18|1;
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(){
	int ans=0;
	char ch=gc();
	while(!isdigit(ch))ch=gc();
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	return ans;
}
typedef pair<int,int> pii;
typedef long long ll;
typedef unsigned long long Ull;
inline int Read(char*s){
	int top=0;
	char ch=gc();
	while(!isdigit(ch))ch=gc();
	while(isdigit(ch))s[++top]=ch,ch=gc();
	return top;
}
char s[205];
int n,dep[205];
bool vs[205];
vector<int>e[205];
void check(int p){
	vs[p]=1;
	for(ri i=0,v;i<e[p].size();++i){
		if(vs[v=e[p][i]]){
			if((dep[v]+dep[p])&1)continue;
			puts("-1");
			exit(0);
		}
		dep[v]=dep[p]+1;check(v);
	}
}
int main(){
	#ifdef ldxcaicai
	freopen("lx.in","r",stdin);
	#endif
	n=read();
	for(ri i=1;i<=n;++i){
		Read(s);
		for(ri j=1;j<=n;++j)if(s[j]=='1')e[i].pb(j);
	}
	check(1);
	int mx=0;
	for(ri s=1;s<=n;++s){
		memset(dep,0,sizeof(dep));
		memset(vs,0,sizeof(vs));
		queue<int>q;
		q.push(s),dep[s]=1;
		while(q.size()){
			int x=q.front();
			q.pop();
			vs[x]=1;
			for(ri i=0,v;i<e[x].size();++i){
				if(vs[v=e[x][i]])continue;
				dep[v]=dep[x]+1;
				vs[v]=1;
				q.push(v);
			}
		}
		for(ri i=1;i<=n;++i)mx=max(mx,dep[i]);
	}
	cout<<mx;
	return 0;
}

Measured memory_bytes: 512
using System;

namespace abc167_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string stringAll = Console.ReadLine();
            string[] stringArray = stringAll.Split(" ");
            int add = int.Parse(stringArray[0]);
            int zero = int.Parse(stringArray[1]);
            int mainasu = int.Parse(stringArray[2]);
            int sum = int.Parse(stringArray[3]);

            int outputInt = 0;

            if(sum < add)
            {
                Console.WriteLine(sum);
                return;
            }
            else if(sum == add)
            {
                Console.WriteLine(add);
                return;
            }
            outputInt = 1 * add;
            sum -= add;

            sum -= zero;
            if (0 >= sum)
            {
                Console.WriteLine(outputInt);
                return;
            }

            int mainasuSum = 0;
            if (0 == mainasu)
            {
            }
            else if(sum < mainasu)
            {
                mainasuSum = -1 * sum;
                outputInt += mainasuSum;
            }
            else
            {
                mainasuSum = -1 * mainasu;
                outputInt += mainasuSum;
            }
            Console.WriteLine(outputInt);
            return;
        }
    }
}


Measured memory_bytes: 27340
#include<stdio.h>
#include<stdlib.h>
#define M 10000
#define NIL -1

typedef struct
{
  int p;
  int l;
  int r;
}Tree;

Tree T[M];
int n;

void preOrder(int m)
{
  if(m == NIL)
    {
      return;
    }
  printf(" %d", m);
  preOrder(T[m].l);
  preOrder(T[m].r);
}
void inOrder(int m)
{
  if(m == NIL)
    {
      return;
    }
  inOrder(T[m].l);
  printf(" %d", m);
  inOrder(T[m].r);
}
void postOrder(int m)
{
  if(m == NIL)
    {
      return;
    }
  postOrder(T[m].l);
  postOrder(T[m].r);
  printf(" %d", m);
}

int main()
{
  int i, a, b, l, r;
  scanf("%d", &n);
  for(i = 0; i < n; i++)
    {
      T[i].p = NIL;
    }
  for(i = 0; i < n; i++)
    {
      scanf("%d", &b);
      scanf("%d", &l);
      scanf("%d", &r);
      T[b].l = l;
      T[b].r = r;
      if(l != NIL)
	{
	  T[l].p = b;
	}
      if(r != NIL)
	{
	  T[r].p = b;
	}
    }
  for(i = 0; i < n; i++)
    {
      if(T[i].p == NIL)
	{
	  a = i;
	}
    }
  printf("Preorder\n");
  preOrder(a);
  printf("\n");
  printf("Inorder\n");
  inOrder(a);
  printf("\n");
  printf("Postorder\n");
  postOrder(a);
  printf("\n");
  return 0;
}





Measured memory_bytes: 2112
import sys
readline = sys.stdin.readline


def chmax(a, b):
    """
    2値の大きい値を返す

    Args:
        a   (int)   : 値１
        b   (int)   : 値２
    Return:
        a   (int)   : aまたはbの大きい値
    """
    if a < b:
        a = b
    return a


def main():

    N, W = map(int, readline().split())

    # knopsock[n][0] = w    :   n = 品物の位置 , w = 重さ
    # knopsock[n][1] = v    :   n = 品物の位置 , v = 価値
    knapsack = [list(map(int, readline().split())) for _ in range(N)]

    # db[n][w] = v          :   w = 現在の重さ, n = 見てきた品物の数, v = 現在の価値
    dp = [[0] * (W + 1) for _ in range(N + 1)]

    for n in range(1, N + 1):
        for w in range(W + 1):
            if w - knapsack[n - 1][0] < 0:
                dp[n][w] = dp[n - 1][w]
            else:
                dp[n][w] = chmax(dp[n - 1][w], dp[n - 1]
                                 [w - knapsack[n - 1][0]] + knapsack[n - 1][1])

    print(dp[N][W])


if __name__ == "__main__":
    main()


Measured memory_bytes: 118640
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 3e5 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r; 
}

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
void solve()
{
	int n, m;
	cin >> n >> m;
	queue<pii> q;
	int ch, dh, cw, dw;
	cin >> ch >> dh >> cw >> dw;
	--ch, --dh, --cw, --dw;
	char c[n][m];
	rep(i, n) rep(j, m) cin >> c[i][j];
	vector<vector<int> > used(n, vector<int> (m)), d(n, vector<int> (m));
	q.push({ch, dh});
	int res = inf;
	int magic = -1;
	while(!q.empty()){
		vector<pii> pts;
		magic++;
		while(!q.empty()){
				pii p = q.front();
				if(p.F == cw && p.S == dw){
					cout << magic;
					return;
				}
				pts.pb(p);
				q.pop();
				rep(i, 4){
					int fx = p.F + dx[i];
					int fy = p.S + dy[i];
					if(fx >= 0 && fx < n && fy >= 0 && fy < m && !used[fx][fy] && c[fx][fy] == '.'){
						q.push({fx, fy});
						used[fx][fy] = 1;
						d[fx][fy] = d[p.F][p.S] + 1;
					}
				}
			}
			for(pii p : pts){
				for(int i = -2; i <= 2; ++i){
					for(int j = -2; j <= 2; ++j){
						int fx = p.F + i;
						int fy = p.S + j;
						if(fx >= 0 && fx < n && fy >= 0 && fy < m && !used[fx][fy] && c[fx][fy] == '.'){
							q.push({fx, fy});
							used[fx][fy] = 1;
							d[fx][fy] = d[p.F][p.S] + 1;
						}		
					}
				}
			}
	}
	cout << -1;
}




int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    // Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

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

using namespace std;

int main(){
	
	int a, b, c, k;

	scanf("%d %d %d", &a, &b, &c);
	scanf("%d", &k);

	int maxi = max(a,max(b,c));
	int total = a+b+c-maxi;
	k = 1<<k;
	total += k*maxi;

	printf("%d\n", total);

	return 0;
}

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

const int N = 100000 + 10, S = 3, MOD = 1000000007;

typedef int Matrix[S][S];
typedef long long i64;

void mul(Matrix lhs, const Matrix rhs) {
  static Matrix res;
  memset(res, 0, sizeof res);
  for (int i = 0; i < S; ++i)
    for (int k = 0; k < S; ++k)
      for (int j = 0; j < S; ++j)
        res[i][j] = (res[i][j] + (i64)lhs[i][k] * rhs[k][j]) % MOD;
  memcpy(lhs, res, sizeof res);
}

void power(Matrix base, int exp) {
  static Matrix res;
  memset(res, 0, sizeof res);
  for (int i = 0; i < S; ++i) res[i][i] = 1;
  for (; exp; exp >>= 1) {
    if (exp & 1) mul(res, base);
    mul(base, base);
  }
  memcpy(base, res, sizeof res);
}

int m, n, a[N];

int main() {
  scanf("%d%d", &m, &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  const Matrix x = {
    {1, 1, 1},
    {0, 1, 2},
    {0, 0, 1}
  };
  const Matrix y = {
    {1, 0, 0},
    {0, 1, 0},
    {1, 0, 1}
  };
  Matrix z, ans;
  memcpy(z, x, sizeof z);
  mul(z, y);
  memset(ans, 0, sizeof ans);
  for (int i = 0; i < S; ++i) ans[i][i] = 1;
  a[n + 1] = m;
  for (int i = 1; i <= n + 1; ++i) {
    Matrix temp;
    memcpy(temp, z, sizeof z);
    power(temp, a[i] - a[i - 1] - 1);
    mul(ans, temp);
    mul(ans, x);
  }
  printf("%d\n", (ans[0][2] + MOD) % MOD);
  return 0;
}


Measured memory_bytes: 512
n=int(input())
a=[]
m1=0
m2=0
for i in range(n):
    a.append(int(input()))
    A=a[i]
    if a[i]>m1:
        m2=m1
        m1=a[i]
        index=i
    elif m1==a[i]:
        m2=a[i]
    elif a[i]>m2:
        m2=a[i]
for i in range(n):
    if i==index:
        print(m2)
    else:
        print(m1)

Measured memory_bytes: 12520
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

string s;

ll getnum(int i, int j) {
  ll keta = 1, res = 0;
  FORR(k, j, i) {
    int t = s[k] - '0';
    res += t * keta;
    keta *= 10;
  }
  return res;
}

int main() {
  cin >> s;

  int n = s.size();
  vector<ll> c(n, 0);
  c[0] = 1;
  FOR(i, 1, n) {
    repr(j, i - 1) {
      c[i] += c[j];
    }
  }
  
  ll ans = 0;
  rep(i, n) {
    FOR(j, i, n) {
      ans += getnum(i, j) * c[i] * c[n - j - 1];
    }
  }
  cout << ans << endl;






  
  return 0;
}

Measured memory_bytes: 256
O = input().rstrip()
E = input().rstrip()

length = len(O) + len(E)
s = ['0'] * length

for i in range(length):
    index = int(i / 2)
    if i % 2 == 0:
        s[i] = O[index]
    else:
        s[i] = E[index]


print(''.join(s))



Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
char a[100000001];
int s=0;
int main(){
	cin>>a;
	for(int i=0;i<strlen(a)-1;i++)
		if(a[i]!=a[i+1])
			s++;
	cout<<s;
	return 0;
}

Measured memory_bytes: 384
#include <vector>
#include <algorithm>
#include <map>
#include <iostream>

typedef long long ll;
using namespace std;
int main(){
  ll n,x;
  cin >> n >> x;
  vector<ll> a(n);
  for(ll i = 0; i<n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  auto score = 0;
  for(auto it=a.begin(); it != a.end(); ++it){
    if(x<*it){
      cout << score << endl;
      return 0;
    }else{
      ++score;
      x -= *it;
    }
  }
  if(x!=0){
    --score;
  }
  cout << score << endl;
return 0;
}



Measured memory_bytes: 384
N = int(input().strip())
X = list(map(int, input().strip().split()))

min_dist = 1 << 32

def evaluate(posi):
    ans = 0
    for i in range(N):
        ans += (X[i]-posi)**2
    return ans

for i in range(1,101):
    tmp = evaluate(i)
    if tmp < min_dist:
        min_dist = tmp

print(min_dist)



Measured memory_bytes: 3060
n,a,b = map(int,input().split())

def comb(n,r,mod=10**9+7):
    a=1
    b=1
    r = min(r,n-r)
    for i in range(r):
        a = a*(n-i)%mod
        b = b*(i+1)%mod
    return a*pow(b,mod-2,mod)%mod

ans = pow(2,n,10**9+7)-1 - comb(n,a) - comb(n,b)
ans %= 10**9+7
print(ans)

Measured memory_bytes: 3064
//Stack Over Flow Recursive

using System;
using System.Collections;
using System.Collections.Generic;
namespace Ccs
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());

            var pr = new Program();

            Console.WriteLine(pr.Rec(0,n));
        }

        private const String sgs = "357";
        private bool Is_sgs(String s)
        {

            bool is_sgs_ = true;
            for (int i = 0; i < sgs.Length; ++i)
                is_sgs_ &= s.Contains(sgs[i].ToString());

            return is_sgs_;
        }

        private bool Is_sgs(long n)
        {
            return this.Is_sgs(n.ToString());
        }

        
        private long Rec(long x, long n)
        {
            //            var x = int.Parse(s);
            if (n < x)
                return 0;
            //            if (Is_sgs(x))
            //                Console.WriteLine(x);

            long ret = Is_sgs(x) ? 1 : 0;

            foreach ( char c in sgs)
                ret += Rec(x * 10 + int.Parse( c.ToString() ), n);

            return ret;
        }
        
    }
}


Measured memory_bytes: 15184
#include <stdlib.h>
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
#define ll long long
const int INF=0x3f3f3f3f;
#define mod 1000000007
using namespace std;
//priority_queue
int Min=0x3f3f3f3f;
int b[100003];
int dp[1000003];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int a;
        cin>>a;
        b[a]=1;
    }
    if(b[0]){cout<<0<<endl;return 0;}
    dp[0]=1;
    for(int i=1;i<=n;i++)
    { if(b[i])continue;
       if(i>0){
        if(!b[i-1])dp[i]=(dp[i]+dp[i-1])%mod;
       }
       if(i>1)
       {
           if(!b[i-2])dp[i]=(dp[i]+dp[i-2])%mod;
       }}
       cout<<dp[n]%mod;
}


Measured memory_bytes: 2944
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int max = -1;
		int ans = 0;
		for(int i = 0;i < N;i++) {
			int p = scn.nextInt();
			ans += p;
			max = Math.max(p, max);
		}
		ans -= max/2;
		System.out.println(ans);
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
static const double pi = 3.141592653589793;

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

  int n; cin >> n;
  if(n == 1) {
    cout << 1 << endl;
    return 0;
  }

  vector<int> x(n), y(n);
  rep(i, n) {
    cin >> x[i] >> y[i];
  }

  int ans = n;
  rep(i, n) {
    rep(j, n) {
      if(i == j) continue;
      int dx = x[j] - x[i], dy = y[j] - y[i];

      int tmp = 0;
      rep(k, n) {
        rep(l, n) {
          if(k == l) continue;
          if(dx == x[l] - x[k] && dy == y[l] - y[k]) ++tmp;
        }
      }

      chmin(ans, n - tmp);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns, MultiWayIf #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Int
import Data.Foldable
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Data.ByteString.Internal (accursedUnutterablePerformIO)
import Debug.Trace

solve :: Int -> Int -> VU.Vector (Int, Int) -> Int
solve !n !k !xys =
  minimum
    $ [ area x12 y12
      | x12 <- xcandidates
      , y12 <- ycandidates
      , countInside x12 y12 >= k
      ]
 where
  xcandidates =
    let xs = VU.fromList $ sort $ VU.toList $ VU.map fst xys
    in  [ (xs VU.! x1, xs VU.! x2)
        | x1 <- [0 .. n - 2]
        , x2 <- [x1 + 1 .. n - 1]
        ]
  ycandidates =
    let ys = VU.fromList $ sort $ VU.toList $ VU.map snd xys
    in  [ (ys VU.! y1, ys VU.! y2)
        | y1 <- [0 .. n - 2]
        , y2 <- [y1 + 1 .. n - 1]
        ]

  countInside (x1, x2) (y1, y2) = VU.length
    $ VU.filter (\(x, y) -> x1 <= x && x <= x2 && y1 <= y && y <= y2) xys

  area (x1, x2) (y1, y2) = (x2 - x1) * (y2 - y1)

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  (n, k) <-
    (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine
  xys <-
    VU.replicateM n
    $   (\vec -> (vec VU.! 0, vec VU.! 1))
    .   VU.unfoldrN 2 readInt
    <$> B.getLine

  print $ solve n k xys


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

using namespace std;

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

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

ll check(ll x) {
    ll res = 0;
    string s = to_string(x);
    ll div = 10;
    while (x) {
        res += x / div;
        x /= 5;
    }

    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    ll n;
    cin >> n;
    if (n % 2) {
        cout << 0 << endl;
        return 0;
    }
    cout << check(n) << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

void printvec(const std::vector<int>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

int N, D;

int main(int argc, char **argv) {
    std::cin >> N >> D;

    int num = D*2 + 1;

    if (N % num == 0) {
        std::cout << N/num << std::endl;
    } else {
        std::cout << N/num + 1 << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())

h_lis = list(map(int, input().split()))

lis = [h_lis[0]]

ans = []

for x in h_lis:
    if (x >= max(lis)):
        ans.append(x)
    lis.append(x)

print(len(ans))


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

using namespace std;

int main(void) {
	int k, i = 0, len = 1, j;
	string s = "aaa", t, buf;
	cin >> s >> k;
	vector<string> ans(k);
	for (; i < k; i++)
		ans[i] = "zzzzz";
	for (; len <= k; len++) {
		for (j = 0; j <= (int)s.size() - len; j++) {
			t = s.substr(j, len);
			for (i = 0; i < k; i++) {
				if (ans[i].compare(t) > 0) {
					buf = ans[i];
					ans[i] = t;
					t = buf;
				}
				else if (ans[i] == t)
					break;
			}
		}
	}
	cout << ans[k - 1] << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define SIZE 20
#define show {for(i=1;i<=SIZE;i++){for(j=1;j<=SIZE;j++)printf("%d",map[j][i]);puts("");}puts("");}

int main(void){
	int N, M, map[SIZE+1][SIZE+1], x, y, i, j, k;
	
	while(scanf("%d",&N), N!=0){
		/* ú» */
		for(i=0; i<=SIZE; i++)
			for(j=0; j<=SIZE; j++) map[i][j]=0;
	
		/* WFðzu */
		for(;N--;){
			scanf("%d %d",&i,&j);
			map[i][j]=1;
		}
		
		/* ¤ */
		x=SIZE/2, y=SIZE/2;
		map[x][y]=0;	/* º_ÌWFðE¤H */
		
		/* Ú® */
		scanf("%d%*c",&M);
		for(;M--;){
			scanf("%c %d%*c",&i,&k);
			
			switch(i){	/* i:ûü(¡c), j:³ */
				case 'N': i=1, j=1; break;	case 'S': i=1, j=-1; break;
				case 'E': i=0, j=1; break;	case 'W': i=0, j=-1; break;
			}
			
			if(i)
				for(;k--;) map[x][y+=j]=0;
			else
				for(;k--;) map[x+=j][y]=0;
//			map[x][y]=0;	/* 0}XÚ®Åà«³ÌWFðE¤H */
		}
		
		/* `FbN */
		for(i=0; i<=SIZE; i++)
			for(j=0; j<=SIZE; j++)
				if(map[i][j]>0) goto brk;		
		brk:
		
		if(i<=SIZE || j<=SIZE) printf("No\n");
		else printf("Yes\n");
	}
	
	return 0;
}

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

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

    rep(r, k) {
        vector<int> brt(n + 1, 0);
        rep(i, n) {
            brt[max(0ll, i - a[i])]++;
            brt[min(ll(n), i + a[i] + 1)]--;
        }
        rep(i, n) {
            brt[i + 1] += brt[i];
        }
        bool alln = true;
        rep(i, n) {
            a[i] = brt[i];
            if (a[i] < n) alln = false;
        }
        // rep(i,n){
        //     cout << brt[i] << " ";
        // }
        // cout << endl;
        if (alln) break;
    }
    rep(i, n) {
        cout << a[i] << " ";
    }
    cout << endl;
}
/*
2 10000
0 0

2 2
*/

Measured memory_bytes: 5604
const lines=readlines(open("/dev/fd/0"))
let
    state=0
    global input
    input()=lines[state+=1]
end
int(s::String)=parse(Int32,s)
intSub(s::SubString{String})=parse(Int32,s)
intLine()=map(intSub,split(input()))
function main()
    r=int(input())
    println(r>2799 ? "AGC" : r>1199 ? "ARC" : "ABC")
end
main()

Measured memory_bytes: 113624
#include<bits/stdc++.h>
using namespace std ;
int main () {
  
  string s ;
  cin >> s ;
  
  int N=(int)s.length() ;
  int l[N] , r[N] ;
  
  for(int i =0 ; i < N ;i++) {
    
    if(i == 0) {
      if(s[i]=='R') l[i] = i ;
      else l[i] = -1 ;
    }
    else {
      if(s[i]=='R') l[i] = i ;
      else l[i] = l[i - 1] ;
    }
  }
  
  for(int i = N - 1; i >=0 ;i--) {
    if(i == N - 1) {
      if(s[i] =='L') r[i] = i ;
      else r[i] = - 1;
    }
    else {
      if(s[i]=='L') r[i] = i ;
      else r[i] = r[i + 1]; 
    }
  }
  
  int t[N] ;
  for(int i = 0 ; i < N ;i++)
    t[i] = 0 ;
  for(int i =0 ; i  < N ;i++)
  {
    if(s[i]=='R'){
      if(r[i] == -1) t[N - 1] ++ ;
      else{
        if( (r[i] - i - 1)%2 == 0 ) t[r[i] - 1]++ ;
        else t[r[i]]++ ;
      }
    }
    else {
      
      if(l[i] == -1) t[0] ++ ;
      else{
        if((i - l[i] - 1)%2 == 0) t[l[i] + 1]++ ;
        else t[l[i]]++ ;
      }
    }
  }
  
  for(int i =0 ; i < N ;i++)
    cout<<t[i]<<" " ;
  cout<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <fstream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


typedef  long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;


#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const int N=5e5+5;
int mod=1e9+7;

ll mul (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll add (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a+b+mod)%mod;
}
ll fastpow(ll b, ll p)
{
    if(p==0)
        return 1;
    ll ans=fastpow(b,p/2);
    ans=mul(ans,ans);
    if(p%2)ans=mul(ans,b);
    return ans;
}

vector<int>v[N];
ll ans=1;
ll n,k;
bool vist[N];

void dfs(int x,ll co)
{
    if (vist[x])
    return ;
    vist[x]=1;
    ans=mul(ans,co);
    ll c=k-2;
    for(int i=0;i<v[x].size();i++)
    {
        if(!vist[v[x][i]])
            dfs(v[x][i],c--);
    }

}


int main()
{
    FIO
    int root=0;
    cin>>n>>k;
    for(int i=0;i<n-1;i++)
    {
        int a,b;
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    int co=0;
    for(int i=1;i<=n;i++)
    {
        if(v[i].size()>co)
            co=v[i].size(),root=i;
    }
    ans=mul(ans,k);
    ll c=k-1;
    vist[root]=1;
    for(int i=0;i<v[root].size();i++)
    {
                if(!vist[v[root][i]])
                    dfs(v[root][i],c--);



    }

    cout<<ans;
    return 0;
}



Measured memory_bytes: 18688